Source code of Windows XP (NT5)
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.

260 lines
7.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: d3drmlightinterobj.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 "d3drmLightInterObj.h"
  15. #include "d3drmObjectArrayObj.h"
  16. extern void *g_dxj_Direct3dRMLightInterpolator;
  17. C_dxj_Direct3dRMLightInterpolatorObject::C_dxj_Direct3dRMLightInterpolatorObject(){
  18. m__dxj_Direct3dRMLightInterpolator=NULL;
  19. m__dxj_Direct3dRMLight=NULL;
  20. parent=NULL;
  21. pinterface=NULL;
  22. creationid = ++g_creationcount;
  23. DPF1(1,"Constructor Creation Direct3dRMLightInterpolator[%d] \n",g_creationcount);
  24. nextobj = g_dxj_Direct3dRMLightInterpolator;
  25. g_dxj_Direct3dRMLightInterpolator = (void *)this;
  26. }
  27. C_dxj_Direct3dRMLightInterpolatorObject::~C_dxj_Direct3dRMLightInterpolatorObject(){
  28. DPF1(1,"Destructor Direct3dRMLightInterpolator [%d] \n",creationid);
  29. C_dxj_Direct3dRMLightInterpolatorObject *prev=NULL;
  30. for(C_dxj_Direct3dRMLightInterpolatorObject *ptr=(C_dxj_Direct3dRMLightInterpolatorObject *)g_dxj_Direct3dRMLightInterpolator;
  31. ptr;
  32. ptr=(C_dxj_Direct3dRMLightInterpolatorObject *)ptr->nextobj)
  33. {
  34. if(ptr == this)
  35. {
  36. if(prev)
  37. prev->nextobj = ptr->nextobj;
  38. else
  39. g_dxj_Direct3dRMLightInterpolator = (void*)ptr->nextobj;
  40. break;
  41. }
  42. prev = ptr;
  43. }
  44. if(m__dxj_Direct3dRMLightInterpolator){
  45. int count = IUNK(m__dxj_Direct3dRMLightInterpolator)->Release();
  46. DPF1(1,"DirectX real IDirect3dRMLightInterpolator Ref count [%d] \n",count);
  47. if(count==0){
  48. m__dxj_Direct3dRMLightInterpolator = NULL;
  49. }
  50. }
  51. if (parent)
  52. IUNK(parent)->Release();
  53. if (m__dxj_Direct3dRMLight)
  54. m__dxj_Direct3dRMLight->Release();
  55. }
  56. DWORD C_dxj_Direct3dRMLightInterpolatorObject::InternalAddRef(){
  57. DWORD i;
  58. i=CComObjectRoot::InternalAddRef();
  59. DPF2(1,"Direct3dRMLightInterpolator[%d] AddRef %d \n",creationid,i);
  60. return i;
  61. }
  62. DWORD C_dxj_Direct3dRMLightInterpolatorObject::InternalRelease(){
  63. DWORD i;
  64. i=CComObjectRoot::InternalRelease();
  65. DPF2(1,"Direct3dRMLightInterpolator [%d] Release %d \n",creationid,i);
  66. return i;
  67. }
  68. HRESULT C_dxj_Direct3dRMLightInterpolatorObject::InternalGetObject(IUnknown **pUnk){
  69. *pUnk=(IUnknown*)m__dxj_Direct3dRMLightInterpolator;
  70. return S_OK;
  71. }
  72. HRESULT C_dxj_Direct3dRMLightInterpolatorObject::InternalSetObject(IUnknown *pUnk){
  73. HRESULT hr;
  74. m__dxj_Direct3dRMLightInterpolator=(LPDIRECT3DRMINTERPOLATOR)pUnk;
  75. hr=pUnk->QueryInterface(IID_IDirect3DRMLight,(void**)&m__dxj_Direct3dRMLight);
  76. return hr;
  77. }
  78. HRESULT C_dxj_Direct3dRMLightInterpolatorObject::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_Direct3dRMLightInterpolator->AttachObject(pObj);
  86. if (pObj) pObj->Release();
  87. return hr;
  88. }
  89. HRESULT C_dxj_Direct3dRMLightInterpolatorObject::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_Direct3dRMLightInterpolator->DetachObject(pObj);
  97. if (pObj) pObj->Release();
  98. return hr;
  99. }
  100. HRESULT C_dxj_Direct3dRMLightInterpolatorObject::getAttachedObjects( I_dxj_Direct3dRMObjectArray __RPC_FAR *__RPC_FAR *rmArray)
  101. {
  102. HRESULT hr;
  103. IDirect3DRMObjectArray *pArray=NULL;
  104. hr=m__dxj_Direct3dRMLightInterpolator->GetAttachedObjects(&pArray);
  105. if FAILED(hr) return hr;
  106. INTERNAL_CREATE(_dxj_Direct3dRMObjectArray,pArray,rmArray);
  107. return S_OK;
  108. }
  109. HRESULT C_dxj_Direct3dRMLightInterpolatorObject::setIndex( /* [in] */ float val){
  110. return m__dxj_Direct3dRMLightInterpolator->SetIndex(val);
  111. }
  112. HRESULT C_dxj_Direct3dRMLightInterpolatorObject::getIndex( float *val){
  113. if (!val) return E_INVALIDARG;
  114. *val=m__dxj_Direct3dRMLightInterpolator->GetIndex();
  115. return S_OK;
  116. }
  117. HRESULT C_dxj_Direct3dRMLightInterpolatorObject::interpolate( float val,
  118. I_dxj_Direct3dRMObject __RPC_FAR *rmObject,
  119. long options){
  120. HRESULT hr;
  121. LPDIRECT3DRMOBJECT pObj=NULL;
  122. DO_GETOBJECT_NOTNULL(LPUNKNOWN,pUnk,rmObject);
  123. //we need to validate some options here or rm goes bezerk with invalid values
  124. //note valid flags are
  125. // one of
  126. // D3DRMINTERPOLATION_CLOSED
  127. // D3DRMINTERPOLATION_OPEN -default
  128. // one of
  129. // D3DRMINTERPOLATION_NEAREST
  130. // D3DRMINTERPOLATION_SPLINE
  131. // D3DRMINTERPOLATION_LINEAR -default
  132. // D3DRMINTERPOLATION_VERTEXCOLOR - only on MeshInterpolator
  133. // D3DRMINTERPOLATION_SLERPNORMALS - not implemented
  134. // VALIDATE FLAGS
  135. DWORD opt2=0;
  136. UINT i4;
  137. if (options & D3DRMINTERPOLATION_CLOSED)
  138. opt2=D3DRMINTERPOLATION_CLOSED;
  139. else
  140. opt2=D3DRMINTERPOLATION_OPEN;
  141. if (options & D3DRMINTERPOLATION_NEAREST)
  142. opt2=opt2 | D3DRMINTERPOLATION_NEAREST;
  143. else if (options & D3DRMINTERPOLATION_SPLINE)
  144. opt2=opt2 | D3DRMINTERPOLATION_SPLINE;
  145. else
  146. opt2=opt2 | D3DRMINTERPOLATION_LINEAR;
  147. if (pUnk){
  148. hr=pUnk->QueryInterface(IID_IDirect3DRMObject, (void**)&pObj);
  149. if FAILED(hr) return hr;
  150. }
  151. hr= m__dxj_Direct3dRMLightInterpolator->Interpolate(val,pObj,(DWORD)opt2);
  152. if (pObj) i4=pObj->Release();
  153. return hr;
  154. }
  155. /////////////////////////////////////////////////////////////////////////////
  156. //STDMETHODIMP C_dxj_Direct3dRMLightInterpolatorObject::setType( long t)
  157. //{
  158. // return m__dxj_Direct3dRMLight->SetType((D3DRMLIGHTTYPE)t);
  159. //}
  160. /////////////////////////////////////////////////////////////////////////////
  161. STDMETHODIMP C_dxj_Direct3dRMLightInterpolatorObject::setColor( long c)
  162. {
  163. return m__dxj_Direct3dRMLight->SetColor((DWORD)c);
  164. }
  165. /////////////////////////////////////////////////////////////////////////////
  166. STDMETHODIMP C_dxj_Direct3dRMLightInterpolatorObject::setColorRGB( float r, float g, float b)
  167. {
  168. return m__dxj_Direct3dRMLight->SetColorRGB(r,g,b);
  169. }
  170. /////////////////////////////////////////////////////////////////////////////
  171. STDMETHODIMP C_dxj_Direct3dRMLightInterpolatorObject::setRange(float r)
  172. {
  173. return m__dxj_Direct3dRMLight->SetRange(r);
  174. }
  175. /////////////////////////////////////////////////////////////////////////////
  176. STDMETHODIMP C_dxj_Direct3dRMLightInterpolatorObject::setUmbra(float u)
  177. {
  178. return m__dxj_Direct3dRMLight->SetUmbra(u);
  179. }
  180. /////////////////////////////////////////////////////////////////////////////
  181. STDMETHODIMP C_dxj_Direct3dRMLightInterpolatorObject::setPenumbra(float u)
  182. {
  183. return m__dxj_Direct3dRMLight->SetPenumbra(u);
  184. }
  185. /////////////////////////////////////////////////////////////////////////////
  186. STDMETHODIMP C_dxj_Direct3dRMLightInterpolatorObject::setConstantAttenuation(float u)
  187. {
  188. return m__dxj_Direct3dRMLight->SetConstantAttenuation(u);
  189. }
  190. /////////////////////////////////////////////////////////////////////////////
  191. STDMETHODIMP C_dxj_Direct3dRMLightInterpolatorObject::setLinearAttenuation(float u)
  192. {
  193. return m__dxj_Direct3dRMLight->SetLinearAttenuation(u);
  194. }
  195. /////////////////////////////////////////////////////////////////////////////
  196. STDMETHODIMP C_dxj_Direct3dRMLightInterpolatorObject::setQuadraticAttenuation(float u)
  197. {
  198. return m__dxj_Direct3dRMLight->SetQuadraticAttenuation(u);
  199. }