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.

259 lines
7.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: d3drmmeshinterobj.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 "d3drmMeshInterObj.h"
  15. #include "d3drmObjectArrayObj.h"
  16. extern void *g_dxj_Direct3dRMMeshInterpolator;
  17. C_dxj_Direct3dRMMeshInterpolatorObject::C_dxj_Direct3dRMMeshInterpolatorObject(){
  18. m__dxj_Direct3dRMMeshInterpolator=NULL;
  19. m__dxj_Direct3dRMMesh=NULL;
  20. parent=NULL;
  21. pinterface=NULL;
  22. creationid = ++g_creationcount;
  23. DPF1(1,"Constructor Creation Direct3dRMMeshInterpolator[%d] \n",g_creationcount);
  24. nextobj = g_dxj_Direct3dRMMeshInterpolator;
  25. g_dxj_Direct3dRMMeshInterpolator = (void *)this;
  26. }
  27. C_dxj_Direct3dRMMeshInterpolatorObject::~C_dxj_Direct3dRMMeshInterpolatorObject(){
  28. DPF1(1,"Destructor Direct3dRMMeshInterpolator [%d] \n",creationid);
  29. C_dxj_Direct3dRMMeshInterpolatorObject *prev=NULL;
  30. for(C_dxj_Direct3dRMMeshInterpolatorObject *ptr=(C_dxj_Direct3dRMMeshInterpolatorObject *)g_dxj_Direct3dRMMeshInterpolator;
  31. ptr;
  32. ptr=(C_dxj_Direct3dRMMeshInterpolatorObject *)ptr->nextobj)
  33. {
  34. if(ptr == this)
  35. {
  36. if(prev)
  37. prev->nextobj = ptr->nextobj;
  38. else
  39. g_dxj_Direct3dRMMeshInterpolator = (void*)ptr->nextobj;
  40. break;
  41. }
  42. prev = ptr;
  43. }
  44. if(m__dxj_Direct3dRMMeshInterpolator){
  45. int count = IUNK(m__dxj_Direct3dRMMeshInterpolator)->Release();
  46. DPF1(1,"DirectX real IDirect3dRMMeshInterpolator Ref count [%d] \n",count);
  47. if(count==0){
  48. m__dxj_Direct3dRMMeshInterpolator = NULL;
  49. }
  50. }
  51. if (parent)
  52. IUNK(parent)->Release();
  53. if (m__dxj_Direct3dRMMesh)
  54. m__dxj_Direct3dRMMesh->Release();
  55. }
  56. DWORD C_dxj_Direct3dRMMeshInterpolatorObject::InternalAddRef(){
  57. DWORD i;
  58. i=CComObjectRoot::InternalAddRef();
  59. DPF2(1,"Direct3dRMMeshInterpolator[%d] AddRef %d \n",creationid,i);
  60. return i;
  61. }
  62. DWORD C_dxj_Direct3dRMMeshInterpolatorObject::InternalRelease(){
  63. DWORD i;
  64. i=CComObjectRoot::InternalRelease();
  65. DPF2(1,"Direct3dRMMeshInterpolator [%d] Release %d \n",creationid,i);
  66. return i;
  67. }
  68. HRESULT C_dxj_Direct3dRMMeshInterpolatorObject::InternalGetObject(IUnknown **pUnk){
  69. *pUnk=(IUnknown*)m__dxj_Direct3dRMMeshInterpolator;
  70. return S_OK;
  71. }
  72. HRESULT C_dxj_Direct3dRMMeshInterpolatorObject::InternalSetObject(IUnknown *pUnk){
  73. HRESULT hr;
  74. m__dxj_Direct3dRMMeshInterpolator=(LPDIRECT3DRMINTERPOLATOR)pUnk;
  75. hr=pUnk->QueryInterface(IID_IDirect3DRMMesh,(void**)&m__dxj_Direct3dRMMesh);
  76. return hr;
  77. }
  78. HRESULT C_dxj_Direct3dRMMeshInterpolatorObject::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_Direct3dRMMeshInterpolator->AttachObject(pObj);
  86. if (pObj) pObj->Release();
  87. return hr;
  88. }
  89. HRESULT C_dxj_Direct3dRMMeshInterpolatorObject::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_Direct3dRMMeshInterpolator->DetachObject(pObj);
  97. if (pObj) pObj->Release();
  98. return hr;
  99. }
  100. HRESULT C_dxj_Direct3dRMMeshInterpolatorObject::getAttachedObjects( /* [retval][out] */ I_dxj_Direct3dRMObjectArray __RPC_FAR *__RPC_FAR *rmArray)
  101. {
  102. HRESULT hr;
  103. IDirect3DRMObjectArray *pArray=NULL;
  104. hr=m__dxj_Direct3dRMMeshInterpolator->GetAttachedObjects(&pArray);
  105. if FAILED(hr) return hr;
  106. INTERNAL_CREATE(_dxj_Direct3dRMObjectArray,pArray,rmArray);
  107. return S_OK;
  108. }
  109. HRESULT C_dxj_Direct3dRMMeshInterpolatorObject::setIndex( /* [in] */ float val){
  110. return m__dxj_Direct3dRMMeshInterpolator->SetIndex(val);
  111. }
  112. HRESULT C_dxj_Direct3dRMMeshInterpolatorObject::getIndex( float *val){
  113. if (!val) return E_INVALIDARG;
  114. *val=m__dxj_Direct3dRMMeshInterpolator->GetIndex();
  115. return S_OK;
  116. }
  117. HRESULT C_dxj_Direct3dRMMeshInterpolatorObject::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 (options & D3DRMINTERPOLATION_VERTEXCOLOR)
  148. opt2=opt2 | D3DRMINTERPOLATION_VERTEXCOLOR;
  149. if (pUnk){
  150. hr=pUnk->QueryInterface(IID_IDirect3DRMObject, (void**)&pObj);
  151. if FAILED(hr) return hr;
  152. }
  153. hr= m__dxj_Direct3dRMMeshInterpolator->Interpolate(val,pObj,(DWORD)opt2);
  154. if (pObj) i4= pObj->Release();
  155. return hr;
  156. }
  157. /////////////////////////////////////////////////////////////////////////////
  158. STDMETHODIMP C_dxj_Direct3dRMMeshInterpolatorObject::setVertices( d3drmGroupIndex id, long idx, long cnt, SAFEARRAY **ppsa)
  159. {
  160. HRESULT hr;
  161. //
  162. // Go through and reformat all the float color values back
  163. // to long, so the array of floats now looks like an array
  164. // D3DRMVERTEXES
  165. //
  166. if (!ISSAFEARRAY1D(ppsa,(DWORD)cnt))
  167. return E_INVALIDARG;
  168. D3DRMVERTEX *values= (D3DRMVERTEX*)((SAFEARRAY*)*ppsa)->pvData;
  169. __try{
  170. hr=m__dxj_Direct3dRMMesh->SetVertices((DWORD)id, (DWORD)idx,(DWORD) cnt, (struct _D3DRMVERTEX *)values);
  171. }
  172. __except(1,1){
  173. return E_INVALIDARG;
  174. }
  175. return hr;
  176. }
  177. /////////////////////////////////////////////////////////////////////////////
  178. STDMETHODIMP C_dxj_Direct3dRMMeshInterpolatorObject::translate(
  179. /* [in] */ float tx,
  180. /* [in] */ float ty,
  181. /* [in] */ float tz) {
  182. return m__dxj_Direct3dRMMesh->Translate(tx,ty,tz);
  183. }
  184. /////////////////////////////////////////////////////////////////////////////
  185. STDMETHODIMP C_dxj_Direct3dRMMeshInterpolatorObject::setGroupColor(
  186. /* [in] */ d3drmGroupIndex id,
  187. /* [in] */ d3dcolor val) {
  188. return m__dxj_Direct3dRMMesh->SetGroupColor((DWORD)id,(D3DCOLOR)val);
  189. }
  190. /////////////////////////////////////////////////////////////////////////////
  191. STDMETHODIMP C_dxj_Direct3dRMMeshInterpolatorObject::setGroupColorRGB(
  192. /* [in] */ d3drmGroupIndex id,
  193. /* [in] */ float r,
  194. float g,
  195. float b) {
  196. return m__dxj_Direct3dRMMesh->SetGroupColorRGB((DWORD)id,r,g,b);
  197. }