![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 ** Copyright (c) 2009 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 /****************************************************************************** 00006 ** $RCSfile: DtAttachableCuboidModelInstance.h,v $ $Revision: 1.0 $ $State: Exp $ 00007 ******************************************************************************/ 00008 00012 00013 #pragma once 00014 #include <vrvOsg/DtOsgModelInstance.h> 00015 #include <osg/Geode> 00016 #include <osg/MatrixTransform> 00017 #include <osg/Drawable> 00018 #include <osg/Material> 00019 00020 namespace makVrv 00021 { 00024 class DT_DLL_VRVOSG DtCubeModelInstance : public DtOsgModelInstance 00025 { 00026 public: 00027 00029 DtCubeModelInstance(DtDe& de); 00030 00032 virtual ~DtCubeModelInstance(); 00033 00035 virtual void setDimensions(float x, float y, float z); 00036 00038 void dimensions( float& length, float& width, float& height ); 00039 00041 virtual void setColor(float r,float g,float b,float a); 00042 00044 const osg::Vec4& color() const; 00045 00047 virtual void setLightingEnabled( bool enabled ); 00048 00051 virtual bool realize(DtModelDefinition& definition); 00052 00054 virtual void setVisible(bool isVisible) {} 00055 00057 virtual void setContributesToBound(bool trueOrFalse); 00058 00059 protected: 00060 00062 virtual void updateColors(); 00063 00065 virtual void updateTransform(); 00066 00068 void createBlendedGeodes(); 00069 00071 void createOpaqueGeode(); 00072 00074 void createSingleSidedBlendedGeode(); 00075 00076 protected: 00077 00079 float myLength; // x dimension 00080 float myWidth; // y dimension 00081 float myHeight; 00082 osg::Vec4 myColor; 00083 00084 osg::ref_ptr<osg::Drawable> myCubeDrawable; 00086 osg::ref_ptr<osg::Geode> myGeode; 00088 osg::ref_ptr<osg::Geode> myBlendedGeode; 00090 osg::ref_ptr<osg::Geode> myFrontGeode; 00092 osg::ref_ptr<osg::Geode> myBackGeode; 00094 osg::ref_ptr<osg::MatrixTransform> myTransform; 00096 osg::ref_ptr<osg::Material> myMaterial; 00097 00098 bool mySingleSided; 00099 }; 00100 00103 class DT_DLL_VRVOSG DtCubeModelInstanceCreator : public DtModelInstanceCreator 00104 { 00105 public: 00106 00108 static void registerCreator(DtDe& de); 00109 00111 virtual ~DtCubeModelInstanceCreator (); 00112 00114 virtual DtModelInstance* create(DtDe& de); 00115 00116 protected: 00117 00118 DtCubeModelInstanceCreator (); 00119 }; 00120 }