Go to the documentation of this file.00001 #ifndef __NYTRO_AssemblyEntity_H
00002 #define __NYTRO_AssemblyEntity_H
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "system/nyCommon.h"
00012 #include "scene/nySceneNode.h"
00013 #include "game/nyEntity.h"
00014
00015 namespace Nytro
00016 {
00017 namespace Game
00018 {
00019 class AssemblyEntityData;
00020
00021 class AssemblyEntityPhysicsObject
00022 {
00023 public:
00024
00025 void loadPropertiesFromXml( XmlElement* pParentElem );
00026
00027 string m_type;
00028 map<string,string> m_properties;
00029 };
00030
00031 class AssemblyEntityPhysicsJoint : public AssemblyEntityPhysicsObject
00032 {
00033 public:
00034
00035 PhysicsJoint* createJoint();
00036 };
00037
00038 class AssemblyEntityPhysicsBody : public AssemblyEntityPhysicsObject
00039 {
00040 public:
00041
00042 PhysicsBody* createBody();
00043 };
00044
00045 class AssemblyEntityPhysicsShape : public AssemblyEntityPhysicsObject
00046 {
00047 public:
00048
00049 PhysicsShape* createShape();
00050 };
00051
00054 class NYTRO_API AssemblyEntitySlot
00055 {
00056 public:
00057
00058 AssemblyEntitySlot();
00059 ~AssemblyEntitySlot();
00060
00062 string m_name,
00064 m_fileName,
00066 m_className,
00068 m_description;
00069 Vector3D m_translation, m_scale, m_pivot;
00070 Quaternion m_rotation;
00072 Base* m_pObject;
00073 AssemblyEntitySlot* m_pParent;
00074 vector<AssemblyEntitySlot*> m_children;
00075 vector<AssemblyEntityPhysicsShape*> m_physicsShapes;
00076 AssemblyEntityPhysicsJoint* m_pPhysicsJoint;
00077 AssemblyEntityPhysicsBody* m_pPhysicsBody;
00078 };
00079
00081 class NYTRO_API AssemblyEntityData : public Resource
00082 {
00083 public:
00084
00085 AssemblyEntityData();
00086 virtual ~AssemblyEntityData();
00087
00088 EResult load( const char* pFilename = NULL );
00089 EResult unload();
00090
00092 const vector<AssemblyEntitySlot*>& getSlots();
00093 const map<string,string>& getAnimations();
00094
00095 protected:
00096
00097 void loadSlotsRecursive( XmlElement* pParentElem, AssemblyEntitySlot* pParentSlot );
00098
00099 vector<AssemblyEntitySlot*> m_slots;
00100 map<string,string> m_animations;
00101 };
00102
00104 class NYTRO_API AssemblyEntity : public Entity
00105 {
00106 public:
00107
00108 NYTRO_CLASS_NAME( AssemblyEntity );
00109
00110 AssemblyEntity();
00111 virtual ~AssemblyEntity();
00112
00113 virtual void free();
00114 virtual bool traceRay( Ray& rRay, float& rWhere,
00115 Vector3D& rPointIn, Vector3D& rPointOut,
00116 Vector3D& rNormalIn, Vector3D& rNormalOut );
00117 void setFromResource( Resource* pRes );
00118
00119 protected:
00120
00121 void createSlotChildrenNodesRecursive( AssemblyEntitySlot* pParentSlot, SceneNode* pParentNode );
00122
00123 map<SceneNode*,vector<PhysicsShape*>> m_nodesPhysicsShapes;
00124 map<SceneNode*,PhysicsJoint*> m_nodesPhysicsJoints;
00125 map<SceneNode*,PhysicsBody*> m_nodesPhysicsBodies;
00126 };
00127 };
00128 };
00129
00130 #endif