summaryrefslogtreecommitdiffstats
path: root/src/object/motion
diff options
context:
space:
mode:
Diffstat (limited to 'src/object/motion')
-rw-r--r--src/object/motion/motion.cpp23
-rw-r--r--src/object/motion/motion.h8
-rw-r--r--src/object/motion/motionant.cpp126
-rw-r--r--src/object/motion/motionant.h2
-rw-r--r--src/object/motion/motionbee.cpp86
-rw-r--r--src/object/motion/motionbee.h2
-rw-r--r--src/object/motion/motionhuman.cpp123
-rw-r--r--src/object/motion/motionhuman.h2
-rw-r--r--src/object/motion/motionmother.cpp77
-rw-r--r--src/object/motion/motionmother.h2
-rw-r--r--src/object/motion/motionspider.cpp39
-rw-r--r--src/object/motion/motionspider.h2
-rw-r--r--src/object/motion/motiontoto.cpp42
-rw-r--r--src/object/motion/motiontoto.h2
-rw-r--r--src/object/motion/motionvehicle.cpp528
-rw-r--r--src/object/motion/motionvehicle.h2
-rw-r--r--src/object/motion/motionworm.cpp23
-rw-r--r--src/object/motion/motionworm.h2
18 files changed, 382 insertions, 709 deletions
diff --git a/src/object/motion/motion.cpp b/src/object/motion/motion.cpp
index 605091f..00b3073 100644
--- a/src/object/motion/motion.cpp
+++ b/src/object/motion/motion.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "common/iman.h"
+#include "object/robotmain.h"
#include "script/cmdtoken.h"
@@ -30,20 +30,16 @@
// Object's constructor.
-CMotion::CMotion(CInstanceManager* iMan, CObject* object)
+CMotion::CMotion(CObject* object)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_MOTION, this, 100);
-
m_app = CApplication::GetInstancePointer();
- m_engine = static_cast< Gfx::CEngine* >(m_iMan->SearchInstance(CLASS_ENGINE));
- m_light = static_cast< Gfx::CLight* >(m_iMan->SearchInstance(CLASS_LIGHT));
- m_particle = static_cast< Gfx::CParticle* >(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_terrain = static_cast< Gfx::CTerrain* >(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast< Gfx::CWater* >(m_iMan->SearchInstance(CLASS_WATER));
- m_camera = static_cast< Gfx::CCamera* >(m_iMan->SearchInstance(CLASS_CAMERA));
- m_main = static_cast< CRobotMain* >(m_iMan->SearchInstance(CLASS_MAIN));
- m_sound = static_cast< CSoundInterface* >(m_iMan->SearchInstance(CLASS_SOUND));
+ m_sound = m_app->GetSound();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_particle = m_engine->GetParticle();
+ m_water = m_engine->GetWater();
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_camera = m_main->GetCamera();
m_object = object;
m_physics = 0;
@@ -62,7 +58,6 @@ CMotion::CMotion(CInstanceManager* iMan, CObject* object)
CMotion::~CMotion()
{
- m_iMan->DeleteInstance(CLASS_MOTION, this);
}
// Deletes the object.
diff --git a/src/object/motion/motion.h b/src/object/motion/motion.h
index 81bcb08..d35ee67 100644
--- a/src/object/motion/motion.h
+++ b/src/object/motion/motion.h
@@ -27,14 +27,12 @@
namespace Gfx {
class CEngine;
-class CLight;
class CParticle;
class CTerrain;
class CWater;
class CCamera;
}
-class CInstanceManager;
class CApplication;
class CBrain;
class CPhysics;
@@ -46,7 +44,7 @@ class CSoundInterface;
class CMotion
{
public:
- CMotion(CInstanceManager* iMan, CObject* object);
+ CMotion(CObject* object);
virtual ~CMotion();
void SetPhysics(CPhysics* physics);
@@ -72,12 +70,8 @@ public:
virtual Math::Vector GetInclinaison();
protected:
-
-protected:
- CInstanceManager* m_iMan;
CApplication* m_app;
Gfx::CEngine* m_engine;
- Gfx::CLight* m_light;
Gfx::CParticle* m_particle;
Gfx::CTerrain* m_terrain;
Gfx::CWater* m_water;
diff --git a/src/object/motion/motionant.cpp b/src/object/motion/motionant.cpp
index 07ee6b8..384d683 100644
--- a/src/object/motion/motionant.cpp
+++ b/src/object/motion/motionant.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "graphics/engine/particle.h"
#include "physics/physics.h"
@@ -35,8 +35,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionAnt::CMotionAnt(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionAnt::CMotionAnt(CObject* object) : CMotion(object)
{
m_armMember = START_TIME;
m_armTimeAbs = START_TIME;
@@ -69,12 +68,8 @@ void CMotionAnt::DeleteObject(bool bAll)
bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
- int rank;
-
-// if ( m_engine->GetRestCreate() < 3+18 ) return false;
-
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
+ int rank;
m_object->SetType(type);
@@ -82,10 +77,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
-
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant1.mod"));
- pModFile->CreateEngineObject(rank);
-
+ modelManager->AddModelReference("ant1.mod", false, rank);
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
@@ -96,29 +88,26 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the head.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant2.mod", false, rank);
m_object->SetPosition(1, Math::Vector(2.0f, 0.0f, 0.0f));
// Creates the tail.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant3.mod", false, rank);
m_object->SetPosition(2, Math::Vector(-1.0f, 0.0f, 0.0f));
// Creates a right-back thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(3, Math::Vector(-0.4f, -0.1f, -0.3f));
// Creates a right-back leg.
@@ -126,161 +115,135 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 3);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(4, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates a right-back foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates two middle-right thighs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.1f, -0.1f, -0.4f));
// Creates two middle-right legs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 6);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates two middle-right foots.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 7);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(8, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates the right front thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(9, Math::Vector(1.4f, -0.1f, -0.6f));
// Creates the right front leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 9);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(10, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates the right front foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 10);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates a left-back thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", true, rank);
m_object->SetPosition(12, Math::Vector(-0.4f, -0.1f, 0.3f));
// Creates a left-back leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 12);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", true, rank);
m_object->SetPosition(13, Math::Vector(0.0f, 0.0f, 1.0f));
// Creates a left-back foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(14, rank);
m_object->SetObjectParent(14, 13);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", true, rank);
m_object->SetPosition(14, Math::Vector(0.0f, 0.0f, 2.0f));
// Creates two middle-left thighs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(15, rank);
m_object->SetObjectParent(15, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", true, rank);
m_object->SetPosition(15, Math::Vector(0.1f, -0.1f, 0.4f));
// Creates two middle-left legs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(16, rank);
m_object->SetObjectParent(16, 15);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", true, rank);
m_object->SetPosition(16, Math::Vector(0.0f, 0.0f, 1.0f));
// Creates two middle-left foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(17, rank);
m_object->SetObjectParent(17, 16);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", true, rank);
m_object->SetPosition(17, Math::Vector(0.0f, 0.0f, 2.0f));
// Creates the left front thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(18, rank);
m_object->SetObjectParent(18, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", true, rank);
m_object->SetPosition(18, Math::Vector(1.4f, -0.1f, 0.6f));
// Creates the left front leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(19, rank);
m_object->SetObjectParent(19, 18);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", true, rank);
m_object->SetPosition(19, Math::Vector(0.0f, 0.0f, 1.0f));
// Creates the left front foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(20, rank);
m_object->SetObjectParent(20, 19);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", true, rank);
m_object->SetPosition(20, Math::Vector(0.0f, 0.0f, 2.0f));
m_object->CreateShadowCircle(4.0f, 0.5f);
@@ -293,7 +256,6 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
diff --git a/src/object/motion/motionant.h b/src/object/motion/motionant.h
index 68a3b7f..45d02b3 100644
--- a/src/object/motion/motionant.h
+++ b/src/object/motion/motionant.h
@@ -46,7 +46,7 @@ enum MotionAntSpecialAction
class CMotionAnt : public CMotion
{
public:
- CMotionAnt(CInstanceManager* iMan, CObject* object);
+ CMotionAnt(CObject* object);
~CMotionAnt();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionbee.cpp b/src/object/motion/motionbee.cpp
index a3421b8..8f69945 100644
--- a/src/object/motion/motionbee.cpp
+++ b/src/object/motion/motionbee.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "physics/physics.h"
@@ -34,8 +34,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionBee::CMotionBee(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionBee::CMotionBee(CObject* object) : CMotion(object)
{
m_armMember = START_TIME;
m_armTimeAbs = START_TIME;
@@ -67,12 +66,8 @@ void CMotionBee::DeleteObject(bool bAll)
bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
- int rank;
-
-// if ( m_engine->GetRestCreate() < 3+18+2 ) return false;
-
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
+ int rank;
m_object->SetType(type);
@@ -80,10 +75,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
-
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee1.mod"));
- pModFile->CreateEngineObject(rank);
-
+ modelManager->AddModelReference("bee1.mod", false, rank);
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
@@ -97,8 +89,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("bee2.mod", false, rank);
m_object->SetPosition(1, Math::Vector(1.6f, 0.3f, 0.0f));
// Creates the tail.
@@ -106,8 +97,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("bee3.mod", false, rank);
m_object->SetPosition(2, Math::Vector(-0.8f, 0.0f, 0.0f));
// Creates a right-back thigh.
@@ -115,8 +105,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(3, Math::Vector(-0.3f, -0.1f, -0.2f));
// Creates a right-back leg.
@@ -124,8 +113,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 3);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(4, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates a right-back foot.
@@ -133,8 +121,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates two middle-right thighs.
@@ -142,8 +129,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.3f, -0.1f, -0.4f));
// Creates two middle-right legs.
@@ -151,8 +137,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 6);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates two middle-right feet.
@@ -160,8 +145,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 7);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(8, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates the right front thigh.
@@ -169,8 +153,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(9, Math::Vector(1.0f, -0.1f, -0.7f));
// Creates the right front leg.
@@ -178,8 +161,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 9);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(10, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates the right front foot.
@@ -187,8 +169,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 10);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates a left-back thigh.
@@ -196,8 +177,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(12, Math::Vector(-0.3f, -0.1f, 0.2f));
m_object->SetAngleY(12, Math::PI);
@@ -206,8 +186,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 12);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(13, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates a left-back foot.
@@ -215,8 +194,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(14, rank);
m_object->SetObjectParent(14, 13);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(14, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates two middle-left thigh.
@@ -224,8 +202,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(15, rank);
m_object->SetObjectParent(15, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(15, Math::Vector(0.3f, -0.1f, 0.4f));
m_object->SetAngleY(15, Math::PI);
@@ -234,8 +211,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(16, rank);
m_object->SetObjectParent(16, 15);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(16, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates two middle-left feet.
@@ -243,8 +219,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(17, rank);
m_object->SetObjectParent(17, 16);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(17, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates front-left thigh.
@@ -252,8 +227,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(18, rank);
m_object->SetObjectParent(18, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(18, Math::Vector(1.0f, -0.1f, 0.7f));
m_object->SetAngleY(18, Math::PI);
@@ -262,8 +236,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(19, rank);
m_object->SetObjectParent(19, 18);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(19, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates front-left foot.
@@ -271,8 +244,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(20, rank);
m_object->SetObjectParent(20, 19);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(20, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates the right wing.
@@ -280,8 +252,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(21, rank);
m_object->SetObjectParent(21, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee7.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("bee7.mod", false, rank);
m_object->SetPosition(21, Math::Vector(0.8f, 0.4f, -0.5f));
// Creates the left wing.
@@ -289,9 +260,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(22, rank);
m_object->SetObjectParent(22, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee7.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("bee7.mod", true, rank);
m_object->SetPosition(22, Math::Vector(0.8f, 0.4f, 0.5f));
m_object->CreateShadowCircle(6.0f, 0.5f);
@@ -304,7 +273,6 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
diff --git a/src/object/motion/motionbee.h b/src/object/motion/motionbee.h
index aa8e5a6..c0347a0 100644
--- a/src/object/motion/motionbee.h
+++ b/src/object/motion/motionbee.h
@@ -40,7 +40,7 @@ enum MotionBeeSpecialAction
class CMotionBee : public CMotion
{
public:
- CMotionBee(CInstanceManager* iMan, CObject* object);
+ CMotionBee(CObject* object);
~CMotionBee();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionhuman.cpp b/src/object/motion/motionhuman.cpp
index a9b79b5..dc5ff34 100644
--- a/src/object/motion/motionhuman.cpp
+++ b/src/object/motion/motionhuman.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
@@ -43,8 +43,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionHuman::CMotionHuman(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionHuman::CMotionHuman(CObject* object) : CMotion(object)
{
m_partiReactor = -1;
m_armMember = START_TIME;
@@ -97,30 +96,22 @@ Error CMotionHuman::SetAction(int action, float time)
bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
char filename[100];
int rank, option, face, glasses;
-// if ( m_engine->GetRestCreate() < 16 ) return false;
-
-
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
m_object->SetType(type);
option = m_object->GetOption();
- std::string baseName;
-
if ( m_main->GetGamerOnlyHead() )
{
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
face = m_main->GetGamerFace();
- baseName = m_app->GetDataFilePath(DIR_MODEL, "human2h%d.mod");
- sprintf(filename, baseName.c_str(), face+1);
- pModFile->ReadModel(filename);
- pModFile->CreateEngineObject(rank);
+ sprintf(filename, "human2h%d.mod", face+1);
+ modelManager->AddModelReference(filename, false, rank);
glasses = m_main->GetGamerGlasses();
if ( glasses != 0 )
@@ -129,10 +120,8 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- baseName = m_app->GetDataFilePath(DIR_MODEL, "human2g%d.mod");
- sprintf(filename, baseName.c_str(), glasses);
- pModFile->ReadModel(filename);
- pModFile->CreateEngineObject(rank);
+ sprintf(filename, "human2g%d.mod", glasses);
+ modelManager->AddModelReference(filename, false, rank);
}
CreatePhysics(type);
@@ -140,7 +129,6 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
@@ -149,19 +137,12 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
- if ( option == 0 ) // head in helmet?
- {
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human1c.mod"));
- }
- if ( option == 1 ) // head without helmet?
- {
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human1h.mod"));
- }
- if ( option == 2 ) // without a backpack?
- {
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human1v.mod"));
- }
- pModFile->CreateEngineObject(rank);
+ if (option == 0) // head in helmet?
+ modelManager->AddModelReference("human1c.mod", false, rank);
+ else if (option == 1) // head without helmet?
+ modelManager->AddModelReference("human1h.mod", false, rank);
+ else if (option == 2) // without a backpack?
+ modelManager->AddModelReference("human1v.mod", false, rank);
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
@@ -178,30 +159,28 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
if ( type == OBJECT_HUMAN )
{
- if ( option == 0 ) // head in helmet?
+ if (option == 0) // head in helmet?
{
face = m_main->GetGamerFace();
- baseName = m_app->GetDataFilePath(DIR_MODEL, "human2c%d.mod");
- sprintf(filename, baseName.c_str(), face+1);
- pModFile->ReadModel(filename);
+ sprintf(filename, "human2c%d.mod", face+1);
+ modelManager->AddModelReference(filename, false, rank);
}
- if ( option == 1 || // head without helmet?
- option == 2 ) // without a backpack?
+ else if (option == 1 || // head without helmet?
+ option == 2) // without a backpack?
{
face = m_main->GetGamerFace();
- baseName = m_app->GetDataFilePath(DIR_MODEL, "human2h%d.mod");
- sprintf(filename, baseName.c_str(), face+1);
- pModFile->ReadModel(filename);
+ sprintf(filename, "human2h%d.mod", face+1);
+ modelManager->AddModelReference(filename, false, rank);
}
}
- if ( type == OBJECT_TECH )
+ else if (type == OBJECT_TECH)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human2t.mod"));
+ modelManager->AddModelReference("human2t.mod", false, rank);
}
- pModFile->CreateEngineObject(rank);
+
m_object->SetPosition(1, Math::Vector(0.0f, 2.7f, 0.0f));
- if ( option == 1 || // head without helmet?
- option == 2 ) // without a backpack?
+ if (option == 1 || // head without helmet?
+ option == 2) // without a backpack?
{
m_object->SetZoom(1, Math::Vector(1.0f, 1.05f, 1.0f));
}
@@ -214,10 +193,8 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(15, rank);
m_object->SetObjectParent(15, 1);
- baseName = m_app->GetDataFilePath(DIR_MODEL, "human2g%d.mod");
- sprintf(filename, baseName.c_str(), glasses);
- pModFile->ReadModel(filename);
- pModFile->CreateEngineObject(rank);
+ sprintf(filename, "human2g%d.mod", glasses);
+ modelManager->AddModelReference(filename, false, rank);
}
// Creates the right arm.
@@ -225,8 +202,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human3.mod", false, rank);
m_object->SetPosition(2, Math::Vector(0.0f, 2.3f, -1.2f));
m_object->SetAngle(2, Math::Vector(90.0f*Math::PI/180.0f, 90.0f*Math::PI/180.0f, -50.0f*Math::PI/180.0f));
@@ -235,8 +211,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human4r.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human4r.mod", false, rank);
m_object->SetPosition(3, Math::Vector(1.3f, 0.0f, 0.0f));
m_object->SetAngle(3, Math::Vector(0.0f*Math::PI/180.0f, -20.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f));
@@ -245,8 +220,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 3);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human5.mod", false, rank);
m_object->SetPosition(4, Math::Vector(1.2f, 0.0f, 0.0f));
// Creates the right thigh.
@@ -254,8 +228,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human6.mod", false, rank);
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -0.7f));
m_object->SetAngle(5, Math::Vector(10.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
@@ -264,8 +237,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 5);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human7.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human7.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.0f, -1.5f, 0.0f));
m_object->SetAngle(6, Math::Vector(0.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, -10.0f*Math::PI/180.0f));
@@ -274,8 +246,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 6);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human8.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human8.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, -1.5f, 0.0f));
m_object->SetAngle(7, Math::Vector(-10.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
@@ -284,9 +255,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human3.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human3.mod", true, rank);
m_object->SetPosition(8, Math::Vector(0.0f, 2.3f, 1.2f));
m_object->SetAngle(8, Math::Vector(-90.0f*Math::PI/180.0f, -90.0f*Math::PI/180.0f, -50.0f*Math::PI/180.0f));
@@ -295,9 +264,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 8);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human4l.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human4l.mod", true, rank);
m_object->SetPosition(9, Math::Vector(1.3f, 0.0f, 0.0f));
m_object->SetAngle(9, Math::Vector(0.0f*Math::PI/180.0f, 20.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f));
@@ -306,9 +273,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 9);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human5.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human5.mod", true, rank);
m_object->SetPosition(10, Math::Vector(1.2f, 0.0f, 0.0f));
// Creates the left thigh.
@@ -316,9 +281,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human6.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human6.mod", true, rank);
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, 0.7f));
m_object->SetAngle(11, Math::Vector(-10.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
@@ -327,9 +290,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 11);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human7.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human7.mod", true, rank);
m_object->SetPosition(12, Math::Vector(0.0f, -1.5f, 0.0f));
m_object->SetAngle(12, Math::Vector(0.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, -10.0f*Math::PI/180.0f));
@@ -338,9 +299,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 12);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human8.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human8.mod", true, rank);
m_object->SetPosition(13, Math::Vector(0.0f, -1.5f, 0.0f));
m_object->SetAngle(13, Math::Vector(10.0f*Math::PI/180.0f, -5.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
@@ -351,8 +310,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(14, rank);
m_object->SetObjectParent(14, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human9.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human9.mod", false, rank);
m_object->SetPosition(14, Math::Vector(-1.5f, 0.3f, -1.35f));
m_object->SetAngleZ(14, Math::PI);
}
@@ -367,7 +325,6 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
diff --git a/src/object/motion/motionhuman.h b/src/object/motion/motionhuman.h
index b365a77..ddb0843 100644
--- a/src/object/motion/motionhuman.h
+++ b/src/object/motion/motionhuman.h
@@ -58,7 +58,7 @@ enum MotionHumanSpecialAction
class CMotionHuman : public CMotion
{
public:
- CMotionHuman(CInstanceManager* iMan, CObject* object);
+ CMotionHuman(CObject* object);
~CMotionHuman();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionmother.cpp b/src/object/motion/motionmother.cpp
index 8ea77a5..573a2e4 100644
--- a/src/object/motion/motionmother.cpp
+++ b/src/object/motion/motionmother.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "physics/physics.h"
@@ -34,8 +34,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionMother::CMotionMother(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionMother::CMotionMother(CObject* object) : CMotion(object)
{
m_armMember = START_TIME;
m_armTimeAbs = START_TIME;
@@ -68,12 +67,8 @@ void CMotionMother::DeleteObject(bool bAll)
bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
- int rank;
-
-// if ( m_engine->GetRestCreate() < 2+12+6 ) return false;
-
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
+ int rank;
m_object->SetType(type);
@@ -81,10 +76,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
-
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother1.mod"));
- pModFile->CreateEngineObject(rank);
-
+ modelManager->AddModelReference("mother1.mod", false, rank);
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
@@ -98,8 +90,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother2.mod", false, rank);
m_object->SetPosition(1, Math::Vector(16.0f, 3.0f, 0.0f));
// Creates a right-back leg.
@@ -107,8 +98,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother3.mod", false, rank);
m_object->SetPosition(2, Math::Vector(-5.0f, -1.0f, -12.0f));
// Creates a right-back foot.
@@ -116,8 +106,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother4.mod", false, rank);
m_object->SetPosition(3, Math::Vector(0.0f, 0.0f, -8.5f));
// Creates a middle-right leg.
@@ -125,8 +114,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother3.mod", false, rank);
m_object->SetPosition(4, Math::Vector(3.5f, -1.0f, -12.0f));
// Creates a middle-right foot.
@@ -134,8 +122,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother4.mod", false, rank);
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -8.5f));
// Creates a right-front leg.
@@ -143,8 +130,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother3.mod", false, rank);
m_object->SetPosition(6, Math::Vector(10.0f, -1.0f, -10.0f));
// Creates a right-front foot.
@@ -152,8 +138,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 6);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother4.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 0.0f, -8.5f));
// Creates a left-back leg.
@@ -161,8 +146,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother3.mod", false, rank);
m_object->SetPosition(8, Math::Vector(-5.0f, -1.0f, 12.0f));
m_object->SetAngleY(8, Math::PI);
@@ -171,8 +155,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 8);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother4.mod", false, rank);
m_object->SetPosition(9, Math::Vector(0.0f, 0.0f, -8.5f));
// Creates a middle-left leg.
@@ -180,8 +163,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother3.mod", false, rank);
m_object->SetPosition(10, Math::Vector(3.5f, -1.0f, 12.0f));
m_object->SetAngleY(10, Math::PI);
@@ -190,8 +172,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 10);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother4.mod", false, rank);
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, -8.5f));
// Creates a left-front leg.
@@ -199,8 +180,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother3.mod", false, rank);
m_object->SetPosition(12, Math::Vector(10.0f, -1.0f, 10.0f));
m_object->SetAngleY(12, Math::PI);
@@ -209,8 +189,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 12);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother4.mod", false, rank);
m_object->SetPosition(13, Math::Vector(0.0f, 0.0f, -8.5f));
// Creates the right antenna.
@@ -218,16 +197,14 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(14, rank);
m_object->SetObjectParent(14, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother5.mod", false, rank);
m_object->SetPosition(14, Math::Vector(6.0f, 1.0f, -2.5f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(15, rank);
m_object->SetObjectParent(15, 14);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother6.mod", false, rank);
m_object->SetPosition(15, Math::Vector(8.0f, 0.0f, 0.0f));
// Creates the left antenna.
@@ -235,16 +212,14 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(16, rank);
m_object->SetObjectParent(16, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother5.mod", false, rank);
m_object->SetPosition(16, Math::Vector(6.0f, 1.0f, 2.5f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(17, rank);
m_object->SetObjectParent(17, 16);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother6.mod", false, rank);
m_object->SetPosition(17, Math::Vector(8.0f, 0.0f, 0.0f));
// Creates the right claw.
@@ -252,8 +227,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(18, rank);
m_object->SetObjectParent(18, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother7.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother7.mod", false, rank);
m_object->SetPosition(18, Math::Vector(-4.0f, -3.5f, -8.0f));
m_object->SetZoomX(18, 1.2f);
@@ -262,9 +236,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(19, rank);
m_object->SetObjectParent(19, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother7.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother7.mod", true, rank);
m_object->SetPosition(19, Math::Vector(-4.0f, -3.5f, 8.0f));
m_object->SetZoomX(19, 1.2f);
@@ -278,7 +250,6 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
diff --git a/src/object/motion/motionmother.h b/src/object/motion/motionmother.h
index 5060315..a6c7e93 100644
--- a/src/object/motion/motionmother.h
+++ b/src/object/motion/motionmother.h
@@ -26,7 +26,7 @@
class CMotionMother : public CMotion
{
public:
- CMotionMother(CInstanceManager* iMan, CObject* object);
+ CMotionMother(CObject* object);
~CMotionMother();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionspider.cpp b/src/object/motion/motionspider.cpp
index 516ec6e..59bc6e0 100644
--- a/src/object/motion/motionspider.cpp
+++ b/src/object/motion/motionspider.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "graphics/engine/particle.h"
#include "physics/physics.h"
@@ -35,8 +35,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionSpider::CMotionSpider(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionSpider::CMotionSpider(CObject* object) : CMotion(object)
{
m_armMember = START_TIME;
m_armTimeAbs = START_TIME;
@@ -69,12 +68,9 @@ void CMotionSpider::DeleteObject(bool bAll)
bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
int rank, i, j, parent;
char name[50];
- std::string baseName;
-
float table[] =
{
// x y z
@@ -99,9 +95,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
0.0f, 0.0f, -2.0f,
};
-// if ( m_engine->GetRestCreate() < 3+32+2 ) return false;
-
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
m_object->SetType(type);
@@ -109,8 +103,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider0.mod")); // doesn't exist
- pModFile->CreateEngineObject(rank);
+ // This is an "empty" object, without triangles
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
@@ -124,8 +117,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("spider1.mod", false, rank);
m_object->SetPosition(1, Math::Vector(1.0f, 0.0f, 0.0f));
// Creates the head.
@@ -133,8 +125,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("spider2.mod", false, rank);
m_object->SetPosition(2, Math::Vector(1.0f, 0.0f, 0.0f));
// Creates legs.
@@ -142,8 +133,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
{
for ( j=0 ; j<4 ; j++ )
{
- baseName = m_app->GetDataFilePath(DIR_MODEL, "spider%d.mod");
- sprintf(name, baseName.c_str(), j+3); // 3..6
+ sprintf(name, "spider%d.mod", j+3); // 3..6
// Creates the right leg.
rank = m_engine->CreateObject();
@@ -152,8 +142,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
if ( j == 0 ) parent = 0;
else parent = 3+i*4+j-1;
m_object->SetObjectParent(3+i*4+j, parent);
- pModFile->ReadModel(name);
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference(name, false, rank);
pos.x = table[i*12+j*3+0];
pos.y = table[i*12+j*3+1];
pos.z = table[i*12+j*3+2];
@@ -166,9 +155,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
if ( j == 0 ) parent = 0;
else parent = 19+i*4+j-1;
m_object->SetObjectParent(19+i*4+j, parent);
- pModFile->ReadModel(name);
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference(name, true, rank);
pos.x = table[i*12+j*3+0];
pos.y = table[i*12+j*3+1];
pos.z = -table[i*12+j*3+2];
@@ -181,8 +168,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(35, rank);
m_object->SetObjectParent(35, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider7.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("spider7.mod", false, rank);
m_object->SetPosition(35, Math::Vector(0.0f, 0.0f, -0.3f));
// Creates the left mandible.
@@ -190,9 +176,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(36, rank);
m_object->SetObjectParent(36, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider7.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("spider7.mod", true, rank);
m_object->SetPosition(36, Math::Vector(0.0f, 0.0f, 0.3f));
m_object->CreateShadowCircle(4.0f, 0.5f);
@@ -205,7 +189,6 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
diff --git a/src/object/motion/motionspider.h b/src/object/motion/motionspider.h
index fbf05f9..89745c4 100644
--- a/src/object/motion/motionspider.h
+++ b/src/object/motion/motionspider.h
@@ -44,7 +44,7 @@ enum MotionSpiderSpecialAction
class CMotionSpider : public CMotion
{
public:
- CMotionSpider(CInstanceManager* iMan, CObject* object);
+ CMotionSpider(CObject* object);
~CMotionSpider();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motiontoto.cpp b/src/object/motion/motiontoto.cpp
index 274f171..ddb1867 100644
--- a/src/object/motion/motiontoto.cpp
+++ b/src/object/motion/motiontoto.cpp
@@ -21,9 +21,9 @@
#include "math/geometry.h"
+#include "graphics/engine/modelmanager.h"
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
-#include "graphics/engine/modelfile.h"
#include "object/robotmain.h"
@@ -38,8 +38,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionToto::CMotionToto(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionToto::CMotionToto(CObject* object) : CMotion(object)
{
m_time = 0.0f;
m_bDisplayInfo = false;
@@ -81,12 +80,9 @@ void CMotionToto::DeleteObject(bool bAll)
bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
int rank;
-// if ( m_engine->GetRestCreate() < 10 ) return false;
-
- pModFile = new Gfx::CModelFile(m_iMan);
m_object->SetType(type);
@@ -94,8 +90,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto1.mod", false, rank);
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
@@ -104,8 +99,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto2.mod", false, rank);
m_object->SetPosition(1, Math::Vector(1.00f, 0.17f, 0.00f));
// Creates the left eye.
@@ -113,9 +107,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto3.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto3.mod", true, rank);
m_object->SetPosition(2, Math::Vector(0.85f, 1.04f, 0.25f));
m_object->SetAngleY(2, -20.0f*Math::PI/180.0f);
@@ -124,8 +116,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto3.mod", false, rank);
m_object->SetPosition(3, Math::Vector(0.85f, 1.04f, -0.25f));
m_object->SetAngleY(3, 20.0f*Math::PI/180.0f);
@@ -134,8 +125,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto4.mod", false, rank);
m_object->SetPosition(4, Math::Vector(0.0f, 1.9f, 0.3f));
m_object->SetAngleX(4, 30.0f*Math::PI/180.0f);
@@ -143,8 +133,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto4.mod", false, rank);
m_object->SetPosition(5, Math::Vector(0.0f, 0.67f, 0.0f));
m_object->SetAngleX(5, 30.0f*Math::PI/180.0f);
@@ -152,8 +141,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 5);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto5.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.0f, 0.70f, 0.0f));
m_object->SetAngleX(6, 30.0f*Math::PI/180.0f);
@@ -162,8 +150,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto4.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 1.9f, -0.3f));
m_object->SetAngleX(7, -30.0f*Math::PI/180.0f);
@@ -171,8 +158,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 7);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto4.mod", false, rank);
m_object->SetPosition(8, Math::Vector(0.0f, 0.67f, 0.0f));
m_object->SetAngleX(8, -30.0f*Math::PI/180.0f);
@@ -180,8 +166,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 8);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto5.mod", false, rank);
m_object->SetPosition(9, Math::Vector(0.0f, 0.70f, 0.0f));
m_object->SetAngleX(9, -30.0f*Math::PI/180.0f);
@@ -193,7 +178,6 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
diff --git a/src/object/motion/motiontoto.h b/src/object/motion/motiontoto.h
index 4072b62..47baa28 100644
--- a/src/object/motion/motiontoto.h
+++ b/src/object/motion/motiontoto.h
@@ -35,7 +35,7 @@ enum MotionTotoAction
class CMotionToto : public CMotion
{
public:
- CMotionToto(CInstanceManager* iMan, CObject* object);
+ CMotionToto(CObject* object);
~CMotionToto();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionvehicle.cpp b/src/object/motion/motionvehicle.cpp
index 849d53e..44b8fdd 100644
--- a/src/object/motion/motionvehicle.cpp
+++ b/src/object/motion/motionvehicle.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "graphics/engine/particle.h"
#include "graphics/engine/terrain.h"
@@ -38,8 +38,7 @@
// Object's constructor.
-CMotionVehicle::CMotionVehicle(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionVehicle::CMotionVehicle(CObject* object) : CMotion(object)
{
int i;
@@ -92,15 +91,12 @@ void CMotionVehicle::DeleteObject(bool bAll)
bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
CObject* pPower;
int rank, i, j, parent;
Gfx::Color color;
char name[50];
-// if ( m_engine->GetRestCreate() < 1+5+18+1 ) return false;
-
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
m_object->SetType(type);
@@ -109,106 +105,105 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
- if ( type == OBJECT_MOBILEfa ||
- type == OBJECT_MOBILEfc ||
- type == OBJECT_MOBILEfi ||
- type == OBJECT_MOBILEfs )
+ if (type == OBJECT_MOBILEfa ||
+ type == OBJECT_MOBILEfc ||
+ type == OBJECT_MOBILEfi ||
+ type == OBJECT_MOBILEfs)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem1f.mod"));
+ modelManager->AddModelReference("lem1f.mod", false, rank);
}
- if ( type == OBJECT_MOBILEta ||
- type == OBJECT_MOBILEtc ||
- type == OBJECT_MOBILEti ||
- type == OBJECT_MOBILEts )
+ else if (type == OBJECT_MOBILEta ||
+ type == OBJECT_MOBILEtc ||
+ type == OBJECT_MOBILEti ||
+ type == OBJECT_MOBILEts)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem1t.mod"));
+ modelManager->AddModelReference("lem1t.mod", false, rank);
}
- if ( type == OBJECT_MOBILEwa ||
- type == OBJECT_MOBILEwc ||
- type == OBJECT_MOBILEwi ||
- type == OBJECT_MOBILEws )
+ else if (type == OBJECT_MOBILEwa ||
+ type == OBJECT_MOBILEwc ||
+ type == OBJECT_MOBILEwi ||
+ type == OBJECT_MOBILEws)
{
- if ( m_object->GetTrainer() )
+ if (m_object->GetTrainer())
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem1wt.mod"));
+ modelManager->AddModelReference("lem1wt.mod", false, rank);
}
else
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem1w.mod"));
+ modelManager->AddModelReference("lem1w.mod", false, rank);
}
}
- if ( type == OBJECT_MOBILEia ||
- type == OBJECT_MOBILEic ||
- type == OBJECT_MOBILEii ||
- type == OBJECT_MOBILEis )
+ else if (type == OBJECT_MOBILEia ||
+ type == OBJECT_MOBILEic ||
+ type == OBJECT_MOBILEii ||
+ type == OBJECT_MOBILEis)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem1i.mod"));
+ modelManager->AddModelReference("lem1i.mod", false, rank);
}
- if ( type == OBJECT_MOBILErt ||
- type == OBJECT_MOBILErc ||
- type == OBJECT_MOBILErr ||
- type == OBJECT_MOBILErs )
+ else if (type == OBJECT_MOBILErt ||
+ type == OBJECT_MOBILErc ||
+ type == OBJECT_MOBILErr ||
+ type == OBJECT_MOBILErs)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller1.mod"));
+ modelManager->AddModelReference("roller1.mod", false, rank);
}
- if ( type == OBJECT_MOBILEsa )
+ else if (type == OBJECT_MOBILEsa)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "subm1.mod"));
+ modelManager->AddModelReference("subm1.mod", false, rank);
}
- if ( type == OBJECT_MOBILEtg )
+ else if (type == OBJECT_MOBILEtg)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "target.mod"));
+ modelManager->AddModelReference("target.mod", false, rank);
}
- if ( type == OBJECT_MOBILEwt )
+ else if (type == OBJECT_MOBILEwt)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "trainerw.mod"));
+ modelManager->AddModelReference("trainerw.mod", false, rank);
}
- if ( type == OBJECT_MOBILEft )
+ else if (type == OBJECT_MOBILEft)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "trainerf.mod"));
+ modelManager->AddModelReference("trainerf.mod", false, rank);
}
- if ( type == OBJECT_MOBILEtt )
+ else if (type == OBJECT_MOBILEtt)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "trainert.mod"));
+ modelManager->AddModelReference("trainert.mod", false, rank);
}
- if ( type == OBJECT_MOBILEit )
+ else if (type == OBJECT_MOBILEit)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "traineri.mod"));
+ modelManager->AddModelReference("traineri.mod", false, rank);
}
- if ( type == OBJECT_MOBILEdr )
+ else if (type == OBJECT_MOBILEdr)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "drawer1.mod"));
+ modelManager->AddModelReference("drawer1.mod", false, rank);
}
- if ( type == OBJECT_APOLLO2 )
+ else if (type == OBJECT_APOLLO2)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj1.mod"));
+ modelManager->AddModelReference("apolloj1.mod", false, rank);
}
- pModFile->CreateEngineObject(rank);
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
// A vehicle must have a obligatory collision
// with a sphere of center (0, y, 0) (see GetCrashSphere).
- if ( type == OBJECT_MOBILErt ||
- type == OBJECT_MOBILErc ||
- type == OBJECT_MOBILErr ||
- type == OBJECT_MOBILErs )
+ if (type == OBJECT_MOBILErt ||
+ type == OBJECT_MOBILErc ||
+ type == OBJECT_MOBILErr ||
+ type == OBJECT_MOBILErs)
{
m_object->CreateCrashSphere(Math::Vector(0.0f, 4.0f, 0.0f), 6.5f, SOUND_BOUMm, 0.45f);
m_object->SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 7.0f);
}
- else if ( type == OBJECT_MOBILEsa )
+ else if (type == OBJECT_MOBILEsa)
{
m_object->CreateCrashSphere(Math::Vector(0.0f, 3.0f, 0.0f), 4.5f, SOUND_BOUMm, 0.45f);
m_object->SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f);
}
- else if ( type == OBJECT_MOBILEdr )
+ else if (type == OBJECT_MOBILEdr)
{
m_object->CreateCrashSphere(Math::Vector(0.0f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f);
m_object->SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 7.0f);
}
- else if ( type == OBJECT_APOLLO2 )
+ else if (type == OBJECT_APOLLO2)
{
m_object->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 8.0f, SOUND_BOUMm, 0.45f);
}
@@ -218,18 +213,17 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetGlobalSphere(Math::Vector(0.0f, 4.0f, 0.0f), 6.0f);
}
- if ( type == OBJECT_MOBILEfa ||
- type == OBJECT_MOBILEta ||
- type == OBJECT_MOBILEwa ||
- type == OBJECT_MOBILEia )
+ if (type == OBJECT_MOBILEfa ||
+ type == OBJECT_MOBILEta ||
+ type == OBJECT_MOBILEwa ||
+ type == OBJECT_MOBILEia)
{
// Creates the arm.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2.mod", false, rank);
m_object->SetPosition(1, Math::Vector(0.0f, 5.3f, 0.0f));
m_object->SetAngleZ(1, ARM_NEUTRAL_ANGLE1);
@@ -238,8 +232,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem3.mod", false, rank);
m_object->SetPosition(2, Math::Vector(5.0f, 0.0f, 0.0f));
m_object->SetAngleZ(2, ARM_NEUTRAL_ANGLE2);
@@ -248,8 +241,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem4.mod", false, rank);
m_object->SetPosition(3, Math::Vector(3.5f, 0.0f, 0.0f));
m_object->SetAngleZ(3, ARM_NEUTRAL_ANGLE3);
m_object->SetAngleX(3, Math::PI/2.0f);
@@ -259,8 +251,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 3);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem5.mod", false, rank);
m_object->SetPosition(4, Math::Vector(1.5f, 0.0f, 0.0f));
m_object->SetAngleZ(4, -Math::PI*0.10f);
@@ -269,24 +260,22 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 3);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem6.mod", false, rank);
m_object->SetPosition(5, Math::Vector(1.5f, 0.0f, 0.0f));
m_object->SetAngleZ(5, Math::PI*0.10f);
}
- if ( type == OBJECT_MOBILEfs ||
- type == OBJECT_MOBILEts ||
- type == OBJECT_MOBILEws ||
- type == OBJECT_MOBILEis )
+ if (type == OBJECT_MOBILEfs ||
+ type == OBJECT_MOBILEts ||
+ type == OBJECT_MOBILEws ||
+ type == OBJECT_MOBILEis)
{
// Creates the arm.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2.mod", false, rank);
m_object->SetPosition(1, Math::Vector(0.0f, 5.3f, 0.0f));
m_object->SetAngleZ(1, 110.0f*Math::PI/180.0f);
@@ -295,8 +284,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem3.mod", false, rank);
m_object->SetPosition(2, Math::Vector(5.0f, 0.0f, 0.0f));
m_object->SetAngleZ(2, -110.0f*Math::PI/180.0f);
@@ -305,41 +293,38 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem4s.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem4s.mod", false, rank);
m_object->SetPosition(3, Math::Vector(3.5f, 0.0f, 0.0f));
m_object->SetAngleZ(3, -65.0f*Math::PI/180.0f);
}
- if ( type == OBJECT_MOBILEfc ||
- type == OBJECT_MOBILEtc ||
- type == OBJECT_MOBILEwc ||
- type == OBJECT_MOBILEic )
+ if (type == OBJECT_MOBILEfc ||
+ type == OBJECT_MOBILEtc ||
+ type == OBJECT_MOBILEwc ||
+ type == OBJECT_MOBILEic)
{
// Creates the cannon.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "canon.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("canon.mod", false, rank);
//? m_object->SetPosition(1, Math::Vector(0.0f, 5.3f, 0.0f));
m_object->SetPosition(1, Math::Vector(0.0f, 5.3f, 0.0f));
m_object->SetAngleZ(1, 0.0f);
}
- if ( type == OBJECT_MOBILEfi ||
- type == OBJECT_MOBILEti ||
- type == OBJECT_MOBILEwi ||
- type == OBJECT_MOBILEii )
+ if (type == OBJECT_MOBILEfi ||
+ type == OBJECT_MOBILEti ||
+ type == OBJECT_MOBILEwi ||
+ type == OBJECT_MOBILEii)
{
// Creates the insect cannon.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "canoni1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("canoni1.mod", false, rank);
m_object->SetPosition(1, Math::Vector(0.0f, 5.3f, 0.0f));
m_object->SetAngleZ(1, 0.0f);
@@ -347,25 +332,23 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "canoni2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("canoni2.mod", false, rank);
m_object->SetPosition(2, Math::Vector(0.0f, 2.5f, 0.0f));
m_object->SetAngleZ(2, 0.0f);
}
- if ( type == OBJECT_MOBILEwa ||
- type == OBJECT_MOBILEwc ||
- type == OBJECT_MOBILEws ||
- type == OBJECT_MOBILEwi ||
- type == OBJECT_MOBILEwt )
+ if (type == OBJECT_MOBILEwa ||
+ type == OBJECT_MOBILEwc ||
+ type == OBJECT_MOBILEws ||
+ type == OBJECT_MOBILEwi ||
+ type == OBJECT_MOBILEwt)
{
// Creates the right-back wheel.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(6, Math::Vector(-3.0f, 1.0f, -3.0f));
// Creates the left-back wheel.
@@ -373,8 +356,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(7, Math::Vector(-3.0f, 1.0f, 3.0f));
m_object->SetAngleY(7, Math::PI);
@@ -383,8 +365,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(8, Math::Vector(2.0f, 1.0f, -3.0f));
// Creates the left-front wheel.
@@ -392,21 +373,19 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(9, Math::Vector(2.0f, 1.0f, 3.0f));
m_object->SetAngleY(9, Math::PI);
}
- if ( type == OBJECT_MOBILEtg )
+ if (type == OBJECT_MOBILEtg)
{
// Creates the right-back wheel.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(6, Math::Vector(-2.0f, 1.0f, -3.0f));
// Creates the left-back wheel.
@@ -414,8 +393,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(7, Math::Vector(-2.0f, 1.0f, 3.0f));
m_object->SetAngleY(7, Math::PI);
@@ -424,8 +402,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(8, Math::Vector(3.0f, 1.0f, -3.0f));
// Creates the left-front wheel.
@@ -433,24 +410,22 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(9, Math::Vector(3.0f, 1.0f, 3.0f));
m_object->SetAngleY(9, Math::PI);
}
- if ( type == OBJECT_MOBILEta ||
- type == OBJECT_MOBILEtc ||
- type == OBJECT_MOBILEti ||
- type == OBJECT_MOBILEts ) // caterpillars?
+ if (type == OBJECT_MOBILEta ||
+ type == OBJECT_MOBILEtc ||
+ type == OBJECT_MOBILEti ||
+ type == OBJECT_MOBILEts) // caterpillars?
{
// Creates the right caterpillar.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2t.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("lem2t.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.0f, 2.0f, -3.0f));
// Creates the left caterpillar.
@@ -458,23 +433,21 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem3t.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("lem3t.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 2.0f, 3.0f));
}
- if ( type == OBJECT_MOBILErt ||
- type == OBJECT_MOBILErc ||
- type == OBJECT_MOBILErr ||
- type == OBJECT_MOBILErs ) // large caterpillars?
+ if (type == OBJECT_MOBILErt ||
+ type == OBJECT_MOBILErc ||
+ type == OBJECT_MOBILErr ||
+ type == OBJECT_MOBILErs) // large caterpillars?
{
// Creates the right caterpillar.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("roller2.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.0f, 2.0f, -3.0f));
// Creates the left caterpillar.
@@ -482,20 +455,18 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("roller3.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 2.0f, 3.0f));
}
- if ( type == OBJECT_MOBILEsa ) // underwater caterpillars?
+ if (type == OBJECT_MOBILEsa) // underwater caterpillars?
{
// Creates the right caterpillar.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "subm4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("subm4.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.0f, 1.0f, -3.0f));
// Creates the left caterpillar.
@@ -503,20 +474,18 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "subm5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("subm5.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 1.0f, 3.0f));
}
- if ( type == OBJECT_MOBILEdr ) // caterpillars?
+ if (type == OBJECT_MOBILEdr) // caterpillars?
{
// Creates the right caterpillar.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "drawer2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("drawer2.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.0f, 1.0f, -3.0f));
// Creates the left caterpillar.
@@ -524,24 +493,22 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "drawer3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("drawer3.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 1.0f, 3.0f));
}
- if ( type == OBJECT_MOBILEfa ||
- type == OBJECT_MOBILEfc ||
- type == OBJECT_MOBILEfs ||
- type == OBJECT_MOBILEfi ||
- type == OBJECT_MOBILEft ) // flying?
+ if (type == OBJECT_MOBILEfa ||
+ type == OBJECT_MOBILEfc ||
+ type == OBJECT_MOBILEfs ||
+ type == OBJECT_MOBILEfi ||
+ type == OBJECT_MOBILEft) // flying?
{
// Creates the front foot.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2f.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2f.mod", false, rank);
m_object->SetPosition(6, Math::Vector(1.7f, 3.0f, 0.0f));
// Creates the right-back foot.
@@ -549,8 +516,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2f.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2f.mod", false, rank);
m_object->SetPosition(7, Math::Vector(-1.8f, 3.0f, -1.5f));
m_object->SetAngleY(7, 120.0f*Math::PI/180.0f);
@@ -559,16 +525,15 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2f.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2f.mod", false, rank);
m_object->SetPosition(8, Math::Vector(-1.8f, 3.0f, 1.5f));
m_object->SetAngleY(8, -120.0f*Math::PI/180.0f);
}
- if ( type == OBJECT_MOBILEia ||
- type == OBJECT_MOBILEic ||
- type == OBJECT_MOBILEis ||
- type == OBJECT_MOBILEii ) // insect legs?
+ if (type == OBJECT_MOBILEia ||
+ type == OBJECT_MOBILEic ||
+ type == OBJECT_MOBILEis ||
+ type == OBJECT_MOBILEii) // insect legs?
{
float table[] =
{
@@ -590,8 +555,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
for ( j=0 ; j<3 ; j++ )
{
- std::string baseName = m_app->GetDataFilePath(DIR_MODEL, "ant%d.mod");
- sprintf(name, baseName.c_str(), j+4); // 4..6
+ sprintf(name, "ant%d.mod", j+4); // 4..6
// Creates the right leg.
rank = m_engine->CreateObject();
@@ -600,8 +564,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
if ( j == 0 ) parent = 0;
else parent = 6+i*3+j-1;
m_object->SetObjectParent(6+i*3+j, parent);
- pModFile->ReadModel(name);
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference(name, false, rank);
pos.x = table[i*9+j*3+0];
pos.y = table[i*9+j*3+1];
pos.z = table[i*9+j*3+2];
@@ -614,9 +577,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
if ( j == 0 ) parent = 0;
else parent = 15+i*3+j-1;
m_object->SetObjectParent(15+i*3+j, parent);
- pModFile->ReadModel(name);
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference(name, true, rank);
pos.x = table[i*9+j*3+0];
pos.y = table[i*9+j*3+1];
pos.z = -table[i*9+j*3+2];
@@ -625,15 +586,14 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
}
}
- if ( type == OBJECT_MOBILErt )
+ if (type == OBJECT_MOBILErt)
{
// Creates the holder.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller2t.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller2t.mod", false, rank);
m_object->SetPosition(1, Math::Vector(0.0f, 0.0f, 0.0f));
m_object->SetAngleZ(1, 0.0f);
@@ -642,21 +602,19 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller3t.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller3t.mod", false, rank);
m_object->SetPosition(2, Math::Vector(9.0f, 4.0f, 0.0f));
m_object->SetAngleZ(2, 0.0f);
}
- if ( type == OBJECT_MOBILErc )
+ if (type == OBJECT_MOBILErc)
{
// Creates the holder.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller2c.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller2c.mod", false, rank);
m_object->SetPosition(1, Math::Vector(3.0f, 4.6f, 0.0f));
m_object->SetAngleZ(1, Math::PI/8.0f);
@@ -665,21 +623,19 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller3p.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller3p.mod", false, rank);
m_object->SetPosition(2, Math::Vector(7.0f, 6.5f, 0.0f));
m_object->SetAngleZ(2, 0.0f);
}
- if ( type == OBJECT_MOBILErr )
+ if (type == OBJECT_MOBILErr)
{
// Creates the holder.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "recover1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("recover1.mod", false, rank);
m_object->SetPosition(1, Math::Vector(2.0f, 5.0f, 0.0f));
// Creates the right arm.
@@ -687,8 +643,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "recover2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("recover2.mod", false, rank);
m_object->SetPosition(2, Math::Vector(0.1f, 0.0f, -5.0f));
m_object->SetAngleZ(2, 126.0f*Math::PI/180.0f);
@@ -697,8 +652,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "recover3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("recover3.mod", false, rank);
m_object->SetPosition(3, Math::Vector(5.0f, 0.0f, -0.5f));
m_object->SetAngleZ(3, -144.0f*Math::PI/180.0f);
@@ -707,9 +661,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "recover2.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("recover2.mod", true, rank);
m_object->SetPosition(4, Math::Vector(0.1f, 0.0f, 5.0f));
m_object->SetAngleZ(4, 126.0f*Math::PI/180.0f);
@@ -718,22 +670,19 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "recover3.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("recover3.mod", true, rank);
m_object->SetPosition(5, Math::Vector(5.0f, 0.0f, 0.5f));
m_object->SetAngleZ(5, -144.0f*Math::PI/180.0f);
}
- if ( type == OBJECT_MOBILErs )
+ if (type == OBJECT_MOBILErs)
{
// Creates the holder.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller2s.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller2s.mod", false, rank);
m_object->SetPosition(1, Math::Vector(0.0f, 0.0f, 0.0f));
m_object->SetAngleZ(1, 0.0f);
@@ -742,8 +691,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller3s.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller3s.mod", false, rank);
m_object->SetPosition(2, Math::Vector(7.0f, 4.5f, 0.0f));
m_object->SetAngleZ(2, 0.0f);
@@ -752,21 +700,19 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller4s.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller4s.mod", false, rank);
m_object->SetPosition(3, Math::Vector(0.0f, 1.0f, 0.0f));
m_object->SetAngleZ(3, 0.0f);
}
- if ( type == OBJECT_MOBILEsa )
+ if (type == OBJECT_MOBILEsa)
{
// Creates the holder.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "subm2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("subm2.mod", false, rank);
m_object->SetPosition(1, Math::Vector(4.2f, 3.0f, 0.0f));
// Creates the right tong.
@@ -774,8 +720,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "subm3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("subm3.mod", false, rank);
m_object->SetPosition(2, Math::Vector(0.5f, 0.0f, -1.5f));
// Creates the left tong.
@@ -783,21 +728,18 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "subm3.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("subm3.mod", true, rank);
m_object->SetPosition(3, Math::Vector(0.5f, 0.0f, 1.5f));
}
- if ( type == OBJECT_MOBILEdr )
+ if (type == OBJECT_MOBILEdr)
{
// Creates the carousel.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "drawer4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("drawer4.mod", false, rank);
m_object->SetPosition(1, Math::Vector(-3.0f, 3.0f, 0.0f));
// Creates the key.
@@ -807,8 +749,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "drawer5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("drawer5.mod", false, rank);
m_posKey = Math::Vector(3.0f, 5.7f, 0.0f);
m_object->SetPosition(2, m_posKey);
m_object->SetAngleY(2, 90.0f*Math::PI/180.0f);
@@ -821,16 +762,14 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10+i, rank);
m_object->SetObjectParent(10+i, 1);
- std::string baseName = m_app->GetDataFilePath(DIR_MODEL, "drawer%d.mod");
- sprintf(name, baseName.c_str(), 10+i);
- pModFile->ReadModel(name);
- pModFile->CreateEngineObject(rank);
+ sprintf(name, "drawer%d.mod", 10+i);
+ modelManager->AddModelReference(name, false, rank);
m_object->SetPosition(10+i, Math::Vector(0.0f, 0.0f, 0.0f));
m_object->SetAngleY(10+i, 45.0f*Math::PI/180.0f*i);
}
}
- if ( type == OBJECT_MOBILEwt )
+ if (type == OBJECT_MOBILEwt)
{
// Creates the key.
if ( m_object->GetToy() )
@@ -839,23 +778,21 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "drawer5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("drawer5.mod", false, rank);
m_posKey = Math::Vector(0.2f, 4.1f, 0.0f);
m_object->SetPosition(2, m_posKey);
m_object->SetAngleY(2, 90.0f*Math::PI/180.0f);
}
}
- if ( type == OBJECT_APOLLO2 )
+ if (type == OBJECT_APOLLO2)
{
// Creates the accessories.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj2.mod")); // antenna
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj2.mod", false, rank); // antenna
m_object->SetPosition(1, Math::Vector(5.5f, 8.8f, 2.0f));
m_object->SetAngleY(1, -120.0f*Math::PI/180.0f);
m_object->SetAngleZ(1, 45.0f*Math::PI/180.0f);
@@ -864,8 +801,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj3.mod")); // camera
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj3.mod", false, rank); // camera
m_object->SetPosition(2, Math::Vector(5.5f, 2.8f, -2.0f));
m_object->SetAngleY(2, 30.0f*Math::PI/180.0f);
@@ -874,32 +810,28 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj4.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel
m_object->SetPosition(6, Math::Vector(-5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj4.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel
m_object->SetPosition(7, Math::Vector(-5.75f, 1.65f, 5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj4.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel
m_object->SetPosition(8, Math::Vector(5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj4.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel
m_object->SetPosition(9, Math::Vector(5.75f, 1.65f, 5.00f));
// Creates mud guards.
@@ -907,56 +839,51 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj6.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj6.mod", false, rank); // wheel
m_object->SetPosition(10, Math::Vector(-5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj6.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj6.mod", false, rank); // wheel
m_object->SetPosition(11, Math::Vector(-5.75f, 1.65f, 5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj5.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj5.mod", false, rank); // wheel
m_object->SetPosition(12, Math::Vector(5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj5.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj5.mod", false, rank); // wheel
m_object->SetPosition(13, Math::Vector(5.75f, 1.65f, 5.00f));
}
-#if 1
- if ( type == OBJECT_MOBILErt ||
- type == OBJECT_MOBILErc ||
- type == OBJECT_MOBILErr ||
- type == OBJECT_MOBILErs )
+ if (type == OBJECT_MOBILErt ||
+ type == OBJECT_MOBILErc ||
+ type == OBJECT_MOBILErr ||
+ type == OBJECT_MOBILErs)
{
m_object->CreateShadowCircle(6.0f, 1.0f);
}
- else if ( type == OBJECT_MOBILEta ||
- type == OBJECT_MOBILEtc ||
- type == OBJECT_MOBILEti ||
- type == OBJECT_MOBILEts ||
- type == OBJECT_MOBILEsa )
+ else if (type == OBJECT_MOBILEta ||
+ type == OBJECT_MOBILEtc ||
+ type == OBJECT_MOBILEti ||
+ type == OBJECT_MOBILEts ||
+ type == OBJECT_MOBILEsa)
{
m_object->CreateShadowCircle(5.0f, 1.0f);
}
- else if ( type == OBJECT_MOBILEdr )
+ else if (type == OBJECT_MOBILEdr)
{
m_object->CreateShadowCircle(4.5f, 1.0f);
}
- else if ( type == OBJECT_APOLLO2 )
+ else if (type == OBJECT_APOLLO2)
{
m_object->CreateShadowCircle(7.0f, 0.8f);
}
@@ -964,50 +891,12 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
m_object->CreateShadowCircle(4.0f, 1.0f);
}
-#else
- if ( type == OBJECT_MOBILErt ||
- type == OBJECT_MOBILErc ||
- type == OBJECT_MOBILErr ||
- type == OBJECT_MOBILErs )
- {
- m_object->CreateShadowCircle(6.0f, 1.0f, D3DSHADOWTANK);
- }
- else if ( type == OBJECT_MOBILEta ||
- type == OBJECT_MOBILEtc ||
- type == OBJECT_MOBILEti ||
- type == OBJECT_MOBILEts )
- {
- m_object->CreateShadowCircle(4.0f, 1.0f, D3DSHADOWTANK);
- }
- else if ( type == OBJECT_MOBILEfa ||
- type == OBJECT_MOBILEfc ||
- type == OBJECT_MOBILEfi ||
- type == OBJECT_MOBILEfs )
- {
- m_object->CreateShadowCircle(4.0f, 1.0f, D3DSHADOWFLY);
- }
- else if ( type == OBJECT_MOBILEwa ||
- type == OBJECT_MOBILEwc ||
- type == OBJECT_MOBILEwi ||
- type == OBJECT_MOBILEws )
- {
- m_object->CreateShadowCircle(4.0f, 1.0f, D3DSHADOWWHEEL);
- }
- else if ( type == OBJECT_APOLLO2 )
- {
- m_object->CreateShadowCircle(6.0f, 0.8f);
- }
- else
- {
- m_object->CreateShadowCircle(4.0f, 1.0f, D3DSHADOWNORM);
- }
-#endif
- if ( type == OBJECT_MOBILEfa ||
- type == OBJECT_MOBILEfc ||
- type == OBJECT_MOBILEfi ||
- type == OBJECT_MOBILEfs ||
- type == OBJECT_MOBILEft ) // flying?
+ if (type == OBJECT_MOBILEfa ||
+ type == OBJECT_MOBILEfc ||
+ type == OBJECT_MOBILEfi ||
+ type == OBJECT_MOBILEfs ||
+ type == OBJECT_MOBILEft) // flying?
{
//? color.r = 0.5f-1.0f;
//? color.g = 0.2f-1.0f;
@@ -1025,9 +914,9 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
CreatePhysics(type);
m_object->SetFloorHeight(0.0f);
- if ( power > 0.0f &&
- type != OBJECT_MOBILEdr &&
- type != OBJECT_APOLLO2 )
+ if (power > 0.0f &&
+ type != OBJECT_MOBILEdr &&
+ type != OBJECT_APOLLO2)
{
color.r = 1.0f;
color.g = 1.0f;
@@ -1036,16 +925,15 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_object->CreateEffectLight(20.0f, color);
// Creates the battery.
- pPower = new CObject(m_iMan);
+ pPower = new CObject();
pPower->SetType(power<=1.0f?OBJECT_POWER:OBJECT_ATOMIC);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
pPower->SetObjectRank(0, rank);
- if ( power <= 1.0f ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "power.mod"));
- else pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "atomic.mod"));
- pModFile->CreateEngineObject(rank);
+ if ( power <= 1.0f ) modelManager->AddModelCopy("power.mod", false, rank);
+ else modelManager->AddModelCopy("atomic.mod", false, rank);
pPower->SetPosition(0, m_object->GetCharacter()->posPower);
pPower->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
@@ -1063,7 +951,6 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
@@ -1989,52 +1876,33 @@ bool CMotionVehicle::EventFrameCanoni(const Event &event)
void CMotionVehicle::UpdateTrackMapping(float left, float right, ObjectType type)
{
- Gfx::Material mat;
- float limit[4];
- int rRank, lRank, i;
+ Gfx::Material mat;
+ mat.diffuse = Gfx::Color(1.0f, 1.0f, 1.0f); // white
+ mat.ambient = Gfx::Color(0.5f, 0.5f, 0.5f);
- memset( &mat, 0, sizeof(Gfx::Material) );
- mat.diffuse.r = 1.0f;
- mat.diffuse.g = 1.0f;
- mat.diffuse.b = 1.0f; // white
- mat.ambient.r = 0.5f;
- mat.ambient.g = 0.5f;
- mat.ambient.b = 0.5f;
+ int rRank = m_object->GetObjectRank(6);
+ int lRank = m_object->GetObjectRank(7);
- rRank = m_object->GetObjectRank(6);
- lRank = m_object->GetObjectRank(7);
-
-
- if ( type == OBJECT_MOBILEdr )
+ if (type == OBJECT_MOBILEdr)
{
- limit[0] = 0.0f;
- limit[1] = 1000000.0f;
- limit[2] = limit[1];
- limit[3] = m_engine->GetLimitLOD(1);
-
m_engine->TrackTextureMapping(rRank, mat, Gfx::ENG_RSTATE_PART1, "drawer.png", "",
- limit[0], limit[1], Gfx::ENG_TEX_MAPPING_X,
+ Gfx::LOD_Constant, Gfx::ENG_TEX_MAPPING_X,
right, 1.0f, 8.0f, 192.0f, 256.0f);
m_engine->TrackTextureMapping(lRank, mat, Gfx::ENG_RSTATE_PART2, "drawer.png", "",
- limit[0], limit[1], Gfx::ENG_TEX_MAPPING_X,
+ Gfx::LOD_Constant, Gfx::ENG_TEX_MAPPING_X,
left, 1.0f, 8.0f, 192.0f, 256.0f);
}
else
{
- limit[0] = 0.0f;
- limit[1] = m_engine->GetLimitLOD(0);
- limit[2] = limit[1];
- limit[3] = m_engine->GetLimitLOD(1);
-
- for ( i=0 ; i<2 ; i++ )
+ for (int i = 0; i < 2; i++)
{
m_engine->TrackTextureMapping(rRank, mat, Gfx::ENG_RSTATE_PART1, "lemt.png", "",
- limit[i*2+0], limit[i*2+1], Gfx::ENG_TEX_MAPPING_X,
+ (i == 0) ? Gfx::LOD_High : Gfx::LOD_Medium, Gfx::ENG_TEX_MAPPING_X,
right, 1.0f, 8.0f, 192.0f, 256.0f);
m_engine->TrackTextureMapping(lRank, mat, Gfx::ENG_RSTATE_PART2, "lemt.png", "",
- limit[i*2+0], limit[i*2+1], Gfx::ENG_TEX_MAPPING_X,
+ (i == 0) ? Gfx::LOD_High : Gfx::LOD_Medium, Gfx::ENG_TEX_MAPPING_X,
left, 1.0f, 8.0f, 192.0f, 256.0f);
}
}
diff --git a/src/object/motion/motionvehicle.h b/src/object/motion/motionvehicle.h
index ca60c1e..ffb25ef 100644
--- a/src/object/motion/motionvehicle.h
+++ b/src/object/motion/motionvehicle.h
@@ -26,7 +26,7 @@
class CMotionVehicle : public CMotion
{
public:
- CMotionVehicle(CInstanceManager* iMan, CObject* object);
+ CMotionVehicle(CObject* object);
~CMotionVehicle();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionworm.cpp b/src/object/motion/motionworm.cpp
index 2401ebd..ee555a8 100644
--- a/src/object/motion/motionworm.cpp
+++ b/src/object/motion/motionworm.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "graphics/engine/particle.h"
#include "graphics/engine/terrain.h"
@@ -42,8 +42,7 @@ const int WORM_PART = 7; // number of parts of a worm
// Object's constructor.
-CMotionWorm::CMotionWorm(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionWorm::CMotionWorm(CObject* object) : CMotion(object)
{
m_timeUp = 18.0f;
m_timeDown = 18.0f;
@@ -81,13 +80,10 @@ void CMotionWorm::DeleteObject(bool bAll)
bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
int rank, i;
float px;
-// if ( m_engine->GetRestCreate() < 2+WORM_PART+1 ) return false;
-
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
m_object->SetType(type);
@@ -95,8 +91,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm0.mod")); // there is no purpose!
- pModFile->CreateEngineObject(rank);
+ // This is an "empty" object, without triangles
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
@@ -111,8 +106,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("worm1.mod", false, rank);
m_object->SetPosition(1, Math::Vector(px, 0.0f, 0.0f));
px -= 1.0f;
@@ -123,8 +117,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2+i, rank);
m_object->SetObjectParent(2+i, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("worm2.mod", false, rank);
m_object->SetPosition(2+i, Math::Vector(px, 0.0f, 0.0f));
px -= 1.0f;
}
@@ -134,8 +127,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2+WORM_PART, rank);
m_object->SetObjectParent(2+WORM_PART, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("worm3.mod", false, rank);
m_object->SetPosition(2+WORM_PART, Math::Vector(px, 0.0f, 0.0f));
m_object->CreateShadowCircle(0.0f, 1.0f, Gfx::ENG_SHADOW_WORM);
@@ -148,7 +140,6 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
diff --git a/src/object/motion/motionworm.h b/src/object/motion/motionworm.h
index aed5a23..7684faf 100644
--- a/src/object/motion/motionworm.h
+++ b/src/object/motion/motionworm.h
@@ -26,7 +26,7 @@
class CMotionWorm : public CMotion
{
public:
- CMotionWorm(CInstanceManager* iMan, CObject* object);
+ CMotionWorm(CObject* object);
~CMotionWorm();
void DeleteObject(bool bAll=false);