home *** CD-ROM | disk | FTP | other *** search
- /* $Id: COMScop.cpp 1.6 1997/05/12 19:13:54 damien Exp $ */
-
- ////////////////////////////////////////////////////////////////////////
- // Scene Operation : stairs //
- //--------------------------------------------------------------------//
- // Implementation of the Scene Operation Interface //
- ////////////////////////////////////////////////////////////////////////
-
-
- #ifndef __COM_SCOP__
- #include "COMScOp.h"
- #endif
-
- #ifndef __SCOP_DLL__
- #include "ScOpDLL.h"
- #endif
-
- #ifndef __I3DSHSCN__
- #include "I3DShScn.h"
- #endif
-
- #ifndef __3DCOFAIL__
- #include "3DCoFail.h"
- #endif
-
- #ifndef __I3DSHTRE__
- #include "I3DShTre.h"
- #endif
-
- #undef INTERFACE
- #define INTERFACE SceneOp
- // Constructor / Destructor of the C++ Object :
- SceneOp::SceneOp() {
- fCRef=0; // Reference Counter
- // Data initialisation :
- fData.fNbStep = 10;
- fData.fDx = 0.0;
- fData.fDy = 1.0;
- fData.fDz = 1.0;
- }
-
- SceneOp::~SceneOp() {
- global_count_Obj--;
- }
-
- // IUnknown Interface :
- HRESULT SceneOp::QueryInterface(THIS_ REFIID riid,LPVOID* ppvObj) {
- *ppvObj=NULL;
-
- // The Behavior knows the interfaces of the parent Objects
- if (IsEqualIID(riid, IID_IUnknown))
- *ppvObj=(LPVOID)this;
- else if (IsEqualIID(riid, IID_I3DExSceneOperation))
- *ppvObj=(LPVOID)this;
- else if (IsEqualIID(riid, IID_I3DExDataExchanger))
- *ppvObj=(LPVOID)this;
- else if (IsEqualIID(riid, IID_I3DExtension))
- *ppvObj=(LPVOID)this;
-
- // we must add reference if we return an interface
- if (*ppvObj!=NULL) {
- ((LPUNKNOWN)*ppvObj)->AddRef();
- return NOERROR;
- }
- else {
- return ResultFromScode(E_NOINTERFACE);
- }
- }
-
- ULONG SceneOp::AddRef(THIS) {
- return fCRef++;
- }
-
- ULONG SceneOp::Release(THIS) {
- ULONG UnreleaseObject=fCRef--;
-
- if (fCRef==0)
- delete this; // No reference left, so destroy the object
-
- return UnreleaseObject;
- // local variable used, because fCRef can be destroyed before.
- }
-
- // I3DExtension methods :
- I3DExtension* SceneOp::Clone(THIS) {
- SceneOp* theClone = new SceneOp;
- if (theClone) {
- theClone->AddRef();
- theClone->fData=fData; // copy the BehaviorData
- }
- return theClone;
- }
-
- HRESULT SceneOp::ShellUtilitiesInit(THIS_ IShUtilities* shellUtilities) {
- InitCoFailure(shellUtilities);
- return NOERROR;
- }
-
- // I3DExDataExchanger methods :
- ExtensionDataMap* SceneOp::GetExtensionDataMap(THIS) {
- return NULL;
- }
-
- void* SceneOp::GetExtensionDataBuffer(THIS) {
- return &fData; // used by the shell to set the new parameters
- }
-
- HRESULT SceneOp::ExtensionDataChanged(THIS) {
- return NOERROR;
- }
-
- HRESULT SceneOp::HandleEvent(THIS_ ULONG SourceID) {
- return ResultFromScode(E_NOTIMPL);
- }
-
- short SceneOp::GetResID(THIS) {
- return 150; // this is the view ID in the resource file.
- }
-
- // I3DExSceneOperation methods :
- HRESULT SceneOp::Prepare(THIS_ I3DShScene *scene, I3DShTreeElement *tree, I3DShSelection* selection, long index, long total) {
- return NOERROR;
- }
-
- Boolean SceneOp::DoIt(THIS_ I3DShScene *scene, I3DShTreeElement *tree, I3DShSelection* selection, long index, long total) {
- I3DShTreeElement *newStep;
- TREETRANSFORM3D stepTransform;
- short iStep;
-
- if (!tree) return FALSE;
-
- for (iStep=0;iStep<fData.fNbStep;iStep++) {
- newStep = tree->Clone(TRUE);
- if (!newStep) return FALSE;
- tree->InsertRight(newStep);
- newStep->GetGlobalTransform(&stepTransform);
- stepTransform.fT[0]+=((NUM3D)iStep)*fData.fDx;
- stepTransform.fT[1]+=((NUM3D)iStep)*fData.fDy;
- stepTransform.fT[2]+=((NUM3D)iStep)*fData.fDz;
- newStep->SetGlobalTransform(&stepTransform);
- }
-
- return TRUE;
- }
-
- HRESULT SceneOp::Prepare8(THIS_ I3DShScene* scene, I3DShTreeElement* tree, I3DShSelection* selection, long index, long total, Boolean* canUndo) {
- *canUndo=false;
- return S_OK;
- }
-
- Boolean SceneOp::UndoIt(THIS_ I3DShScene* scene, I3DShTreeElement* tree, I3DShSelection* selection, long index, long total) {
- return false;
- }
-
- Boolean SceneOp::RedoIt(THIS_ I3DShScene* scene, I3DShTreeElement* tree, I3DShSelection* selection, long index, long total) {
- return false;
- }
-