00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "OctTreeComponent.h"
00019 #include "../../core/GameManager.h"
00020
00021
00022
00023
00024 OctTreeComponent::OctTreeComponent(Entity *parent, const std::string &fileName, s32 minPolysPerNode)
00025 : SceneComponent(parent, true)
00026 {
00027
00028 ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager();
00029
00030
00031 IMesh *mesh = pSceneMgr->getMesh(fileName.c_str());
00032 mSceneNode = pSceneMgr->addOctTreeSceneNode(mesh, 0, parent->getID(), minPolysPerNode, true);
00033 mSceneNode->setPosition(parent->getPosition());
00034
00035
00036 mTriSelector = pSceneMgr->createOctTreeTriangleSelector(mesh, mSceneNode);
00037 mMetaSelector = pSceneMgr->createMetaTriangleSelector();
00038 }
00039
00040
00041 OctTreeComponent::OctTreeComponent(Entity *parent, IMesh *mesh, s32 minPolysPerNode)
00042 : SceneComponent(parent, true)
00043 {
00044
00045 ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager();
00046
00047
00048 mSceneNode = pSceneMgr->addOctTreeSceneNode(mesh, 0, parent->getID(), minPolysPerNode, true);
00049 mSceneNode->setPosition(parent->getPosition());
00050
00051
00052 mTriSelector = pSceneMgr->createOctTreeTriangleSelector(mesh, mSceneNode);
00053 mMetaSelector = pSceneMgr->createMetaTriangleSelector();
00054 }
00055
00056
00057 OctTreeComponent::OctTreeComponent(Entity *parent, IAnimatedMesh *mesh, s32 minPolysPerNode)
00058 : SceneComponent(parent, true)
00059 {
00060
00061 ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager();
00062
00063
00064 mSceneNode = pSceneMgr->addOctTreeSceneNode(mesh, 0, parent->getID(), minPolysPerNode, true);
00065 mSceneNode->setPosition(parent->getPosition());
00066
00067
00068 mTriSelector = pSceneMgr->createOctTreeTriangleSelector(mesh, mSceneNode);
00069 mMetaSelector = pSceneMgr->createMetaTriangleSelector();
00070 }
00071
00072
00073 OctTreeComponent::~OctTreeComponent()
00074 {
00075 }
00076
00077
00078 OctTreeComponent* OctTreeComponent::refFactory(Entity *parent, const std::string &fileName,
00079 s32 minPolysPerNode)
00080 {
00081 return new OctTreeComponent(parent, fileName, minPolysPerNode);
00082 }
00083
00084
00085
00086 void bindOctTreeComponent(asIScriptEngine *engine)
00087 {
00088
00089 int r;
00090
00091
00092 r = engine->RegisterObjectType("OctTreeComponent", sizeof(OctTreeComponent), asOBJ_REF); assert(r >= 0);
00093
00094
00095 bindSceneComponentBase<OctTreeComponent>(engine, "OctTreeComponent");
00096
00097
00098 r = engine->RegisterObjectBehaviour("OctTreeComponent", asBEHAVE_FACTORY, "OctTreeComponent@ f(Entity @, " \
00099 "const string &, s32)",
00100 asFUNCTIONPR(OctTreeComponent::refFactory, (Entity*, const std::string&,
00101 s32), OctTreeComponent*), asCALL_CDECL); assert(r >= 0);
00102 }
00103
00104