| 19 | } |
| 20 | |
| 21 | bool StaticMeshVisual::load(const std::string& visual) |
| 22 | { |
| 23 | VisualController::load(visual); |
| 24 | assert(visual.find(".3DS") != std::string::npos || visual.find(".MMB") != std::string::npos || visual.find(".MMS") != std::string::npos || visual.find(".MDMS") != std::string::npos); |
| 25 | |
| 26 | m_MeshHandle = m_World.getStaticMeshAllocator().loadMeshVDF(visual); |
| 27 | |
| 28 | if (!m_MeshHandle.isValid()) |
| 29 | return false; |
| 30 | |
| 31 | Meshes::WorldStaticMesh& mdata = m_World.getStaticMeshAllocator().getMesh(m_MeshHandle); |
| 32 | |
| 33 | // TODO: Put these into a compound-component or something |
| 34 | m_VisualEntities = Content::entitifyMesh(m_World, m_MeshHandle, mdata.mesh); |
| 35 | |
| 36 | // If we haven't already, create an instancebuffer for this mesh |
| 37 | //if(mdata.instanceDataBufferIndex == (uint32_t)-1) |
| 38 | // mdata.instanceDataBufferIndex = ((Engine::GameEngine&)m_World.getEngine()).getDefaultRenderSystem().requestInstanceDataBuffer(); |
| 39 | |
| 40 | Components::PositionComponent& hostPos = m_World.getEntity<Components::PositionComponent>(m_Entity); |
| 41 | |
| 42 | for (Handle::EntityHandle e : m_VisualEntities) |
| 43 | { |
| 44 | // Init positions |
| 45 | Components::EntityComponent& entity = m_World.getEntity<Components::EntityComponent>(e); |
| 46 | Components::Actions::initComponent<Components::PositionComponent>(m_World.getComponentAllocator(), e); |
| 47 | |
| 48 | // Copy world-matrix |
| 49 | Components::PositionComponent& pos = m_World.getEntity<Components::PositionComponent>(e); |
| 50 | pos = hostPos; |
| 51 | |
| 52 | Components::Actions::initComponent<Components::BBoxComponent>(m_World.getComponentAllocator(), e); |
| 53 | Components::BBoxComponent& bbox = m_World.getEntity<Components::BBoxComponent>(e); |
| 54 | bbox.m_SphereRadius = mdata.boundingSphereRadius; |
| 55 | bbox.m_BBox3D = mdata.bBox3D; |
| 56 | } |
| 57 | |
| 58 | updateCollision(); |
| 59 | |
| 60 | return true; |
| 61 | } |
| 62 | |
| 63 | void StaticMeshVisual::setDiffuseTexture(size_t index, const std::string& texture) |
| 64 | { |
nothing calls this directly
no test coverage detected