00001 /*! \file 00002 \author victorien ferry & www.m4nkind.com 00003 \brief This file applies the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 , read file COPYING. 00004 */ 00005 #ifndef COM_M4NKIND_Object3DMeshVirtual_H 00006 #define COM_M4NKIND_Object3DMeshVirtual_H 00007 00008 #include "Object3DVirtual.h" 00009 #include "PackFloatByte_Limits.h" 00010 #include "PackList.h" 00011 #include "VirtualMachine.h" 00012 /*! 00013 \class Object3DMeshVirtual 00014 \ingroup BaseObjectInherited_VedaLib3DEngine 00015 \brief Define a renderable 3D object with a polygon mesh. 00016 The object can be defined in any way, so this class 00017 is still virtual. 00018 */ 00019 00020 class Object3DMeshVirtual : public Object3DVirtual 00021 { 00022 /*================================================================== 00023 PUBLIC 00024 ==================================================================*/ 00025 public: 00026 /*! 00027 \brief Constructor. There should only be members initialisation there. 00028 */ 00029 Object3DMeshVirtual(void); 00030 00031 /*! 00032 \brief Class Inheritance Descriptors. Also forces a destructor. See BASEOBJECT_DECLARE_... in .cpp 00033 */ 00034 BASEOBJECT_DEFINE_VIRTUALCLASS(Object3DMeshVirtual); 00035 #ifdef _ENGINE_EDITABLE_ 00036 /*! 00037 \brief a GUI could need to play, draw, print, or output from any way, a preview of a 00038 created object. This is done with this method. sub classes can implement it (or not) in 00039 any way, to explicit current shape of an object.<br> 00040 Extended to draw. 00041 \param _frameDate a date, in second, which defines the effect cinematic. 00042 \param _pPreviewViewPort the viewport to render. Can't be 0L. 00043 \param _pPreviewConfiguration 00044 */ 00045 virtual void ProcessPreview(double _frameDate,VirtualMachine::InternalViewPort *_pPreviewViewPort,const PreviewConfiguration *_pPreviewConfiguration); 00046 #endif 00047 00048 /*! 00049 \brief Process a real time computing and drawing. Can be extended. 00050 \param _frameDate a date, in second, which defines the effect cinematic. 00051 \param _pViewPort description of the viewport where to render. 00052 \param _rgba red green blue alpha component. 00053 \param _shapeIndex optional index for multiple shape objects. def to zero. 00054 \param _pModifierList optional ShapeModifierList pointer, to modify objects. 00055 */ 00056 virtual void RenderObject( double _frameDate, 00057 VirtualMachine::InternalViewPort *_pViewPort, 00058 const float _rgba[4], 00059 unsigned int _shapeIndex=0, 00060 ShapeModifierList *_pModifierList=0L ); 00061 /* 00062 \brief get the VirtualMachine's object. 00063 \param _shapeIndex optional index for multiple shape objects. def to zero. 00064 \return a drawable 3d object . 00065 */ 00066 /* anti-object acess !!! inline VirtualMachine::InternalObject3DBuffer *GetObject3DBuffer(unsigned int _shapeIndex=0) 00067 {if( _shapeIndex>=m_CurrentNumberOf3DBuffer) return 0L; 00068 return m_pObject3DBufferTable[ _shapeIndex ].m_pObject3DBuffer; 00069 };*/ 00070 00071 /* 00072 \brief Access to the texture linked. 00073 * DISABLED: ANTI-OBJECT!!!INTERFERENCE !! 00074 it's a private affair ! ->MEGADEPRECATED * 00075 \return the hardware abstract texture. 00076 */ 00077 //VirtualMachine::InternalTexture *GetTexture(); 00078 00079 /*================================================================== 00080 PROTECTED 00081 ==================================================================*/ 00082 protected: 00083 /*! 00084 \brief update the shape of the object for this date, during 00085 the lifetime the object, when it is created. 00086 by defdault, does nothing, so static object can be created 00087 with CreateInternal() only. 00088 \param _newShapeTime the new date. 00089 \param _shapeIndex the index of the shape to modify. 00090 */ 00091 virtual void CreateShape(float _newShapeTime, unsigned int _shapeIndex=0); 00092 //! an object shape is relative to a time date, and the extended object's attributes. 00093 float m_LastShapeTime; 00094 //! last shape modifier applied. 00095 ShapeModifierList *m_pLastShapeModifierList; 00096 //! flag for each object shape: 00097 typedef enum { 00098 //! means object is compiled, cannot be reshaped. 00099 OB3DFlag_Static=1, 00100 //! means the object always look the camera. 00101 OB3DFlag_LookCam=2, 00102 //! means object shape is static, and is pre-rendered to a 32x32 image. 00103 OB3DFlag_PreRender32=4, // 00104 //! means object shape is static, and is pre-rendered to a 128x128 image. 00105 OB3DFlag_PreRender128=8, 00106 //! means SetColor() affect the whole object, else color is computed per vertex. 00107 OB3DFlag_OneColor=16, 00108 //! start of possible flag extension for inheritage. 00109 OB3DFlag_Object3DVirtual_LastFlag=32 00110 } OB3DBitFlag ; 00111 00112 //! property flags (OB3DFlag_...) 00113 PackULong_Flags mSer_Flags; 00114 00115 //! The only texture for the object. We support 1 texture by object in this class. 00116 PackObjectReference mSer_TextureRef; 00117 00118 /* 00119 \brief Nested class that can describe a 3D Object, or a billboard 00120 square with the prerendered object (in that case, m_pRenderTexture is not null.) 00121 */ 00122 class Object3DBufferHandler { 00123 public: 00124 //! constructor that init pointers to null: 00125 Object3DBufferHandler(); 00126 //! the hardwareAbstracted vertex buffer for this object: 00127 VirtualMachine::InternalObject3DBuffer *m_pObject3DBuffer; 00128 //! current active number of vertex, <= m_pObject3DBuffer->totalnb 00129 unsigned int m_ActiveNumberOfVertex; 00130 //! if pre-rendered, this texture holds the rendering, and override the Texture3D object: 00131 VirtualMachine::InternalTexture *m_pRenderTexture; 00132 }; 00133 //!, should be available if created: 00134 Object3DBufferHandler *m_pObject3DBufferTable; 00135 00136 //! current number of InternalObject3DBuffer created in table m_pObject3DVirtualBufferTable. Most of the time it's 1. 00137 unsigned int m_CurrentNumberOf3DBuffer; 00138 00139 //! \class BoundingBox 00140 //! \brief nested class used to calculkate the bouding bow of a 3D shape. 00141 class BoundingBox { 00142 public: 00143 float m_x1,m_x2,m_y1,m_y2,m_z1,m_z2; 00144 //! \brief init box. 00145 void FindBoundingBox( VirtualMachine::InternalObject3DBuffer *_pOb3d ); 00146 } ; 00147 00148 /*! 00149 \brief tool for CreateInternal(). If mSer_Flags ask it,(OB3DFlag_PreRender) 00150 all objects previously constructed are rendered to a texture, and 00151 the object is replaced by a billboard with the same dimensions. 00152 */ 00153 bool CreateInternal_RenderObjectToTexture(void); 00154 /*! 00155 \brief tool for CreateInternal(). If mSer_Flags ask it,(OB3DFlag_Static) 00156 once the object shape is created (to date 0 seconds), the object shape 00157 is frozen and changes will be ignored. Note: It applies to all shapes. 00158 It allows some optilizations... 00159 00160 */ 00161 void CreateInternal_FreezeStaticShape(void); 00162 00163 #ifdef _ENGINE_EDITABLE_ 00164 /*! 00165 \brief that closes everything. Still, the object exist and can be rebuild the same using Create() 00166 */ 00167 virtual void CloseInternal(void); 00168 #endif 00169 }; 00170 00171 #endif
/\/\ 4 N k ! N D _______ _ __ ___ _____ ___ _ _ ____ ___________ __//___ /________ |/ / ___________\_______/ \ / _ _ \/ _ / _ / _/_/____/ _ __ / / / / / / / \ \/ / / \ \ / \\___/___/___/ ¯ _____/_____/ ______\___/_____/\________\\ \________/_ ___ __ l____\ /elD! http://www.m4nkind.com \____/