Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

226 lines
6.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: d3drmmaterialinterobj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // d3drmViewport2Obj.cpp : Implementation of CDirectApp and DLL registration.
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dms.h"
  14. #include "d3drmMaterialInterObj.h"
  15. #include "d3drmObjectArrayObj.h"
  16. extern void *g_dxj_Direct3dRMMaterialInterpolator;
  17. C_dxj_Direct3dRMMaterialInterpolatorObject::C_dxj_Direct3dRMMaterialInterpolatorObject(){
  18. m__dxj_Direct3dRMMaterialInterpolator=NULL;
  19. m__dxj_Direct3dRMMaterial2=NULL;
  20. parent=NULL;
  21. pinterface=NULL;
  22. creationid = ++g_creationcount;
  23. DPF1(1,"Constructor Creation Direct3dRMMaterialInterpolator[%d] \n",g_creationcount);
  24. nextobj = g_dxj_Direct3dRMMaterialInterpolator;
  25. g_dxj_Direct3dRMMaterialInterpolator = (void *)this;
  26. }
  27. C_dxj_Direct3dRMMaterialInterpolatorObject::~C_dxj_Direct3dRMMaterialInterpolatorObject(){
  28. DPF1(1,"Destructor Direct3dRMMaterialInterpolator [%d] \n",creationid);
  29. C_dxj_Direct3dRMMaterialInterpolatorObject *prev=NULL;
  30. for(C_dxj_Direct3dRMMaterialInterpolatorObject *ptr=(C_dxj_Direct3dRMMaterialInterpolatorObject *)g_dxj_Direct3dRMMaterialInterpolator;
  31. ptr;
  32. ptr=(C_dxj_Direct3dRMMaterialInterpolatorObject *)ptr->nextobj)
  33. {
  34. if(ptr == this)
  35. {
  36. if(prev)
  37. prev->nextobj = ptr->nextobj;
  38. else
  39. g_dxj_Direct3dRMMaterialInterpolator = (void*)ptr->nextobj;
  40. break;
  41. }
  42. prev = ptr;
  43. }
  44. if(m__dxj_Direct3dRMMaterialInterpolator){
  45. int count = IUNK(m__dxj_Direct3dRMMaterialInterpolator)->Release();
  46. DPF1(1,"DirectX real IDirect3dRMMaterialInterpolator Ref count [%d] \n",count);
  47. if(count==0){
  48. m__dxj_Direct3dRMMaterialInterpolator = NULL;
  49. }
  50. }
  51. if (parent)
  52. IUNK(parent)->Release();
  53. if (m__dxj_Direct3dRMMaterial2)
  54. m__dxj_Direct3dRMMaterial2->Release();
  55. }
  56. DWORD C_dxj_Direct3dRMMaterialInterpolatorObject::InternalAddRef(){
  57. DWORD i;
  58. i=CComObjectRoot::InternalAddRef();
  59. DPF2(1,"Direct3dRMMaterialInterpolator[%d] AddRef %d \n",creationid,i);
  60. return i;
  61. }
  62. DWORD C_dxj_Direct3dRMMaterialInterpolatorObject::InternalRelease(){
  63. DWORD i;
  64. i=CComObjectRoot::InternalRelease();
  65. DPF2(1,"Direct3dRMMaterialInterpolator [%d] Release %d \n",creationid,i);
  66. return i;
  67. }
  68. HRESULT C_dxj_Direct3dRMMaterialInterpolatorObject::InternalGetObject(IUnknown **pUnk){
  69. *pUnk=(IUnknown*)m__dxj_Direct3dRMMaterialInterpolator;
  70. return S_OK;
  71. }
  72. HRESULT C_dxj_Direct3dRMMaterialInterpolatorObject::InternalSetObject(IUnknown *pUnk){
  73. HRESULT hr;
  74. m__dxj_Direct3dRMMaterialInterpolator=(LPDIRECT3DRMINTERPOLATOR)pUnk;
  75. hr=pUnk->QueryInterface(IID_IDirect3DRMMaterial2,(void**)&m__dxj_Direct3dRMMaterial2);
  76. return hr;
  77. }
  78. HRESULT C_dxj_Direct3dRMMaterialInterpolatorObject::attachObject( /* [in] */ I_dxj_Direct3dRMObject __RPC_FAR *rmObject){
  79. HRESULT hr;
  80. if (!rmObject) return E_INVALIDARG;
  81. DO_GETOBJECT_NOTNULL(LPUNKNOWN,pUnk,rmObject);
  82. LPDIRECT3DRMOBJECT pObj=NULL;
  83. hr=pUnk->QueryInterface(IID_IDirect3DRMObject, (void**)&pObj);
  84. if FAILED(hr) return hr;
  85. hr=m__dxj_Direct3dRMMaterialInterpolator->AttachObject(pObj);
  86. if (pObj) pObj->Release();
  87. return hr;
  88. }
  89. HRESULT C_dxj_Direct3dRMMaterialInterpolatorObject::detachObject( /* [in] */ I_dxj_Direct3dRMObject __RPC_FAR *rmObject){
  90. HRESULT hr;
  91. if (!rmObject) return E_INVALIDARG;
  92. DO_GETOBJECT_NOTNULL(LPUNKNOWN,pUnk,rmObject);
  93. LPDIRECT3DRMOBJECT pObj=NULL;
  94. hr=pUnk->QueryInterface(IID_IDirect3DRMObject, (void**)&pObj);
  95. if FAILED(hr) return hr;
  96. hr=m__dxj_Direct3dRMMaterialInterpolator->DetachObject(pObj);
  97. if (pObj) pObj->Release();
  98. return hr;
  99. }
  100. HRESULT C_dxj_Direct3dRMMaterialInterpolatorObject::setIndex( /* [in] */ float val){
  101. return m__dxj_Direct3dRMMaterialInterpolator->SetIndex(val);
  102. }
  103. HRESULT C_dxj_Direct3dRMMaterialInterpolatorObject::getIndex( float *val){
  104. if (!val) return E_INVALIDARG;
  105. *val=m__dxj_Direct3dRMMaterialInterpolator->GetIndex();
  106. return S_OK;
  107. }
  108. HRESULT C_dxj_Direct3dRMMaterialInterpolatorObject::interpolate( float val,
  109. I_dxj_Direct3dRMObject __RPC_FAR *rmObject,
  110. long options){
  111. HRESULT hr;
  112. LPDIRECT3DRMOBJECT pObj=NULL;
  113. DO_GETOBJECT_NOTNULL(LPUNKNOWN,pUnk,rmObject);
  114. //we need to validate some options here or rm goes bezerk with invalid values
  115. //note valid flags are
  116. // one of
  117. // D3DRMINTERPOLATION_CLOSED
  118. // D3DRMINTERPOLATION_OPEN -default
  119. // one of
  120. // D3DRMINTERPOLATION_NEAREST
  121. // D3DRMINTERPOLATION_SPLINE
  122. // D3DRMINTERPOLATION_LINEAR -default
  123. // D3DRMINTERPOLATION_VERTEXCOLOR - only on MeshInterpolator
  124. // D3DRMINTERPOLATION_SLERPNORMALS - not implemented
  125. // VALIDATE FLAGS
  126. DWORD opt2=0;
  127. UINT i4;
  128. if (options & D3DRMINTERPOLATION_CLOSED)
  129. opt2=D3DRMINTERPOLATION_CLOSED;
  130. else
  131. opt2=D3DRMINTERPOLATION_OPEN;
  132. if (options & D3DRMINTERPOLATION_NEAREST)
  133. opt2=opt2 | D3DRMINTERPOLATION_NEAREST;
  134. else if (options & D3DRMINTERPOLATION_SPLINE)
  135. opt2=opt2 | D3DRMINTERPOLATION_SPLINE;
  136. else
  137. opt2=opt2 | D3DRMINTERPOLATION_LINEAR;
  138. if (pUnk){
  139. hr=pUnk->QueryInterface(IID_IDirect3DRMObject, (void**)&pObj);
  140. if FAILED(hr) return hr;
  141. }
  142. hr= m__dxj_Direct3dRMMaterialInterpolator->Interpolate(val,pObj,(DWORD)opt2);
  143. if (pObj) i4=pObj->Release();
  144. return hr;
  145. }
  146. HRESULT C_dxj_Direct3dRMMaterialInterpolatorObject::setPower( float p)
  147. {
  148. return m__dxj_Direct3dRMMaterial2->SetPower(p);
  149. }
  150. HRESULT C_dxj_Direct3dRMMaterialInterpolatorObject::setSpecular( float r,float g, float b)
  151. {
  152. return m__dxj_Direct3dRMMaterial2->SetSpecular(r,g,b);
  153. }
  154. HRESULT C_dxj_Direct3dRMMaterialInterpolatorObject::setEmissive( float r,float g, float b)
  155. {
  156. return m__dxj_Direct3dRMMaterial2->SetEmissive(r,g,b);
  157. }
  158. HRESULT C_dxj_Direct3dRMMaterialInterpolatorObject::getAttachedObjects( /* [retval][out] */ I_dxj_Direct3dRMObjectArray __RPC_FAR *__RPC_FAR *rmArray)
  159. {
  160. HRESULT hr;
  161. IDirect3DRMObjectArray *pArray=NULL;
  162. hr=m__dxj_Direct3dRMMaterialInterpolator->GetAttachedObjects(&pArray);
  163. if FAILED(hr) return hr;
  164. INTERNAL_CREATE(_dxj_Direct3dRMObjectArray,pArray,rmArray);
  165. return S_OK;
  166. }