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.

227 lines
6.6 KiB

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