From f9b09d08f0a5c87e16a09be887cce347f895014e Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 20 Jun 2015 19:27:43 +0200 Subject: [PATCH] Create CObjectFactory * move functions creating objects to new class CObjectFactory * replace calls to CObject::Create*() with CObjectManager::Create() * move creation/deletion of some objects to better places * make CModelManager non-singleton * clean up some code in changed functions --- src/CMakeLists.txt | 1 + src/app/app.cpp | 11 - src/app/app.h | 4 - src/graphics/engine/engine.cpp | 9 +- src/graphics/engine/engine.h | 4 + src/graphics/engine/modelmanager.cpp | 2 - src/graphics/engine/modelmanager.h | 2 +- src/object/auto/autoconvert.cpp | 16 +- src/object/auto/autoderrick.cpp | 10 +- src/object/auto/autoegg.cpp | 19 +- src/object/auto/autoenergy.cpp | 18 +- src/object/auto/autofactory.cpp | 26 +- src/object/auto/autonest.cpp | 9 +- src/object/auto/autonuclear.cpp | 17 +- src/object/motion/motion.cpp | 15 - src/object/motion/motion.h | 4 +- src/object/motion/motionant.cpp | 7 +- src/object/motion/motionant.h | 2 +- src/object/motion/motionbee.cpp | 7 +- src/object/motion/motionbee.h | 2 +- src/object/motion/motiondummy.cpp | 6 +- src/object/motion/motiondummy.h | 2 +- src/object/motion/motionhuman.cpp | 10 +- src/object/motion/motionhuman.h | 2 +- src/object/motion/motionmother.cpp | 7 +- src/object/motion/motionmother.h | 2 +- src/object/motion/motionspider.cpp | 8 +- src/object/motion/motionspider.h | 2 +- src/object/motion/motiontoto.cpp | 7 +- src/object/motion/motiontoto.h | 2 +- src/object/motion/motionvehicle.cpp | 8 +- src/object/motion/motionvehicle.h | 2 +- src/object/motion/motionworm.cpp | 8 +- src/object/motion/motionworm.h | 2 +- src/object/object.cpp | 3449 +----------------------- src/object/object.h | 247 +- src/object/object_factory.cpp | 3673 ++++++++++++++++++++++++++ src/object/object_factory.h | 80 + src/object/object_type.h | 238 ++ src/object/objman.cpp | 298 +-- src/object/objman.h | 38 +- src/object/robotmain.cpp | 85 +- src/object/robotmain.h | 3 + src/object/task/taskbuild.cpp | 9 +- src/object/task/taskflag.cpp | 34 +- src/object/task/taskrecover.cpp | 11 +- src/object/task/tasksearch.cpp | 28 +- src/script/scriptfunc.cpp | 70 +- 48 files changed, 4233 insertions(+), 4283 deletions(-) create mode 100644 src/object/object_factory.cpp create mode 100644 src/object/object_factory.h create mode 100644 src/object/object_type.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a4e5cb15..d85bd7e0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -158,6 +158,7 @@ set(BASE_SOURCES object/motion/motionvehicle.cpp object/motion/motionworm.cpp object/object.cpp + object/object_factory.cpp object/robotmain.cpp object/objman.cpp object/task/task.cpp diff --git a/src/app/app.cpp b/src/app/app.cpp index a558437e..023660b9 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -105,14 +105,12 @@ CApplication::CApplication() m_private = new ApplicationPrivate(); m_iMan = new CInstanceManager(); m_pathManager = new CPathManager(); - m_objMan = new CObjectManager(); m_eventQueue = new CEventQueue(); m_profile = new CProfile(); m_input = new CInput(); m_engine = nullptr; m_device = nullptr; - m_modelManager = nullptr; m_controller = nullptr; m_sound = nullptr; @@ -174,9 +172,6 @@ CApplication::~CApplication() delete m_input; m_input = nullptr; - delete m_objMan; - m_objMan = nullptr; - delete m_eventQueue; m_eventQueue = nullptr; @@ -572,9 +567,6 @@ bool CApplication::Create() return false; } - // Create model manager - m_modelManager = new Gfx::CModelManager(m_engine); - // Create the robot application. m_controller = new CController(this, !defaultValues); @@ -650,9 +642,6 @@ void CApplication::Destroy() delete m_sound; m_sound = nullptr; - delete m_modelManager; - m_modelManager = nullptr; - if (m_engine != nullptr) { m_engine->Destroy(); diff --git a/src/app/app.h b/src/app/app.h index c4c3427d..3420f4d4 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -359,16 +359,12 @@ protected: //! Instance manager // TODO: to be removed CInstanceManager* m_iMan; - //! Object manager - CObjectManager* m_objMan; //! Global event queue CEventQueue* m_eventQueue; //! Graphics engine Gfx::CEngine* m_engine; //! Graphics device Gfx::CDevice* m_device; - //! 3D models manager - Gfx::CModelManager* m_modelManager; //! Sound subsystem CSoundInterface* m_sound; //! Game controller - game engine and UI diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index f90bb5aa..b485f460 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -32,6 +32,7 @@ #include "graphics/engine/cloud.h" #include "graphics/engine/lightman.h" #include "graphics/engine/lightning.h" +#include "graphics/engine/modelmanager.h" #include "graphics/engine/particle.h" #include "graphics/engine/planet.h" #include "graphics/engine/pyro.h" @@ -229,6 +230,11 @@ CDevice* CEngine::GetDevice() return m_device; } +CModelManager* CEngine::GetModelManager() +{ + return m_modelManager.get(); +} + CText* CEngine::GetText() { return m_text; @@ -278,6 +284,7 @@ bool CEngine::Create() { m_size = m_app->GetVideoConfig().size; + m_modelManager.reset(new CModelManager(this)); m_lightMan = new CLightManager(this); m_text = new CText(this); m_particle = new CParticle(this); @@ -324,7 +331,7 @@ bool CEngine::Create() void CEngine::Destroy() { m_text->Destroy(); - + delete m_pause; m_pause = nullptr; diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h index 669bb834..809412ce 100644 --- a/src/graphics/engine/engine.h +++ b/src/graphics/engine/engine.h @@ -48,6 +48,7 @@ #include #include #include +#include class CApplication; @@ -61,6 +62,7 @@ namespace Gfx { class CDevice; +class CModelManager; class CLightManager; class CText; class CParticle; @@ -694,6 +696,7 @@ public: //! Returns the text rendering engine CText* GetText(); + CModelManager* GetModelManager(); //! Returns the light manager CLightManager* GetLightManager(); //! Returns the particle manager @@ -1328,6 +1331,7 @@ protected: CApplication* m_app; CSoundInterface* m_sound; CDevice* m_device; + std::unique_ptr m_modelManager; CText* m_text; CLightManager* m_lightMan; CParticle* m_particle; diff --git a/src/graphics/engine/modelmanager.cpp b/src/graphics/engine/modelmanager.cpp index d875ca1a..29ccb878 100644 --- a/src/graphics/engine/modelmanager.cpp +++ b/src/graphics/engine/modelmanager.cpp @@ -27,8 +27,6 @@ #include -template<> Gfx::CModelManager* CSingleton::m_instance = nullptr; - namespace Gfx { CModelManager::CModelManager(CEngine* engine) diff --git a/src/graphics/engine/modelmanager.h b/src/graphics/engine/modelmanager.h index 3805631d..e075dd54 100644 --- a/src/graphics/engine/modelmanager.h +++ b/src/graphics/engine/modelmanager.h @@ -51,7 +51,7 @@ class CModelFile; * its own and unique base engine object. This is especially useful * for models where the geometry must be altered. */ -class CModelManager : public CSingleton +class CModelManager { public: CModelManager(CEngine* engine); diff --git a/src/object/auto/autoconvert.cpp b/src/object/auto/autoconvert.cpp index c56a1295..d97db396 100644 --- a/src/object/auto/autoconvert.cpp +++ b/src/object/auto/autoconvert.cpp @@ -492,20 +492,10 @@ bool CAutoConvert::SearchVehicle() void CAutoConvert::CreateMetal() { - Math::Vector pos; - float angle; - CObject* fret; + Math::Vector pos = m_object->GetPosition(0); + float angle = m_object->GetAngleY(0); - pos = m_object->GetPosition(0); - angle = m_object->GetAngleY(0); - - fret = new CObject(); - if ( !fret->CreateResource(pos, angle, OBJECT_METAL) ) - { - delete fret; - m_main->DisplayError(ERR_TOOMANY, m_object); - return; - } + CObject* fret = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, OBJECT_METAL); if ( m_bResetDelete ) { diff --git a/src/object/auto/autoderrick.cpp b/src/object/auto/autoderrick.cpp index 81357b12..fc8978e7 100644 --- a/src/object/auto/autoderrick.cpp +++ b/src/object/auto/autoderrick.cpp @@ -518,15 +518,7 @@ bool CAutoDerrick::SearchFree(Math::Vector pos) void CAutoDerrick::CreateFret(Math::Vector pos, float angle, ObjectType type, float height) { - CObject* fret; - - fret = new CObject(); - if ( !fret->CreateResource(pos, angle, type) ) - { - delete fret; - m_main->DisplayError(ERR_TOOMANY, m_object); - return; - } + CObject* fret = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, type); fret->SetLock(true); // object not yet usable if ( m_object->GetResetCap() == RESET_MOVE ) diff --git a/src/object/auto/autoegg.cpp b/src/object/auto/autoegg.cpp index c82e0f97..764b195f 100644 --- a/src/object/auto/autoegg.cpp +++ b/src/object/auto/autoegg.cpp @@ -166,8 +166,6 @@ void CAutoEgg::Start(int param) bool CAutoEgg::EventProcess(const Event &event) { - CObject* alien; - CAuto::EventProcess(event); if ( m_engine->GetPause() ) return true; @@ -180,15 +178,10 @@ bool CAutoEgg::EventProcess(const Event &event) m_progress += event.rTime*m_speed; if ( m_progress < 1.0f ) return true; - alien = new CObject(); - if ( !alien->CreateInsect(m_object->GetPosition(0), m_object->GetAngleY(0), m_type) ) - { - delete alien; - m_phase = AEP_DELAY; - m_progress = 0.0f; - m_speed = 1.0f/2.0f; - return true; - } + Math::Vector pos = m_object->GetPosition(0); + float angle = m_object->GetAngleY(0); + CObject* alien = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, m_type); + alien->SetActivity(false); CBrain* brain = alien->GetBrain(); if(brain != nullptr) @@ -200,8 +193,8 @@ bool CAutoEgg::EventProcess(const Event &event) Init(); } - alien = SearchAlien(); - if ( alien == 0 ) return true; + CObject* alien = SearchAlien(); + if ( alien == nullptr ) return true; alien->SetActivity(false); m_progress += event.rTime*m_speed; diff --git a/src/object/auto/autoenergy.cpp b/src/object/auto/autoenergy.cpp index 3f53b5f5..d09d4f14 100644 --- a/src/object/auto/autoenergy.cpp +++ b/src/object/auto/autoenergy.cpp @@ -458,20 +458,10 @@ bool CAutoEnergy::SearchVehicle() void CAutoEnergy::CreatePower() { - CObject* power; - Math::Vector pos; - float angle; - - pos = m_object->GetPosition(0); - angle = m_object->GetAngleY(0); - - power = new CObject(); - if ( !power->CreateResource(pos, angle, OBJECT_POWER) ) - { - delete power; - m_main->DisplayError(ERR_TOOMANY, m_object); - return; - } + Math::Vector pos = m_object->GetPosition(0); + float angle = m_object->GetAngleY(0); + float powerLevel = 1.0f; + CObject* power = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, OBJECT_POWER, powerLevel); power->SetLock(true); // battery not yet usable pos = power->GetPosition(0); diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp index 720513a3..f1bdeeda 100644 --- a/src/object/auto/autofactory.cpp +++ b/src/object/auto/autofactory.cpp @@ -639,16 +639,9 @@ bool CAutoFactory::NearestVehicle() bool CAutoFactory::CreateVehicle() { - CObject* vehicle; - Math::Matrix* mat; - CPhysics* physics; - Math::Vector pos; - float angle; - char* name; + float angle = m_object->GetAngleY(0); - angle = m_object->GetAngleY(0); - - mat = m_object->GetWorldMatrix(0); + Math::Vector pos; if ( m_type == OBJECT_MOBILErt || m_type == OBJECT_MOBILErc || m_type == OBJECT_MOBILErr || @@ -660,21 +653,16 @@ bool CAutoFactory::CreateVehicle() { pos = Math::Vector(4.0f, 0.0f, 0.0f); } + Math::Matrix* mat = m_object->GetWorldMatrix(0); pos = Transform(*mat, pos); - vehicle = new CObject(); - if ( !vehicle->CreateVehicle(pos, angle, m_type, -1.0f, false, false) ) - { - delete vehicle; - m_main->DisplayError(ERR_TOOMANY, m_object); - return false; - } + CObject* vehicle = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, m_type); vehicle->UpdateMapping(); vehicle->SetLock(true); // not usable vehicle->SetRange(30.0f); - physics = vehicle->GetPhysics(); - if ( physics != 0 ) + CPhysics* physics = vehicle->GetPhysics(); + if ( physics != nullptr ) { physics->SetFreeze(true); // it doesn't move } @@ -684,7 +672,7 @@ bool CAutoFactory::CreateVehicle() { for ( int i=0 ; ; i++ ) { - name = m_main->GetNewScriptName(m_type, i); + char* name = m_main->GetNewScriptName(m_type, i); if ( name == nullptr ) break; Program* prog = brain->GetOrAddProgram(i); vehicle->ReadProgram(prog, name); diff --git a/src/object/auto/autonest.cpp b/src/object/auto/autonest.cpp index 52f4d776..77327d1a 100644 --- a/src/object/auto/autonest.cpp +++ b/src/object/auto/autonest.cpp @@ -180,14 +180,7 @@ bool CAutoNest::SearchFree(Math::Vector pos) void CAutoNest::CreateFret(Math::Vector pos, float angle, ObjectType type) { - CObject* fret; - - fret = new CObject(); - if ( !fret->CreateResource(pos, angle, type) ) - { - delete fret; - return; - } + CObject* fret = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, type); fret->SetLock(true); // not usable fret->SetZoom(0, 0.0f); } diff --git a/src/object/auto/autonuclear.cpp b/src/object/auto/autonuclear.cpp index cd362844..e3bad7e1 100644 --- a/src/object/auto/autonuclear.cpp +++ b/src/object/auto/autonuclear.cpp @@ -392,20 +392,11 @@ bool CAutoNuclear::SearchVehicle() void CAutoNuclear::CreatePower() { - CObject* power; - Math::Vector pos; - float angle; + Math::Vector pos = m_object->GetPosition(0); + float angle = m_object->GetAngleY(0); - pos = m_object->GetPosition(0); - angle = m_object->GetAngleY(0); - - power = new CObject(); - if ( !power->CreateResource(pos, angle, OBJECT_ATOMIC) ) - { - delete power; - m_main->DisplayError(ERR_TOOMANY, m_object); - return; - } + float powerLevel = 1.0f; + CObject* power = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, OBJECT_ATOMIC, powerLevel); power->SetTruck(m_object); power->SetPosition(0, Math::Vector(22.0f, 3.0f, 0.0f)); diff --git a/src/object/motion/motion.cpp b/src/object/motion/motion.cpp index d7044937..425fd840 100644 --- a/src/object/motion/motion.cpp +++ b/src/object/motion/motion.cpp @@ -65,13 +65,6 @@ CMotion::~CMotion() { } -// Deletes the object. - -void CMotion::DeleteObject(bool bAll) -{ -} - - void CMotion::SetPhysics(CPhysics* physics) { m_physics = physics; @@ -82,14 +75,6 @@ void CMotion::SetBrain(CBrain* brain) m_brain = brain; } - -// Creates. - -bool CMotion::Create(Math::Vector pos, float angle, ObjectType type, float power) -{ - return true; -} - // Management of an event. bool CMotion::EventProcess(const Event &event) diff --git a/src/object/motion/motion.h b/src/object/motion/motion.h index a116b3fc..d8447a80 100644 --- a/src/object/motion/motion.h +++ b/src/object/motion/motion.h @@ -54,8 +54,8 @@ public: void SetPhysics(CPhysics* physics); void SetBrain(CBrain* brain); - virtual void DeleteObject(bool bAll=false); - virtual bool Create(Math::Vector pos, float angle, ObjectType type, float power); + virtual void DeleteObject(bool bAll=false) = 0; + virtual void Create(Math::Vector pos, float angle, ObjectType type, float power, Gfx::CModelManager* modelManager) = 0; virtual bool EventProcess(const Event &event); virtual Error SetAction(int action, float time=0.2f); virtual int GetAction(); diff --git a/src/object/motion/motionant.cpp b/src/object/motion/motionant.cpp index ea48ed6c..aea3ccf0 100644 --- a/src/object/motion/motionant.cpp +++ b/src/object/motion/motionant.cpp @@ -68,10 +68,9 @@ void CMotionAnt::DeleteObject(bool bAll) // Creates a vehicle poses some rolling on the floor. -bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type, - float power) +void CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type, + float power, Gfx::CModelManager* modelManager) { - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); int rank; m_object->SetType(type); @@ -258,8 +257,6 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type, m_object->SetPosition(0, pos); // to display the shadows immediately m_engine->LoadAllTextures(); - - return true; } // Creates the physics of the object. diff --git a/src/object/motion/motionant.h b/src/object/motion/motionant.h index 660418a3..f028df88 100644 --- a/src/object/motion/motionant.h +++ b/src/object/motion/motionant.h @@ -53,7 +53,7 @@ public: ~CMotionAnt(); void DeleteObject(bool bAll=false); - bool Create(Math::Vector pos, float angle, ObjectType type, float power); + void Create(Math::Vector pos, float angle, ObjectType type, float power, Gfx::CModelManager* modelManager); bool EventProcess(const Event &event); protected: diff --git a/src/object/motion/motionbee.cpp b/src/object/motion/motionbee.cpp index 089bd169..c954bede 100644 --- a/src/object/motion/motionbee.cpp +++ b/src/object/motion/motionbee.cpp @@ -66,10 +66,9 @@ void CMotionBee::DeleteObject(bool bAll) // Creates a vehicle traveling any lands on the ground. -bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type, - float power) +void CMotionBee::Create(Math::Vector pos, float angle, ObjectType type, + float power, Gfx::CModelManager* modelManager) { - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); int rank; m_object->SetType(type); @@ -275,8 +274,6 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type, m_object->SetPosition(0, pos); // to display the shadows immediately m_engine->LoadAllTextures(); - - return true; } // Creates the physical object. diff --git a/src/object/motion/motionbee.h b/src/object/motion/motionbee.h index a09ef3a5..f15dc947 100644 --- a/src/object/motion/motionbee.h +++ b/src/object/motion/motionbee.h @@ -47,7 +47,7 @@ public: ~CMotionBee(); void DeleteObject(bool bAll=false); - bool Create(Math::Vector pos, float angle, ObjectType type, float power); + void Create(Math::Vector pos, float angle, ObjectType type, float power, Gfx::CModelManager* modelManager); bool EventProcess(const Event &event); protected: diff --git a/src/object/motion/motiondummy.cpp b/src/object/motion/motiondummy.cpp index a3ba540b..8874d9a8 100644 --- a/src/object/motion/motiondummy.cpp +++ b/src/object/motion/motiondummy.cpp @@ -47,8 +47,8 @@ void CMotionDummy::DeleteObject(bool bAll) // Creates a Dummy traveling any lands on the ground. -bool CMotionDummy::Create(Math::Vector pos, float angle, ObjectType type, - float power) +void CMotionDummy::Create(Math::Vector pos, float angle, ObjectType type, + float power, Gfx::CModelManager*) { m_object->SetType(type); @@ -81,7 +81,5 @@ bool CMotionDummy::Create(Math::Vector pos, float angle, ObjectType type, m_physics->SetCirMotionY(MO_ADVACCEL, 2.0f); m_physics->SetCirMotionY(MO_RECACCEL, 2.0f); m_physics->SetCirMotionY(MO_STOACCEL, 2.0f); - - return true; } diff --git a/src/object/motion/motiondummy.h b/src/object/motion/motiondummy.h index a2c84604..b6227e84 100644 --- a/src/object/motion/motiondummy.h +++ b/src/object/motion/motiondummy.h @@ -31,6 +31,6 @@ public: ~CMotionDummy(); void DeleteObject(bool bAll=false); - bool Create(Math::Vector pos, float angle, ObjectType type, float power); + void Create(Math::Vector pos, float angle, ObjectType type, float power, Gfx::CModelManager* modelManager); }; diff --git a/src/object/motion/motionhuman.cpp b/src/object/motion/motionhuman.cpp index d49fae5d..60ade452 100644 --- a/src/object/motion/motionhuman.cpp +++ b/src/object/motion/motionhuman.cpp @@ -96,14 +96,12 @@ Error CMotionHuman::SetAction(int action, float time) // Creates cosmonaut on the ground. -bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type, - float power) +void CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type, + float power, Gfx::CModelManager* modelManager) { char filename[100]; int rank, option, face, glasses; - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - m_object->SetType(type); option = m_object->GetOption(); @@ -132,7 +130,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type, m_engine->LoadAllTextures(); - return true; + return; } // Creates the main base. @@ -327,8 +325,6 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type, m_object->SetPosition(0, pos); // to display the shadows immediately m_engine->LoadAllTextures(); - - return true; } // Creates the physical object. diff --git a/src/object/motion/motionhuman.h b/src/object/motion/motionhuman.h index 4eac4038..87a05606 100644 --- a/src/object/motion/motionhuman.h +++ b/src/object/motion/motionhuman.h @@ -65,7 +65,7 @@ public: ~CMotionHuman(); void DeleteObject(bool bAll=false); - bool Create(Math::Vector pos, float angle, ObjectType type, float power); + void Create(Math::Vector pos, float angle, ObjectType type, float power, Gfx::CModelManager* modelManager); bool EventProcess(const Event &event); Error SetAction(int action, float time=0.2f); diff --git a/src/object/motion/motionmother.cpp b/src/object/motion/motionmother.cpp index c88480ff..59772b3f 100644 --- a/src/object/motion/motionmother.cpp +++ b/src/object/motion/motionmother.cpp @@ -67,10 +67,9 @@ void CMotionMother::DeleteObject(bool bAll) // Creates a vehicle traveling any lands on the ground. -bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type, - float power) +void CMotionMother::Create(Math::Vector pos, float angle, ObjectType type, + float power, Gfx::CModelManager* modelManager) { - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); int rank; m_object->SetType(type); @@ -252,8 +251,6 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type, m_object->SetPosition(0, pos); // to display the shadows immediately m_engine->LoadAllTextures(); - - return true; } // Creates the physics of the object. diff --git a/src/object/motion/motionmother.h b/src/object/motion/motionmother.h index 13fe4660..d3ead13c 100644 --- a/src/object/motion/motionmother.h +++ b/src/object/motion/motionmother.h @@ -33,7 +33,7 @@ public: ~CMotionMother(); void DeleteObject(bool bAll=false); - bool Create(Math::Vector pos, float angle, ObjectType type, float power); + void Create(Math::Vector pos, float angle, ObjectType type, float power, Gfx::CModelManager* modelManager); bool EventProcess(const Event &event); protected: diff --git a/src/object/motion/motionspider.cpp b/src/object/motion/motionspider.cpp index 435111d3..a1d82bb5 100644 --- a/src/object/motion/motionspider.cpp +++ b/src/object/motion/motionspider.cpp @@ -68,8 +68,8 @@ void CMotionSpider::DeleteObject(bool bAll) // Creates a vehicle traveling any lands on the ground. -bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type, - float power) +void CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type, + float power, Gfx::CModelManager* modelManager) { int rank, i, j, parent; char name[50]; @@ -98,8 +98,6 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type, 0.0f, 0.0f, -2.0f, }; - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - m_object->SetType(type); // Creates the main base. @@ -191,8 +189,6 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type, m_object->SetPosition(0, pos); // to display the shadows immediately m_engine->LoadAllTextures(); - - return true; } // Creates the physics of the object. diff --git a/src/object/motion/motionspider.h b/src/object/motion/motionspider.h index 1a99bfd2..78337800 100644 --- a/src/object/motion/motionspider.h +++ b/src/object/motion/motionspider.h @@ -51,7 +51,7 @@ public: ~CMotionSpider(); void DeleteObject(bool bAll=false); - bool Create(Math::Vector pos, float angle, ObjectType type, float power); + void Create(Math::Vector pos, float angle, ObjectType type, float power, Gfx::CModelManager* modelManager); bool EventProcess(const Event &event); protected: diff --git a/src/object/motion/motiontoto.cpp b/src/object/motion/motiontoto.cpp index ef3fb689..5f2df1ef 100644 --- a/src/object/motion/motiontoto.cpp +++ b/src/object/motion/motiontoto.cpp @@ -80,10 +80,9 @@ void CMotionToto::DeleteObject(bool bAll) // Creates a vehicle traveling any lands on the ground. -bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type, - float power) +void CMotionToto::Create(Math::Vector pos, float angle, ObjectType type, + float power, Gfx::CModelManager* modelManager) { - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); int rank; @@ -180,8 +179,6 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type, m_object->SetPosition(0, pos); // to display the shadows immediately m_engine->LoadAllTextures(); - - return true; } diff --git a/src/object/motion/motiontoto.h b/src/object/motion/motiontoto.h index a071781a..e691cad7 100644 --- a/src/object/motion/motiontoto.h +++ b/src/object/motion/motiontoto.h @@ -42,7 +42,7 @@ public: ~CMotionToto(); void DeleteObject(bool bAll=false); - bool Create(Math::Vector pos, float angle, ObjectType type, float power); + void Create(Math::Vector pos, float angle, ObjectType type, float power, Gfx::CModelManager* modelManager); bool EventProcess(const Event &event); Error SetAction(int action, float time=0.2f); void SetLinkType(ObjectType type); diff --git a/src/object/motion/motionvehicle.cpp b/src/object/motion/motionvehicle.cpp index 86d1d13d..7bfce100 100644 --- a/src/object/motion/motionvehicle.cpp +++ b/src/object/motion/motionvehicle.cpp @@ -91,16 +91,14 @@ void CMotionVehicle::DeleteObject(bool bAll) // Creates a vehicle traveling any lands on the ground. -bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, - float power) +void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, + float power, Gfx::CModelManager* modelManager) { CObject* pPower; int rank, i, j, parent; Gfx::Color color; char name[50]; - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - m_object->SetType(type); // Creates the main base. @@ -954,8 +952,6 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, m_object->SetPosition(0, pos); //to display the shadows immediately m_engine->LoadAllTextures(); - - return true; } // Creates the physics of the object. diff --git a/src/object/motion/motionvehicle.h b/src/object/motion/motionvehicle.h index 93428860..41e69ad8 100644 --- a/src/object/motion/motionvehicle.h +++ b/src/object/motion/motionvehicle.h @@ -33,7 +33,7 @@ public: ~CMotionVehicle(); void DeleteObject(bool bAll=false); - bool Create(Math::Vector pos, float angle, ObjectType type, float power); + void Create(Math::Vector pos, float angle, ObjectType type, float power, Gfx::CModelManager* modelManager); bool EventProcess(const Event &event); bool GetTraceDown(); diff --git a/src/object/motion/motionworm.cpp b/src/object/motion/motionworm.cpp index 073a9628..11c802e2 100644 --- a/src/object/motion/motionworm.cpp +++ b/src/object/motion/motionworm.cpp @@ -80,14 +80,12 @@ void CMotionWorm::DeleteObject(bool bAll) // Creates a vehicle traveling any lands on the ground. -bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type, - float power) +void CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type, + float power, Gfx::CModelManager* modelManager) { int rank, i; float px; - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - m_object->SetType(type); // Creates the main base. @@ -142,8 +140,6 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type, m_object->SetPosition(0, pos); // to display the shadows immediately m_engine->LoadAllTextures(); - - return true; } // Creates the physics of the object. diff --git a/src/object/motion/motionworm.h b/src/object/motion/motionworm.h index 5353bf27..0eb9a9f0 100644 --- a/src/object/motion/motionworm.h +++ b/src/object/motion/motionworm.h @@ -33,7 +33,7 @@ public: ~CMotionWorm(); void DeleteObject(bool bAll=false); - bool Create(Math::Vector pos, float angle, ObjectType type, float power); + void Create(Math::Vector pos, float angle, ObjectType type, float power, Gfx::CModelManager* modelManager); bool EventProcess(const Event &event); bool SetParam(int rank, float value); diff --git a/src/object/object.cpp b/src/object/object.cpp index 392c0c4e..f00e3d2b 100644 --- a/src/object/object.cpp +++ b/src/object/object.cpp @@ -38,42 +38,10 @@ #include "math/geometry.h" #include "object/auto/auto.h" -#include "object/auto/autobase.h" -#include "object/auto/autoconvert.h" -#include "object/auto/autoderrick.h" -#include "object/auto/autodestroyer.h" -#include "object/auto/autoegg.h" -#include "object/auto/autoenergy.h" -#include "object/auto/autofactory.h" -#include "object/auto/autoflag.h" -#include "object/auto/autohuston.h" -#include "object/auto/autoinfo.h" #include "object/auto/autojostle.h" -#include "object/auto/autokid.h" -#include "object/auto/autolabo.h" -#include "object/auto/automush.h" -#include "object/auto/autonest.h" -#include "object/auto/autonuclear.h" -#include "object/auto/autopara.h" -#include "object/auto/autoportico.h" -#include "object/auto/autoradar.h" -#include "object/auto/autorepair.h" -#include "object/auto/autoresearch.h" -#include "object/auto/autoroot.h" -#include "object/auto/autosafe.h" -#include "object/auto/autostation.h" -#include "object/auto/autotower.h" #include "object/brain.h" #include "object/motion/motion.h" -#include "object/motion/motionant.h" -#include "object/motion/motionbee.h" -#include "object/motion/motiondummy.h" -#include "object/motion/motionhuman.h" -#include "object/motion/motionmother.h" -#include "object/motion/motionspider.h" -#include "object/motion/motiontoto.h" #include "object/motion/motionvehicle.h" -#include "object/motion/motionworm.h" #include "object/robotmain.h" #include "object/objman.h" #include "object/level/parserline.h" @@ -2034,168 +2002,6 @@ void CObject::SetDrawFront(bool bDraw) } } - -// Creates a vehicle traveling any pose on the floor. - -bool CObject::CreateVehicle(Math::Vector pos, float angle, ObjectType type, - float power, bool bTrainer, bool bToy) -{ - m_type = type; - - if ( type == OBJECT_TOTO ) - { - m_motion = new CMotionToto(this); - m_motion->Create(pos, angle, type, 1.0f); - return true; - } - - SetTrainer(bTrainer); - SetToy(bToy); - - m_physics = new CPhysics(this); - m_brain = new CBrain(this); - - m_physics->SetBrain(m_brain); - m_brain->SetPhysics(m_physics); - -#if 0 - if ( type == OBJECT_MOBILEfc || - type == OBJECT_MOBILEtc || - type == OBJECT_MOBILEwc || - type == OBJECT_MOBILEic ) // fireball cannon? - { - m_showLimitRadius = 160.0f; - } - if ( type == OBJECT_MOBILEfi || - type == OBJECT_MOBILEti || - type == OBJECT_MOBILEwi || - type == OBJECT_MOBILEii ) // orgaball cannon? - { - m_showLimitRadius = 160.0f; - } - if ( type == OBJECT_MOBILErc ) // phazer cannon? - { - m_showLimitRadius = 160.0f; - } - if ( type == OBJECT_MOBILErs ) // robot shield? - { - m_showLimitRadius = 50.0f; - } -#endif - if ( type == OBJECT_MOBILErt ) // robot thumper? - { - m_showLimitRadius = 400.0f; - } - - if ( type == OBJECT_HUMAN || - type == OBJECT_TECH ) - { - m_motion = new CMotionHuman(this); - } - else if ( type == OBJECT_CONTROLLER ) - { - m_motion = new CMotionDummy(this); //dummy object - } - else - { - m_motion = new CMotionVehicle(this); - } - if ( m_motion == 0 ) return false; - - m_physics->SetMotion(m_motion); - m_brain->SetMotion(m_motion); - m_motion->SetPhysics(m_physics); - m_motion->SetBrain(m_brain); - if ( !m_motion->Create(pos, angle, type, power) ) - { - if ( m_physics != 0 ) - { - m_physics->DeleteObject(); - delete m_physics; - m_physics = 0; - } - if ( m_brain != 0 ) - { - m_brain->DeleteObject(); - delete m_brain; - m_brain = 0; - } - if ( m_motion != 0 ) - { - m_motion->DeleteObject(); - delete m_motion; - m_motion = 0; - } - return false; - } - - return true; -} - -// Creates an insect lands on any ground. - -bool CObject::CreateInsect(Math::Vector pos, float angle, ObjectType type) -{ - m_type = type; - - m_physics = new CPhysics(this); - m_brain = new CBrain(this); - - m_physics->SetBrain(m_brain); - m_brain->SetPhysics(m_physics); - - if ( type == OBJECT_MOTHER ) - { - m_motion = new CMotionMother(this); - } - if ( type == OBJECT_ANT ) - { - m_motion = new CMotionAnt(this); - } - if ( type == OBJECT_SPIDER ) - { - m_motion = new CMotionSpider(this); - } - if ( type == OBJECT_BEE ) - { - m_motion = new CMotionBee(this); - } - if ( type == OBJECT_WORM ) - { - m_motion = new CMotionWorm(this); - } - if ( m_motion == 0 ) return false; - - m_physics->SetMotion(m_motion); - m_brain->SetMotion(m_motion); - m_motion->SetPhysics(m_physics); - m_motion->SetBrain(m_brain); - if ( !m_motion->Create(pos, angle, type, 0.0f) ) - { - if ( m_physics != 0 ) - { - m_physics->DeleteObject(); - delete m_physics; - m_physics = 0; - } - if ( m_brain != 0 ) - { - m_brain->DeleteObject(); - delete m_brain; - m_brain = 0; - } - if ( m_motion != 0 ) - { - m_motion->DeleteObject(); - delete m_motion; - m_motion = 0; - } - return false; - } - - return true; -} - // Creates shade under a vehicle as a negative light. bool CObject::CreateShadowLight(float height, Gfx::Color color) @@ -2292,3237 +2098,6 @@ bool CObject::CreateShadowCircle(float radius, float intensity, return true; } -// Creates a building laying on the ground. - -bool CObject::CreateBuilding(Math::Vector pos, float angle, float height, - ObjectType type, float power) -{ - Math::Point p; - int rank, i; - - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - - SetType(type); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object - SetObjectRank(0, rank); - - if ( m_type == OBJECT_PORTICO ) - { - modelManager->AddModelReference("portico1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("portico2.mod", false, rank); - SetPosition(1, Math::Vector(0.0f, 67.0f, 0.0f)); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(2, rank); - SetObjectParent(2, 1); - modelManager->AddModelReference("portico3.mod", false, rank); - SetPosition(2, Math::Vector(0.0f, 0.0f, -33.0f)); - SetAngleY(2, 45.0f*Math::PI/180.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(3, rank); - SetObjectParent(3, 2); - modelManager->AddModelReference("portico4.mod", false, rank); - SetPosition(3, Math::Vector(50.0f, 0.0f, 0.0f)); - SetAngleY(3, -60.0f*Math::PI/180.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(4, rank); - SetObjectParent(4, 3); - modelManager->AddModelReference("portico5.mod", false, rank); - SetPosition(4, Math::Vector(35.0f, 0.0f, 0.0f)); - SetAngleY(4, -55.0f*Math::PI/180.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(5, rank); - SetObjectParent(5, 1); - modelManager->AddModelReference("portico3.mod", false, rank); - SetPosition(5, Math::Vector(0.0f, 0.0f, 33.0f)); - SetAngleY(5, -45.0f*Math::PI/180.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(6, rank); - SetObjectParent(6, 5); - modelManager->AddModelReference("portico4.mod", false, rank); - SetPosition(6, Math::Vector(50.0f, 0.0f, 0.0f)); - SetAngleY(6, 60.0f*Math::PI/180.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(7, rank); - SetObjectParent(7, 6); - modelManager->AddModelReference("portico5.mod", false, rank); - SetPosition(7, Math::Vector(35.0f, 0.0f, 0.0f)); - SetAngleY(7, 55.0f*Math::PI/180.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(8, rank); - SetObjectParent(8, 0); - modelManager->AddModelReference("portico6.mod", false, rank); - SetPosition(8, Math::Vector(-35.0f, 50.0f, -35.0f)); - SetAngleY(8, -Math::PI/2.0f); - SetZoom(8, 2.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(9, rank); - SetObjectParent(9, 8); - modelManager->AddModelReference("portico7.mod", false, rank); - SetPosition(9, Math::Vector(0.0f, 4.5f, 1.9f)); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(10, rank); - SetObjectParent(10, 0); - modelManager->AddModelReference("portico6.mod", false, rank); - SetPosition(10, Math::Vector(-35.0f, 50.0f, 35.0f)); - SetAngleY(10, -Math::PI/2.0f); - SetZoom(10, 2.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(11, rank); - SetObjectParent(11, 10); - modelManager->AddModelReference("portico7.mod", false, rank); - SetPosition(11, Math::Vector(0.0f, 4.5f, 1.9f)); - - CreateCrashSphere(Math::Vector( 0.0f, 28.0f, 0.0f), 45.5f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 27.0f, 10.0f, -42.0f), 15.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 10.0f, -42.0f), 15.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-27.0f, 10.0f, -42.0f), 15.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 27.0f, 10.0f, 42.0f), 15.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 10.0f, 42.0f), 15.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-27.0f, 10.0f, 42.0f), 15.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-32.0f, 45.0f, -32.0f), 10.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-32.0f, 45.0f, 32.0f), 10.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 32.0f, 45.0f, -32.0f), 10.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 32.0f, 45.0f, 32.0f), 10.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 35.0f, 0.0f), 50.0f); - - CreateShadowCircle(50.0f, 1.0f); - } - - if ( m_type == OBJECT_BASE ) - { - modelManager->AddModelReference("base1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - for ( i=0 ; i<8 ; i++ ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1+i, rank); - SetObjectParent(1+i, 0); - modelManager->AddModelReference("base2.mod", false, rank); - p = Math::RotatePoint(-Math::PI/4.0f*i, 27.8f); - SetPosition(1+i, Math::Vector(p.x, 30.0f, p.y)); - SetAngleY(1+i, Math::PI/4.0f*i); - SetAngleZ(1+i, Math::PI/2.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(10+i, rank); - SetObjectParent(10+i, 1+i); - modelManager->AddModelReference("base4.mod", false, rank); - SetPosition(10+i, Math::Vector(23.5f, 0.0f, 7.0f)); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(18+i, rank); - SetObjectParent(18+i, 1+i); - modelManager->AddModelReference("base4.mod", true, rank); - SetPosition(18+i, Math::Vector(23.5f, 0.0f, -7.0f)); - } - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(9, rank); - SetObjectParent(9, 0); - modelManager->AddModelReference("base3.mod", false, rank); // central pillar - - CreateCrashSphere(Math::Vector( 0.0f, 33.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 39.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 45.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 51.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 57.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 63.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 69.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 82.0f, 0.0f), 8.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 18.0f, 94.0f, 0.0f), 10.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-18.0f, 94.0f, 0.0f), 10.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 94.0f, 18.0f), 10.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 94.0f, -18.0f), 10.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 13.0f, 94.0f, 13.0f), 10.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-13.0f, 94.0f, 13.0f), 10.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 13.0f, 94.0f, -13.0f), 10.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-13.0f, 94.0f, -13.0f), 10.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f,104.0f, 0.0f), 14.0f, SOUND_BOUMm, 0.45f); - - SetGlobalSphere(Math::Vector(0.0f, 45.0f, 0.0f), 10.0f); - - CreateShadowCircle(60.0f, 1.0f); - m_showLimitRadius = 200.0f; - - m_terrain->AddBuildingLevel(pos, 28.6f, 73.4f, 30.0f, 0.4f); - } - - if ( m_type == OBJECT_DERRICK ) - { - modelManager->AddModelReference("derrick1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("derrick2.mod", false, rank); - - CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(0.0f, 10.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(0.0f, 17.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(0.0f, 26.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(7.0f, 17.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 10.0f); - - CreateShadowCircle(10.0f, 0.4f); - } - - if ( m_type == OBJECT_RESEARCH ) - { - modelManager->AddModelReference("search1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("search2.mod", false, rank); - SetPosition(1, Math::Vector(0.0f, 13.0f, 0.0f)); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(2, rank); - SetObjectParent(2, 1); - modelManager->AddModelReference("search3.mod", false, rank); - SetPosition(2, Math::Vector(0.0f, 4.0f, 0.0f)); - SetAngleZ(2, 35.0f*Math::PI/180.0f); - - CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 9.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(0.0f, 6.0f, 0.0f), 9.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(0.0f, 14.0f, 0.0f), 7.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 8.0f, 0.0f), 12.0f); - - m_character.posPower = Math::Vector(7.5f, 3.0f, 0.0f); - - CreateShadowCircle(12.0f, 1.0f); - } - - if ( m_type == OBJECT_RADAR ) - { - modelManager->AddModelReference("radar1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("radar2.mod", false, rank); - SetPosition(1, Math::Vector(0.0f, 5.0f, 0.0f)); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(2, rank); - SetObjectParent(2, 0); - modelManager->AddModelReference("radar3.mod", false, rank); - SetPosition(2, Math::Vector(0.0f, 11.0f, 0.0f)); - SetAngleY(2, -Math::PI/2.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(3, rank); - SetObjectParent(3, 2); - modelManager->AddModelReference("radar4.mod", false, rank); - SetPosition(3, Math::Vector(0.0f, 4.5f, 1.9f)); - - CreateCrashSphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(0.0f, 11.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 7.0f, 0.0f), 7.0f); - - CreateShadowCircle(8.0f, 1.0f); - } - - if ( m_type == OBJECT_INFO ) - { - modelManager->AddModelReference("info1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("info2.mod", false, rank); - SetPosition(1, Math::Vector(0.0f, 5.0f, 0.0f)); - - for ( i=0 ; i<3 ; i++ ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(2+i*2, rank); - SetObjectParent(2+i*2, 1); - modelManager->AddModelReference("info3.mod", false, rank); - SetPosition(2+i*2, Math::Vector(0.0f, 4.5f, 0.0f)); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(3+i*2, rank); - SetObjectParent(3+i*2, 2+i*2); - modelManager->AddModelReference("radar4.mod", false, rank); - SetPosition(3+i*2, Math::Vector(0.0f, 0.0f, -4.0f)); - - SetAngleY(2+i*2, 2.0f*Math::PI/3.0f*i); - } - - CreateCrashSphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(0.0f, 11.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 6.0f); - - CreateShadowCircle(8.0f, 1.0f); - } - - if ( m_type == OBJECT_ENERGY ) - { - modelManager->AddModelCopy("energy.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - CreateCrashSphere(Math::Vector(-2.0f, 13.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-7.0f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 1.0f, 0.0f), 1.5f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(-7.0f, 5.0f, 0.0f), 5.0f); - - m_character.posPower = Math::Vector(0.0f, 3.0f, 0.0f); - m_energy = power; // initializes the energy level - - CreateShadowCircle(6.0f, 0.5f); - } - - if ( m_type == OBJECT_LABO ) - { - modelManager->AddModelReference("labo1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("labo2.mod", false, rank); - SetPosition(1, Math::Vector(-9.0f, 3.0f, 0.0f)); - SetAngleZ(1, Math::PI/2.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(2, rank); - SetObjectParent(2, 1); - modelManager->AddModelReference("labo3.mod", false, rank); - SetPosition(2, Math::Vector(9.0f, -1.0f, 0.0f)); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(3, rank); - SetObjectParent(3, 2); - modelManager->AddModelReference("labo4.mod", false, rank); - SetPosition(3, Math::Vector(0.0f, 0.0f, 0.0f)); - SetAngleZ(3, 80.0f*Math::PI/180.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(4, rank); - SetObjectParent(4, 2); - modelManager->AddModelReference("labo4.mod", false, rank); - SetPosition(4, Math::Vector(0.0f, 0.0f, 0.0f)); - SetAngleZ(4, 80.0f*Math::PI/180.0f); - SetAngleY(4, Math::PI*2.0f/3.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(5, rank); - SetObjectParent(5, 2); - modelManager->AddModelReference("labo4.mod", false, rank); - SetPosition(5, Math::Vector(0.0f, 0.0f, 0.0f)); - SetAngleZ(5, 80.0f*Math::PI/180.0f); - SetAngleY(5, -Math::PI*2.0f/3.0f); - - CreateCrashSphere(Math::Vector( 0.0f, 1.0f, 0.0f), 1.5f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 11.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 10.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-12.0f, 3.0f, 3.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-12.0f, 3.0f, -3.0f), 4.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(-10.0f, 5.0f, 0.0f), 7.0f); - - m_character.posPower = Math::Vector(0.0f, 3.0f, 0.0f); - - CreateShadowCircle(7.0f, 0.5f); - } - - if ( m_type == OBJECT_FACTORY ) - { - modelManager->AddModelReference("factory1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - for ( i=0 ; i<9 ; i++ ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1+i, rank); - SetObjectParent(1+i, 0); - modelManager->AddModelReference("factory2.mod", false, rank); - SetPosition(1+i, Math::Vector(10.0f, 2.0f*i, 10.0f)); - SetAngleZ(1+i, Math::PI/2.0f); - SetZoomZ(1+i, 0.30f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(10+i, rank); - SetObjectParent(10+i, 0); - modelManager->AddModelReference("factory2.mod", false, rank); - SetPosition(10+i, Math::Vector(10.0f, 2.0f*i, -10.0f)); - SetAngleZ(10+i, -Math::PI/2.0f); - SetAngleY(10+i, Math::PI); - SetZoomZ(10+i, 0.30f); - } - - for ( i=0 ; i<2 ; i++ ) - { - float s = static_cast(i*2-1); - CreateCrashSphere(Math::Vector(-10.0f, 2.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -3.0f, 2.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 3.0f, 2.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 10.0f, 2.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 9.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -3.0f, 9.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 3.0f, 9.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 10.0f, 9.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 16.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -3.0f, 16.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 3.0f, 16.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 10.0f, 16.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 16.0f, 4.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -3.0f, 16.0f, 4.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 3.0f, 16.0f, 4.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 10.0f, 16.0f, 4.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 2.0f, 4.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 9.0f, 4.0f*s), 4.0f, SOUND_BOUMm, 0.45f); - } - CreateCrashSphere(Math::Vector(-10.0f, 21.0f, -4.0f), 3.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 18.0f); - - CreateShadowCircle(24.0f, 0.3f); - } - - if ( m_type == OBJECT_REPAIR ) - { - modelManager->AddModelReference("repair1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("repair2.mod", false, rank); - SetPosition(1, Math::Vector(-11.0f, 13.5f, 0.0f)); - SetAngleZ(1, Math::PI/2.0f); - - m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f); - - CreateCrashSphere(Math::Vector(-11.0f, 0.0f, 4.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-11.0f, 0.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-11.0f, 0.0f, -4.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-11.0f, 10.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(-11.0f, 13.0f, 0.0f), 15.0f); - } - - if ( m_type == OBJECT_DESTROYER ) - { - modelManager->AddModelReference("destroy1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("destroy2.mod", false, rank); - SetPosition(1, Math::Vector(0.0f, 0.0f, 0.0f)); - - m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f); - - CreateCrashSphere(Math::Vector(-3.5f, 0.0f, -13.5f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 3.5f, 0.0f, -13.5f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-3.5f, 0.0f, 13.5f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 3.5f, 0.0f, 13.5f), 4.0f, SOUND_BOUMm, 0.45f); - - CreateShadowCircle(19.0f, 1.0f); - } - - if ( m_type == OBJECT_STATION ) - { - modelManager->AddModelCopy("station.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f); - - CreateCrashSphere(Math::Vector(-15.0f, 2.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-15.0f, 6.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(-15.0f, 5.0f, 0.0f), 6.0f); - - m_energy = power; // initialise le niveau d'�nergie - } - - if ( m_type == OBJECT_CONVERT ) - { - modelManager->AddModelReference("convert1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("convert2.mod", false, rank); - SetPosition(1, Math::Vector(0.0f, 14.0f, 0.0f)); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(2, rank); - SetObjectParent(2, 0); - modelManager->AddModelReference("convert3.mod", false, rank); - SetPosition(2, Math::Vector(0.0f, 11.5f, 0.0f)); - SetAngleX(2, -Math::PI*0.35f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(3, rank); - SetObjectParent(3, 0); - modelManager->AddModelReference("convert3.mod", false, rank); - SetPosition(3, Math::Vector(0.0f, 11.5f, 0.0f)); - SetAngleY(3, Math::PI); - SetAngleX(3, -Math::PI*0.35f); - - m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f); - - CreateCrashSphere(Math::Vector(-10.0f, 2.0f, 4.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 2.0f, -4.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 9.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 14.0f, 0.0f), 1.5f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(-3.0f, 8.0f, 0.0f), 14.0f); - } - - if ( m_type == OBJECT_TOWER ) - { - modelManager->AddModelReference("tower.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("roller2c.mod", false, rank); - SetPosition(1, Math::Vector(0.0f, 20.0f, 0.0f)); - SetAngleZ(1, Math::PI/2.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(2, rank); - SetObjectParent(2, 1); - modelManager->AddModelReference("roller3c.mod", false, rank); - SetPosition(2, Math::Vector(4.5f, 0.0f, 0.0f)); - SetAngleZ(2, 0.0f); - - CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 6.5f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(0.0f, 8.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(0.0f, 15.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(0.0f, 24.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 7.0f); - - m_character.posPower = Math::Vector(5.0f, 3.0f, 0.0f); - - CreateShadowCircle(6.0f, 1.0f); - m_showLimitRadius = Gfx::LTNG_PROTECTION_RADIUS; - } - - if ( m_type == OBJECT_NUCLEAR ) - { - modelManager->AddModelReference("nuclear1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("nuclear2.mod", false, rank); - SetPosition(1, Math::Vector(20.0f, 10.0f, 0.0f)); - SetAngleZ(1, 135.0f*Math::PI/180.0f); - - CreateCrashSphere(Math::Vector( 0.0f, 0.0f, 0.0f), 19.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 24.0f, 0.0f), 15.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(22.0f, 1.0f, 0.0f), 1.5f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 17.0f, 0.0f), 26.0f); - - m_character.posPower = Math::Vector(22.0f, 3.0f, 0.0f); - - CreateShadowCircle(21.0f, 1.0f); - } - - if ( m_type == OBJECT_PARA ) - { - modelManager->AddModelReference("para.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - m_terrain->AddBuildingLevel(pos, 16.0f, 18.0f, 1.0f, 0.5f); - - CreateCrashSphere(Math::Vector( 13.0f, 3.0f, 13.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 11.0f, 15.0f, 11.0f), 2.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-13.0f, 3.0f, 13.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-11.0f, 15.0f, -11.0f), 2.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 13.0f, 3.0f, -13.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 11.0f, 15.0f, -11.0f), 2.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-13.0f, 3.0f, -13.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-11.0f, 15.0f, -11.0f), 2.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 26.0f, 0.0f), 9.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 54.0f, 0.0f), 14.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 20.0f); - - CreateShadowCircle(21.0f, 1.0f); - m_showLimitRadius = Gfx::LTNG_PROTECTION_RADIUS; - } - - if ( m_type == OBJECT_SAFE ) - { - modelManager->AddModelReference("safe1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("safe2.mod", false, rank); - SetZoom(1, 1.05f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(2, rank); - SetObjectParent(2, 0); - modelManager->AddModelReference("safe3.mod", false, rank); - SetZoom(2, 1.05f); - - m_terrain->AddBuildingLevel(pos, 18.0f, 20.0f, 1.0f, 0.5f); - - CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 13.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 1.0f, 0.0f), 13.0f); - - CreateShadowCircle(23.0f, 1.0f); - } - - if ( m_type == OBJECT_HUSTON ) - { - modelManager->AddModelReference("huston1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("huston2.mod", false, rank); - SetPosition(1, Math::Vector(0.0f, 39.0f, 30.0f)); - SetAngleY(1, -Math::PI/2.0f); - SetZoom(1, 3.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(2, rank); - SetObjectParent(2, 1); - modelManager->AddModelReference("huston3.mod", false, rank); - SetPosition(2, Math::Vector(0.0f, 4.5f, 1.9f)); - - CreateCrashSphere(Math::Vector( 15.0f, 6.0f, -53.0f), 16.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-15.0f, 6.0f, -53.0f), 16.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 15.0f, 6.0f, -26.0f), 16.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-15.0f, 6.0f, -26.0f), 16.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 15.0f, 6.0f, 0.0f), 16.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-15.0f, 6.0f, 0.0f), 16.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 15.0f, 6.0f, 26.0f), 16.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-15.0f, 6.0f, 26.0f), 16.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 15.0f, 6.0f, 53.0f), 16.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-15.0f, 6.0f, 53.0f), 16.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 27.0f, 30.0f), 12.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 45.0f, 30.0f), 14.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 26.0f, 4.0f, -61.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-26.0f, 4.0f, -61.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 26.0f, 4.0f, 61.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-26.0f, 4.0f, 61.0f), 5.0f, SOUND_BOUMm, 0.45f); - } - - if ( m_type == OBJECT_TARGET1 ) - { - modelManager->AddModelReference("target1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, 1.5f); - SetFloorHeight(0.0f); - - CreateCrashSphere(Math::Vector( 0.0f, 50.0f+14.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -7.0f, 50.0f+12.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 7.0f, 50.0f+12.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-12.0f, 50.0f+ 7.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 12.0f, 50.0f+ 7.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-14.0f, 50.0f+ 0.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 14.0f, 50.0f+ 0.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-12.0f, 50.0f- 7.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 12.0f, 50.0f- 7.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -7.0f, 50.0f-12.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 7.0f, 50.0f-12.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 50.0f-14.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - - CreateCrashSphere(Math::Vector(0.0f, 30.0f, 0.0f), 2.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(0.0f, 24.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(0.0f, 16.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(0.0f, 4.0f, 0.0f), 8.0f, SOUND_BOUMm, 0.45f); - - CreateShadowCircle(15.0f, 1.0f); - } - - if ( m_type == OBJECT_TARGET2 ) - { - modelManager->AddModelReference("target2.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - height += 50.0f*1.5f; - } - - if ( m_type == OBJECT_NEST ) - { - modelManager->AddModelReference("nest.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - m_terrain->AddBuildingLevel(pos, 3.0f, 5.0f, 1.0f, 0.5f); - - CreateShadowCircle(4.0f, 1.0f); - } - - if ( m_type == OBJECT_START ) - { - modelManager->AddModelReference("start.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f); - } - - if ( m_type == OBJECT_END ) - { - modelManager->AddModelReference("end.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f); - } - -#if 0 - if ( power > 0.0f ) // creates a battery? - { - CObject* pPower; - - 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 ) modelManager->AddModelReference("power.mod", false, rank); - else modelManager->AddModelReference("atomic.mod", false, rank); - - pPower->SetPosition(0, GetCharacter()->posPower); - pPower->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - pPower->SetGlobalSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.5f); - - pPower->SetTruck(this); - SetPower(pPower); - - if ( power <= 1.0f ) pPower->SetEnergy(power); - else pPower->SetEnergy(power/100.0f); - } -#endif - - pos = GetPosition(0); - pos.y += height; - SetPosition(0, pos); // to display the shadows immediately - - CreateOtherObject(type); - m_engine->LoadAllTextures(); - - return true; -} - -// Creates a small resource set on the ground. - -bool CObject::CreateResource(Math::Vector pos, float angle, ObjectType type, - float power) -{ - int rank; - float radius, height; - - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - - SetType(type); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object - SetObjectRank(0, rank); - SetEnergy(power); - - std::string name; - if ( type == OBJECT_STONE ) name = "stone.mod"; - if ( type == OBJECT_URANIUM ) name = "uranium.mod"; - if ( type == OBJECT_METAL ) name = "metal.mod"; - if ( type == OBJECT_POWER ) name = "power.mod"; - if ( type == OBJECT_ATOMIC ) name = "atomic.mod"; - if ( type == OBJECT_BULLET ) name = "bullet.mod"; - if ( type == OBJECT_BBOX ) name = "bbox.mod"; - if ( type == OBJECT_KEYa ) name = "keya.mod"; - if ( type == OBJECT_KEYb ) name = "keyb.mod"; - if ( type == OBJECT_KEYc ) name = "keyc.mod"; - if ( type == OBJECT_KEYd ) name = "keyd.mod"; - if ( type == OBJECT_TNT ) name = "tnt.mod"; - if ( type == OBJECT_SCRAP1 ) name = "scrap1.mod"; - if ( type == OBJECT_SCRAP2 ) name = "scrap2.mod"; - if ( type == OBJECT_SCRAP3 ) name = "scrap3.mod"; - if ( type == OBJECT_SCRAP4 ) name = "scrap4.mod"; - if ( type == OBJECT_SCRAP5 ) name = "scrap5.mod"; - if ( type == OBJECT_BOMB ) name = "bomb.mod"; - if ( type == OBJECT_WAYPOINT ) name = "waypoint.mod"; - if ( type == OBJECT_SHOW ) name = "show.mod"; - if ( type == OBJECT_WINFIRE ) name = "winfire.mod"; - if ( type == OBJECT_BAG ) name = "bag.mod"; - if ( type == OBJECT_MARKSTONE ) name = "cross1.mod"; - if ( type == OBJECT_MARKURANIUM ) name = "cross3.mod"; - if ( type == OBJECT_MARKPOWER ) name = "cross2.mod"; - if ( type == OBJECT_MARKKEYa ) name = "crossa.mod"; - if ( type == OBJECT_MARKKEYb ) name = "crossb.mod"; - if ( type == OBJECT_MARKKEYc ) name = "crossc.mod"; - if ( type == OBJECT_MARKKEYd ) name = "crossd.mod"; - if ( type == OBJECT_EGG ) name = "egg.mod"; - - if (type == OBJECT_POWER || type == OBJECT_ATOMIC) - { - modelManager->AddModelCopy(name, false, rank); - } - else - { - modelManager->AddModelReference(name, false, rank); - } - - SetPosition(0, pos); - SetAngleY(0, angle); - - if ( type == OBJECT_SHOW ) // remains in the air? - { - return true; - } - - radius = 1.5f; - height = 0.0f; - - if ( type == OBJECT_MARKSTONE || - type == OBJECT_MARKURANIUM || - type == OBJECT_MARKKEYa || - type == OBJECT_MARKKEYb || - type == OBJECT_MARKKEYc || - type == OBJECT_MARKKEYd || - type == OBJECT_MARKPOWER || - type == OBJECT_WAYPOINT ) - { - } - else if ( type == OBJECT_EGG ) - { - CreateCrashSphere(Math::Vector(-1.0f, 2.8f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 10.0f); - radius = 3.0f; - } - else if ( type == OBJECT_BOMB ) - { - CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 3.0f); - radius = 3.0f; - } - else if ( type == OBJECT_BAG ) - { - CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f); - SetZoom(0, 1.5f); - radius = 5.0f; - height = -1.4f; - } - else - { - CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.5f); - } - CreateShadowCircle(radius, 1.0f); - - SetFloorHeight(0.0f); - CreateOtherObject(type); - m_engine->LoadAllTextures(); - FloorAdjust(); - - pos = GetPosition(0); - pos.y += height; - SetPosition(0, pos); // to display the shadows immediately - - return true; -} - -// Creates a flag placed on the ground. - -bool CObject::CreateFlag(Math::Vector pos, float angle, ObjectType type) -{ - int rank, i; - - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - - SetType(type); - - std::string name; - - name = ""; - if ( type == OBJECT_FLAGb ) name = "flag1b.mod"; - if ( type == OBJECT_FLAGr ) name = "flag1r.mod"; - if ( type == OBJECT_FLAGg ) name = "flag1g.mod"; - if ( type == OBJECT_FLAGy ) name = "flag1y.mod"; - if ( type == OBJECT_FLAGv ) name = "flag1v.mod"; - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object - SetObjectRank(0, rank); - modelManager->AddModelReference(name, false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - name = ""; - if ( type == OBJECT_FLAGb ) name = "flag2b.mod"; - if ( type == OBJECT_FLAGr ) name = "flag2r.mod"; - if ( type == OBJECT_FLAGg ) name = "flag2g.mod"; - if ( type == OBJECT_FLAGy ) name = "flag2y.mod"; - if ( type == OBJECT_FLAGv ) name = "flag2v.mod"; - - for ( i=0 ; i<4 ; i++ ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1+i, rank); - SetObjectParent(1+i, i); - modelManager->AddModelReference(name, false, rank); - if ( i == 0 ) SetPosition(1+i, Math::Vector(0.15f, 5.0f, 0.0f)); - else SetPosition(1+i, Math::Vector(0.79f, 0.0f, 0.0f)); - } - - SetJotlerSphere(Math::Vector(0.0f, 4.0f, 0.0f), 1.0f); - CreateShadowCircle(2.0f, 0.3f); - - SetFloorHeight(0.0f); - CreateOtherObject(type); - m_engine->LoadAllTextures(); - FloorAdjust(); - - pos = GetPosition(0); - SetPosition(0, pos); // to display the shadows immediately - - return true; -} - -// Creates a barrier placed on the ground. - -bool CObject::CreateBarrier(Math::Vector pos, float angle, float height, - ObjectType type) -{ - int rank; - - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - - SetType(type); - - if ( type == OBJECT_BARRIER0 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("barrier0.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector( 3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - - CreateShadowCircle(6.0f, 0.5f, Gfx::ENG_SHADOW_WORM); - } - - if ( type == OBJECT_BARRIER1 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("barrier1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector( 8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - - CreateShadowCircle(12.0f, 0.5f, Gfx::ENG_SHADOW_WORM); - } - - if ( type == OBJECT_BARRIER2 ) // cardboard? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("barrier2.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector( 8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - - CreateShadowCircle(12.0f, 0.8f, Gfx::ENG_SHADOW_WORM); - } - - if ( type == OBJECT_BARRIER3 ) // match + straw? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("barrier3.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector( 8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); - - CreateShadowCircle(10.0f, 0.5f, Gfx::ENG_SHADOW_WORM); - } - - pos = GetPosition(0); - SetPosition(0, pos); // to display the shadows immediately - - SetFloorHeight(0.0f); - CreateOtherObject(type); - FloorAdjust(); - - pos = GetPosition(0); - pos.y += height; - SetPosition(0, pos); - - return true; -} - -// Creates a plant placed on the ground. - -bool CObject::CreatePlant(Math::Vector pos, float angle, float height, - ObjectType type) -{ - int rank; - - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - - SetType(type); - - if ( type == OBJECT_PLANT0 || - type == OBJECT_PLANT1 || - type == OBJECT_PLANT2 || - type == OBJECT_PLANT3 || - type == OBJECT_PLANT4 ) // standard? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - if ( type == OBJECT_PLANT0 ) modelManager->AddModelReference("plant0.mod", false, rank); - if ( type == OBJECT_PLANT1 ) modelManager->AddModelReference("plant1.mod", false, rank); - if ( type == OBJECT_PLANT2 ) modelManager->AddModelReference("plant2.mod", false, rank); - if ( type == OBJECT_PLANT3 ) modelManager->AddModelReference("plant3.mod", false, rank); - if ( type == OBJECT_PLANT4 ) modelManager->AddModelReference("plant4.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - height -= 2.0f; - - CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); - SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f); - SetJotlerSphere(Math::Vector(0.0f, 0.0f, 0.0f), 8.0f); - - CreateShadowCircle(8.0f, 0.5f); - } - - if ( type == OBJECT_PLANT5 || - type == OBJECT_PLANT6 || - type == OBJECT_PLANT7 ) // clover? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - if ( type == OBJECT_PLANT5 ) modelManager->AddModelReference("plant5.mod", false, rank); - if ( type == OBJECT_PLANT6 ) modelManager->AddModelReference("plant6.mod", false, rank); - if ( type == OBJECT_PLANT7 ) modelManager->AddModelReference("plant7.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - -//? CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 3.0f, SOUND_BOUM, 0.10f); - SetJotlerSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f); - - CreateShadowCircle(5.0f, 0.3f); - } - - if ( type == OBJECT_PLANT8 || - type == OBJECT_PLANT9 ) // squash? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - if ( type == OBJECT_PLANT8 ) modelManager->AddModelReference("plant8.mod", false, rank); - if ( type == OBJECT_PLANT9 ) modelManager->AddModelReference("plant9.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); - CreateCrashSphere(Math::Vector(0.0f, 10.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); - - CreateShadowCircle(10.0f, 0.5f); - } - - if ( type == OBJECT_PLANT10 || - type == OBJECT_PLANT11 || - type == OBJECT_PLANT12 || - type == OBJECT_PLANT13 || - type == OBJECT_PLANT14 ) // succulent? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - if ( type == OBJECT_PLANT10 ) modelManager->AddModelReference("plant10.mod", false, rank); - if ( type == OBJECT_PLANT11 ) modelManager->AddModelReference("plant11.mod", false, rank); - if ( type == OBJECT_PLANT12 ) modelManager->AddModelReference("plant12.mod", false, rank); - if ( type == OBJECT_PLANT13 ) modelManager->AddModelReference("plant13.mod", false, rank); - if ( type == OBJECT_PLANT14 ) modelManager->AddModelReference("plant14.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector(0.0f, 12.0f, 0.0f), 5.0f, SOUND_BOUM, 0.10f); - SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 6.0f); - SetJotlerSphere(Math::Vector(0.0f, 4.0f, 0.0f), 8.0f); - - CreateShadowCircle(8.0f, 0.3f); - } - - if ( type == OBJECT_PLANT15 || - type == OBJECT_PLANT16 || - type == OBJECT_PLANT17 || - type == OBJECT_PLANT18 || - type == OBJECT_PLANT19 ) // fern? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - if ( type == OBJECT_PLANT15 ) modelManager->AddModelReference("plant15.mod", false, rank); - if ( type == OBJECT_PLANT16 ) modelManager->AddModelReference("plant16.mod", false, rank); - if ( type == OBJECT_PLANT17 ) modelManager->AddModelReference("plant17.mod", false, rank); - if ( type == OBJECT_PLANT18 ) modelManager->AddModelReference("plant18.mod", false, rank); - if ( type == OBJECT_PLANT19 ) modelManager->AddModelReference("plant19.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - if ( type != OBJECT_PLANT19 ) - { - CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); - SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f); - } - SetJotlerSphere(Math::Vector(0.0f, 0.0f, 0.0f), 8.0f); - - CreateShadowCircle(8.0f, 0.5f); - } - - if ( type == OBJECT_TREE0 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("tree0.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 2.0f), 3.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector(-1.0f, 10.0f, 1.0f), 2.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector( 0.0f, 17.0f, 0.0f), 2.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector( 1.0f, 27.0f, 0.0f), 2.0f, SOUND_BOUMs, 0.20f); - - CreateShadowCircle(8.0f, 0.5f); - } - - if ( type == OBJECT_TREE1 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("tree1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 2.0f), 3.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector(-2.0f, 11.0f, 1.0f), 2.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector(-2.0f, 19.0f, 2.0f), 2.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector( 2.0f, 26.0f, 0.0f), 2.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector( 2.0f, 34.0f,-2.0f), 2.0f, SOUND_BOUMs, 0.20f); - - CreateShadowCircle(8.0f, 0.5f); - } - - if ( type == OBJECT_TREE2 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("tree2.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 1.0f), 3.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector(-2.0f, 10.0f, 1.0f), 2.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector(-2.0f, 19.0f, 2.0f), 2.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector( 2.0f, 25.0f, 0.0f), 2.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector( 3.0f, 32.0f,-2.0f), 2.0f, SOUND_BOUMs, 0.20f); - - CreateShadowCircle(8.0f, 0.5f); - } - - if ( type == OBJECT_TREE3 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("tree3.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector(-2.0f, 3.0f, 2.0f), 3.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector(-3.0f, 9.0f, 1.0f), 2.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector( 0.0f, 18.0f, 0.0f), 2.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector( 0.0f, 27.0f, 7.0f), 2.0f, SOUND_BOUMs, 0.20f); - - CreateShadowCircle(8.0f, 0.5f); - } - - if ( type == OBJECT_TREE4 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("tree4.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector(0.0f, 10.0f, 0.0f), 10.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector(0.0f, 21.0f, 0.0f), 8.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector(0.0f, 32.0f, 0.0f), 7.0f, SOUND_BOUMs, 0.20f); - - CreateShadowCircle(8.0f, 0.5f); - } - - if ( type == OBJECT_TREE5 ) // giant tree (for the world "teen") - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("tree5.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector( 0.0f, 5.0f,-10.0f), 25.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector(-65.0f, 5.0f, 65.0f), 20.0f, SOUND_BOUMs, 0.20f); - CreateCrashSphere(Math::Vector( 38.0f, 5.0f, 21.0f), 18.0f, SOUND_BOUMs, 0.20f); - - CreateShadowCircle(50.0f, 0.5f); - } - - pos = GetPosition(0); - SetPosition(0, pos); // to display the shadows immediately - - SetFloorHeight(0.0f); - CreateOtherObject(type); - - pos = GetPosition(0); - pos.y += height; - SetPosition(0, pos); - - return true; -} - -// Creates a mushroom placed on the ground. - -bool CObject::CreateMushroom(Math::Vector pos, float angle, float height, - ObjectType type) -{ - int rank; - - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - - SetType(type); - - if ( type == OBJECT_MUSHROOM1 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("mush1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector(0.0f, 4.0f, 0.0f), 3.0f, SOUND_BOUM, 0.10f); - SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 5.5f); - SetJotlerSphere(Math::Vector(0.0f, 3.0f, 0.0f), 5.5f); - - CreateShadowCircle(6.0f, 0.5f); - } - - if ( type == OBJECT_MUSHROOM2 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("mush2.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector(0.0f, 5.0f, 0.0f), 3.0f, SOUND_BOUM, 0.10f); - SetGlobalSphere(Math::Vector(0.0f, 4.0f, 0.0f), 5.5f); - SetJotlerSphere(Math::Vector(0.0f, 4.0f, 0.0f), 5.5f); - - CreateShadowCircle(5.0f, 0.5f); - } - - pos = GetPosition(0); - SetPosition(0, pos); // to display the shadows immediately - - SetFloorHeight(0.0f); - CreateOtherObject(type); - - pos = GetPosition(0); - pos.y += height; - SetPosition(0, pos); - - return true; -} - -// Creates a toy placed on the ground. - -bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height, - ObjectType type) -{ - Math::Matrix* mat; - Gfx::Color color; - int rank; - float fShadow; - bool bFloorAdjust = true; - - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - - SetType(type); - - fShadow = Math::Norm(1.0f-height/10.0f); - - if ( type == OBJECT_TEEN0 ) // orange pencil lg=10 - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen0.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector( 5.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 2.5f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-2.5f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-5.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - - CreateShadowCircle(5.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM); - } - - if ( type == OBJECT_TEEN1 ) // blue pencil lg=14 - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector( 6.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 4.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 2.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-2.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-4.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-6.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - - CreateShadowCircle(6.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM); - } - - if ( type == OBJECT_TEEN2 ) // red pencil lg=16 - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen2.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector( 7.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 4.7f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 2.3f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-2.3f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-4.7f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-7.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - - CreateShadowCircle(6.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM); - } - - if ( type == OBJECT_TEEN3 ) // jar with pencils - { - rank = m_engine->CreateObject(); -//? m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_METAL); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen3.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 4.0f, 0.0f), 4.0f); - CreateShadowCircle(6.0f, 0.5f*fShadow); - } - - if ( type == OBJECT_TEEN4 ) // scissors - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen4.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-9.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-6.0f, 1.0f, 0.0f), 1.1f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-3.0f, 1.0f, 0.0f), 1.2f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 1.0f, 0.0f), 1.3f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 5.1f, 1.0f,-1.3f), 2.6f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 8.0f, 1.0f, 2.2f), 2.3f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 9.4f, 1.0f,-2.0f), 2.0f, SOUND_BOUMm, 0.45f); - - CreateShadowCircle(10.0f, 0.5f*fShadow, Gfx::ENG_SHADOW_WORM); - } - - if ( type == OBJECT_TEEN5 ) // CD - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen5.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - SetFloorHeight(0.0f); - bFloorAdjust = false; - - m_terrain->AddBuildingLevel(pos, 5.9f, 6.1f, 0.2f, 0.5f); - CreateShadowCircle(8.0f, 0.2f*fShadow); - } - - if ( type == OBJECT_TEEN6 ) // book 1 - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen6.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-5.0f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 4.5f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); - - CreateShadowCircle(20.0f, 0.2f*fShadow); - } - - if ( type == OBJECT_TEEN7 ) // book 2 - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen7.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-5.0f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 4.5f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); - - CreateShadowCircle(20.0f, 0.2f*fShadow); - } - - if ( type == OBJECT_TEEN8 ) // a stack of books 1 - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen8.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-5.0f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 4.5f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); - - SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 12.0f); - CreateShadowCircle(20.0f, 0.2f*fShadow); - } - - if ( type == OBJECT_TEEN9 ) // a stack of books 2 - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen9.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-5.0f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 4.5f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); - - SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 12.0f); - CreateShadowCircle(20.0f, 0.2f*fShadow); - } - - if ( type == OBJECT_TEEN10 ) // bookcase - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen10.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-26.0f, 3.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-15.0f, 3.0f,-4.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-15.0f, 3.0f, 5.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -4.0f, 3.0f,-4.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -4.0f, 3.0f, 5.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 6.0f, 3.0f,-4.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 6.0f, 3.0f, 4.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 14.0f, 3.0f,-3.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 14.0f, 3.0f, 2.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 24.0f, 3.0f, 5.0f), 6.0f, SOUND_BOUMm, 0.45f); - - SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 20.0f); - CreateShadowCircle(40.0f, 0.2f*fShadow); - } - - if ( type == OBJECT_TEEN11 ) // lamp - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen11.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - SetZoom(0, zoom); - - mat = GetWorldMatrix(0); - pos = Math::Transform(*mat, Math::Vector(-56.0f, 22.0f, 0.0f)); - m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), Math::Point(20.0f, 20.0f), Gfx::PARTISELY, 1.0f, 0.0f, 0.0f); - - pos = Math::Transform(*mat, Math::Vector(-65.0f, 40.0f, 0.0f)); - color.r = 4.0f; - color.g = 2.0f; - color.b = 0.0f; // yellow-orange - color.a = 0.0f; - m_main->CreateSpot(pos, color); - } - - if ( type == OBJECT_TEEN12 ) // coke - { - rank = m_engine->CreateObject(); -//? m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_METAL); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen12.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 9.0f, 0.0f), 5.0f); - CreateShadowCircle(4.5f, 1.0f*fShadow); - } - - if ( type == OBJECT_TEEN13 ) // cardboard farm - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen13.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-10.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 10.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 10.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 10.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); - - SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 15.0f); - CreateShadowCircle(20.0f, 1.0f*fShadow); - } - - if ( type == OBJECT_TEEN14 ) // open box - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen14.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-10.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 10.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 10.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 10.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); - - SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 15.0f); - CreateShadowCircle(20.0f, 1.0f*fShadow); - } - - if ( type == OBJECT_TEEN15 ) // stack of cartons - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen15.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-10.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 10.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 10.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 10.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); - - SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 15.0f); - CreateShadowCircle(20.0f, 1.0f*fShadow); - } - - if ( type == OBJECT_TEEN16 ) // watering can - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen16.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-8.0f, 4.0f, 0.0f), 12.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 8.0f, 4.0f, 0.0f), 12.0f, SOUND_BOUMm, 0.45f); - - SetGlobalSphere(Math::Vector(0.0f, 13.0f, 0.0f), 20.0f); - CreateShadowCircle(18.0f, 1.0f*fShadow); - } - - if ( type == OBJECT_TEEN17 ) // wheel | - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen17.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector( 0.0f, 31.0f, 0.0f), 31.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 31.0f, 0.0f), 31.0f); - CreateShadowCircle(24.0f, 0.5f*fShadow); - } - - if ( type == OBJECT_TEEN18 ) // wheel / - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen18.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector( 0.0f, 31.0f, 0.0f), 31.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 31.0f, 0.0f), 31.0f); - CreateShadowCircle(24.0f, 0.5f*fShadow); - } - - if ( type == OBJECT_TEEN19 ) // wheel = - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen19.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector( 0.0f, 10.0f, 0.0f), 32.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 32.0f); - CreateShadowCircle(33.0f, 1.0f*fShadow); - } - - if ( type == OBJECT_TEEN20 ) // wall with shelf - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen20.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-175.0f, 0.0f, -5.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-175.0f, 0.0f, -35.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -55.0f, 0.0f, -5.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -55.0f, 0.0f, -35.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -37.0f, 0.0f, -5.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -37.0f, 0.0f, -35.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 83.0f, 0.0f, -5.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 83.0f, 0.0f, -35.0f), 4.0f, SOUND_BOUMm, 0.45f); - } - - if ( type == OBJECT_TEEN21 ) // wall with window - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen21.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - } - - if ( type == OBJECT_TEEN22 ) // wall with door and shelf - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen22.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-135.0f, 0.0f, -5.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-135.0f, 0.0f, -35.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -15.0f, 0.0f, -5.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -15.0f, 0.0f, -35.0f), 4.0f, SOUND_BOUMm, 0.45f); - } - - if ( type == OBJECT_TEEN23 ) // skateboard on wheels - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen23.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - if ( m_option == 1 ) // passage under the prohibited skateboard? - { - CreateCrashSphere(Math::Vector(-10.0f, 2.0f, 0.0f), 11.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 10.0f, 2.0f, 0.0f), 11.0f, SOUND_BOUMm, 0.45f); - } - - CreateCrashSphere(Math::Vector(-23.0f, 2.0f, 7.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-23.0f, 2.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-23.0f, 2.0f,-7.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 23.0f, 2.0f, 7.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 23.0f, 2.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 23.0f, 2.0f,-7.0f), 3.0f, SOUND_BOUMm, 0.45f); - - CreateShadowCircle(35.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM); - } - - if ( type == OBJECT_TEEN24 ) // skate / - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen24.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-12.0f, 0.0f, -3.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-12.0f, 0.0f, 3.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateShadowCircle(20.0f, 0.2f*fShadow); - } - - if ( type == OBJECT_TEEN25 ) // skate / - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen25.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-12.0f, 0.0f, -3.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-12.0f, 0.0f, 3.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateShadowCircle(20.0f, 0.2f*fShadow); - } - - if ( type == OBJECT_TEEN26 ) // ceiling lamp - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen26.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - SetFloorHeight(0.0f); - - mat = GetWorldMatrix(0); - pos = Math::Transform(*mat, Math::Vector(0.0f, 50.0f, 0.0f)); - m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), Math::Point(100.0f, 100.0f), Gfx::PARTISELY, 1.0f, 0.0f, 0.0f); - - pos = Math::Transform(*mat, Math::Vector(0.0f, 50.0f, 0.0f)); - color.r = 4.0f; - color.g = 2.0f; - color.b = 0.0f; // yellow-orange - color.a = 0.0f; - m_main->CreateSpot(pos, color); - } - - if ( type == OBJECT_TEEN27 ) // large plant? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen27.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); - CreateShadowCircle(40.0f, 0.5f); - } - - if ( type == OBJECT_TEEN28 ) // bottle? - { - rank = m_engine->CreateObject(); -//? m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_METAL); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen28.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 5.0f, SOUND_BOUM, 0.10f); - CreateShadowCircle(7.0f, 0.6f*fShadow); - } - - if ( type == OBJECT_TEEN29 ) // bridge? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen29.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - bFloorAdjust = false; - } - - if ( type == OBJECT_TEEN30 ) // jump? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen30.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(0.0f, 4.0f, 0.0f), 15.0f, SOUND_BOUM, 0.10f); - SetGlobalSphere(Math::Vector(0.0f, 15.0f, 0.0f), 17.0f); - CreateShadowCircle(20.0f, 1.0f*fShadow); - } - - if ( type == OBJECT_TEEN31 ) // basket? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen31.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-10.0f, 2.0f, 0.0f), 5.0f, SOUND_BOUM, 0.10f); - CreateCrashSphere(Math::Vector( 0.0f, 2.0f, 0.0f), 6.0f, SOUND_BOUM, 0.10f); - CreateCrashSphere(Math::Vector( 9.0f, 4.0f, 1.0f), 6.0f, SOUND_BOUM, 0.10f); - - SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 10.0f); - CreateShadowCircle(16.0f, 0.6f*fShadow); - } - - if ( type == OBJECT_TEEN32 ) // chair? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen32.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector( 17.5f, 1.0f, 17.5f), 3.5f, SOUND_BOUM, 0.10f); - CreateCrashSphere(Math::Vector( 17.5f, 1.0f, -17.5f), 3.5f, SOUND_BOUM, 0.10f); - CreateCrashSphere(Math::Vector(-17.5f, 1.0f, 17.5f), 3.5f, SOUND_BOUM, 0.10f); - CreateCrashSphere(Math::Vector(-17.5f, 1.0f, -17.5f), 3.5f, SOUND_BOUM, 0.10f); - SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 26.0f); - CreateShadowCircle(35.0f, 0.3f*fShadow); - } - - if ( type == OBJECT_TEEN33 ) // panel? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen33.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); - CreateShadowCircle(10.0f, 0.3f*fShadow); - } - - if ( type == OBJECT_TEEN34 ) // stone? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen34.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); - CreateShadowCircle(3.0f, 1.0f*fShadow); - } - - if ( type == OBJECT_TEEN35 ) // pipe? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen35.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(-40.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f); - CreateCrashSphere(Math::Vector(-20.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f); - CreateCrashSphere(Math::Vector( 0.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f); - CreateCrashSphere(Math::Vector( 20.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f); - CreateCrashSphere(Math::Vector( 40.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f); - CreateShadowCircle(40.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM); - } - - if ( type == OBJECT_TEEN36 ) // trunk? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen36.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - bFloorAdjust = false; - } - - if ( type == OBJECT_TEEN37 ) // boat? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen37.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - bFloorAdjust = false; - } - - if ( type == OBJECT_TEEN38 ) // fan? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen38a.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("teen38b.mod", false, rank); // engine - SetPosition(1, Math::Vector(0.0f, 30.0f, 0.0f)); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(2, rank); - SetObjectParent(2, 1); - modelManager->AddModelReference("teen38c.mod", false, rank); // propeller - SetPosition(2, Math::Vector(0.0f, 0.0f, 0.0f)); - - CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f); - SetGlobalSphere(Math::Vector(0.0f, 2.0f, 0.0f), 10.0f); - CreateShadowCircle(15.0f, 0.5f*fShadow); - } - - if ( type == OBJECT_TEEN39 ) // potted plant? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen39.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 8.5f, SOUND_BOUM, 0.10f); - SetGlobalSphere(Math::Vector(0.0f, 2.0f, 0.0f), 8.5f); - CreateShadowCircle(10.0f, 1.0f*fShadow); - } - - if ( type == OBJECT_TEEN40 ) // balloon? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen40.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(0.0f, 5.0f, 0.0f), 11.0f, SOUND_BOUM, 0.10f); - SetGlobalSphere(Math::Vector(0.0f, 14.0f, 0.0f), 15.0f); - CreateShadowCircle(15.0f, 0.7f*fShadow); - } - - if ( type == OBJECT_TEEN41 ) // fence? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen41.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - } - - if ( type == OBJECT_TEEN42 ) // clover? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen42.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 2.0f, SOUND_BOUM, 0.10f); - CreateShadowCircle(15.0f, 0.4f*fShadow); - } - - if ( type == OBJECT_TEEN43 ) // clover? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen43.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 2.0f, SOUND_BOUM, 0.10f); - CreateShadowCircle(15.0f, 0.4f*fShadow); - } - - if ( type == OBJECT_TEEN44 ) // car? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("teen44.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, zoom); - - CreateCrashSphere(Math::Vector(0.0f, 10.0f, 0.0f), 55.0f, SOUND_BOUM, 0.10f); - SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 55.0f); - CreateShadowCircle(55.0f, 1.0f*fShadow); - } - - pos = GetPosition(0); - SetPosition(0, pos); // to display the shadows immediately - - if ( bFloorAdjust ) - { - SetFloorHeight(0.0f); - FloorAdjust(); - } - - CreateOtherObject(type); - - pos = GetPosition(0); - pos.y += height; - SetPosition(0, pos); - - return true; -} - -// Creates a crystal placed on the ground. - -bool CObject::CreateQuartz(Math::Vector pos, float angle, float height, - ObjectType type) -{ - float radius; - int rank; - - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - - SetType(type); - - if ( type == OBJECT_QUARTZ0 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ); - SetObjectRank(0, rank); - modelManager->AddModelReference("quartz0.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 3.5f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 2.0f, 0.0f), 3.5f); - - CreateShadowCircle(4.0f, 0.5f); - } - if ( type == OBJECT_QUARTZ1 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ); - SetObjectRank(0, rank); - modelManager->AddModelReference("quartz1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector(0.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 4.0f, 0.0f), 5.0f); - - CreateShadowCircle(5.0f, 0.5f); - } - if ( type == OBJECT_QUARTZ2 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ); - SetObjectRank(0, rank); - modelManager->AddModelReference("quartz2.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector(0.0f, 6.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 6.0f); - - CreateShadowCircle(6.0f, 0.5f); - } - if ( type == OBJECT_QUARTZ3 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ); - SetObjectRank(0, rank); - modelManager->AddModelReference("quartz3.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - - CreateCrashSphere(Math::Vector(0.0f, 10.0f, 0.0f), 10.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 10.0f); - - CreateShadowCircle(10.0f, 0.5f); - } - - pos = GetPosition(0); - SetPosition(0, pos); // to display the shadows immediately - - SetFloorHeight(0.0f); - CreateOtherObject(type); - - pos = GetPosition(0); - pos.y += height; - SetPosition(0, pos); - - if ( type == OBJECT_QUARTZ0 ) - { - pos.y += 4.0f; - radius = 2.0f; - } - if ( type == OBJECT_QUARTZ1 ) - { - pos.y += 6.0f; - radius = 4.0f; - } - if ( type == OBJECT_QUARTZ2 ) - { - pos.y += 10.0f; - radius = 5.0f; - } - if ( type == OBJECT_QUARTZ3 ) - { - pos.y += 16.0f; - radius = 8.0f; - } - m_particle->CreateParticle(pos, pos, Math::Point(2.0f, 2.0f), Gfx::PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f); - m_particle->CreateParticle(pos, pos, Math::Point(2.0f, 2.0f), Gfx::PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f); - - return true; -} - -// Creates a root placed on the ground. - -bool CObject::CreateRoot(Math::Vector pos, float angle, float height, - ObjectType type) -{ - int rank; - - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - - SetType(type); - - if ( type == OBJECT_ROOT0 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("root0.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, 2.0f); - - CreateCrashSphere(Math::Vector(-5.0f, 1.0f, 0.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 4.0f, 1.0f, 2.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 4.0f, 1.0f, -3.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 2.0f, 5.0f, -1.0f), 1.5f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector(-4.0f, 5.0f, -1.0f), 1.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector(-2.0f, 8.0f, -0.5f), 1.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 0.0f, 10.0f, -0.5f), 1.0f, SOUND_BOUMv, 0.15f); -//? SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 11.0f); - - CreateShadowCircle(16.0f, 0.5f); - } - if ( type == OBJECT_ROOT1 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("root1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, 2.0f); - - CreateCrashSphere(Math::Vector(-4.0f, 1.0f, 1.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 0.0f, 1.0f, 2.0f), 1.5f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 3.0f, 1.0f, -2.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector(-2.0f, 5.0f, 1.0f), 1.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 2.0f, 5.0f, 0.0f), 1.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 0.0f, 8.0f, 1.0f), 1.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 0.0f, 12.0f, 1.0f), 1.0f, SOUND_BOUMv, 0.15f); -//? SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 12.0f); - - CreateShadowCircle(16.0f, 0.5f); - } - if ( type == OBJECT_ROOT2 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("root2.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, 2.0f); - - CreateCrashSphere(Math::Vector(-3.0f, 1.0f, 0.5f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 3.0f, 1.0f, -1.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector(-1.0f, 4.5f, 0.0f), 1.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 3.0f, 7.0f, 1.0f), 1.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 0.0f, 7.0f, -1.0f), 1.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 4.0f, 11.0f, 1.0f), 1.0f, SOUND_BOUMv, 0.15f); -//? SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 10.0f); - - CreateShadowCircle(16.0f, 0.5f); - } - if ( type == OBJECT_ROOT3 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("root3.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, 2.0f); - - CreateCrashSphere(Math::Vector(-4.0f, 1.0f, 1.0f), 3.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 4.0f, 1.0f, -3.0f), 3.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 6.0f, 1.0f, 4.0f), 3.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector(-2.5f, 7.0f, 2.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 4.0f, 7.0f, 2.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 3.0f, 6.0f, -1.0f), 1.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 0.0f, 12.0f, 0.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 1.0f, 16.0f, 0.0f), 1.0f, SOUND_BOUMv, 0.15f); -//? SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 14.0f); - - CreateShadowCircle(22.0f, 0.5f); - } - if ( type == OBJECT_ROOT4 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("root4.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, 2.0f); - - CreateCrashSphere(Math::Vector( -7.0f, 2.0f, 3.0f), 4.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 5.0f, 2.0f, -6.0f), 4.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 6.0f, 2.0f, 6.0f), 3.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector(-11.0f, 1.0f, -2.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 1.0f, 1.0f, -7.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( -4.0f, 10.0f, 3.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 1.0f, 11.0f, 7.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 3.0f, 11.0f, -3.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( -3.0f, 17.0f, 1.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( -3.0f, 23.0f, -1.0f), 2.0f, SOUND_BOUMv, 0.15f); -//? SetGlobalSphere(Math::Vector(0.0f, 12.0f, 0.0f), 20.0f); - - CreateShadowCircle(30.0f, 0.5f); - } - if ( type == OBJECT_ROOT5 ) // gravity root ? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("root4.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, 2.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("root5.mod", false, rank); - SetPosition(1, Math::Vector(-5.0f, 28.0f, -4.0f)); - SetAngleX(1, -30.0f*Math::PI/180.0f); - SetAngleZ(1, 20.0f*Math::PI/180.0f); - - CreateCrashSphere(Math::Vector( -7.0f, 2.0f, 3.0f), 4.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 5.0f, 2.0f, -6.0f), 4.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 6.0f, 2.0f, 6.0f), 3.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector(-11.0f, 1.0f, -2.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 1.0f, 1.0f, -7.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( -4.0f, 10.0f, 3.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 1.0f, 11.0f, 7.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( 3.0f, 11.0f, -3.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( -3.0f, 17.0f, 1.0f), 2.0f, SOUND_BOUMv, 0.15f); - CreateCrashSphere(Math::Vector( -3.0f, 23.0f, -1.0f), 2.0f, SOUND_BOUMv, 0.15f); -//? SetGlobalSphere(Math::Vector(0.0f, 12.0f, 0.0f), 20.0f); - - CreateShadowCircle(30.0f, 0.5f); - } - - pos = GetPosition(0); - SetPosition(0, pos); // to display the shadows immediately - - SetFloorHeight(0.0f); - CreateOtherObject(type); - - pos = GetPosition(0); - pos.y += height; - SetPosition(0, pos); - - return true; -} - -// Creates a small home. - -bool CObject::CreateHome(Math::Vector pos, float angle, float height, - ObjectType type) -{ - int rank; - - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - - SetType(type); - - if ( type == OBJECT_HOME1 ) - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); - SetObjectRank(0, rank); - modelManager->AddModelReference("home1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, 1.3f); - - CreateCrashSphere(Math::Vector(0.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUMs, 0.25f); -//? SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 11.0f); - CreateShadowCircle(16.0f, 0.5f); - } - - pos = GetPosition(0); - SetPosition(0, pos); // to display the shadows immediately - - SetFloorHeight(0.0f); - CreateOtherObject(type); - - pos = GetPosition(0); - pos.y += height; - SetPosition(0, pos); - - return true; -} - -// Creates ruin placed on the ground. - -bool CObject::CreateRuin(Math::Vector pos, float angle, float height, - ObjectType type) -{ - int rank; - - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - - SetType(type); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object - SetObjectRank(0, rank); - - std::string name; - if ( type == OBJECT_RUINmobilew1 ) name = "ruin1.mod"; - if ( type == OBJECT_RUINmobilew2 ) name = "ruin1.mod"; - if ( type == OBJECT_RUINmobilet1 ) name = "ruin2.mod"; - if ( type == OBJECT_RUINmobilet2 ) name = "ruin2.mod"; - if ( type == OBJECT_RUINmobiler1 ) name = "ruin3.mod"; - if ( type == OBJECT_RUINmobiler2 ) name = "ruin3.mod"; - if ( type == OBJECT_RUINfactory ) name = "ruin4.mod"; - if ( type == OBJECT_RUINdoor ) name = "ruin5.mod"; - if ( type == OBJECT_RUINsupport ) name = "ruin6.mod"; - if ( type == OBJECT_RUINradar ) name = "ruin7.mod"; - if ( type == OBJECT_RUINconvert ) name = "ruin8.mod"; - if ( type == OBJECT_RUINbase ) name = "ruin9.mod"; - if ( type == OBJECT_RUINhead ) name = "ruin10.mod"; - - modelManager->AddModelReference(name, false, rank); - - SetPosition(0, pos); - SetAngleY(0, angle); - - if ( type == OBJECT_RUINmobilew1 ) // vehicle had wheels? - { - // Creates the right-back wheel. - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(6, rank); - SetObjectParent(6, 0); - - modelManager->AddModelReference("ruin1w.mod", false, rank); - - SetPosition(6, Math::Vector(-3.0f, 1.8f, -4.0f)); - SetAngleX(6, -Math::PI/2.0f); - - // Creates the left-back wheel. - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(7, rank); - SetObjectParent(7, 0); - - modelManager->AddModelReference("ruin1w.mod", false, rank); - - SetPosition(7, Math::Vector(-3.0f, 1.0f, 3.0f)); - SetAngleY(7, Math::PI-0.3f); - SetAngleX(7, -0.3f); - - // Creates the right-front wheel. - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(8, rank); - SetObjectParent(8, 0); - - modelManager->AddModelReference("ruin1w.mod", false, rank); - - SetPosition(8, Math::Vector(2.0f, 1.6f, -3.0f)); - SetAngleY(8, 0.3f); - - // Creates the left-front wheel. - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(9, rank); - SetObjectParent(9, 0); - - modelManager->AddModelReference("ruin1w.mod", false, rank); - - SetPosition(9, Math::Vector(2.0f, 1.0f, 3.0f)); - SetAngleY(9, Math::PI-0.2f); - SetAngleX(9, 0.2f); - - CreateCrashSphere(Math::Vector(0.0f, 2.8f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); -//? SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 10.0f); - - CreateShadowCircle(4.0f, 1.0f); - } - - if ( type == OBJECT_RUINmobilew2 ) // vehicle has wheels? - { - // Creates the left-back wheel. - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(7, rank); - SetObjectParent(7, 0); - - modelManager->AddModelReference("ruin1w.mod", false, rank); - - SetPosition(7, Math::Vector(-3.0f, 1.0f, 3.0f)); - SetAngleY(7, Math::PI+0.3f); - SetAngleX(7, 0.4f); - - // Creates the left-front wheel. - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(9, rank); - SetObjectParent(9, 0); - - modelManager->AddModelReference("ruin1w.mod", false, rank); - - SetPosition(9, Math::Vector(2.0f, 1.0f, 3.0f)); - SetAngleY(9, Math::PI+0.3f); - SetAngleX(9, -0.3f); - - CreateCrashSphere(Math::Vector(0.0f, 2.8f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); -//? SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 10.0f); - - CreateShadowCircle(4.0f, 1.0f); - } - - if ( type == OBJECT_RUINmobilet1 ) // vehicle have caterpillars? - { - // Creates the cannon. - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - - modelManager->AddModelReference("ruin2c.mod", false, rank); - - SetPosition(1, Math::Vector(3.0f, 5.0f, -2.5f)); - SetAngleX(1, -Math::PI*0.85f); - SetAngleY(1, -0.4f); - SetAngleZ(1, -0.1f); - - CreateCrashSphere(Math::Vector(1.0f, 2.8f, -1.0f), 5.0f, SOUND_BOUMm, 0.45f); -//? SetGlobalSphere(Math::Vector(1.0f, 5.0f, -1.0f), 10.0f); - - CreateShadowCircle(5.0f, 1.0f); - } - - if ( type == OBJECT_RUINmobilet2 ) // vehicle have caterpillars? - { - CreateCrashSphere(Math::Vector(0.0f, 2.8f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); -//? SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 10.0f); - - CreateShadowCircle(5.0f, 1.0f); - } - - if ( type == OBJECT_RUINmobiler1 ) // vehicle skating? - { - CreateCrashSphere(Math::Vector(1.0f, 2.8f, -1.0f), 5.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(1.0f, 5.0f, -1.0f), 10.0f); - - CreateShadowCircle(5.0f, 1.0f); - } - - if ( type == OBJECT_RUINmobiler2 ) // vehicle skating? - { - CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 10.0f); - - CreateShadowCircle(6.0f, 1.0f); - } - - if ( type == OBJECT_RUINfactory ) // factory ? - { - CreateCrashSphere(Math::Vector( 9.0f, 1.0f, -11.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 2.0f, -11.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 4.0f, -10.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-12.0f, 11.0f, -4.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 4.0f, -2.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-11.0f, 8.0f, 3.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-11.0f, 2.0f, 4.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-11.0f, 2.0f, 10.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -4.0f, 0.0f, 10.0f), 3.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 18.0f); - - CreateShadowCircle(20.0f, 0.7f); - } - - if ( type == OBJECT_RUINdoor ) // converter holder? - { - CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); -//? SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 6.0f); - - CreateShadowCircle(6.0f, 1.0f); - } - - if ( type == OBJECT_RUINsupport ) // radar holder? - { - CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); -//? SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f); - - CreateShadowCircle(3.0f, 1.0f); - } - - if ( type == OBJECT_RUINradar ) // radar base? - { - CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); -//? SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 6.0f); - - CreateShadowCircle(6.0f, 1.0f); - } - - if ( type == OBJECT_RUINconvert ) // converter? - { - m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f); - - CreateCrashSphere(Math::Vector(-10.0f, 0.0f, 4.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-10.0f, 0.0f, -4.0f), 5.0f, SOUND_BOUMm, 0.45f); -//? SetGlobalSphere(Math::Vector(-3.0f, 0.0f, 0.0f), 14.0f); - } - - if ( type == OBJECT_RUINbase ) // base? - { - CreateCrashSphere(Math::Vector( 0.0f, 15.0f, 0.0f),28.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 17.0f, 6.0f, 42.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 17.0f, 17.0f, 42.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-17.0f, 6.0f, 42.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-17.0f, 17.0f, 42.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-42.0f, 6.0f, 17.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-42.0f, 17.0f, 17.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-42.0f, 6.0f, -17.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-42.0f, 17.0f, -17.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-17.0f, 6.0f, -42.0f), 6.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-17.0f, 10.0f, -42.0f), 4.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 15.0f, 13.0f, -34.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 31.0f, 15.0f, -13.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 21.0f, 8.0f, -39.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 26.0f, 8.0f, -33.0f), 5.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 48.0f); - - CreateShadowCircle(40.0f, 1.0f); - } - - if ( type == OBJECT_RUINhead ) // base cap? - { - CreateCrashSphere(Math::Vector( 0.0f, 13.0f, 0.0f),20.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, -8.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f,-16.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f,-22.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-21.0f, 7.0f, 9.0f), 8.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -9.0f, 7.0f, 21.0f), 8.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 21.0f, 7.0f, 9.0f), 8.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 9.0f, 7.0f, 21.0f), 8.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-21.0f, 7.0f, -9.0f), 8.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( -9.0f, 7.0f, -21.0f), 8.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 21.0f, 7.0f, -9.0f), 8.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 9.0f, 7.0f, -21.0f), 8.0f, SOUND_BOUMm, 0.45f); - SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 35.0f); - - CreateShadowCircle(30.0f, 1.0f); - } - - pos = GetPosition(0); - SetPosition(0, pos); //to display the shadows immediately - - SetFloorHeight(0.0f); - CreateOtherObject(type); - - if ( type != OBJECT_RUINfactory && - type != OBJECT_RUINconvert && - type != OBJECT_RUINbase ) - { - FloorAdjust(); - } - - pos = GetPosition(0); - pos.y += height; - SetPosition(0, pos); //to display the shadows immediately - - if ( type == OBJECT_RUINmobilew1 ) - { - pos = GetPosition(0); - pos.y -= 0.5f; - SetPosition(0, pos); - - angle = GetAngleX(0)-0.1f; - SetAngleX(0, angle); - } - - if ( type == OBJECT_RUINmobilew2 ) - { - pos = GetPosition(0); - pos.y -= 1.5f; - SetPosition(0, pos); - - angle = GetAngleX(0)-0.9f; - SetAngleX(0, angle); - - angle = GetAngleZ(0)-0.1f; - SetAngleZ(0, angle); - } - - if ( type == OBJECT_RUINmobilet1 ) - { - pos = GetPosition(0); - pos.y -= 0.9f; - SetPosition(0, pos); - - angle = GetAngleX(0)-0.3f; - SetAngleX(0, angle); - } - - if ( type == OBJECT_RUINmobilet2 ) - { - pos = GetPosition(0); - pos.y -= 1.5f; - SetPosition(0, pos); - - angle = GetAngleX(0)-0.3f; - SetAngleX(0, angle); - - angle = GetAngleZ(0)+0.8f; - SetAngleZ(0, angle); - } - - if ( type == OBJECT_RUINmobiler1 ) - { - pos = GetPosition(0); - pos.y += 4.0f; - SetPosition(0, pos); - - angle = GetAngleX(0)-Math::PI*0.6f; - SetAngleX(0, angle); - - angle = GetAngleZ(0)-0.2f; - SetAngleZ(0, angle); - } - - if ( type == OBJECT_RUINmobiler2 ) - { - pos = GetPosition(0); - pos.y += 2.0f; - SetPosition(0, pos); - - angle = GetAngleX(0)-0.1f; - SetAngleX(0, angle); - - angle = GetAngleZ(0)-0.3f; - SetAngleZ(0, angle); - } - - if ( type == OBJECT_RUINdoor ) - { - pos = GetPosition(0); - pos.y -= 0.5f; - SetPosition(0, pos); - - angle = GetAngleZ(0)-0.1f; - SetAngleZ(0, angle); - } - - if ( type == OBJECT_RUINsupport ) - { - pos = GetPosition(0); - pos.y += 0.5f; - SetPosition(0, pos); - -//? angle = GetAngleY(0)+0.1f; -//? SetAngleY(0, angle); - - angle = GetAngleX(0)+0.1f; - SetAngleX(0, angle); - - angle = GetAngleZ(0)+0.1f; - SetAngleZ(0, angle); - } - - if ( type == OBJECT_RUINradar ) - { - pos = GetPosition(0); - pos.y -= 0.5f; - SetPosition(0, pos); - - angle = GetAngleX(0)+0.15f; - SetAngleX(0, angle); - - angle = GetAngleZ(0)+0.1f; - SetAngleZ(0, angle); - } - - if ( type == OBJECT_RUINconvert ) - { - pos = GetPosition(0); - pos.y -= 1.0f; - SetPosition(0, pos); - } - - if ( type == OBJECT_RUINbase ) - { - pos = GetPosition(0); - pos.y -= 1.0f; - SetPosition(0, pos); - - angle = GetAngleX(0)+0.15f; - SetAngleX(0, angle); - } - - if ( type == OBJECT_RUINhead ) - { - pos = GetPosition(0); - pos.y += 8.0f; - SetPosition(0, pos); - - angle = GetAngleX(0)+Math::PI*0.4f; - SetAngleX(0, angle); - } - - return true; -} - -// Creates a gadget apollo. - -bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type) -{ - int rank, i; - - Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); - - SetType(type); - - if ( type == OBJECT_APOLLO1 ) // LEM ? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object - SetObjectRank(0, rank); - modelManager->AddModelReference("apollol1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetZoom(0, 1.2f); - SetFloorHeight(0.0f); - - for ( i=0 ; i<4 ; i++ ) // creates feet - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(i+1, rank); - SetObjectParent(i+1, 0); - modelManager->AddModelReference("apollol2.mod", false, rank); - SetAngleY(i+1, Math::PI/2.0f*i); - } - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(5, rank); - SetObjectParent(5, 0); - modelManager->AddModelReference("apollol3.mod", false, rank); // ladder - -//? m_terrain->AddBuildingLevel(pos, 10.0f, 13.0f, 12.0f, 0.0f); - - CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 0.0f), 9.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 11.0f, 5.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-11.0f, 5.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 5.0f, -11.0f), 3.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 0.0f, 5.0f, 11.0f), 3.0f, SOUND_BOUMm, 0.45f); - - SetGlobalSphere(Math::Vector(0.0f, 4.0f, 0.0f), 9.0f); - - CreateShadowCircle(16.0f, 0.5f); - } - - if ( type == OBJECT_APOLLO2 ) // jeep - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); //it is a stationary object - SetObjectRank(0, rank); - modelManager->AddModelReference("apolloj1.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - // Wheels. - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel - SetPosition(1, Math::Vector(-5.75f, 1.65f, -5.0f)); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(2, rank); - SetObjectParent(2, 0); - modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel - SetPosition(2, Math::Vector(-5.75f, 1.65f, 5.0f)); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(3, rank); - SetObjectParent(3, 0); - modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel - SetPosition(3, Math::Vector(5.75f, 1.65f, -5.0f)); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(4, rank); - SetObjectParent(4, 0); - modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel - SetPosition(4, Math::Vector(5.75f, 1.65f, 5.0f)); - - // Accessories: - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(5, rank); - SetObjectParent(5, 0); - modelManager->AddModelReference("apolloj2.mod", false, rank); // antenna - SetPosition(5, Math::Vector(5.5f, 8.8f, 2.0f)); - SetAngleY(5, -120.0f*Math::PI/180.0f); - SetAngleZ(5, 45.0f*Math::PI/180.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(6, rank); - SetObjectParent(6, 0); - modelManager->AddModelReference("apolloj3.mod", false, rank); // camera - SetPosition(6, Math::Vector(5.5f, 2.8f, -2.0f)); - SetAngleY(6, 30.0f*Math::PI/180.0f); - - CreateCrashSphere(Math::Vector( 3.0f, 2.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector(-3.0f, 2.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); - CreateCrashSphere(Math::Vector( 7.0f, 9.0f, 2.0f), 2.0f, SOUND_BOUMm, 0.20f); - - CreateShadowCircle(7.0f, 0.8f); - - FloorAdjust(); - } - - if ( type == OBJECT_APOLLO3 ) // flag? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object - SetObjectRank(0, rank); - modelManager->AddModelReference("apollof.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - SetJotlerSphere(Math::Vector(0.0f, 4.0f, 0.0f), 1.0f); - CreateShadowCircle(2.0f, 0.3f); - } - - if ( type == OBJECT_APOLLO4 ) // module? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object - SetObjectRank(0, rank); - modelManager->AddModelReference("apollom.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 2.0f, SOUND_BOUMm, 0.45f); - CreateShadowCircle(5.0f, 0.8f); - - FloorAdjust(); - } - - if ( type == OBJECT_APOLLO5 ) // antenna? - { - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object - SetObjectRank(0, rank); - modelManager->AddModelReference("apolloa.mod", false, rank); - SetPosition(0, pos); - SetAngleY(0, angle); - SetFloorHeight(0.0f); - - rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); - SetObjectRank(1, rank); - SetObjectParent(1, 0); - modelManager->AddModelReference("apolloj2.mod", false, rank); // antenna - SetPosition(1, Math::Vector(0.0f, 5.0f, 0.0f)); - SetAngleY(1, -120.0f*Math::PI/180.0f); - SetAngleZ(1, 45.0f*Math::PI/180.0f); - - CreateCrashSphere(Math::Vector(0.0f, 4.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.35f); - CreateShadowCircle(3.0f, 0.7f); - } - - CreateOtherObject(type); - - pos = GetPosition(0); - SetPosition(0, pos); // to display the shadows immediately - - return true; -} - -// Creates all sub-objects for managing the object. - -void CObject::CreateOtherObject(ObjectType type) -{ - if ( type == OBJECT_BASE ) - { - m_auto = new CAutoBase(this); - } - if ( type == OBJECT_PORTICO ) - { - m_auto = new CAutoPortico(this); - } - if ( type == OBJECT_DERRICK ) - { - m_auto = new CAutoDerrick(this); - } - if ( type == OBJECT_FACTORY ) - { - m_auto = new CAutoFactory(this); - } - if ( type == OBJECT_REPAIR ) - { - m_auto = new CAutoRepair(this); - } - if ( type == OBJECT_DESTROYER ) - { - m_auto = new CAutoDestroyer(this); - } - if ( type == OBJECT_STATION ) - { - m_auto = new CAutoStation(this); - } - if ( type == OBJECT_CONVERT ) - { - m_auto = new CAutoConvert(this); - } - if ( type == OBJECT_TOWER ) - { - m_auto = new CAutoTower(this); - } - if ( type == OBJECT_RESEARCH ) - { - m_auto = new CAutoResearch(this); - } - if ( type == OBJECT_RADAR ) - { - m_auto = new CAutoRadar(this); - } - if ( type == OBJECT_INFO ) - { - m_auto = new CAutoInfo(this); - } - if ( type == OBJECT_ENERGY ) - { - m_auto = new CAutoEnergy(this); - } - if ( type == OBJECT_LABO ) - { - m_auto = new CAutoLabo(this); - } - if ( type == OBJECT_NUCLEAR ) - { - m_auto = new CAutoNuclear(this); - } - if ( type == OBJECT_PARA ) - { - m_auto = new CAutoPara(this); - } - if ( type == OBJECT_SAFE ) - { - m_auto = new CAutoSafe(this); - } - if ( type == OBJECT_HUSTON ) - { - m_auto = new CAutoHuston(this); - } - if ( type == OBJECT_EGG ) - { - m_auto = new CAutoEgg(this); - } - if ( type == OBJECT_NEST ) - { - m_auto = new CAutoNest(this); - } - if ( type == OBJECT_ROOT5 ) - { - m_auto = new CAutoRoot(this); - } - if ( type == OBJECT_MUSHROOM2 ) - { - m_auto = new CAutoMush(this); - } - if ( type == OBJECT_FLAGb || - type == OBJECT_FLAGr || - type == OBJECT_FLAGg || - type == OBJECT_FLAGy || - type == OBJECT_FLAGv ) - { - m_auto = new CAutoFlag(this); - } - if ( type == OBJECT_TEEN36 || // trunk? - type == OBJECT_TEEN37 || // boat? - type == OBJECT_TEEN38 ) // fan? - { - m_auto = new CAutoKid(this); - } -} - - // Reads a program. bool CObject::ReadProgram(Program* program, const char* filename) @@ -6372,8 +2947,6 @@ bool CObject::GetClip() bool CObject::JostleObject(float force) { - CAutoJostle* pa; - if ( m_type == OBJECT_FLAGb || m_type == OBJECT_FLAGr || m_type == OBJECT_FLAGg || @@ -6389,7 +2962,7 @@ bool CObject::JostleObject(float force) if ( m_auto != 0 ) return false; m_auto = new CAutoJostle(this); - pa = static_cast(m_auto); + CAutoJostle* pa = static_cast(m_auto); pa->Start(0, force); } @@ -6911,7 +3484,10 @@ void CObject::StopShowLimit() m_bShowLimit = false; } - +void CObject::SetShowLimitRadius(float radius) +{ + m_showLimitRadius = radius; +} // Indicates whether a program is under execution. @@ -7163,6 +3739,11 @@ CPhysics* CObject::GetPhysics() return m_physics; } +void CObject::SetPhysics(CPhysics* physics) +{ + m_physics = physics; +} + // Returns the brain associated to the object. CBrain* CObject::GetBrain() @@ -7170,6 +3751,11 @@ CBrain* CObject::GetBrain() return m_brain; } +void CObject::SetBrain(CBrain* brain) +{ + m_brain = brain; +} + // Returns the movement associated to the object. CMotion* CObject::GetMotion() @@ -7177,6 +3763,11 @@ CMotion* CObject::GetMotion() return m_motion; } +void CObject::SetMotion(CMotion* motion) +{ + m_motion = motion; +} + // Returns the controller associated to the object. CAuto* CObject::GetAuto() diff --git a/src/object/object.h b/src/object/object.h index 1efbf2a7..5345f746 100644 --- a/src/object/object.h +++ b/src/object/object.h @@ -28,6 +28,8 @@ #include "graphics/engine/engine.h" #include "graphics/engine/camera.h" +#include "object/object_type.h" + #include "sound/sound.h" @@ -43,222 +45,6 @@ class CScript; class CLevelParserLine; struct Program; - -/** - * \enum ObjectType - * \brief Type of game object - */ -enum ObjectType -{ - OBJECT_NULL = 0, //! < object destroyed - OBJECT_FIX = 1, //! < stationary scenery - OBJECT_PORTICO = 2, //! < Portico - OBJECT_BASE = 3, //! < SpaceShip - OBJECT_DERRICK = 4, //! < Derrick - OBJECT_FACTORY = 5, //! < BotFactory - OBJECT_STATION = 6, //! < PowerStation - OBJECT_CONVERT = 7, //! < Converter - OBJECT_REPAIR = 8, //! < RepairStation - OBJECT_TOWER = 9, //! < DefenseTower - OBJECT_NEST = 10, //! < AlienNest - OBJECT_RESEARCH = 11, //! < ResearchCenter - OBJECT_RADAR = 12, //! < RadarStation - OBJECT_ENERGY = 13, //! < PowerPlant - OBJECT_LABO = 14, //! < AutoLab - OBJECT_NUCLEAR = 15, //! < NuclearPlant - OBJECT_START = 16, //! < StartArea - OBJECT_END = 17, //! < EndArea - OBJECT_INFO = 18, //! < ExchangePost - OBJECT_PARA = 19, //! < PowerCaptor - OBJECT_TARGET1 = 20, //! < Target1 (gate) - OBJECT_TARGET2 = 21, //! < Target2 (center) - OBJECT_SAFE = 22, //! < Vault - OBJECT_HUSTON = 23, //! < Houston - OBJECT_DESTROYER = 24, //! < Destroyer - OBJECT_FRET = 30, //! < transportable (unused) - OBJECT_STONE = 31, //! < TitaniumOre - OBJECT_URANIUM = 32, //! < UraniumOre - OBJECT_METAL = 33, //! < Titanium - OBJECT_POWER = 34, //! < PowerCell - OBJECT_ATOMIC = 35, //! < NuclearCell - OBJECT_BULLET = 36, //! < OrgaMatter - OBJECT_BBOX = 37, //! < BlackBox - OBJECT_TNT = 38, //! < TNT - OBJECT_SCRAP1 = 40, //! < Scrap1 (metal) - OBJECT_SCRAP2 = 41, //! < Scrap2 (metal) - OBJECT_SCRAP3 = 42, //! < Scrap3 (metal) - OBJECT_SCRAP4 = 43, //! < Scrap4 (plastic) - OBJECT_SCRAP5 = 44, //! < Scrap5 (plastic) - OBJECT_MARKPOWER = 50, //! < PowerSpot - OBJECT_MARKSTONE = 51, //! < TitaniumSpot - OBJECT_MARKURANIUM = 52, //! < UraniumSpot - OBJECT_MARKKEYa = 53, //! < KeyASpot - OBJECT_MARKKEYb = 54, //! < KeyBSpot - OBJECT_MARKKEYc = 55, //! < KeyCSpot - OBJECT_MARKKEYd = 56, //! < KeyDSpot - OBJECT_BOMB = 60, //! < Mine - OBJECT_WINFIRE = 61, //! < Firework - OBJECT_SHOW = 62, //! < arrow above object (Visit) - OBJECT_BAG = 63, //! < Bag - OBJECT_PLANT0 = 70, //! < Greenery0 - OBJECT_PLANT1 = 71, //! < Greenery1 - OBJECT_PLANT2 = 72, //! < Greenery2 - OBJECT_PLANT3 = 73, //! < Greenery3 - OBJECT_PLANT4 = 74, //! < Greenery4 - OBJECT_PLANT5 = 75, //! < Greenery5 - OBJECT_PLANT6 = 76, //! < Greenery6 - OBJECT_PLANT7 = 77, //! < Greenery7 - OBJECT_PLANT8 = 78, //! < Greenery8 - OBJECT_PLANT9 = 79, //! < Greenery9 - OBJECT_PLANT10 = 80, //! < Greenery10 - OBJECT_PLANT11 = 81, //! < Greenery11 - OBJECT_PLANT12 = 82, //! < Greenery12 - OBJECT_PLANT13 = 83, //! < Greenery13 - OBJECT_PLANT14 = 84, //! < Greenery14 - OBJECT_PLANT15 = 85, //! < Greenery15 - OBJECT_PLANT16 = 86, //! < Greenery16 - OBJECT_PLANT17 = 87, //! < Greenery17 - OBJECT_PLANT18 = 88, //! < Greenery18 - OBJECT_PLANT19 = 89, //! < Greenery19 - OBJECT_TREE0 = 90, //! < Tree0 - OBJECT_TREE1 = 91, //! < Tree1 - OBJECT_TREE2 = 92, //! < Tree2 - OBJECT_TREE3 = 93, //! < Tree3 - OBJECT_TREE4 = 94, //! < Tree4 - OBJECT_TREE5 = 95, //! < Tree5 - OBJECT_MOBILEwt = 100, //! < PracticeBot - OBJECT_MOBILEtt = 101, //! < track-trainer (unused) - OBJECT_MOBILEft = 102, //! < fly-trainer (unused) - OBJECT_MOBILEit = 103, //! < insect-trainer (unused) - OBJECT_MOBILEwa = 110, //! < WheeledGrabber - OBJECT_MOBILEta = 111, //! < TrackedGrabber - OBJECT_MOBILEfa = 112, //! < WingedGrabber - OBJECT_MOBILEia = 113, //! < LeggedGrabber - OBJECT_MOBILEwc = 120, //! < WheeledShooter - OBJECT_MOBILEtc = 121, //! < TrackedShooter - OBJECT_MOBILEfc = 122, //! < WingedShooter - OBJECT_MOBILEic = 123, //! < LeggedShooter - OBJECT_MOBILEwi = 130, //! < WheeledOrgaShooter - OBJECT_MOBILEti = 131, //! < TrackedOrgaShooter - OBJECT_MOBILEfi = 132, //! < WingedOrgaShooter - OBJECT_MOBILEii = 133, //! < LeggedOrgaShooter - OBJECT_MOBILEws = 140, //! < WheeledSniffer - OBJECT_MOBILEts = 141, //! < TrackedSniffer - OBJECT_MOBILEfs = 142, //! < WingedSniffer - OBJECT_MOBILEis = 143, //! < LeggedSniffer - OBJECT_MOBILErt = 200, //! < Thumper - OBJECT_MOBILErc = 201, //! < PhazerShooter - OBJECT_MOBILErr = 202, //! < Recycler - OBJECT_MOBILErs = 203, //! < Shielder - OBJECT_MOBILEsa = 210, //! < Subber - OBJECT_MOBILEtg = 211, //! < TargetBot - OBJECT_MOBILEdr = 212, //! < Scribbler - OBJECT_CONTROLLER = 213, //! < MissionController - OBJECT_WAYPOINT = 250, //! < WayPoint - OBJECT_FLAGb = 260, //! < BlueFlag - OBJECT_FLAGr = 261, //! < RedFlag - OBJECT_FLAGg = 262, //! < GreenFlag - OBJECT_FLAGy = 263, //! < YellowFlag - OBJECT_FLAGv = 264, //! < VioletFlag - OBJECT_KEYa = 270, //! < KeyA - OBJECT_KEYb = 271, //! < KeyB - OBJECT_KEYc = 272, //! < KeyC - OBJECT_KEYd = 273, //! < KeyD - OBJECT_HUMAN = 300, //! < Me - OBJECT_TOTO = 301, //! < Robby (toto) - OBJECT_TECH = 302, //! < Tech - OBJECT_BARRIER0 = 400, //! < Barrier0 - OBJECT_BARRIER1 = 401, //! < Barrier1 - OBJECT_BARRIER2 = 402, //! < Barrier2 - OBJECT_BARRIER3 = 403, //! < Barrier3 - OBJECT_MOTHER = 500, //! < AlienQueen - OBJECT_EGG = 501, //! < AlienEgg - OBJECT_ANT = 502, //! < AlienAnt - OBJECT_SPIDER = 503, //! < AlienSpider - OBJECT_BEE = 504, //! < AlienWasp - OBJECT_WORM = 505, //! < AlienWorm - OBJECT_RUINmobilew1 = 600, //! < WreckBotw1 - OBJECT_RUINmobilew2 = 601, //! < WreckBotw2 - OBJECT_RUINmobilet1 = 602, //! < WreckBott1 - OBJECT_RUINmobilet2 = 603, //! < WreckBott2 - OBJECT_RUINmobiler1 = 604, //! < WreckBotr1 - OBJECT_RUINmobiler2 = 605, //! < WreckBotr2 - OBJECT_RUINfactory = 606, //! < RuinBotFactory - OBJECT_RUINdoor = 607, //! < RuinDoor - OBJECT_RUINsupport = 608, //! < RuinSupport - OBJECT_RUINradar = 609, //! < RuinRadar - OBJECT_RUINconvert = 610, //! < RuinConvert - OBJECT_RUINbase = 611, //! < RuinBaseCamp - OBJECT_RUINhead = 612, //! < RuinHeadCamp - OBJECT_TEEN0 = 620, //! < Teen0 - OBJECT_TEEN1 = 621, //! < Teen1 - OBJECT_TEEN2 = 622, //! < Teen2 - OBJECT_TEEN3 = 623, //! < Teen3 - OBJECT_TEEN4 = 624, //! < Teen4 - OBJECT_TEEN5 = 625, //! < Teen5 - OBJECT_TEEN6 = 626, //! < Teen6 - OBJECT_TEEN7 = 627, //! < Teen7 - OBJECT_TEEN8 = 628, //! < Teen8 - OBJECT_TEEN9 = 629, //! < Teen9 - OBJECT_TEEN10 = 630, //! < Teen10 - OBJECT_TEEN11 = 631, //! < Teen11 - OBJECT_TEEN12 = 632, //! < Teen12 - OBJECT_TEEN13 = 633, //! < Teen13 - OBJECT_TEEN14 = 634, //! < Teen14 - OBJECT_TEEN15 = 635, //! < Teen15 - OBJECT_TEEN16 = 636, //! < Teen16 - OBJECT_TEEN17 = 637, //! < Teen17 - OBJECT_TEEN18 = 638, //! < Teen18 - OBJECT_TEEN19 = 639, //! < Teen19 - OBJECT_TEEN20 = 640, //! < Teen20 - OBJECT_TEEN21 = 641, //! < Teen21 - OBJECT_TEEN22 = 642, //! < Teen22 - OBJECT_TEEN23 = 643, //! < Teen23 - OBJECT_TEEN24 = 644, //! < Teen24 - OBJECT_TEEN25 = 645, //! < Teen25 - OBJECT_TEEN26 = 646, //! < Teen26 - OBJECT_TEEN27 = 647, //! < Teen27 - OBJECT_TEEN28 = 648, //! < Teen28 - OBJECT_TEEN29 = 649, //! < Teen29 - OBJECT_TEEN30 = 650, //! < Teen30 - OBJECT_TEEN31 = 651, //! < Teen31 - OBJECT_TEEN32 = 652, //! < Teen32 - OBJECT_TEEN33 = 653, //! < Teen33 - OBJECT_TEEN34 = 654, //! < Stone (Teen34) - OBJECT_TEEN35 = 655, //! < Teen35 - OBJECT_TEEN36 = 656, //! < Teen36 - OBJECT_TEEN37 = 657, //! < Teen37 - OBJECT_TEEN38 = 658, //! < Teen38 - OBJECT_TEEN39 = 659, //! < Teen39 - OBJECT_TEEN40 = 660, //! < Teen40 - OBJECT_TEEN41 = 661, //! < Teen41 - OBJECT_TEEN42 = 662, //! < Teen42 - OBJECT_TEEN43 = 663, //! < Teen43 - OBJECT_TEEN44 = 664, //! < Teen44 - OBJECT_QUARTZ0 = 700, //! < Quartz0 - OBJECT_QUARTZ1 = 701, //! < Quartz1 - OBJECT_QUARTZ2 = 702, //! < Quartz2 - OBJECT_QUARTZ3 = 703, //! < Quartz3 - OBJECT_ROOT0 = 710, //! < MegaStalk0 - OBJECT_ROOT1 = 711, //! < MegaStalk1 - OBJECT_ROOT2 = 712, //! < MegaStalk2 - OBJECT_ROOT3 = 713, //! < MegaStalk3 - OBJECT_ROOT4 = 714, //! < MegaStalk4 - OBJECT_ROOT5 = 715, //! < MegaStalk5 - OBJECT_MUSHROOM1 = 731, //! < Mushroom1 - OBJECT_MUSHROOM2 = 732, //! < Mushroom2 - OBJECT_APOLLO1 = 900, //! < ApolloLEM - OBJECT_APOLLO2 = 901, //! < ApolloJeep - OBJECT_APOLLO3 = 902, //! < ApolloFlag - OBJECT_APOLLO4 = 903, //! < ApolloModule - OBJECT_APOLLO5 = 904, //! < ApolloAntenna - OBJECT_HOME1 = 910, //! < Home - - OBJECT_MAX = 1000 //! < number of values -}; - - - // The father of all parts must always be the part number zero! const int OBJECTMAXPART = 40; @@ -344,13 +130,6 @@ enum ResetCap RESET_DELETE = 2, }; -enum RadarFilter -{ - FILTER_NONE = 0, - FILTER_ONLYLANDING = 1, - FILTER_ONLYFLYING = 2, -}; - @@ -387,21 +166,6 @@ public: void SetDrawWorld(bool bDraw); void SetDrawFront(bool bDraw); - bool CreateVehicle(Math::Vector pos, float angle, ObjectType type, float power, bool bTrainer, bool bToy); - bool CreateInsect(Math::Vector pos, float angle, ObjectType type); - bool CreateBuilding(Math::Vector pos, float angle, float height, ObjectType type, float power=1.0f); - bool CreateResource(Math::Vector pos, float angle, ObjectType type, float power=1.0f); - bool CreateFlag(Math::Vector pos, float angle, ObjectType type); - bool CreateBarrier(Math::Vector pos, float angle, float height, ObjectType type); - bool CreatePlant(Math::Vector pos, float angle, float height, ObjectType type); - bool CreateMushroom(Math::Vector pos, float angle, float height, ObjectType type); - bool CreateTeen(Math::Vector pos, float angle, float zoom, float height, ObjectType type); - bool CreateQuartz(Math::Vector pos, float angle, float height, ObjectType type); - bool CreateRoot(Math::Vector pos, float angle, float height, ObjectType type); - bool CreateHome(Math::Vector pos, float angle, float height, ObjectType type); - bool CreateRuin(Math::Vector pos, float angle, float height, ObjectType type); - bool CreateApollo(Math::Vector pos, float angle, ObjectType type); - bool ReadProgram(Program* program, const char* filename); bool WriteProgram(Program* program, char* filename); @@ -610,6 +374,7 @@ public: bool StartShowLimit(); void StopShowLimit(); + void SetShowLimitRadius(float radius); bool IsProgram(); void CreateSelectParticle(); @@ -618,8 +383,11 @@ public: CScript* GetRunScript(); CBotVar* GetBotVar(); CPhysics* GetPhysics(); + void SetPhysics(CPhysics* physics); CBrain* GetBrain(); + void SetBrain(CBrain* brain); CMotion* GetMotion(); + void SetMotion(CMotion* motion); CAuto* GetAuto(); void SetAuto(CAuto* automat); @@ -645,8 +413,6 @@ public: float GetTraceWidth(); void SetTraceWidth(float width); - std::string GetModelDirName(); - static DriveType GetDriveFromObject(ObjectType type); static ToolType GetToolFromObject(ObjectType type); @@ -654,7 +420,6 @@ protected: bool EventFrame(const Event &event); void VirusFrame(float rTime); void PartiFrame(float rTime); - void CreateOtherObject(ObjectType type); void InitPart(int part); void UpdateTotalPart(); int SearchDescendant(int parent, int n); diff --git a/src/object/object_factory.cpp b/src/object/object_factory.cpp new file mode 100644 index 00000000..f10265ea --- /dev/null +++ b/src/object/object_factory.cpp @@ -0,0 +1,3673 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ + +#include "object/object_factory.h" + +#include "graphics/engine/engine.h" +#include "graphics/engine/modelmanager.h" +#include "graphics/engine/terrain.h" +#include "graphics/engine/lightning.h" + +#include "object/brain.h" +#include "object/robotmain.h" +#include "object/auto/autobase.h" +#include "object/auto/autoconvert.h" +#include "object/auto/autoderrick.h" +#include "object/auto/autodestroyer.h" +#include "object/auto/autoegg.h" +#include "object/auto/autoenergy.h" +#include "object/auto/autofactory.h" +#include "object/auto/autoflag.h" +#include "object/auto/autohuston.h" +#include "object/auto/autoinfo.h" +#include "object/auto/autojostle.h" +#include "object/auto/autokid.h" +#include "object/auto/autolabo.h" +#include "object/auto/automush.h" +#include "object/auto/autonest.h" +#include "object/auto/autonuclear.h" +#include "object/auto/autopara.h" +#include "object/auto/autoportico.h" +#include "object/auto/autoradar.h" +#include "object/auto/autorepair.h" +#include "object/auto/autoresearch.h" +#include "object/auto/autoroot.h" +#include "object/auto/autosafe.h" +#include "object/auto/autostation.h" +#include "object/auto/autotower.h" +#include "object/motion/motionant.h" +#include "object/motion/motionbee.h" +#include "object/motion/motiondummy.h" +#include "object/motion/motionhuman.h" +#include "object/motion/motionmother.h" +#include "object/motion/motionspider.h" +#include "object/motion/motiontoto.h" +#include "object/motion/motionvehicle.h" +#include "object/motion/motionworm.h" + +#include "math/geometry.h" + +#include "physics/physics.h" + +CObjectFactory::CObjectFactory(Gfx::CEngine* engine, + Gfx::CTerrain* terrain, + Gfx::CModelManager* modelManager, + Gfx::CParticle* particle, + CRobotMain* main) + : m_engine(engine) + , m_terrain(terrain) + , m_modelManager(modelManager) + , m_particle(particle) + , m_main(main) +{} + +CObject* CObjectFactory::CreateObject(Math::Vector pos, float angle, ObjectType type, + float power, float zoom, float height, + bool trainer, bool toy, int option) +{ + switch (type) + { + case OBJECT_NULL: + return nullptr; + + case OBJECT_PORTICO: + case OBJECT_BASE: + case OBJECT_DERRICK: + case OBJECT_FACTORY: + case OBJECT_STATION: + case OBJECT_CONVERT: + case OBJECT_REPAIR: + case OBJECT_DESTROYER: + case OBJECT_TOWER: + case OBJECT_NEST: + case OBJECT_RESEARCH: + case OBJECT_RADAR: + case OBJECT_INFO: + case OBJECT_ENERGY: + case OBJECT_LABO: + case OBJECT_NUCLEAR: + case OBJECT_PARA: + case OBJECT_SAFE: + case OBJECT_HUSTON: + case OBJECT_TARGET1: + case OBJECT_TARGET2: + case OBJECT_START: + case OBJECT_END: + return CreateBuilding(pos, angle, height, type, power); + + case OBJECT_FRET: + case OBJECT_STONE: + case OBJECT_URANIUM: + case OBJECT_METAL: + case OBJECT_POWER: + case OBJECT_ATOMIC: + case OBJECT_BULLET: + case OBJECT_BBOX: + case OBJECT_KEYa: + case OBJECT_KEYb: + case OBJECT_KEYc: + case OBJECT_KEYd: + case OBJECT_TNT: + case OBJECT_SCRAP1: + case OBJECT_SCRAP2: + case OBJECT_SCRAP3: + case OBJECT_SCRAP4: + case OBJECT_SCRAP5: + case OBJECT_BOMB: + case OBJECT_WAYPOINT: + case OBJECT_SHOW: + case OBJECT_WINFIRE: + case OBJECT_BAG: + case OBJECT_MARKPOWER: + case OBJECT_MARKSTONE: + case OBJECT_MARKURANIUM: + case OBJECT_MARKKEYa: + case OBJECT_MARKKEYb: + case OBJECT_MARKKEYc: + case OBJECT_MARKKEYd: + case OBJECT_EGG: + return CreateResource(pos, angle, type, power); + + case OBJECT_FLAGb: + case OBJECT_FLAGr: + case OBJECT_FLAGg: + case OBJECT_FLAGy: + case OBJECT_FLAGv: + return CreateFlag(pos, angle, type); + + case OBJECT_BARRIER0: + case OBJECT_BARRIER1: + case OBJECT_BARRIER2: + case OBJECT_BARRIER3: + return CreateBarrier(pos, angle, height, type); + + case OBJECT_PLANT0: + case OBJECT_PLANT1: + case OBJECT_PLANT2: + case OBJECT_PLANT3: + case OBJECT_PLANT4: + case OBJECT_PLANT5: + case OBJECT_PLANT6: + case OBJECT_PLANT7: + case OBJECT_PLANT8: + case OBJECT_PLANT9: + case OBJECT_PLANT10: + case OBJECT_PLANT11: + case OBJECT_PLANT12: + case OBJECT_PLANT13: + case OBJECT_PLANT14: + case OBJECT_PLANT15: + case OBJECT_PLANT16: + case OBJECT_PLANT17: + case OBJECT_PLANT18: + case OBJECT_PLANT19: + case OBJECT_TREE0: + case OBJECT_TREE1: + case OBJECT_TREE2: + case OBJECT_TREE3: + case OBJECT_TREE4: + case OBJECT_TREE5: + return CreatePlant(pos, angle, height, type); + + case OBJECT_MUSHROOM1: + case OBJECT_MUSHROOM2: + return CreateMushroom(pos, angle, height, type); + + case OBJECT_TEEN0: + case OBJECT_TEEN1: + case OBJECT_TEEN2: + case OBJECT_TEEN3: + case OBJECT_TEEN4: + case OBJECT_TEEN5: + case OBJECT_TEEN6: + case OBJECT_TEEN7: + case OBJECT_TEEN8: + case OBJECT_TEEN9: + case OBJECT_TEEN10: + case OBJECT_TEEN11: + case OBJECT_TEEN12: + case OBJECT_TEEN13: + case OBJECT_TEEN14: + case OBJECT_TEEN15: + case OBJECT_TEEN16: + case OBJECT_TEEN17: + case OBJECT_TEEN18: + case OBJECT_TEEN19: + case OBJECT_TEEN20: + case OBJECT_TEEN21: + case OBJECT_TEEN22: + case OBJECT_TEEN23: + case OBJECT_TEEN24: + case OBJECT_TEEN25: + case OBJECT_TEEN26: + case OBJECT_TEEN27: + case OBJECT_TEEN28: + case OBJECT_TEEN29: + case OBJECT_TEEN30: + case OBJECT_TEEN31: + case OBJECT_TEEN32: + case OBJECT_TEEN33: + case OBJECT_TEEN34: + case OBJECT_TEEN35: + case OBJECT_TEEN36: + case OBJECT_TEEN37: + case OBJECT_TEEN38: + case OBJECT_TEEN39: + case OBJECT_TEEN40: + case OBJECT_TEEN41: + case OBJECT_TEEN42: + case OBJECT_TEEN43: + case OBJECT_TEEN44: + return CreateTeen(pos, angle, zoom, height, type, option); + + case OBJECT_QUARTZ0: + case OBJECT_QUARTZ1: + case OBJECT_QUARTZ2: + case OBJECT_QUARTZ3: + return CreateQuartz(pos, angle, height, type); + + case OBJECT_ROOT0: + case OBJECT_ROOT1: + case OBJECT_ROOT2: + case OBJECT_ROOT3: + case OBJECT_ROOT4: + case OBJECT_ROOT5: + return CreateRoot(pos, angle, height, type); + + case OBJECT_HOME1: + return CreateHome(pos, angle, height, type); + + case OBJECT_RUINmobilew1: + case OBJECT_RUINmobilew2: + case OBJECT_RUINmobilet1: + case OBJECT_RUINmobilet2: + case OBJECT_RUINmobiler1: + case OBJECT_RUINmobiler2: + case OBJECT_RUINfactory: + case OBJECT_RUINdoor: + case OBJECT_RUINsupport: + case OBJECT_RUINradar: + case OBJECT_RUINconvert: + case OBJECT_RUINbase: + case OBJECT_RUINhead: + return CreateRuin(pos, angle, height, type); + + case OBJECT_APOLLO1: + case OBJECT_APOLLO3: + case OBJECT_APOLLO4: + case OBJECT_APOLLO5: + return CreateApollo(pos, angle, type); + + case OBJECT_MOTHER: + case OBJECT_ANT: + case OBJECT_SPIDER: + case OBJECT_BEE: + case OBJECT_WORM: + return CreateInsect(pos, angle, type); // no eggs + + case OBJECT_HUMAN: + case OBJECT_TECH: + case OBJECT_TOTO: + case OBJECT_MOBILEfa: + case OBJECT_MOBILEta: + case OBJECT_MOBILEwa: + case OBJECT_MOBILEia: + case OBJECT_MOBILEfc: + case OBJECT_MOBILEtc: + case OBJECT_MOBILEwc: + case OBJECT_MOBILEic: + case OBJECT_MOBILEfi: + case OBJECT_MOBILEti: + case OBJECT_MOBILEwi: + case OBJECT_MOBILEii: + case OBJECT_MOBILEfs: + case OBJECT_MOBILEts: + case OBJECT_MOBILEws: + case OBJECT_MOBILEis: + case OBJECT_MOBILErt: + case OBJECT_MOBILErc: + case OBJECT_MOBILErr: + case OBJECT_MOBILErs: + case OBJECT_MOBILEsa: + case OBJECT_MOBILEtg: + case OBJECT_MOBILEft: + case OBJECT_MOBILEtt: + case OBJECT_MOBILEwt: + case OBJECT_MOBILEit: + case OBJECT_MOBILEdr: + case OBJECT_APOLLO2: + return CreateVehicle(pos, angle, type, power, trainer, toy, option); + + default: + break; + } + + return nullptr; +} + +// Creates a building laying on the ground. + +CObject* CObjectFactory::CreateBuilding(Math::Vector pos, float angle, float height, ObjectType type, float power) +{ + CObject* obj = new CObject(); + + obj->SetType(type); + + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object + obj->SetObjectRank(0, rank); + + if ( type == OBJECT_PORTICO ) + { + m_modelManager->AddModelReference("portico1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("portico2.mod", false, rank); + obj->SetPosition(1, Math::Vector(0.0f, 67.0f, 0.0f)); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(2, rank); + obj->SetObjectParent(2, 1); + m_modelManager->AddModelReference("portico3.mod", false, rank); + obj->SetPosition(2, Math::Vector(0.0f, 0.0f, -33.0f)); + obj->SetAngleY(2, 45.0f*Math::PI/180.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(3, rank); + obj->SetObjectParent(3, 2); + m_modelManager->AddModelReference("portico4.mod", false, rank); + obj->SetPosition(3, Math::Vector(50.0f, 0.0f, 0.0f)); + obj->SetAngleY(3, -60.0f*Math::PI/180.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(4, rank); + obj->SetObjectParent(4, 3); + m_modelManager->AddModelReference("portico5.mod", false, rank); + obj->SetPosition(4, Math::Vector(35.0f, 0.0f, 0.0f)); + obj->SetAngleY(4, -55.0f*Math::PI/180.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(5, rank); + obj->SetObjectParent(5, 1); + m_modelManager->AddModelReference("portico3.mod", false, rank); + obj->SetPosition(5, Math::Vector(0.0f, 0.0f, 33.0f)); + obj->SetAngleY(5, -45.0f*Math::PI/180.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(6, rank); + obj->SetObjectParent(6, 5); + m_modelManager->AddModelReference("portico4.mod", false, rank); + obj->SetPosition(6, Math::Vector(50.0f, 0.0f, 0.0f)); + obj->SetAngleY(6, 60.0f*Math::PI/180.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(7, rank); + obj->SetObjectParent(7, 6); + m_modelManager->AddModelReference("portico5.mod", false, rank); + obj->SetPosition(7, Math::Vector(35.0f, 0.0f, 0.0f)); + obj->SetAngleY(7, 55.0f*Math::PI/180.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(8, rank); + obj->SetObjectParent(8, 0); + m_modelManager->AddModelReference("portico6.mod", false, rank); + obj->SetPosition(8, Math::Vector(-35.0f, 50.0f, -35.0f)); + obj->SetAngleY(8, -Math::PI/2.0f); + obj->SetZoom(8, 2.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(9, rank); + obj->SetObjectParent(9, 8); + m_modelManager->AddModelReference("portico7.mod", false, rank); + obj->SetPosition(9, Math::Vector(0.0f, 4.5f, 1.9f)); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(10, rank); + obj->SetObjectParent(10, 0); + m_modelManager->AddModelReference("portico6.mod", false, rank); + obj->SetPosition(10, Math::Vector(-35.0f, 50.0f, 35.0f)); + obj->SetAngleY(10, -Math::PI/2.0f); + obj->SetZoom(10, 2.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(11, rank); + obj->SetObjectParent(11, 10); + m_modelManager->AddModelReference("portico7.mod", false, rank); + obj->SetPosition(11, Math::Vector(0.0f, 4.5f, 1.9f)); + + obj->CreateCrashSphere(Math::Vector( 0.0f, 28.0f, 0.0f), 45.5f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 27.0f, 10.0f, -42.0f), 15.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 10.0f, -42.0f), 15.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-27.0f, 10.0f, -42.0f), 15.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 27.0f, 10.0f, 42.0f), 15.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 10.0f, 42.0f), 15.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-27.0f, 10.0f, 42.0f), 15.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-32.0f, 45.0f, -32.0f), 10.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-32.0f, 45.0f, 32.0f), 10.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 32.0f, 45.0f, -32.0f), 10.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 32.0f, 45.0f, 32.0f), 10.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 35.0f, 0.0f), 50.0f); + + obj->CreateShadowCircle(50.0f, 1.0f); + } + + if ( type == OBJECT_BASE ) + { + m_modelManager->AddModelReference("base1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + for (int i=0 ; i<8 ; i++ ) + { + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1+i, rank); + obj->SetObjectParent(1+i, 0); + m_modelManager->AddModelReference("base2.mod", false, rank); + Math::Point p = Math::RotatePoint(-Math::PI/4.0f*i, 27.8f); + obj->SetPosition(1+i, Math::Vector(p.x, 30.0f, p.y)); + obj->SetAngleY(1+i, Math::PI/4.0f*i); + obj->SetAngleZ(1+i, Math::PI/2.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(10+i, rank); + obj->SetObjectParent(10+i, 1+i); + m_modelManager->AddModelReference("base4.mod", false, rank); + obj->SetPosition(10+i, Math::Vector(23.5f, 0.0f, 7.0f)); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(18+i, rank); + obj->SetObjectParent(18+i, 1+i); + m_modelManager->AddModelReference("base4.mod", true, rank); + obj->SetPosition(18+i, Math::Vector(23.5f, 0.0f, -7.0f)); + } + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(9, rank); + obj->SetObjectParent(9, 0); + m_modelManager->AddModelReference("base3.mod", false, rank); // central pillar + + obj->CreateCrashSphere(Math::Vector( 0.0f, 33.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 39.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 45.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 51.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 57.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 63.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 69.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 82.0f, 0.0f), 8.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 18.0f, 94.0f, 0.0f), 10.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-18.0f, 94.0f, 0.0f), 10.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 94.0f, 18.0f), 10.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 94.0f, -18.0f), 10.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 13.0f, 94.0f, 13.0f), 10.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-13.0f, 94.0f, 13.0f), 10.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 13.0f, 94.0f, -13.0f), 10.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-13.0f, 94.0f, -13.0f), 10.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f,104.0f, 0.0f), 14.0f, SOUND_BOUMm, 0.45f); + + obj->SetGlobalSphere(Math::Vector(0.0f, 45.0f, 0.0f), 10.0f); + + obj->CreateShadowCircle(60.0f, 1.0f); + obj->SetShowLimitRadius(200.0f); + + m_terrain->AddBuildingLevel(pos, 28.6f, 73.4f, 30.0f, 0.4f); + } + + if ( type == OBJECT_DERRICK ) + { + m_modelManager->AddModelReference("derrick1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("derrick2.mod", false, rank); + + obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(0.0f, 10.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(0.0f, 17.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(0.0f, 26.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(7.0f, 17.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 10.0f); + + obj->CreateShadowCircle(10.0f, 0.4f); + } + + if ( type == OBJECT_RESEARCH ) + { + m_modelManager->AddModelReference("search1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("search2.mod", false, rank); + obj->SetPosition(1, Math::Vector(0.0f, 13.0f, 0.0f)); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(2, rank); + obj->SetObjectParent(2, 1); + m_modelManager->AddModelReference("search3.mod", false, rank); + obj->SetPosition(2, Math::Vector(0.0f, 4.0f, 0.0f)); + obj->SetAngleZ(2, 35.0f*Math::PI/180.0f); + + obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 9.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(0.0f, 6.0f, 0.0f), 9.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(0.0f, 14.0f, 0.0f), 7.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 8.0f, 0.0f), 12.0f); + + obj->GetCharacter()->posPower = Math::Vector(7.5f, 3.0f, 0.0f); + + obj->CreateShadowCircle(12.0f, 1.0f); + } + + if ( type == OBJECT_RADAR ) + { + m_modelManager->AddModelReference("radar1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("radar2.mod", false, rank); + obj->SetPosition(1, Math::Vector(0.0f, 5.0f, 0.0f)); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(2, rank); + obj->SetObjectParent(2, 0); + m_modelManager->AddModelReference("radar3.mod", false, rank); + obj->SetPosition(2, Math::Vector(0.0f, 11.0f, 0.0f)); + obj->SetAngleY(2, -Math::PI/2.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(3, rank); + obj->SetObjectParent(3, 2); + m_modelManager->AddModelReference("radar4.mod", false, rank); + obj->SetPosition(3, Math::Vector(0.0f, 4.5f, 1.9f)); + + obj->CreateCrashSphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(0.0f, 11.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 7.0f, 0.0f), 7.0f); + + obj->CreateShadowCircle(8.0f, 1.0f); + } + + if ( type == OBJECT_INFO ) + { + m_modelManager->AddModelReference("info1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("info2.mod", false, rank); + obj->SetPosition(1, Math::Vector(0.0f, 5.0f, 0.0f)); + + for (int i=0 ; i<3 ; i++ ) + { + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(2+i*2, rank); + obj->SetObjectParent(2+i*2, 1); + m_modelManager->AddModelReference("info3.mod", false, rank); + obj->SetPosition(2+i*2, Math::Vector(0.0f, 4.5f, 0.0f)); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(3+i*2, rank); + obj->SetObjectParent(3+i*2, 2+i*2); + m_modelManager->AddModelReference("radar4.mod", false, rank); + obj->SetPosition(3+i*2, Math::Vector(0.0f, 0.0f, -4.0f)); + + obj->SetAngleY(2+i*2, 2.0f*Math::PI/3.0f*i); + } + + obj->CreateCrashSphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(0.0f, 11.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 6.0f); + + obj->CreateShadowCircle(8.0f, 1.0f); + } + + if ( type == OBJECT_ENERGY ) + { + m_modelManager->AddModelCopy("energy.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + obj->CreateCrashSphere(Math::Vector(-2.0f, 13.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-7.0f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 1.0f, 0.0f), 1.5f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(-7.0f, 5.0f, 0.0f), 5.0f); + + obj->GetCharacter()->posPower = Math::Vector(0.0f, 3.0f, 0.0f); + obj->SetEnergy(power); // initializes the energy level + + obj->CreateShadowCircle(6.0f, 0.5f); + } + + if ( type == OBJECT_LABO ) + { + m_modelManager->AddModelReference("labo1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("labo2.mod", false, rank); + obj->SetPosition(1, Math::Vector(-9.0f, 3.0f, 0.0f)); + obj->SetAngleZ(1, Math::PI/2.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(2, rank); + obj->SetObjectParent(2, 1); + m_modelManager->AddModelReference("labo3.mod", false, rank); + obj->SetPosition(2, Math::Vector(9.0f, -1.0f, 0.0f)); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(3, rank); + obj->SetObjectParent(3, 2); + m_modelManager->AddModelReference("labo4.mod", false, rank); + obj->SetPosition(3, Math::Vector(0.0f, 0.0f, 0.0f)); + obj->SetAngleZ(3, 80.0f*Math::PI/180.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(4, rank); + obj->SetObjectParent(4, 2); + m_modelManager->AddModelReference("labo4.mod", false, rank); + obj->SetPosition(4, Math::Vector(0.0f, 0.0f, 0.0f)); + obj->SetAngleZ(4, 80.0f*Math::PI/180.0f); + obj->SetAngleY(4, Math::PI*2.0f/3.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(5, rank); + obj->SetObjectParent(5, 2); + m_modelManager->AddModelReference("labo4.mod", false, rank); + obj->SetPosition(5, Math::Vector(0.0f, 0.0f, 0.0f)); + obj->SetAngleZ(5, 80.0f*Math::PI/180.0f); + obj->SetAngleY(5, -Math::PI*2.0f/3.0f); + + obj->CreateCrashSphere(Math::Vector( 0.0f, 1.0f, 0.0f), 1.5f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 11.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 10.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-12.0f, 3.0f, 3.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-12.0f, 3.0f, -3.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(-10.0f, 5.0f, 0.0f), 7.0f); + + obj->GetCharacter()->posPower = Math::Vector(0.0f, 3.0f, 0.0f); + + obj->CreateShadowCircle(7.0f, 0.5f); + } + + if ( type == OBJECT_FACTORY ) + { + m_modelManager->AddModelReference("factory1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + for (int i=0 ; i<9 ; i++ ) + { + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1+i, rank); + obj->SetObjectParent(1+i, 0); + m_modelManager->AddModelReference("factory2.mod", false, rank); + obj->SetPosition(1+i, Math::Vector(10.0f, 2.0f*i, 10.0f)); + obj->SetAngleZ(1+i, Math::PI/2.0f); + obj->SetZoomZ(1+i, 0.30f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(10+i, rank); + obj->SetObjectParent(10+i, 0); + m_modelManager->AddModelReference("factory2.mod", false, rank); + obj->SetPosition(10+i, Math::Vector(10.0f, 2.0f*i, -10.0f)); + obj->SetAngleZ(10+i, -Math::PI/2.0f); + obj->SetAngleY(10+i, Math::PI); + obj->SetZoomZ(10+i, 0.30f); + } + + for (int i=0 ; i<2 ; i++ ) + { + float s = static_cast(i*2-1); + obj->CreateCrashSphere(Math::Vector(-10.0f, 2.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -3.0f, 2.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 3.0f, 2.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 10.0f, 2.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 9.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -3.0f, 9.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 3.0f, 9.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 10.0f, 9.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 16.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -3.0f, 16.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 3.0f, 16.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 10.0f, 16.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 16.0f, 4.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -3.0f, 16.0f, 4.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 3.0f, 16.0f, 4.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 10.0f, 16.0f, 4.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 2.0f, 4.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 9.0f, 4.0f*s), 4.0f, SOUND_BOUMm, 0.45f); + } + obj->CreateCrashSphere(Math::Vector(-10.0f, 21.0f, -4.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 18.0f); + + obj->CreateShadowCircle(24.0f, 0.3f); + } + + if ( type == OBJECT_REPAIR ) + { + m_modelManager->AddModelReference("repair1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("repair2.mod", false, rank); + obj->SetPosition(1, Math::Vector(-11.0f, 13.5f, 0.0f)); + obj->SetAngleZ(1, Math::PI/2.0f); + + m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f); + + obj->CreateCrashSphere(Math::Vector(-11.0f, 0.0f, 4.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-11.0f, 0.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-11.0f, 0.0f, -4.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-11.0f, 10.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(-11.0f, 13.0f, 0.0f), 15.0f); + } + + if ( type == OBJECT_DESTROYER ) + { + m_modelManager->AddModelReference("destroy1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("destroy2.mod", false, rank); + obj->SetPosition(1, Math::Vector(0.0f, 0.0f, 0.0f)); + + m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f); + + obj->CreateCrashSphere(Math::Vector(-3.5f, 0.0f, -13.5f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 3.5f, 0.0f, -13.5f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-3.5f, 0.0f, 13.5f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 3.5f, 0.0f, 13.5f), 4.0f, SOUND_BOUMm, 0.45f); + + obj->CreateShadowCircle(19.0f, 1.0f); + } + + if ( type == OBJECT_STATION ) + { + m_modelManager->AddModelCopy("station.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f); + + obj->CreateCrashSphere(Math::Vector(-15.0f, 2.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-15.0f, 6.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(-15.0f, 5.0f, 0.0f), 6.0f); + + obj->SetEnergy(power); + } + + if ( type == OBJECT_CONVERT ) + { + m_modelManager->AddModelReference("convert1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("convert2.mod", false, rank); + obj->SetPosition(1, Math::Vector(0.0f, 14.0f, 0.0f)); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(2, rank); + obj->SetObjectParent(2, 0); + m_modelManager->AddModelReference("convert3.mod", false, rank); + obj->SetPosition(2, Math::Vector(0.0f, 11.5f, 0.0f)); + obj->SetAngleX(2, -Math::PI*0.35f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(3, rank); + obj->SetObjectParent(3, 0); + m_modelManager->AddModelReference("convert3.mod", false, rank); + obj->SetPosition(3, Math::Vector(0.0f, 11.5f, 0.0f)); + obj->SetAngleY(3, Math::PI); + obj->SetAngleX(3, -Math::PI*0.35f); + + m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f); + + obj->CreateCrashSphere(Math::Vector(-10.0f, 2.0f, 4.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 2.0f, -4.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 9.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 14.0f, 0.0f), 1.5f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(-3.0f, 8.0f, 0.0f), 14.0f); + } + + if ( type == OBJECT_TOWER ) + { + m_modelManager->AddModelReference("tower.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("roller2c.mod", false, rank); + obj->SetPosition(1, Math::Vector(0.0f, 20.0f, 0.0f)); + obj->SetAngleZ(1, Math::PI/2.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(2, rank); + obj->SetObjectParent(2, 1); + m_modelManager->AddModelReference("roller3c.mod", false, rank); + obj->SetPosition(2, Math::Vector(4.5f, 0.0f, 0.0f)); + obj->SetAngleZ(2, 0.0f); + + obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 6.5f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(0.0f, 8.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(0.0f, 15.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(0.0f, 24.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 7.0f); + + obj->GetCharacter()->posPower = Math::Vector(5.0f, 3.0f, 0.0f); + + obj->CreateShadowCircle(6.0f, 1.0f); + obj->SetShowLimitRadius(Gfx::LTNG_PROTECTION_RADIUS); + } + + if ( type == OBJECT_NUCLEAR ) + { + m_modelManager->AddModelReference("nuclear1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("nuclear2.mod", false, rank); + obj->SetPosition(1, Math::Vector(20.0f, 10.0f, 0.0f)); + obj->SetAngleZ(1, 135.0f*Math::PI/180.0f); + + obj->CreateCrashSphere(Math::Vector( 0.0f, 0.0f, 0.0f), 19.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 24.0f, 0.0f), 15.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(22.0f, 1.0f, 0.0f), 1.5f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 17.0f, 0.0f), 26.0f); + + obj->GetCharacter()->posPower = Math::Vector(22.0f, 3.0f, 0.0f); + + obj->CreateShadowCircle(21.0f, 1.0f); + } + + if ( type == OBJECT_PARA ) + { + m_modelManager->AddModelReference("para.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + m_terrain->AddBuildingLevel(pos, 16.0f, 18.0f, 1.0f, 0.5f); + + obj->CreateCrashSphere(Math::Vector( 13.0f, 3.0f, 13.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 11.0f, 15.0f, 11.0f), 2.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-13.0f, 3.0f, 13.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-11.0f, 15.0f, -11.0f), 2.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 13.0f, 3.0f, -13.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 11.0f, 15.0f, -11.0f), 2.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-13.0f, 3.0f, -13.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-11.0f, 15.0f, -11.0f), 2.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 26.0f, 0.0f), 9.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 54.0f, 0.0f), 14.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 20.0f); + + obj->CreateShadowCircle(21.0f, 1.0f); + obj->SetShowLimitRadius(Gfx::LTNG_PROTECTION_RADIUS); + } + + if ( type == OBJECT_SAFE ) + { + m_modelManager->AddModelReference("safe1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("safe2.mod", false, rank); + obj->SetZoom(1, 1.05f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(2, rank); + obj->SetObjectParent(2, 0); + m_modelManager->AddModelReference("safe3.mod", false, rank); + obj->SetZoom(2, 1.05f); + + m_terrain->AddBuildingLevel(pos, 18.0f, 20.0f, 1.0f, 0.5f); + + obj->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 13.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 1.0f, 0.0f), 13.0f); + + obj->CreateShadowCircle(23.0f, 1.0f); + } + + if ( type == OBJECT_HUSTON ) + { + m_modelManager->AddModelReference("huston1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("huston2.mod", false, rank); + obj->SetPosition(1, Math::Vector(0.0f, 39.0f, 30.0f)); + obj->SetAngleY(1, -Math::PI/2.0f); + obj->SetZoom(1, 3.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(2, rank); + obj->SetObjectParent(2, 1); + m_modelManager->AddModelReference("huston3.mod", false, rank); + obj->SetPosition(2, Math::Vector(0.0f, 4.5f, 1.9f)); + + obj->CreateCrashSphere(Math::Vector( 15.0f, 6.0f, -53.0f), 16.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-15.0f, 6.0f, -53.0f), 16.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 15.0f, 6.0f, -26.0f), 16.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-15.0f, 6.0f, -26.0f), 16.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 15.0f, 6.0f, 0.0f), 16.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-15.0f, 6.0f, 0.0f), 16.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 15.0f, 6.0f, 26.0f), 16.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-15.0f, 6.0f, 26.0f), 16.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 15.0f, 6.0f, 53.0f), 16.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-15.0f, 6.0f, 53.0f), 16.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 27.0f, 30.0f), 12.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 45.0f, 30.0f), 14.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 26.0f, 4.0f, -61.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-26.0f, 4.0f, -61.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 26.0f, 4.0f, 61.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-26.0f, 4.0f, 61.0f), 5.0f, SOUND_BOUMm, 0.45f); + } + + if ( type == OBJECT_TARGET1 ) + { + m_modelManager->AddModelReference("target1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, 1.5f); + obj->SetFloorHeight(0.0f); + + obj->CreateCrashSphere(Math::Vector( 0.0f, 50.0f+14.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -7.0f, 50.0f+12.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 7.0f, 50.0f+12.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-12.0f, 50.0f+ 7.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 12.0f, 50.0f+ 7.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-14.0f, 50.0f+ 0.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 14.0f, 50.0f+ 0.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-12.0f, 50.0f- 7.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 12.0f, 50.0f- 7.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -7.0f, 50.0f-12.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 7.0f, 50.0f-12.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 50.0f-14.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + + obj->CreateCrashSphere(Math::Vector(0.0f, 30.0f, 0.0f), 2.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(0.0f, 24.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(0.0f, 16.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(0.0f, 4.0f, 0.0f), 8.0f, SOUND_BOUMm, 0.45f); + + obj->CreateShadowCircle(15.0f, 1.0f); + } + + if ( type == OBJECT_TARGET2 ) + { + m_modelManager->AddModelReference("target2.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + height += 50.0f*1.5f; + } + + if ( type == OBJECT_NEST ) + { + m_modelManager->AddModelReference("nest.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + m_terrain->AddBuildingLevel(pos, 3.0f, 5.0f, 1.0f, 0.5f); + + obj->CreateShadowCircle(4.0f, 1.0f); + } + + if ( type == OBJECT_START ) + { + m_modelManager->AddModelReference("start.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f); + } + + if ( type == OBJECT_END ) + { + m_modelManager->AddModelReference("end.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f); + } + +#if 0 + if ( power > 0.0f ) // creates a battery? + { + CObject* pPower; + + pPower = new CObject(); + pPower->obj->SetType(power<=1.0f?OBJECT_POWER:OBJECT_ATOMIC); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + pPower->obj->SetObjectRank(0, rank); + + if ( power <= 1.0f ) m_modelManager->AddModelReference("power.mod", false, rank); + else m_modelManager->AddModelReference("atomic.mod", false, rank); + + pPower->obj->SetPosition(0, GetCharacter()->posPower); + pPower->obj->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + pPower->obj->SetGlobalSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.5f); + + pPower->SetTruck(obj); + SetPower(pPower); + + if ( power <= 1.0f ) pPower->obj->SetEnergy(power); + else pPower->obj->SetEnergy(power/100.0f); + } +#endif + + pos = obj->GetPosition(0); + pos.y += height; + obj->SetPosition(0, pos); // to display the shadows immediately + + AddObjectAuto(obj); + m_engine->LoadAllTextures(); + + return obj; +} + +// Creates a small resource set on the ground. + +CObject* CObjectFactory::CreateResource(Math::Vector pos, float angle, ObjectType type, float power) +{ + CObject* obj = new CObject(); + + obj->SetType(type); + + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object + obj->SetObjectRank(0, rank); + obj->SetEnergy(power); + + std::string name; + if ( type == OBJECT_STONE ) name = "stone.mod"; + if ( type == OBJECT_URANIUM ) name = "uranium.mod"; + if ( type == OBJECT_METAL ) name = "metal.mod"; + if ( type == OBJECT_POWER ) name = "power.mod"; + if ( type == OBJECT_ATOMIC ) name = "atomic.mod"; + if ( type == OBJECT_BULLET ) name = "bullet.mod"; + if ( type == OBJECT_BBOX ) name = "bbox.mod"; + if ( type == OBJECT_KEYa ) name = "keya.mod"; + if ( type == OBJECT_KEYb ) name = "keyb.mod"; + if ( type == OBJECT_KEYc ) name = "keyc.mod"; + if ( type == OBJECT_KEYd ) name = "keyd.mod"; + if ( type == OBJECT_TNT ) name = "tnt.mod"; + if ( type == OBJECT_SCRAP1 ) name = "scrap1.mod"; + if ( type == OBJECT_SCRAP2 ) name = "scrap2.mod"; + if ( type == OBJECT_SCRAP3 ) name = "scrap3.mod"; + if ( type == OBJECT_SCRAP4 ) name = "scrap4.mod"; + if ( type == OBJECT_SCRAP5 ) name = "scrap5.mod"; + if ( type == OBJECT_BOMB ) name = "bomb.mod"; + if ( type == OBJECT_WAYPOINT ) name = "waypoint.mod"; + if ( type == OBJECT_SHOW ) name = "show.mod"; + if ( type == OBJECT_WINFIRE ) name = "winfire.mod"; + if ( type == OBJECT_BAG ) name = "bag.mod"; + if ( type == OBJECT_MARKSTONE ) name = "cross1.mod"; + if ( type == OBJECT_MARKURANIUM ) name = "cross3.mod"; + if ( type == OBJECT_MARKPOWER ) name = "cross2.mod"; + if ( type == OBJECT_MARKKEYa ) name = "crossa.mod"; + if ( type == OBJECT_MARKKEYb ) name = "crossb.mod"; + if ( type == OBJECT_MARKKEYc ) name = "crossc.mod"; + if ( type == OBJECT_MARKKEYd ) name = "crossd.mod"; + if ( type == OBJECT_EGG ) name = "egg.mod"; + + if (type == OBJECT_POWER || type == OBJECT_ATOMIC) + { + m_modelManager->AddModelCopy(name, false, rank); + } + else + { + m_modelManager->AddModelReference(name, false, rank); + } + + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + if ( type == OBJECT_SHOW ) // remains in the air? + { + return obj; + } + + float radius = 1.5f; + float height = 0.0f; + + if ( type == OBJECT_MARKSTONE || + type == OBJECT_MARKURANIUM || + type == OBJECT_MARKKEYa || + type == OBJECT_MARKKEYb || + type == OBJECT_MARKKEYc || + type == OBJECT_MARKKEYd || + type == OBJECT_MARKPOWER || + type == OBJECT_WAYPOINT ) + { + } + else if ( type == OBJECT_EGG ) + { + obj->CreateCrashSphere(Math::Vector(-1.0f, 2.8f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 10.0f); + radius = 3.0f; + } + else if ( type == OBJECT_BOMB ) + { + obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 3.0f); + radius = 3.0f; + } + else if ( type == OBJECT_BAG ) + { + obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f); + obj->SetZoom(0, 1.5f); + radius = 5.0f; + height = -1.4f; + } + else + { + obj->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.5f); + } + obj->CreateShadowCircle(radius, 1.0f); + + obj->SetFloorHeight(0.0f); + AddObjectAuto(obj); + m_engine->LoadAllTextures(); + obj->FloorAdjust(); + + pos = obj->GetPosition(0); + pos.y += height; + obj->SetPosition(0, pos); // to display the shadows immediately + + return obj; +} + +// Creates a flag placed on the ground. + +CObject* CObjectFactory::CreateFlag(Math::Vector pos, float angle, ObjectType type) +{ + CObject* obj = new CObject(); + + obj->SetType(type); + + std::string name; + + name = ""; + if ( type == OBJECT_FLAGb ) name = "flag1b.mod"; + if ( type == OBJECT_FLAGr ) name = "flag1r.mod"; + if ( type == OBJECT_FLAGg ) name = "flag1g.mod"; + if ( type == OBJECT_FLAGy ) name = "flag1y.mod"; + if ( type == OBJECT_FLAGv ) name = "flag1v.mod"; + + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference(name, false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + name = ""; + if ( type == OBJECT_FLAGb ) name = "flag2b.mod"; + if ( type == OBJECT_FLAGr ) name = "flag2r.mod"; + if ( type == OBJECT_FLAGg ) name = "flag2g.mod"; + if ( type == OBJECT_FLAGy ) name = "flag2y.mod"; + if ( type == OBJECT_FLAGv ) name = "flag2v.mod"; + + for (int i=0 ; i<4 ; i++ ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1+i, rank); + obj->SetObjectParent(1+i, i); + m_modelManager->AddModelReference(name, false, rank); + if ( i == 0 ) obj->SetPosition(1+i, Math::Vector(0.15f, 5.0f, 0.0f)); + else obj->SetPosition(1+i, Math::Vector(0.79f, 0.0f, 0.0f)); + } + + obj->SetJotlerSphere(Math::Vector(0.0f, 4.0f, 0.0f), 1.0f); + obj->CreateShadowCircle(2.0f, 0.3f); + + obj->SetFloorHeight(0.0f); + AddObjectAuto(obj); + m_engine->LoadAllTextures(); + obj->FloorAdjust(); + + pos = obj->GetPosition(0); + obj->SetPosition(0, pos); // to display the shadows immediately + + return obj; +} + +// Creates a barrier placed on the ground. + +CObject* CObjectFactory::CreateBarrier(Math::Vector pos, float angle, float height, ObjectType type) +{ + CObject* obj = new CObject(); + + obj->SetType(type); + + if ( type == OBJECT_BARRIER0 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("barrier0.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector( 3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + + obj->CreateShadowCircle(6.0f, 0.5f, Gfx::ENG_SHADOW_WORM); + } + + if ( type == OBJECT_BARRIER1 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("barrier1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector( 8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + + obj->CreateShadowCircle(12.0f, 0.5f, Gfx::ENG_SHADOW_WORM); + } + + if ( type == OBJECT_BARRIER2 ) // cardboard? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("barrier2.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector( 8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + + obj->CreateShadowCircle(12.0f, 0.8f, Gfx::ENG_SHADOW_WORM); + } + + if ( type == OBJECT_BARRIER3 ) // match + straw? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("barrier3.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector( 8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f); + + obj->CreateShadowCircle(10.0f, 0.5f, Gfx::ENG_SHADOW_WORM); + } + + pos = obj->GetPosition(0); + obj->SetPosition(0, pos); // to display the shadows immediately + + obj->SetFloorHeight(0.0f); + AddObjectAuto(obj); + obj->FloorAdjust(); + + pos = obj->GetPosition(0); + pos.y += height; + obj->SetPosition(0, pos); + + return obj; +} + +// Creates a plant placed on the ground. + +CObject* CObjectFactory::CreatePlant(Math::Vector pos, float angle, float height, ObjectType type) +{ + CObject* obj = new CObject(); + + obj->SetType(type); + + if ( type == OBJECT_PLANT0 || + type == OBJECT_PLANT1 || + type == OBJECT_PLANT2 || + type == OBJECT_PLANT3 || + type == OBJECT_PLANT4 ) // standard? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + if ( type == OBJECT_PLANT0 ) m_modelManager->AddModelReference("plant0.mod", false, rank); + if ( type == OBJECT_PLANT1 ) m_modelManager->AddModelReference("plant1.mod", false, rank); + if ( type == OBJECT_PLANT2 ) m_modelManager->AddModelReference("plant2.mod", false, rank); + if ( type == OBJECT_PLANT3 ) m_modelManager->AddModelReference("plant3.mod", false, rank); + if ( type == OBJECT_PLANT4 ) m_modelManager->AddModelReference("plant4.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + height -= 2.0f; + + obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); + obj->SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f); + obj->SetJotlerSphere(Math::Vector(0.0f, 0.0f, 0.0f), 8.0f); + + obj->CreateShadowCircle(8.0f, 0.5f); + } + + if ( type == OBJECT_PLANT5 || + type == OBJECT_PLANT6 || + type == OBJECT_PLANT7 ) // clover? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + if ( type == OBJECT_PLANT5 ) m_modelManager->AddModelReference("plant5.mod", false, rank); + if ( type == OBJECT_PLANT6 ) m_modelManager->AddModelReference("plant6.mod", false, rank); + if ( type == OBJECT_PLANT7 ) m_modelManager->AddModelReference("plant7.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + +//? obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 3.0f, SOUND_BOUM, 0.10f); + obj->SetJotlerSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f); + + obj->CreateShadowCircle(5.0f, 0.3f); + } + + if ( type == OBJECT_PLANT8 || + type == OBJECT_PLANT9 ) // squash? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + if ( type == OBJECT_PLANT8 ) m_modelManager->AddModelReference("plant8.mod", false, rank); + if ( type == OBJECT_PLANT9 ) m_modelManager->AddModelReference("plant9.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); + obj->CreateCrashSphere(Math::Vector(0.0f, 10.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); + + obj->CreateShadowCircle(10.0f, 0.5f); + } + + if ( type == OBJECT_PLANT10 || + type == OBJECT_PLANT11 || + type == OBJECT_PLANT12 || + type == OBJECT_PLANT13 || + type == OBJECT_PLANT14 ) // succulent? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + if ( type == OBJECT_PLANT10 ) m_modelManager->AddModelReference("plant10.mod", false, rank); + if ( type == OBJECT_PLANT11 ) m_modelManager->AddModelReference("plant11.mod", false, rank); + if ( type == OBJECT_PLANT12 ) m_modelManager->AddModelReference("plant12.mod", false, rank); + if ( type == OBJECT_PLANT13 ) m_modelManager->AddModelReference("plant13.mod", false, rank); + if ( type == OBJECT_PLANT14 ) m_modelManager->AddModelReference("plant14.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector(0.0f, 12.0f, 0.0f), 5.0f, SOUND_BOUM, 0.10f); + obj->SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 6.0f); + obj->SetJotlerSphere(Math::Vector(0.0f, 4.0f, 0.0f), 8.0f); + + obj->CreateShadowCircle(8.0f, 0.3f); + } + + if ( type == OBJECT_PLANT15 || + type == OBJECT_PLANT16 || + type == OBJECT_PLANT17 || + type == OBJECT_PLANT18 || + type == OBJECT_PLANT19 ) // fern? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + if ( type == OBJECT_PLANT15 ) m_modelManager->AddModelReference("plant15.mod", false, rank); + if ( type == OBJECT_PLANT16 ) m_modelManager->AddModelReference("plant16.mod", false, rank); + if ( type == OBJECT_PLANT17 ) m_modelManager->AddModelReference("plant17.mod", false, rank); + if ( type == OBJECT_PLANT18 ) m_modelManager->AddModelReference("plant18.mod", false, rank); + if ( type == OBJECT_PLANT19 ) m_modelManager->AddModelReference("plant19.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + if ( type != OBJECT_PLANT19 ) + { + obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); + obj->SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f); + } + obj->SetJotlerSphere(Math::Vector(0.0f, 0.0f, 0.0f), 8.0f); + + obj->CreateShadowCircle(8.0f, 0.5f); + } + + if ( type == OBJECT_TREE0 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("tree0.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 2.0f), 3.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector(-1.0f, 10.0f, 1.0f), 2.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 17.0f, 0.0f), 2.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector( 1.0f, 27.0f, 0.0f), 2.0f, SOUND_BOUMs, 0.20f); + + obj->CreateShadowCircle(8.0f, 0.5f); + } + + if ( type == OBJECT_TREE1 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("tree1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 2.0f), 3.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector(-2.0f, 11.0f, 1.0f), 2.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector(-2.0f, 19.0f, 2.0f), 2.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector( 2.0f, 26.0f, 0.0f), 2.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector( 2.0f, 34.0f,-2.0f), 2.0f, SOUND_BOUMs, 0.20f); + + obj->CreateShadowCircle(8.0f, 0.5f); + } + + if ( type == OBJECT_TREE2 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("tree2.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 1.0f), 3.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector(-2.0f, 10.0f, 1.0f), 2.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector(-2.0f, 19.0f, 2.0f), 2.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector( 2.0f, 25.0f, 0.0f), 2.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector( 3.0f, 32.0f,-2.0f), 2.0f, SOUND_BOUMs, 0.20f); + + obj->CreateShadowCircle(8.0f, 0.5f); + } + + if ( type == OBJECT_TREE3 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("tree3.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector(-2.0f, 3.0f, 2.0f), 3.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector(-3.0f, 9.0f, 1.0f), 2.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 18.0f, 0.0f), 2.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 27.0f, 7.0f), 2.0f, SOUND_BOUMs, 0.20f); + + obj->CreateShadowCircle(8.0f, 0.5f); + } + + if ( type == OBJECT_TREE4 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("tree4.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector(0.0f, 10.0f, 0.0f), 10.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector(0.0f, 21.0f, 0.0f), 8.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector(0.0f, 32.0f, 0.0f), 7.0f, SOUND_BOUMs, 0.20f); + + obj->CreateShadowCircle(8.0f, 0.5f); + } + + if ( type == OBJECT_TREE5 ) // giant tree (for the world "teen") + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("tree5.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector( 0.0f, 5.0f,-10.0f), 25.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector(-65.0f, 5.0f, 65.0f), 20.0f, SOUND_BOUMs, 0.20f); + obj->CreateCrashSphere(Math::Vector( 38.0f, 5.0f, 21.0f), 18.0f, SOUND_BOUMs, 0.20f); + + obj->CreateShadowCircle(50.0f, 0.5f); + } + + pos = obj->GetPosition(0); + obj->SetPosition(0, pos); // to display the shadows immediately + + obj->SetFloorHeight(0.0f); + AddObjectAuto(obj); + + pos = obj->GetPosition(0); + pos.y += height; + obj->SetPosition(0, pos); + + return obj; +} + +// Creates a mushroom placed on the ground. + +CObject* CObjectFactory::CreateMushroom(Math::Vector pos, float angle, float height, ObjectType type) +{ + CObject* obj = new CObject(); + + obj->SetType(type); + + if ( type == OBJECT_MUSHROOM1 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("mush1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector(0.0f, 4.0f, 0.0f), 3.0f, SOUND_BOUM, 0.10f); + obj->SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 5.5f); + obj->SetJotlerSphere(Math::Vector(0.0f, 3.0f, 0.0f), 5.5f); + + obj->CreateShadowCircle(6.0f, 0.5f); + } + + if ( type == OBJECT_MUSHROOM2 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("mush2.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector(0.0f, 5.0f, 0.0f), 3.0f, SOUND_BOUM, 0.10f); + obj->SetGlobalSphere(Math::Vector(0.0f, 4.0f, 0.0f), 5.5f); + obj->SetJotlerSphere(Math::Vector(0.0f, 4.0f, 0.0f), 5.5f); + + obj->CreateShadowCircle(5.0f, 0.5f); + } + + pos = obj->GetPosition(0); + obj->SetPosition(0, pos); // to display the shadows immediately + + obj->SetFloorHeight(0.0f); + AddObjectAuto(obj); + + pos = obj->GetPosition(0); + pos.y += height; + obj->SetPosition(0, pos); + + return obj; +} + +// Creates a toy placed on the ground. + +CObject* CObjectFactory::CreateTeen(Math::Vector pos, float angle, float zoom, float height, ObjectType type, int option) +{ + CObject* obj = new CObject(); + + obj->SetType(type); + obj->SetOption(option); + + float fShadow = Math::Norm(1.0f-height/10.0f); + bool floorAdjust = true; + + if ( type == OBJECT_TEEN0 ) // orange pencil lg=10 + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen0.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector( 5.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 2.5f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-2.5f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-5.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + + obj->CreateShadowCircle(5.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM); + } + + if ( type == OBJECT_TEEN1 ) // blue pencil lg=14 + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector( 6.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 4.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 2.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-2.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-4.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-6.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + + obj->CreateShadowCircle(6.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM); + } + + if ( type == OBJECT_TEEN2 ) // red pencil lg=16 + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen2.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector( 7.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 4.7f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 2.3f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-2.3f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-4.7f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-7.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + + obj->CreateShadowCircle(6.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM); + } + + if ( type == OBJECT_TEEN3 ) // jar with pencils + { + int rank = m_engine->CreateObject(); +//? m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_METAL); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen3.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 4.0f, 0.0f), 4.0f); + obj->CreateShadowCircle(6.0f, 0.5f*fShadow); + } + + if ( type == OBJECT_TEEN4 ) // scissors + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen4.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-9.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-6.0f, 1.0f, 0.0f), 1.1f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-3.0f, 1.0f, 0.0f), 1.2f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 1.0f, 0.0f), 1.3f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 5.1f, 1.0f,-1.3f), 2.6f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 8.0f, 1.0f, 2.2f), 2.3f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 9.4f, 1.0f,-2.0f), 2.0f, SOUND_BOUMm, 0.45f); + + obj->CreateShadowCircle(10.0f, 0.5f*fShadow, Gfx::ENG_SHADOW_WORM); + } + + if ( type == OBJECT_TEEN5 ) // CD + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen5.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + obj->SetFloorHeight(0.0f); + floorAdjust = false; + + m_terrain->AddBuildingLevel(pos, 5.9f, 6.1f, 0.2f, 0.5f); + obj->CreateShadowCircle(8.0f, 0.2f*fShadow); + } + + if ( type == OBJECT_TEEN6 ) // book 1 + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen6.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-5.0f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 4.5f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); + + obj->CreateShadowCircle(20.0f, 0.2f*fShadow); + } + + if ( type == OBJECT_TEEN7 ) // book 2 + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen7.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-5.0f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 4.5f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); + + obj->CreateShadowCircle(20.0f, 0.2f*fShadow); + } + + if ( type == OBJECT_TEEN8 ) // a stack of books 1 + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen8.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-5.0f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 4.5f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); + + obj->SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 12.0f); + obj->CreateShadowCircle(20.0f, 0.2f*fShadow); + } + + if ( type == OBJECT_TEEN9 ) // a stack of books 2 + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen9.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 7.5f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-5.0f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 4.5f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-5.0f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 4.5f, 3.0f,-7.5f), 5.0f, SOUND_BOUMm, 0.45f); + + obj->SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 12.0f); + obj->CreateShadowCircle(20.0f, 0.2f*fShadow); + } + + if ( type == OBJECT_TEEN10 ) // bookcase + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen10.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-26.0f, 3.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-15.0f, 3.0f,-4.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-15.0f, 3.0f, 5.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -4.0f, 3.0f,-4.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -4.0f, 3.0f, 5.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 6.0f, 3.0f,-4.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 6.0f, 3.0f, 4.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 14.0f, 3.0f,-3.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 14.0f, 3.0f, 2.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 24.0f, 3.0f, 5.0f), 6.0f, SOUND_BOUMm, 0.45f); + + obj->SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 20.0f); + obj->CreateShadowCircle(40.0f, 0.2f*fShadow); + } + + if ( type == OBJECT_TEEN11 ) // lamp + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen11.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + obj->SetZoom(0, zoom); + + Math::Matrix* mat = obj->GetWorldMatrix(0); + pos = Math::Transform(*mat, Math::Vector(-56.0f, 22.0f, 0.0f)); + m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), Math::Point(20.0f, 20.0f), Gfx::PARTISELY, 1.0f, 0.0f, 0.0f); + + pos = Math::Transform(*mat, Math::Vector(-65.0f, 40.0f, 0.0f)); + Gfx::Color color; + color.r = 4.0f; + color.g = 2.0f; + color.b = 0.0f; // yellow-orange + color.a = 0.0f; + m_main->CreateSpot(pos, color); + } + + if ( type == OBJECT_TEEN12 ) // coke + { + int rank = m_engine->CreateObject(); +//? m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_METAL); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen12.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 9.0f, 0.0f), 5.0f); + obj->CreateShadowCircle(4.5f, 1.0f*fShadow); + } + + if ( type == OBJECT_TEEN13 ) // cardboard farm + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen13.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-10.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 10.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 10.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 10.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); + + obj->SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 15.0f); + obj->CreateShadowCircle(20.0f, 1.0f*fShadow); + } + + if ( type == OBJECT_TEEN14 ) // open box + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen14.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-10.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 10.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 10.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 10.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); + + obj->SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 15.0f); + obj->CreateShadowCircle(20.0f, 1.0f*fShadow); + } + + if ( type == OBJECT_TEEN15 ) // stack of cartons + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen15.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-10.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 10.0f, 4.0f,-7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 10.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 10.0f, 4.0f, 7.0f), 5.0f, SOUND_BOUMm, 0.45f); + + obj->SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 15.0f); + obj->CreateShadowCircle(20.0f, 1.0f*fShadow); + } + + if ( type == OBJECT_TEEN16 ) // watering can + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen16.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-8.0f, 4.0f, 0.0f), 12.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 8.0f, 4.0f, 0.0f), 12.0f, SOUND_BOUMm, 0.45f); + + obj->SetGlobalSphere(Math::Vector(0.0f, 13.0f, 0.0f), 20.0f); + obj->CreateShadowCircle(18.0f, 1.0f*fShadow); + } + + if ( type == OBJECT_TEEN17 ) // wheel | + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen17.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector( 0.0f, 31.0f, 0.0f), 31.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 31.0f, 0.0f), 31.0f); + obj->CreateShadowCircle(24.0f, 0.5f*fShadow); + } + + if ( type == OBJECT_TEEN18 ) // wheel / + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen18.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector( 0.0f, 31.0f, 0.0f), 31.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 31.0f, 0.0f), 31.0f); + obj->CreateShadowCircle(24.0f, 0.5f*fShadow); + } + + if ( type == OBJECT_TEEN19 ) // wheel = + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen19.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector( 0.0f, 10.0f, 0.0f), 32.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 32.0f); + obj->CreateShadowCircle(33.0f, 1.0f*fShadow); + } + + if ( type == OBJECT_TEEN20 ) // wall with shelf + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen20.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-175.0f, 0.0f, -5.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-175.0f, 0.0f, -35.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -55.0f, 0.0f, -5.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -55.0f, 0.0f, -35.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -37.0f, 0.0f, -5.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -37.0f, 0.0f, -35.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 83.0f, 0.0f, -5.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 83.0f, 0.0f, -35.0f), 4.0f, SOUND_BOUMm, 0.45f); + } + + if ( type == OBJECT_TEEN21 ) // wall with window + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen21.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + } + + if ( type == OBJECT_TEEN22 ) // wall with door and shelf + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen22.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-135.0f, 0.0f, -5.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-135.0f, 0.0f, -35.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -15.0f, 0.0f, -5.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -15.0f, 0.0f, -35.0f), 4.0f, SOUND_BOUMm, 0.45f); + } + + if ( type == OBJECT_TEEN23 ) // skateboard on wheels + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen23.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + if ( option == 1 ) // passage under the prohibited skateboard? + { + obj->CreateCrashSphere(Math::Vector(-10.0f, 2.0f, 0.0f), 11.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 10.0f, 2.0f, 0.0f), 11.0f, SOUND_BOUMm, 0.45f); + } + + obj->CreateCrashSphere(Math::Vector(-23.0f, 2.0f, 7.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-23.0f, 2.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-23.0f, 2.0f,-7.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 23.0f, 2.0f, 7.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 23.0f, 2.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 23.0f, 2.0f,-7.0f), 3.0f, SOUND_BOUMm, 0.45f); + + obj->CreateShadowCircle(35.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM); + } + + if ( type == OBJECT_TEEN24 ) // skate / + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen24.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-12.0f, 0.0f, -3.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-12.0f, 0.0f, 3.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateShadowCircle(20.0f, 0.2f*fShadow); + } + + if ( type == OBJECT_TEEN25 ) // skate / + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen25.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-12.0f, 0.0f, -3.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-12.0f, 0.0f, 3.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateShadowCircle(20.0f, 0.2f*fShadow); + } + + if ( type == OBJECT_TEEN26 ) // ceiling lamp + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen26.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + obj->SetFloorHeight(0.0f); + + Math::Matrix* mat = obj->GetWorldMatrix(0); + pos = Math::Transform(*mat, Math::Vector(0.0f, 50.0f, 0.0f)); + m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), Math::Point(100.0f, 100.0f), Gfx::PARTISELY, 1.0f, 0.0f, 0.0f); + + pos = Math::Transform(*mat, Math::Vector(0.0f, 50.0f, 0.0f)); + Gfx::Color color; + color.r = 4.0f; + color.g = 2.0f; + color.b = 0.0f; // yellow-orange + color.a = 0.0f; + m_main->CreateSpot(pos, color); + } + + if ( type == OBJECT_TEEN27 ) // large plant? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen27.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); + obj->CreateShadowCircle(40.0f, 0.5f); + } + + if ( type == OBJECT_TEEN28 ) // bottle? + { + int rank = m_engine->CreateObject(); +//? m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_METAL); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen28.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 5.0f, SOUND_BOUM, 0.10f); + obj->CreateShadowCircle(7.0f, 0.6f*fShadow); + } + + if ( type == OBJECT_TEEN29 ) // bridge? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen29.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + floorAdjust = false; + } + + if ( type == OBJECT_TEEN30 ) // jump? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen30.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(0.0f, 4.0f, 0.0f), 15.0f, SOUND_BOUM, 0.10f); + obj->SetGlobalSphere(Math::Vector(0.0f, 15.0f, 0.0f), 17.0f); + obj->CreateShadowCircle(20.0f, 1.0f*fShadow); + } + + if ( type == OBJECT_TEEN31 ) // basket? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen31.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-10.0f, 2.0f, 0.0f), 5.0f, SOUND_BOUM, 0.10f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 2.0f, 0.0f), 6.0f, SOUND_BOUM, 0.10f); + obj->CreateCrashSphere(Math::Vector( 9.0f, 4.0f, 1.0f), 6.0f, SOUND_BOUM, 0.10f); + + obj->SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 10.0f); + obj->CreateShadowCircle(16.0f, 0.6f*fShadow); + } + + if ( type == OBJECT_TEEN32 ) // chair? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen32.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector( 17.5f, 1.0f, 17.5f), 3.5f, SOUND_BOUM, 0.10f); + obj->CreateCrashSphere(Math::Vector( 17.5f, 1.0f, -17.5f), 3.5f, SOUND_BOUM, 0.10f); + obj->CreateCrashSphere(Math::Vector(-17.5f, 1.0f, 17.5f), 3.5f, SOUND_BOUM, 0.10f); + obj->CreateCrashSphere(Math::Vector(-17.5f, 1.0f, -17.5f), 3.5f, SOUND_BOUM, 0.10f); + obj->SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 26.0f); + obj->CreateShadowCircle(35.0f, 0.3f*fShadow); + } + + if ( type == OBJECT_TEEN33 ) // panel? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen33.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); + obj->CreateShadowCircle(10.0f, 0.3f*fShadow); + } + + if ( type == OBJECT_TEEN34 ) // stone? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen34.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); + obj->CreateShadowCircle(3.0f, 1.0f*fShadow); + } + + if ( type == OBJECT_TEEN35 ) // pipe? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen35.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(-40.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f); + obj->CreateCrashSphere(Math::Vector(-20.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f); + obj->CreateCrashSphere(Math::Vector( 20.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f); + obj->CreateCrashSphere(Math::Vector( 40.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f); + obj->CreateShadowCircle(40.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM); + } + + if ( type == OBJECT_TEEN36 ) // trunk? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen36.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + floorAdjust = false; + } + + if ( type == OBJECT_TEEN37 ) // boat? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen37.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + floorAdjust = false; + } + + if ( type == OBJECT_TEEN38 ) // fan? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen38a.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("teen38b.mod", false, rank); // engine + obj->SetPosition(1, Math::Vector(0.0f, 30.0f, 0.0f)); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(2, rank); + obj->SetObjectParent(2, 1); + m_modelManager->AddModelReference("teen38c.mod", false, rank); // propeller + obj->SetPosition(2, Math::Vector(0.0f, 0.0f, 0.0f)); + + obj->CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f); + obj->SetGlobalSphere(Math::Vector(0.0f, 2.0f, 0.0f), 10.0f); + obj->CreateShadowCircle(15.0f, 0.5f*fShadow); + } + + if ( type == OBJECT_TEEN39 ) // potted plant? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen39.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 8.5f, SOUND_BOUM, 0.10f); + obj->SetGlobalSphere(Math::Vector(0.0f, 2.0f, 0.0f), 8.5f); + obj->CreateShadowCircle(10.0f, 1.0f*fShadow); + } + + if ( type == OBJECT_TEEN40 ) // balloon? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen40.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(0.0f, 5.0f, 0.0f), 11.0f, SOUND_BOUM, 0.10f); + obj->SetGlobalSphere(Math::Vector(0.0f, 14.0f, 0.0f), 15.0f); + obj->CreateShadowCircle(15.0f, 0.7f*fShadow); + } + + if ( type == OBJECT_TEEN41 ) // fence? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen41.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + } + + if ( type == OBJECT_TEEN42 ) // clover? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen42.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 2.0f, SOUND_BOUM, 0.10f); + obj->CreateShadowCircle(15.0f, 0.4f*fShadow); + } + + if ( type == OBJECT_TEEN43 ) // clover? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen43.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 2.0f, SOUND_BOUM, 0.10f); + obj->CreateShadowCircle(15.0f, 0.4f*fShadow); + } + + if ( type == OBJECT_TEEN44 ) // car? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("teen44.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, zoom); + + obj->CreateCrashSphere(Math::Vector(0.0f, 10.0f, 0.0f), 55.0f, SOUND_BOUM, 0.10f); + obj->SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 55.0f); + obj->CreateShadowCircle(55.0f, 1.0f*fShadow); + } + + pos = obj->GetPosition(0); + obj->SetPosition(0, pos); // to display the shadows immediately + + if ( floorAdjust ) + { + obj->SetFloorHeight(0.0f); + obj->FloorAdjust(); + } + + AddObjectAuto(obj); + + pos = obj->GetPosition(0); + pos.y += height; + obj->SetPosition(0, pos); + + return obj; +} + +// Creates a crystal placed on the ground. + +CObject* CObjectFactory::CreateQuartz(Math::Vector pos, float angle, float height, ObjectType type) +{ + CObject* obj = new CObject(); + + obj->SetType(type); + + if ( type == OBJECT_QUARTZ0 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("quartz0.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 3.5f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 2.0f, 0.0f), 3.5f); + + obj->CreateShadowCircle(4.0f, 0.5f); + } + if ( type == OBJECT_QUARTZ1 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("quartz1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector(0.0f, 4.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 4.0f, 0.0f), 5.0f); + + obj->CreateShadowCircle(5.0f, 0.5f); + } + if ( type == OBJECT_QUARTZ2 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("quartz2.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector(0.0f, 6.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 6.0f); + + obj->CreateShadowCircle(6.0f, 0.5f); + } + if ( type == OBJECT_QUARTZ3 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("quartz3.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + obj->CreateCrashSphere(Math::Vector(0.0f, 10.0f, 0.0f), 10.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 10.0f); + + obj->CreateShadowCircle(10.0f, 0.5f); + } + + pos = obj->GetPosition(0); + obj->SetPosition(0, pos); // to display the shadows immediately + + obj->SetFloorHeight(0.0f); + AddObjectAuto(obj); + + pos = obj->GetPosition(0); + pos.y += height; + obj->SetPosition(0, pos); + + float radius = 0.0f; + if ( type == OBJECT_QUARTZ0 ) + { + pos.y += 4.0f; + radius = 2.0f; + } + if ( type == OBJECT_QUARTZ1 ) + { + pos.y += 6.0f; + radius = 4.0f; + } + if ( type == OBJECT_QUARTZ2 ) + { + pos.y += 10.0f; + radius = 5.0f; + } + if ( type == OBJECT_QUARTZ3 ) + { + pos.y += 16.0f; + radius = 8.0f; + } + m_particle->CreateParticle(pos, pos, Math::Point(2.0f, 2.0f), Gfx::PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f); + m_particle->CreateParticle(pos, pos, Math::Point(2.0f, 2.0f), Gfx::PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f); + + return obj; +} + +// Creates a root placed on the ground. + +CObject* CObjectFactory::CreateRoot(Math::Vector pos, float angle, float height, ObjectType type) +{ + CObject* obj = new CObject(); + + obj->SetType(type); + + if ( type == OBJECT_ROOT0 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("root0.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, 2.0f); + + obj->CreateCrashSphere(Math::Vector(-5.0f, 1.0f, 0.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 4.0f, 1.0f, 2.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 4.0f, 1.0f, -3.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 2.0f, 5.0f, -1.0f), 1.5f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector(-4.0f, 5.0f, -1.0f), 1.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector(-2.0f, 8.0f, -0.5f), 1.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 10.0f, -0.5f), 1.0f, SOUND_BOUMv, 0.15f); +//? obj->SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 11.0f); + + obj->CreateShadowCircle(16.0f, 0.5f); + } + if ( type == OBJECT_ROOT1 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("root1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, 2.0f); + + obj->CreateCrashSphere(Math::Vector(-4.0f, 1.0f, 1.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 1.0f, 2.0f), 1.5f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 3.0f, 1.0f, -2.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector(-2.0f, 5.0f, 1.0f), 1.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 2.0f, 5.0f, 0.0f), 1.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 8.0f, 1.0f), 1.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 12.0f, 1.0f), 1.0f, SOUND_BOUMv, 0.15f); +//? obj->SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 12.0f); + + obj->CreateShadowCircle(16.0f, 0.5f); + } + if ( type == OBJECT_ROOT2 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("root2.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, 2.0f); + + obj->CreateCrashSphere(Math::Vector(-3.0f, 1.0f, 0.5f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 3.0f, 1.0f, -1.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector(-1.0f, 4.5f, 0.0f), 1.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 3.0f, 7.0f, 1.0f), 1.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 7.0f, -1.0f), 1.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 4.0f, 11.0f, 1.0f), 1.0f, SOUND_BOUMv, 0.15f); +//? obj->SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 10.0f); + + obj->CreateShadowCircle(16.0f, 0.5f); + } + if ( type == OBJECT_ROOT3 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("root3.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, 2.0f); + + obj->CreateCrashSphere(Math::Vector(-4.0f, 1.0f, 1.0f), 3.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 4.0f, 1.0f, -3.0f), 3.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 6.0f, 1.0f, 4.0f), 3.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector(-2.5f, 7.0f, 2.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 4.0f, 7.0f, 2.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 3.0f, 6.0f, -1.0f), 1.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 12.0f, 0.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 1.0f, 16.0f, 0.0f), 1.0f, SOUND_BOUMv, 0.15f); +//? obj->SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 14.0f); + + obj->CreateShadowCircle(22.0f, 0.5f); + } + if ( type == OBJECT_ROOT4 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("root4.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, 2.0f); + + obj->CreateCrashSphere(Math::Vector( -7.0f, 2.0f, 3.0f), 4.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 5.0f, 2.0f, -6.0f), 4.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 6.0f, 2.0f, 6.0f), 3.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector(-11.0f, 1.0f, -2.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 1.0f, 1.0f, -7.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( -4.0f, 10.0f, 3.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 1.0f, 11.0f, 7.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 3.0f, 11.0f, -3.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( -3.0f, 17.0f, 1.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( -3.0f, 23.0f, -1.0f), 2.0f, SOUND_BOUMv, 0.15f); +//? obj->SetGlobalSphere(Math::Vector(0.0f, 12.0f, 0.0f), 20.0f); + + obj->CreateShadowCircle(30.0f, 0.5f); + } + if ( type == OBJECT_ROOT5 ) // gravity root ? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("root4.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, 2.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("root5.mod", false, rank); + obj->SetPosition(1, Math::Vector(-5.0f, 28.0f, -4.0f)); + obj->SetAngleX(1, -30.0f*Math::PI/180.0f); + obj->SetAngleZ(1, 20.0f*Math::PI/180.0f); + + obj->CreateCrashSphere(Math::Vector( -7.0f, 2.0f, 3.0f), 4.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 5.0f, 2.0f, -6.0f), 4.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 6.0f, 2.0f, 6.0f), 3.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector(-11.0f, 1.0f, -2.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 1.0f, 1.0f, -7.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( -4.0f, 10.0f, 3.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 1.0f, 11.0f, 7.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( 3.0f, 11.0f, -3.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( -3.0f, 17.0f, 1.0f), 2.0f, SOUND_BOUMv, 0.15f); + obj->CreateCrashSphere(Math::Vector( -3.0f, 23.0f, -1.0f), 2.0f, SOUND_BOUMv, 0.15f); +//? obj->SetGlobalSphere(Math::Vector(0.0f, 12.0f, 0.0f), 20.0f); + + obj->CreateShadowCircle(30.0f, 0.5f); + } + + pos = obj->GetPosition(0); + obj->SetPosition(0, pos); // to display the shadows immediately + + obj->SetFloorHeight(0.0f); + AddObjectAuto(obj); + + pos = obj->GetPosition(0); + pos.y += height; + obj->SetPosition(0, pos); + + return obj; +} + +// Creates a small home. + +CObject* CObjectFactory::CreateHome(Math::Vector pos, float angle, float height, ObjectType type) +{ + CObject* obj = new CObject(); + + obj->SetType(type); + + if ( type == OBJECT_HOME1 ) + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("home1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, 1.3f); + + obj->CreateCrashSphere(Math::Vector(0.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUMs, 0.25f); +//? obj->SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 11.0f); + obj->CreateShadowCircle(16.0f, 0.5f); + } + + pos = obj->GetPosition(0); + obj->SetPosition(0, pos); // to display the shadows immediately + + obj->SetFloorHeight(0.0f); + AddObjectAuto(obj); + + pos = obj->GetPosition(0); + pos.y += height; + obj->SetPosition(0, pos); + + return obj; +} + +// Creates ruin placed on the ground. + +CObject* CObjectFactory::CreateRuin(Math::Vector pos, float angle, float height, ObjectType type) +{ + CObject* obj = new CObject(); + + obj->SetType(type); + + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object + obj->SetObjectRank(0, rank); + + std::string name; + if ( type == OBJECT_RUINmobilew1 ) name = "ruin1.mod"; + if ( type == OBJECT_RUINmobilew2 ) name = "ruin1.mod"; + if ( type == OBJECT_RUINmobilet1 ) name = "ruin2.mod"; + if ( type == OBJECT_RUINmobilet2 ) name = "ruin2.mod"; + if ( type == OBJECT_RUINmobiler1 ) name = "ruin3.mod"; + if ( type == OBJECT_RUINmobiler2 ) name = "ruin3.mod"; + if ( type == OBJECT_RUINfactory ) name = "ruin4.mod"; + if ( type == OBJECT_RUINdoor ) name = "ruin5.mod"; + if ( type == OBJECT_RUINsupport ) name = "ruin6.mod"; + if ( type == OBJECT_RUINradar ) name = "ruin7.mod"; + if ( type == OBJECT_RUINconvert ) name = "ruin8.mod"; + if ( type == OBJECT_RUINbase ) name = "ruin9.mod"; + if ( type == OBJECT_RUINhead ) name = "ruin10.mod"; + + m_modelManager->AddModelReference(name, false, rank); + + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + + if ( type == OBJECT_RUINmobilew1 ) // vehicle had wheels? + { + // Creates the right-back wheel. + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(6, rank); + obj->SetObjectParent(6, 0); + + m_modelManager->AddModelReference("ruin1w.mod", false, rank); + + obj->SetPosition(6, Math::Vector(-3.0f, 1.8f, -4.0f)); + obj->SetAngleX(6, -Math::PI/2.0f); + + // Creates the left-back wheel. + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(7, rank); + obj->SetObjectParent(7, 0); + + m_modelManager->AddModelReference("ruin1w.mod", false, rank); + + obj->SetPosition(7, Math::Vector(-3.0f, 1.0f, 3.0f)); + obj->SetAngleY(7, Math::PI-0.3f); + obj->SetAngleX(7, -0.3f); + + // Creates the right-front wheel. + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(8, rank); + obj->SetObjectParent(8, 0); + + m_modelManager->AddModelReference("ruin1w.mod", false, rank); + + obj->SetPosition(8, Math::Vector(2.0f, 1.6f, -3.0f)); + obj->SetAngleY(8, 0.3f); + + // Creates the left-front wheel. + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(9, rank); + obj->SetObjectParent(9, 0); + + m_modelManager->AddModelReference("ruin1w.mod", false, rank); + + obj->SetPosition(9, Math::Vector(2.0f, 1.0f, 3.0f)); + obj->SetAngleY(9, Math::PI-0.2f); + obj->SetAngleX(9, 0.2f); + + obj->CreateCrashSphere(Math::Vector(0.0f, 2.8f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); +//? obj->SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 10.0f); + + obj->CreateShadowCircle(4.0f, 1.0f); + } + + if ( type == OBJECT_RUINmobilew2 ) // vehicle has wheels? + { + // Creates the left-back wheel. + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(7, rank); + obj->SetObjectParent(7, 0); + + m_modelManager->AddModelReference("ruin1w.mod", false, rank); + + obj->SetPosition(7, Math::Vector(-3.0f, 1.0f, 3.0f)); + obj->SetAngleY(7, Math::PI+0.3f); + obj->SetAngleX(7, 0.4f); + + // Creates the left-front wheel. + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(9, rank); + obj->SetObjectParent(9, 0); + + m_modelManager->AddModelReference("ruin1w.mod", false, rank); + + obj->SetPosition(9, Math::Vector(2.0f, 1.0f, 3.0f)); + obj->SetAngleY(9, Math::PI+0.3f); + obj->SetAngleX(9, -0.3f); + + obj->CreateCrashSphere(Math::Vector(0.0f, 2.8f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); +//? obj->SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 10.0f); + + obj->CreateShadowCircle(4.0f, 1.0f); + } + + if ( type == OBJECT_RUINmobilet1 ) // vehicle have caterpillars? + { + // Creates the cannon. + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + + m_modelManager->AddModelReference("ruin2c.mod", false, rank); + + obj->SetPosition(1, Math::Vector(3.0f, 5.0f, -2.5f)); + obj->SetAngleX(1, -Math::PI*0.85f); + obj->SetAngleY(1, -0.4f); + obj->SetAngleZ(1, -0.1f); + + obj->CreateCrashSphere(Math::Vector(1.0f, 2.8f, -1.0f), 5.0f, SOUND_BOUMm, 0.45f); +//? obj->SetGlobalSphere(Math::Vector(1.0f, 5.0f, -1.0f), 10.0f); + + obj->CreateShadowCircle(5.0f, 1.0f); + } + + if ( type == OBJECT_RUINmobilet2 ) // vehicle have caterpillars? + { + obj->CreateCrashSphere(Math::Vector(0.0f, 2.8f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); +//? obj->SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 10.0f); + + obj->CreateShadowCircle(5.0f, 1.0f); + } + + if ( type == OBJECT_RUINmobiler1 ) // vehicle skating? + { + obj->CreateCrashSphere(Math::Vector(1.0f, 2.8f, -1.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(1.0f, 5.0f, -1.0f), 10.0f); + + obj->CreateShadowCircle(5.0f, 1.0f); + } + + if ( type == OBJECT_RUINmobiler2 ) // vehicle skating? + { + obj->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 5.0f, 0.0f), 10.0f); + + obj->CreateShadowCircle(6.0f, 1.0f); + } + + if ( type == OBJECT_RUINfactory ) // factory ? + { + obj->CreateCrashSphere(Math::Vector( 9.0f, 1.0f, -11.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 2.0f, -11.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 4.0f, -10.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-12.0f, 11.0f, -4.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 4.0f, -2.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-11.0f, 8.0f, 3.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-11.0f, 2.0f, 4.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-11.0f, 2.0f, 10.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -4.0f, 0.0f, 10.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 18.0f); + + obj->CreateShadowCircle(20.0f, 0.7f); + } + + if ( type == OBJECT_RUINdoor ) // converter holder? + { + obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); +//? obj->SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 6.0f); + + obj->CreateShadowCircle(6.0f, 1.0f); + } + + if ( type == OBJECT_RUINsupport ) // radar holder? + { + obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); +//? obj->SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f); + + obj->CreateShadowCircle(3.0f, 1.0f); + } + + if ( type == OBJECT_RUINradar ) // radar base? + { + obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); +//? obj->SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 6.0f); + + obj->CreateShadowCircle(6.0f, 1.0f); + } + + if ( type == OBJECT_RUINconvert ) // converter? + { + m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f); + + obj->CreateCrashSphere(Math::Vector(-10.0f, 0.0f, 4.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-10.0f, 0.0f, -4.0f), 5.0f, SOUND_BOUMm, 0.45f); +//? obj->SetGlobalSphere(Math::Vector(-3.0f, 0.0f, 0.0f), 14.0f); + } + + if ( type == OBJECT_RUINbase ) // base? + { + obj->CreateCrashSphere(Math::Vector( 0.0f, 15.0f, 0.0f),28.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 17.0f, 6.0f, 42.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 17.0f, 17.0f, 42.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-17.0f, 6.0f, 42.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-17.0f, 17.0f, 42.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-42.0f, 6.0f, 17.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-42.0f, 17.0f, 17.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-42.0f, 6.0f, -17.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-42.0f, 17.0f, -17.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-17.0f, 6.0f, -42.0f), 6.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-17.0f, 10.0f, -42.0f), 4.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 15.0f, 13.0f, -34.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 31.0f, 15.0f, -13.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 21.0f, 8.0f, -39.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 26.0f, 8.0f, -33.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 48.0f); + + obj->CreateShadowCircle(40.0f, 1.0f); + } + + if ( type == OBJECT_RUINhead ) // base cap? + { + obj->CreateCrashSphere(Math::Vector( 0.0f, 13.0f, 0.0f),20.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, -8.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f,-16.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f,-22.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-21.0f, 7.0f, 9.0f), 8.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -9.0f, 7.0f, 21.0f), 8.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 21.0f, 7.0f, 9.0f), 8.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 9.0f, 7.0f, 21.0f), 8.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-21.0f, 7.0f, -9.0f), 8.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( -9.0f, 7.0f, -21.0f), 8.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 21.0f, 7.0f, -9.0f), 8.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 9.0f, 7.0f, -21.0f), 8.0f, SOUND_BOUMm, 0.45f); + obj->SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 35.0f); + + obj->CreateShadowCircle(30.0f, 1.0f); + } + + pos = obj->GetPosition(0); + obj->SetPosition(0, pos); //to display the shadows immediately + + obj->SetFloorHeight(0.0f); + AddObjectAuto(obj); + + if ( type != OBJECT_RUINfactory && + type != OBJECT_RUINconvert && + type != OBJECT_RUINbase ) + { + obj->FloorAdjust(); + } + + pos = obj->GetPosition(0); + pos.y += height; + obj->SetPosition(0, pos); //to display the shadows immediately + + if ( type == OBJECT_RUINmobilew1 ) + { + pos = obj->GetPosition(0); + pos.y -= 0.5f; + obj->SetPosition(0, pos); + + angle = obj->GetAngleX(0)-0.1f; + obj->SetAngleX(0, angle); + } + + if ( type == OBJECT_RUINmobilew2 ) + { + pos = obj->GetPosition(0); + pos.y -= 1.5f; + obj->SetPosition(0, pos); + + angle = obj->GetAngleX(0)-0.9f; + obj->SetAngleX(0, angle); + + angle = obj->GetAngleZ(0)-0.1f; + obj->SetAngleZ(0, angle); + } + + if ( type == OBJECT_RUINmobilet1 ) + { + pos = obj->GetPosition(0); + pos.y -= 0.9f; + obj->SetPosition(0, pos); + + angle = obj->GetAngleX(0)-0.3f; + obj->SetAngleX(0, angle); + } + + if ( type == OBJECT_RUINmobilet2 ) + { + pos = obj->GetPosition(0); + pos.y -= 1.5f; + obj->SetPosition(0, pos); + + angle = obj->GetAngleX(0)-0.3f; + obj->SetAngleX(0, angle); + + angle = obj->GetAngleZ(0)+0.8f; + obj->SetAngleZ(0, angle); + } + + if ( type == OBJECT_RUINmobiler1 ) + { + pos = obj->GetPosition(0); + pos.y += 4.0f; + obj->SetPosition(0, pos); + + angle = obj->GetAngleX(0)-Math::PI*0.6f; + obj->SetAngleX(0, angle); + + angle = obj->GetAngleZ(0)-0.2f; + obj->SetAngleZ(0, angle); + } + + if ( type == OBJECT_RUINmobiler2 ) + { + pos = obj->GetPosition(0); + pos.y += 2.0f; + obj->SetPosition(0, pos); + + angle = obj->GetAngleX(0)-0.1f; + obj->SetAngleX(0, angle); + + angle = obj->GetAngleZ(0)-0.3f; + obj->SetAngleZ(0, angle); + } + + if ( type == OBJECT_RUINdoor ) + { + pos = obj->GetPosition(0); + pos.y -= 0.5f; + obj->SetPosition(0, pos); + + angle = obj->GetAngleZ(0)-0.1f; + obj->SetAngleZ(0, angle); + } + + if ( type == OBJECT_RUINsupport ) + { + pos = obj->GetPosition(0); + pos.y += 0.5f; + obj->SetPosition(0, pos); + +//? angle = GetAngleY(0)+0.1f; +//? obj->SetAngleY(0, angle); + + angle = obj->GetAngleX(0)+0.1f; + obj->SetAngleX(0, angle); + + angle = obj->GetAngleZ(0)+0.1f; + obj->SetAngleZ(0, angle); + } + + if ( type == OBJECT_RUINradar ) + { + pos = obj->GetPosition(0); + pos.y -= 0.5f; + obj->SetPosition(0, pos); + + angle = obj->GetAngleX(0)+0.15f; + obj->SetAngleX(0, angle); + + angle = obj->GetAngleZ(0)+0.1f; + obj->SetAngleZ(0, angle); + } + + if ( type == OBJECT_RUINconvert ) + { + pos = obj->GetPosition(0); + pos.y -= 1.0f; + obj->SetPosition(0, pos); + } + + if ( type == OBJECT_RUINbase ) + { + pos = obj->GetPosition(0); + pos.y -= 1.0f; + obj->SetPosition(0, pos); + + angle = obj->GetAngleX(0)+0.15f; + obj->SetAngleX(0, angle); + } + + if ( type == OBJECT_RUINhead ) + { + pos = obj->GetPosition(0); + pos.y += 8.0f; + obj->SetPosition(0, pos); + + angle = obj->GetAngleX(0)+Math::PI*0.4f; + obj->SetAngleX(0, angle); + } + + return obj; +} + +// Creates a gadget apollo. + +CObject* CObjectFactory::CreateApollo(Math::Vector pos, float angle, ObjectType type) +{ + CObject* obj = new CObject(); + + obj->SetType(type); + + if ( type == OBJECT_APOLLO1 ) // LEM ? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("apollol1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetZoom(0, 1.2f); + obj->SetFloorHeight(0.0f); + + for (int i=0 ; i<4 ; i++ ) // creates feet + { + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(i+1, rank); + obj->SetObjectParent(i+1, 0); + m_modelManager->AddModelReference("apollol2.mod", false, rank); + obj->SetAngleY(i+1, Math::PI/2.0f*i); + } + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(5, rank); + obj->SetObjectParent(5, 0); + m_modelManager->AddModelReference("apollol3.mod", false, rank); // ladder + +//? m_terrain->AddBuildingLevel(pos, 10.0f, 13.0f, 12.0f, 0.0f); + + obj->CreateCrashSphere(Math::Vector( 0.0f, 4.0f, 0.0f), 9.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 11.0f, 5.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-11.0f, 5.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 5.0f, -11.0f), 3.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 0.0f, 5.0f, 11.0f), 3.0f, SOUND_BOUMm, 0.45f); + + obj->SetGlobalSphere(Math::Vector(0.0f, 4.0f, 0.0f), 9.0f); + + obj->CreateShadowCircle(16.0f, 0.5f); + } + + if ( type == OBJECT_APOLLO2 ) // jeep + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); //it is a stationary object + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("apolloj1.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + // Wheels. + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel + obj->SetPosition(1, Math::Vector(-5.75f, 1.65f, -5.0f)); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(2, rank); + obj->SetObjectParent(2, 0); + m_modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel + obj->SetPosition(2, Math::Vector(-5.75f, 1.65f, 5.0f)); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(3, rank); + obj->SetObjectParent(3, 0); + m_modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel + obj->SetPosition(3, Math::Vector(5.75f, 1.65f, -5.0f)); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(4, rank); + obj->SetObjectParent(4, 0); + m_modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel + obj->SetPosition(4, Math::Vector(5.75f, 1.65f, 5.0f)); + + // Accessories: + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(5, rank); + obj->SetObjectParent(5, 0); + m_modelManager->AddModelReference("apolloj2.mod", false, rank); // antenna + obj->SetPosition(5, Math::Vector(5.5f, 8.8f, 2.0f)); + obj->SetAngleY(5, -120.0f*Math::PI/180.0f); + obj->SetAngleZ(5, 45.0f*Math::PI/180.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(6, rank); + obj->SetObjectParent(6, 0); + m_modelManager->AddModelReference("apolloj3.mod", false, rank); // camera + obj->SetPosition(6, Math::Vector(5.5f, 2.8f, -2.0f)); + obj->SetAngleY(6, 30.0f*Math::PI/180.0f); + + obj->CreateCrashSphere(Math::Vector( 3.0f, 2.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector(-3.0f, 2.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f); + obj->CreateCrashSphere(Math::Vector( 7.0f, 9.0f, 2.0f), 2.0f, SOUND_BOUMm, 0.20f); + + obj->CreateShadowCircle(7.0f, 0.8f); + + obj->FloorAdjust(); + } + + if ( type == OBJECT_APOLLO3 ) // flag? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("apollof.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + obj->SetJotlerSphere(Math::Vector(0.0f, 4.0f, 0.0f), 1.0f); + obj->CreateShadowCircle(2.0f, 0.3f); + } + + if ( type == OBJECT_APOLLO4 ) // module? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("apollom.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + obj->CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 2.0f, SOUND_BOUMm, 0.45f); + obj->CreateShadowCircle(5.0f, 0.8f); + + obj->FloorAdjust(); + } + + if ( type == OBJECT_APOLLO5 ) // antenna? + { + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object + obj->SetObjectRank(0, rank); + m_modelManager->AddModelReference("apolloa.mod", false, rank); + obj->SetPosition(0, pos); + obj->SetAngleY(0, angle); + obj->SetFloorHeight(0.0f); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + obj->SetObjectRank(1, rank); + obj->SetObjectParent(1, 0); + m_modelManager->AddModelReference("apolloj2.mod", false, rank); // antenna + obj->SetPosition(1, Math::Vector(0.0f, 5.0f, 0.0f)); + obj->SetAngleY(1, -120.0f*Math::PI/180.0f); + obj->SetAngleZ(1, 45.0f*Math::PI/180.0f); + + obj->CreateCrashSphere(Math::Vector(0.0f, 4.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.35f); + obj->CreateShadowCircle(3.0f, 0.7f); + } + + AddObjectAuto(obj); + + pos = obj->GetPosition(0); + obj->SetPosition(0, pos); // to display the shadows immediately + + return obj; +} + +// Creates a vehicle traveling any pose on the floor. + +CObject* CObjectFactory::CreateVehicle(Math::Vector pos, float angle, ObjectType type, float power, bool trainer, bool toy, int option) +{ + CObject* obj = new CObject(); + + obj->SetType(type); + obj->SetOption(option); + + if ( type == OBJECT_TOTO ) + { + CMotion* motion = new CMotionToto(obj); + motion->Create(pos, angle, type, 1.0f, m_modelManager); + obj->SetMotion(motion); + return obj; + } + + if ( type == OBJECT_HUMAN || + type == OBJECT_TECH ) + { + obj->SetTrainer(false); + } + else + { + obj->SetTrainer(trainer); + } + + obj->SetToy(toy); + + CPhysics* physics = new CPhysics(obj); + CBrain* brain = new CBrain(obj); + + physics->SetBrain(brain); + brain->SetPhysics(physics); + + obj->SetPhysics(physics); + obj->SetBrain(brain); + + float showLimitRadius = 0.0f; +#if 0 + if ( type == OBJECT_MOBILEfc || + type == OBJECT_MOBILEtc || + type == OBJECT_MOBILEwc || + type == OBJECT_MOBILEic ) // fireball cannon? + { + showLimitRadius = 160.0f; + } + if ( type == OBJECT_MOBILEfi || + type == OBJECT_MOBILEti || + type == OBJECT_MOBILEwi || + type == OBJECT_MOBILEii ) // orgaball cannon? + { + showLimitRadius = 160.0f; + } + if ( type == OBJECT_MOBILErc ) // phazer cannon? + { + showLimitRadius = 160.0f; + } + if ( type == OBJECT_MOBILErs ) // robot shield? + { + showLimitRadius = 50.0f; + } +#endif + if ( type == OBJECT_MOBILErt ) // robot thumper? + { + showLimitRadius = 400.0f; + } + obj->SetShowLimitRadius(showLimitRadius); + + CMotion* motion = nullptr; + + if ( type == OBJECT_HUMAN || + type == OBJECT_TECH ) + { + motion = new CMotionHuman(obj); + } + else if ( type == OBJECT_CONTROLLER ) + { + motion = new CMotionDummy(obj); //dummy object + } + else + { + motion = new CMotionVehicle(obj); + } + + physics->SetMotion(motion); + brain->SetMotion(motion); + motion->SetPhysics(physics); + motion->SetBrain(brain); + motion->Create(pos, angle, type, power, m_modelManager); + + obj->SetMotion(motion); + + return obj; +} + +// Creates an insect lands on any ground. + +CObject* CObjectFactory::CreateInsect(Math::Vector pos, float angle, ObjectType type) +{ + CObject* obj = new CObject(); + + obj->SetType(type); + + CPhysics* physics = new CPhysics(obj); + CBrain* brain = new CBrain(obj); + + physics->SetBrain(brain); + brain->SetPhysics(physics); + + obj->SetPhysics(physics); + obj->SetBrain(brain); + + CMotion* motion = nullptr; + if ( type == OBJECT_MOTHER ) + { + motion = new CMotionMother(obj); + } + if ( type == OBJECT_ANT ) + { + motion = new CMotionAnt(obj); + } + if ( type == OBJECT_SPIDER ) + { + motion = new CMotionSpider(obj); + } + if ( type == OBJECT_BEE ) + { + motion = new CMotionBee(obj); + } + if ( type == OBJECT_WORM ) + { + motion = new CMotionWorm(obj); + } + + physics->SetMotion(motion); + brain->SetMotion(motion); + motion->SetPhysics(physics); + motion->SetBrain(brain); + + motion->Create(pos, angle, type, 0.0f, m_modelManager); + + obj->SetMotion(motion); + + return obj; +} + +// Creates all sub-objects for managing the object. + +void CObjectFactory::AddObjectAuto(CObject* obj) +{ + CAuto* objAuto = nullptr; + + auto type = obj->GetType(); + + if ( type == OBJECT_BASE ) + { + objAuto = new CAutoBase(obj); + } + if ( type == OBJECT_PORTICO ) + { + objAuto = new CAutoPortico(obj); + } + if ( type == OBJECT_DERRICK ) + { + objAuto = new CAutoDerrick(obj); + } + if ( type == OBJECT_FACTORY ) + { + objAuto = new CAutoFactory(obj); + } + if ( type == OBJECT_REPAIR ) + { + objAuto = new CAutoRepair(obj); + } + if ( type == OBJECT_DESTROYER ) + { + objAuto = new CAutoDestroyer(obj); + } + if ( type == OBJECT_STATION ) + { + objAuto = new CAutoStation(obj); + } + if ( type == OBJECT_CONVERT ) + { + objAuto = new CAutoConvert(obj); + } + if ( type == OBJECT_TOWER ) + { + objAuto = new CAutoTower(obj); + } + if ( type == OBJECT_RESEARCH ) + { + objAuto = new CAutoResearch(obj); + } + if ( type == OBJECT_RADAR ) + { + objAuto = new CAutoRadar(obj); + } + if ( type == OBJECT_INFO ) + { + objAuto = new CAutoInfo(obj); + } + if ( type == OBJECT_ENERGY ) + { + objAuto = new CAutoEnergy(obj); + } + if ( type == OBJECT_LABO ) + { + objAuto = new CAutoLabo(obj); + } + if ( type == OBJECT_NUCLEAR ) + { + objAuto = new CAutoNuclear(obj); + } + if ( type == OBJECT_PARA ) + { + objAuto = new CAutoPara(obj); + } + if ( type == OBJECT_SAFE ) + { + objAuto = new CAutoSafe(obj); + } + if ( type == OBJECT_HUSTON ) + { + objAuto = new CAutoHuston(obj); + } + if ( type == OBJECT_EGG ) + { + objAuto = new CAutoEgg(obj); + } + if ( type == OBJECT_NEST ) + { + objAuto = new CAutoNest(obj); + } + if ( type == OBJECT_ROOT5 ) + { + objAuto = new CAutoRoot(obj); + } + if ( type == OBJECT_MUSHROOM2 ) + { + objAuto = new CAutoMush(obj); + } + if ( type == OBJECT_FLAGb || + type == OBJECT_FLAGr || + type == OBJECT_FLAGg || + type == OBJECT_FLAGy || + type == OBJECT_FLAGv ) + { + objAuto = new CAutoFlag(obj); + } + if ( type == OBJECT_TEEN36 || // trunk? + type == OBJECT_TEEN37 || // boat? + type == OBJECT_TEEN38 ) // fan? + { + objAuto = new CAutoKid(obj); + } + + if (objAuto != nullptr) + { + obj->SetAuto(objAuto); + objAuto->Init(); + } +} diff --git a/src/object/object_factory.h b/src/object/object_factory.h new file mode 100644 index 00000000..221fa282 --- /dev/null +++ b/src/object/object_factory.h @@ -0,0 +1,80 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ + +/** + * \file object/object_factory.h + * \brief CObjectFactory - factory for game objects + */ + +#pragma once + +#include "math/vector.h" + +#include "object/object_type.h" + +#include + +namespace Gfx { +class CEngine; +class CModelManager; +class CParticle; +class CTerrain; +} // namespace Gfx + +class CObject; +class CRobotMain; + +class CObjectFactory +{ +public: + CObjectFactory(Gfx::CEngine* engine, + Gfx::CTerrain* terrain, + Gfx::CModelManager* modelManager, + Gfx::CParticle* particle, + CRobotMain* main); + + CObject* CreateObject(Math::Vector pos, float angle, ObjectType type, + float power, float zoom, float height, + bool trainer, bool toy, int option); + + CObject* CreateBuilding(Math::Vector pos, float angle, float height, ObjectType type, float power=1.0f); + CObject* CreateResource(Math::Vector pos, float angle, ObjectType type, float power=1.0f); + CObject* CreateVehicle(Math::Vector pos, float angle, ObjectType type, float power, bool trainer, bool toy, int option); + CObject* CreateInsect(Math::Vector pos, float angle, ObjectType type); + CObject* CreateFlag(Math::Vector pos, float angle, ObjectType type); + CObject* CreateBarrier(Math::Vector pos, float angle, float height, ObjectType type); + CObject* CreatePlant(Math::Vector pos, float angle, float height, ObjectType type); + CObject* CreateMushroom(Math::Vector pos, float angle, float height, ObjectType type); + CObject* CreateTeen(Math::Vector pos, float angle, float zoom, float height, ObjectType type, int option); + CObject* CreateQuartz(Math::Vector pos, float angle, float height, ObjectType type); + CObject* CreateRoot(Math::Vector pos, float angle, float height, ObjectType type); + CObject* CreateHome(Math::Vector pos, float angle, float height, ObjectType type); + CObject* CreateRuin(Math::Vector pos, float angle, float height, ObjectType type); + CObject* CreateApollo(Math::Vector pos, float angle, ObjectType type); + +private: + void AddObjectAuto(CObject* obj); + +private: + Gfx::CEngine* m_engine; + Gfx::CTerrain* m_terrain; + Gfx::CModelManager* m_modelManager; + Gfx::CParticle* m_particle; + CRobotMain* m_main; +}; diff --git a/src/object/object_type.h b/src/object/object_type.h new file mode 100644 index 00000000..0e903f4e --- /dev/null +++ b/src/object/object_type.h @@ -0,0 +1,238 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ + +/** + * \file object/object_type.h + * \brief ObjectType enum + */ + +#pragma once + +/** + * \enum ObjectType + * \brief Type of game object + */ +enum ObjectType +{ + OBJECT_NULL = 0, //! < object destroyed + OBJECT_FIX = 1, //! < stationary scenery + OBJECT_PORTICO = 2, //! < Portico + OBJECT_BASE = 3, //! < SpaceShip + OBJECT_DERRICK = 4, //! < Derrick + OBJECT_FACTORY = 5, //! < BotFactory + OBJECT_STATION = 6, //! < PowerStation + OBJECT_CONVERT = 7, //! < Converter + OBJECT_REPAIR = 8, //! < RepairStation + OBJECT_TOWER = 9, //! < DefenseTower + OBJECT_NEST = 10, //! < AlienNest + OBJECT_RESEARCH = 11, //! < ResearchCenter + OBJECT_RADAR = 12, //! < RadarStation + OBJECT_ENERGY = 13, //! < PowerPlant + OBJECT_LABO = 14, //! < AutoLab + OBJECT_NUCLEAR = 15, //! < NuclearPlant + OBJECT_START = 16, //! < StartArea + OBJECT_END = 17, //! < EndArea + OBJECT_INFO = 18, //! < ExchangePost + OBJECT_PARA = 19, //! < PowerCaptor + OBJECT_TARGET1 = 20, //! < Target1 (gate) + OBJECT_TARGET2 = 21, //! < Target2 (center) + OBJECT_SAFE = 22, //! < Vault + OBJECT_HUSTON = 23, //! < Houston + OBJECT_DESTROYER = 24, //! < Destroyer + OBJECT_FRET = 30, //! < transportable (unused) + OBJECT_STONE = 31, //! < TitaniumOre + OBJECT_URANIUM = 32, //! < UraniumOre + OBJECT_METAL = 33, //! < Titanium + OBJECT_POWER = 34, //! < PowerCell + OBJECT_ATOMIC = 35, //! < NuclearCell + OBJECT_BULLET = 36, //! < OrgaMatter + OBJECT_BBOX = 37, //! < BlackBox + OBJECT_TNT = 38, //! < TNT + OBJECT_SCRAP1 = 40, //! < Scrap1 (metal) + OBJECT_SCRAP2 = 41, //! < Scrap2 (metal) + OBJECT_SCRAP3 = 42, //! < Scrap3 (metal) + OBJECT_SCRAP4 = 43, //! < Scrap4 (plastic) + OBJECT_SCRAP5 = 44, //! < Scrap5 (plastic) + OBJECT_MARKPOWER = 50, //! < PowerSpot + OBJECT_MARKSTONE = 51, //! < TitaniumSpot + OBJECT_MARKURANIUM = 52, //! < UraniumSpot + OBJECT_MARKKEYa = 53, //! < KeyASpot + OBJECT_MARKKEYb = 54, //! < KeyBSpot + OBJECT_MARKKEYc = 55, //! < KeyCSpot + OBJECT_MARKKEYd = 56, //! < KeyDSpot + OBJECT_BOMB = 60, //! < Mine + OBJECT_WINFIRE = 61, //! < Firework + OBJECT_SHOW = 62, //! < arrow above object (Visit) + OBJECT_BAG = 63, //! < Bag + OBJECT_PLANT0 = 70, //! < Greenery0 + OBJECT_PLANT1 = 71, //! < Greenery1 + OBJECT_PLANT2 = 72, //! < Greenery2 + OBJECT_PLANT3 = 73, //! < Greenery3 + OBJECT_PLANT4 = 74, //! < Greenery4 + OBJECT_PLANT5 = 75, //! < Greenery5 + OBJECT_PLANT6 = 76, //! < Greenery6 + OBJECT_PLANT7 = 77, //! < Greenery7 + OBJECT_PLANT8 = 78, //! < Greenery8 + OBJECT_PLANT9 = 79, //! < Greenery9 + OBJECT_PLANT10 = 80, //! < Greenery10 + OBJECT_PLANT11 = 81, //! < Greenery11 + OBJECT_PLANT12 = 82, //! < Greenery12 + OBJECT_PLANT13 = 83, //! < Greenery13 + OBJECT_PLANT14 = 84, //! < Greenery14 + OBJECT_PLANT15 = 85, //! < Greenery15 + OBJECT_PLANT16 = 86, //! < Greenery16 + OBJECT_PLANT17 = 87, //! < Greenery17 + OBJECT_PLANT18 = 88, //! < Greenery18 + OBJECT_PLANT19 = 89, //! < Greenery19 + OBJECT_TREE0 = 90, //! < Tree0 + OBJECT_TREE1 = 91, //! < Tree1 + OBJECT_TREE2 = 92, //! < Tree2 + OBJECT_TREE3 = 93, //! < Tree3 + OBJECT_TREE4 = 94, //! < Tree4 + OBJECT_TREE5 = 95, //! < Tree5 + OBJECT_MOBILEwt = 100, //! < PracticeBot + OBJECT_MOBILEtt = 101, //! < track-trainer (unused) + OBJECT_MOBILEft = 102, //! < fly-trainer (unused) + OBJECT_MOBILEit = 103, //! < insect-trainer (unused) + OBJECT_MOBILEwa = 110, //! < WheeledGrabber + OBJECT_MOBILEta = 111, //! < TrackedGrabber + OBJECT_MOBILEfa = 112, //! < WingedGrabber + OBJECT_MOBILEia = 113, //! < LeggedGrabber + OBJECT_MOBILEwc = 120, //! < WheeledShooter + OBJECT_MOBILEtc = 121, //! < TrackedShooter + OBJECT_MOBILEfc = 122, //! < WingedShooter + OBJECT_MOBILEic = 123, //! < LeggedShooter + OBJECT_MOBILEwi = 130, //! < WheeledOrgaShooter + OBJECT_MOBILEti = 131, //! < TrackedOrgaShooter + OBJECT_MOBILEfi = 132, //! < WingedOrgaShooter + OBJECT_MOBILEii = 133, //! < LeggedOrgaShooter + OBJECT_MOBILEws = 140, //! < WheeledSniffer + OBJECT_MOBILEts = 141, //! < TrackedSniffer + OBJECT_MOBILEfs = 142, //! < WingedSniffer + OBJECT_MOBILEis = 143, //! < LeggedSniffer + OBJECT_MOBILErt = 200, //! < Thumper + OBJECT_MOBILErc = 201, //! < PhazerShooter + OBJECT_MOBILErr = 202, //! < Recycler + OBJECT_MOBILErs = 203, //! < Shielder + OBJECT_MOBILEsa = 210, //! < Subber + OBJECT_MOBILEtg = 211, //! < TargetBot + OBJECT_MOBILEdr = 212, //! < Scribbler + OBJECT_CONTROLLER = 213, //! < MissionController + OBJECT_WAYPOINT = 250, //! < WayPoint + OBJECT_FLAGb = 260, //! < BlueFlag + OBJECT_FLAGr = 261, //! < RedFlag + OBJECT_FLAGg = 262, //! < GreenFlag + OBJECT_FLAGy = 263, //! < YellowFlag + OBJECT_FLAGv = 264, //! < VioletFlag + OBJECT_KEYa = 270, //! < KeyA + OBJECT_KEYb = 271, //! < KeyB + OBJECT_KEYc = 272, //! < KeyC + OBJECT_KEYd = 273, //! < KeyD + OBJECT_HUMAN = 300, //! < Me + OBJECT_TOTO = 301, //! < Robby (toto) + OBJECT_TECH = 302, //! < Tech + OBJECT_BARRIER0 = 400, //! < Barrier0 + OBJECT_BARRIER1 = 401, //! < Barrier1 + OBJECT_BARRIER2 = 402, //! < Barrier2 + OBJECT_BARRIER3 = 403, //! < Barrier3 + OBJECT_MOTHER = 500, //! < AlienQueen + OBJECT_EGG = 501, //! < AlienEgg + OBJECT_ANT = 502, //! < AlienAnt + OBJECT_SPIDER = 503, //! < AlienSpider + OBJECT_BEE = 504, //! < AlienWasp + OBJECT_WORM = 505, //! < AlienWorm + OBJECT_RUINmobilew1 = 600, //! < WreckBotw1 + OBJECT_RUINmobilew2 = 601, //! < WreckBotw2 + OBJECT_RUINmobilet1 = 602, //! < WreckBott1 + OBJECT_RUINmobilet2 = 603, //! < WreckBott2 + OBJECT_RUINmobiler1 = 604, //! < WreckBotr1 + OBJECT_RUINmobiler2 = 605, //! < WreckBotr2 + OBJECT_RUINfactory = 606, //! < RuinBotFactory + OBJECT_RUINdoor = 607, //! < RuinDoor + OBJECT_RUINsupport = 608, //! < RuinSupport + OBJECT_RUINradar = 609, //! < RuinRadar + OBJECT_RUINconvert = 610, //! < RuinConvert + OBJECT_RUINbase = 611, //! < RuinBaseCamp + OBJECT_RUINhead = 612, //! < RuinHeadCamp + OBJECT_TEEN0 = 620, //! < Teen0 + OBJECT_TEEN1 = 621, //! < Teen1 + OBJECT_TEEN2 = 622, //! < Teen2 + OBJECT_TEEN3 = 623, //! < Teen3 + OBJECT_TEEN4 = 624, //! < Teen4 + OBJECT_TEEN5 = 625, //! < Teen5 + OBJECT_TEEN6 = 626, //! < Teen6 + OBJECT_TEEN7 = 627, //! < Teen7 + OBJECT_TEEN8 = 628, //! < Teen8 + OBJECT_TEEN9 = 629, //! < Teen9 + OBJECT_TEEN10 = 630, //! < Teen10 + OBJECT_TEEN11 = 631, //! < Teen11 + OBJECT_TEEN12 = 632, //! < Teen12 + OBJECT_TEEN13 = 633, //! < Teen13 + OBJECT_TEEN14 = 634, //! < Teen14 + OBJECT_TEEN15 = 635, //! < Teen15 + OBJECT_TEEN16 = 636, //! < Teen16 + OBJECT_TEEN17 = 637, //! < Teen17 + OBJECT_TEEN18 = 638, //! < Teen18 + OBJECT_TEEN19 = 639, //! < Teen19 + OBJECT_TEEN20 = 640, //! < Teen20 + OBJECT_TEEN21 = 641, //! < Teen21 + OBJECT_TEEN22 = 642, //! < Teen22 + OBJECT_TEEN23 = 643, //! < Teen23 + OBJECT_TEEN24 = 644, //! < Teen24 + OBJECT_TEEN25 = 645, //! < Teen25 + OBJECT_TEEN26 = 646, //! < Teen26 + OBJECT_TEEN27 = 647, //! < Teen27 + OBJECT_TEEN28 = 648, //! < Teen28 + OBJECT_TEEN29 = 649, //! < Teen29 + OBJECT_TEEN30 = 650, //! < Teen30 + OBJECT_TEEN31 = 651, //! < Teen31 + OBJECT_TEEN32 = 652, //! < Teen32 + OBJECT_TEEN33 = 653, //! < Teen33 + OBJECT_TEEN34 = 654, //! < Stone (Teen34) + OBJECT_TEEN35 = 655, //! < Teen35 + OBJECT_TEEN36 = 656, //! < Teen36 + OBJECT_TEEN37 = 657, //! < Teen37 + OBJECT_TEEN38 = 658, //! < Teen38 + OBJECT_TEEN39 = 659, //! < Teen39 + OBJECT_TEEN40 = 660, //! < Teen40 + OBJECT_TEEN41 = 661, //! < Teen41 + OBJECT_TEEN42 = 662, //! < Teen42 + OBJECT_TEEN43 = 663, //! < Teen43 + OBJECT_TEEN44 = 664, //! < Teen44 + OBJECT_QUARTZ0 = 700, //! < Quartz0 + OBJECT_QUARTZ1 = 701, //! < Quartz1 + OBJECT_QUARTZ2 = 702, //! < Quartz2 + OBJECT_QUARTZ3 = 703, //! < Quartz3 + OBJECT_ROOT0 = 710, //! < MegaStalk0 + OBJECT_ROOT1 = 711, //! < MegaStalk1 + OBJECT_ROOT2 = 712, //! < MegaStalk2 + OBJECT_ROOT3 = 713, //! < MegaStalk3 + OBJECT_ROOT4 = 714, //! < MegaStalk4 + OBJECT_ROOT5 = 715, //! < MegaStalk5 + OBJECT_MUSHROOM1 = 731, //! < Mushroom1 + OBJECT_MUSHROOM2 = 732, //! < Mushroom2 + OBJECT_APOLLO1 = 900, //! < ApolloLEM + OBJECT_APOLLO2 = 901, //! < ApolloJeep + OBJECT_APOLLO3 = 902, //! < ApolloFlag + OBJECT_APOLLO4 = 903, //! < ApolloModule + OBJECT_APOLLO5 = 904, //! < ApolloAntenna + OBJECT_HOME1 = 910, //! < Home + + OBJECT_MAX = 1000 //! < number of values +}; diff --git a/src/object/objman.cpp b/src/object/objman.cpp index fee7b64c..c38ba715 100644 --- a/src/object/objman.cpp +++ b/src/object/objman.cpp @@ -23,6 +23,7 @@ #include "math/all.h" #include "object/object.h" +#include "object/object_factory.h" #include "object/auto/auto.h" #include "physics/physics.h" @@ -33,7 +34,12 @@ template<> CObjectManager* CSingleton::m_instance = nullptr; -CObjectManager::CObjectManager() +CObjectManager::CObjectManager(Gfx::CEngine* engine, + Gfx::CTerrain* terrain, + Gfx::CModelManager* modelManager, + Gfx::CParticle* particle, + CRobotMain* main) + : m_objectFactory(new CObjectFactory(engine, terrain, modelManager, particle, main)) { } @@ -92,295 +98,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, ObjectType float power, float zoom, float height, bool trainer, bool toy, int option) { - CObject* object = nullptr; - - if ( type == OBJECT_NULL ) return nullptr; - - if ( type == OBJECT_HUMAN || - type == OBJECT_TECH ) - { - trainer = false; // necessarily - } - - if ( type == OBJECT_PORTICO || - type == OBJECT_BASE || - type == OBJECT_DERRICK || - type == OBJECT_FACTORY || - type == OBJECT_STATION || - type == OBJECT_CONVERT || - type == OBJECT_REPAIR || - type == OBJECT_DESTROYER|| - type == OBJECT_TOWER || - type == OBJECT_NEST || - type == OBJECT_RESEARCH || - type == OBJECT_RADAR || - type == OBJECT_INFO || - type == OBJECT_ENERGY || - type == OBJECT_LABO || - type == OBJECT_NUCLEAR || - type == OBJECT_PARA || - type == OBJECT_SAFE || - type == OBJECT_HUSTON || - type == OBJECT_TARGET1 || - type == OBJECT_TARGET2 || - type == OBJECT_START || - type == OBJECT_END ) - { - object = new CObject(); - object->CreateBuilding(pos, angle, height, type, power); - - CAuto* automat = object->GetAuto(); - if (automat != nullptr) - { - automat->Init(); - } - } - else - if ( type == OBJECT_FRET || - type == OBJECT_STONE || - type == OBJECT_URANIUM || - type == OBJECT_METAL || - type == OBJECT_POWER || - type == OBJECT_ATOMIC || - type == OBJECT_BULLET || - type == OBJECT_BBOX || - type == OBJECT_KEYa || - type == OBJECT_KEYb || - type == OBJECT_KEYc || - type == OBJECT_KEYd || - type == OBJECT_TNT || - type == OBJECT_SCRAP1 || - type == OBJECT_SCRAP2 || - type == OBJECT_SCRAP3 || - type == OBJECT_SCRAP4 || - type == OBJECT_SCRAP5 || - type == OBJECT_BOMB || - type == OBJECT_WAYPOINT || - type == OBJECT_SHOW || - type == OBJECT_WINFIRE || - type == OBJECT_BAG || - type == OBJECT_MARKPOWER || - type == OBJECT_MARKSTONE || - type == OBJECT_MARKURANIUM || - type == OBJECT_MARKKEYa || - type == OBJECT_MARKKEYb || - type == OBJECT_MARKKEYc || - type == OBJECT_MARKKEYd || - type == OBJECT_EGG ) - { - object = new CObject(); - object->CreateResource(pos, angle, type, power); - } - else - if ( type == OBJECT_FLAGb || - type == OBJECT_FLAGr || - type == OBJECT_FLAGg || - type == OBJECT_FLAGy || - type == OBJECT_FLAGv ) - { - object = new CObject(); - object->CreateFlag(pos, angle, type); - } - else - if ( type == OBJECT_BARRIER0 || - type == OBJECT_BARRIER1 || - type == OBJECT_BARRIER2 || - type == OBJECT_BARRIER3 ) - { - object = new CObject(); - object->CreateBarrier(pos, angle, height, type); - } - else - if ( type == OBJECT_PLANT0 || - type == OBJECT_PLANT1 || - type == OBJECT_PLANT2 || - type == OBJECT_PLANT3 || - type == OBJECT_PLANT4 || - type == OBJECT_PLANT5 || - type == OBJECT_PLANT6 || - type == OBJECT_PLANT7 || - type == OBJECT_PLANT8 || - type == OBJECT_PLANT9 || - type == OBJECT_PLANT10 || - type == OBJECT_PLANT11 || - type == OBJECT_PLANT12 || - type == OBJECT_PLANT13 || - type == OBJECT_PLANT14 || - type == OBJECT_PLANT15 || - type == OBJECT_PLANT16 || - type == OBJECT_PLANT17 || - type == OBJECT_PLANT18 || - type == OBJECT_PLANT19 || - type == OBJECT_TREE0 || - type == OBJECT_TREE1 || - type == OBJECT_TREE2 || - type == OBJECT_TREE3 || - type == OBJECT_TREE4 || - type == OBJECT_TREE5 ) - { - object = new CObject(); - object->CreatePlant(pos, angle, height, type); - } - else - if ( type == OBJECT_MUSHROOM1 || - type == OBJECT_MUSHROOM2 ) - { - object = new CObject(); - object->CreateMushroom(pos, angle, height, type); - } - else - if ( type == OBJECT_TEEN0 || - type == OBJECT_TEEN1 || - type == OBJECT_TEEN2 || - type == OBJECT_TEEN3 || - type == OBJECT_TEEN4 || - type == OBJECT_TEEN5 || - type == OBJECT_TEEN6 || - type == OBJECT_TEEN7 || - type == OBJECT_TEEN8 || - type == OBJECT_TEEN9 || - type == OBJECT_TEEN10 || - type == OBJECT_TEEN11 || - type == OBJECT_TEEN12 || - type == OBJECT_TEEN13 || - type == OBJECT_TEEN14 || - type == OBJECT_TEEN15 || - type == OBJECT_TEEN16 || - type == OBJECT_TEEN17 || - type == OBJECT_TEEN18 || - type == OBJECT_TEEN19 || - type == OBJECT_TEEN20 || - type == OBJECT_TEEN21 || - type == OBJECT_TEEN22 || - type == OBJECT_TEEN23 || - type == OBJECT_TEEN24 || - type == OBJECT_TEEN25 || - type == OBJECT_TEEN26 || - type == OBJECT_TEEN27 || - type == OBJECT_TEEN28 || - type == OBJECT_TEEN29 || - type == OBJECT_TEEN30 || - type == OBJECT_TEEN31 || - type == OBJECT_TEEN32 || - type == OBJECT_TEEN33 || - type == OBJECT_TEEN34 || - type == OBJECT_TEEN35 || - type == OBJECT_TEEN36 || - type == OBJECT_TEEN37 || - type == OBJECT_TEEN38 || - type == OBJECT_TEEN39 || - type == OBJECT_TEEN40 || - type == OBJECT_TEEN41 || - type == OBJECT_TEEN42 || - type == OBJECT_TEEN43 || - type == OBJECT_TEEN44 ) - { - object = new CObject(); - object->SetOption(option); - object->CreateTeen(pos, angle, zoom, height, type); - } - else - if ( type == OBJECT_QUARTZ0 || - type == OBJECT_QUARTZ1 || - type == OBJECT_QUARTZ2 || - type == OBJECT_QUARTZ3 ) - { - object = new CObject(); - object->CreateQuartz(pos, angle, height, type); - } - else - if ( type == OBJECT_ROOT0 || - type == OBJECT_ROOT1 || - type == OBJECT_ROOT2 || - type == OBJECT_ROOT3 || - type == OBJECT_ROOT4 || - type == OBJECT_ROOT5 ) - { - object = new CObject(); - object->CreateRoot(pos, angle, height, type); - } - else - if ( type == OBJECT_HOME1 ) - { - object = new CObject(); - object->CreateHome(pos, angle, height, type); - } - else - if ( type == OBJECT_RUINmobilew1 || - type == OBJECT_RUINmobilew2 || - type == OBJECT_RUINmobilet1 || - type == OBJECT_RUINmobilet2 || - type == OBJECT_RUINmobiler1 || - type == OBJECT_RUINmobiler2 || - type == OBJECT_RUINfactory || - type == OBJECT_RUINdoor || - type == OBJECT_RUINsupport || - type == OBJECT_RUINradar || - type == OBJECT_RUINconvert || - type == OBJECT_RUINbase || - type == OBJECT_RUINhead ) - { - object = new CObject(); - object->CreateRuin(pos, angle, height, type); - } - else - if ( type == OBJECT_APOLLO1 || - type == OBJECT_APOLLO3 || - type == OBJECT_APOLLO4 || - type == OBJECT_APOLLO5 ) - { - object = new CObject(); - object->CreateApollo(pos, angle, type); - } - else - if ( type == OBJECT_MOTHER || - type == OBJECT_ANT || - type == OBJECT_SPIDER || - type == OBJECT_BEE || - type == OBJECT_WORM ) - { - object = new CObject(); - object->CreateInsect(pos, angle, type); // no eggs - } - else - if ( type == OBJECT_HUMAN || - type == OBJECT_TECH || - type == OBJECT_TOTO || - type == OBJECT_MOBILEfa || - type == OBJECT_MOBILEta || - type == OBJECT_MOBILEwa || - type == OBJECT_MOBILEia || - type == OBJECT_MOBILEfc || - type == OBJECT_MOBILEtc || - type == OBJECT_MOBILEwc || - type == OBJECT_MOBILEic || - type == OBJECT_MOBILEfi || - type == OBJECT_MOBILEti || - type == OBJECT_MOBILEwi || - type == OBJECT_MOBILEii || - type == OBJECT_MOBILEfs || - type == OBJECT_MOBILEts || - type == OBJECT_MOBILEws || - type == OBJECT_MOBILEis || - type == OBJECT_MOBILErt || - type == OBJECT_MOBILErc || - type == OBJECT_MOBILErr || - type == OBJECT_MOBILErs || - type == OBJECT_MOBILEsa || - type == OBJECT_MOBILEtg || - type == OBJECT_MOBILEft || - type == OBJECT_MOBILEtt || - type == OBJECT_MOBILEwt || - type == OBJECT_MOBILEit || - type == OBJECT_MOBILEdr || - type == OBJECT_APOLLO2 ) - { - object = new CObject(); - object->SetOption(option); - object->CreateVehicle(pos, angle, type, power, trainer, toy); - } - - return object; + return m_objectFactory->CreateObject(pos, angle, type, power, zoom, height, trainer, toy, option); } bool CObjectManager::DestroyObject(int id) diff --git a/src/object/objman.h b/src/object/objman.h index 52d9e5af..ac5f4a28 100644 --- a/src/object/objman.h +++ b/src/object/objman.h @@ -24,11 +24,35 @@ #pragma once -#include "object/object.h" - #include "common/singleton.h" +#include "math/const.h" +#include "math/vector.h" + +#include "object/object_type.h" + #include +#include +#include + +namespace Gfx { +class CEngine; +class CModelManager; +class CParticle; +class CTerrain; +} // namespace Gfx + +class CObject; +class CRobotMain; +class CObjectFactory; + +enum RadarFilter +{ + FILTER_NONE = 0, + FILTER_ONLYLANDING = 1, + FILTER_ONLYFLYING = 2, +}; + /** * \class ObjectManager @@ -37,7 +61,11 @@ class CObjectManager : public CSingleton { public: - CObjectManager(); + CObjectManager(Gfx::CEngine* engine, + Gfx::CTerrain* terrain, + Gfx::CModelManager* modelManager, + Gfx::CParticle* particle, + CRobotMain* main); virtual ~CObjectManager(); //! Registers new object @@ -52,8 +80,7 @@ public: const std::map& GetAllObjects(); //! Removes all objects void Flush(); - - + //! Creates an object CObject* CreateObject(Math::Vector pos, float angle, ObjectType type, float power = -1.f, float zoom = 1.f, float height = 0.f, bool trainer = false, bool toy = false, int option = 0); //! Destroys an object @@ -75,5 +102,6 @@ public: protected: std::map m_table; + std::unique_ptr m_objectFactory; }; diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index d60bdcb7..ef322985 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -128,10 +128,13 @@ CRobotMain::CRobotMain(CController* controller) m_ctrl = controller; m_app = nullptr; + m_objMan = nullptr; + m_eventQueue = nullptr; m_sound = nullptr; m_engine = nullptr; + m_modelManager = nullptr; m_lightMan = nullptr; m_particle = nullptr; m_water = nullptr; @@ -153,7 +156,7 @@ CRobotMain::CRobotMain(CController* controller) m_time = 0.0f; m_gameTime = 0.0f; - + m_missionTimerEnabled = false; m_missionTimerStarted = false; m_missionTimer = 0.0f; @@ -245,6 +248,7 @@ void CRobotMain::Create(bool loadProfile) m_sound = m_app->GetSound(); m_engine = Gfx::CEngine::GetInstancePointer(); + m_modelManager = m_engine->GetModelManager(); m_lightMan = m_engine->GetLightManager(); m_particle = m_engine->GetParticle(); m_water = m_engine->GetWater(); @@ -263,7 +267,13 @@ void CRobotMain::Create(bool loadProfile) m_short = new Ui::CMainShort(); m_map = new Ui::CMainMap(); m_displayInfo = nullptr; - + + m_objMan = new CObjectManager(m_engine, + m_terrain, + m_modelManager, + m_particle, + this); + m_engine->SetTerrain(m_terrain); m_engine->SetMovieLock(m_movieLock); @@ -341,7 +351,10 @@ CRobotMain::~CRobotMain() delete m_map; m_map = nullptr; - + + delete m_objMan; + m_objMan = nullptr; + m_dialog = nullptr; m_input = nullptr; m_pause = nullptr; @@ -457,7 +470,7 @@ void CRobotMain::ChangePhase(Phase phase) m_engine->SetRankView(0); m_terrain->FlushRelief(); m_engine->DeleteAllObjects(); - Gfx::CModelManager::GetInstancePointer()->DeleteAllModelCopies(); + m_modelManager->DeleteAllModelCopies(); m_engine->SetWaterAddColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)); m_engine->SetBackground(""); m_engine->SetBackForce(false); @@ -489,8 +502,8 @@ void CRobotMain::ChangePhase(Phase phase) iMan->Flush(CLASS_PHYSICS); iMan->Flush(CLASS_BRAIN); iMan->Flush(CLASS_PYRO); - - CObjectManager::GetInstancePointer()->Flush(); + + m_objMan->Flush(); Math::Point dim, pos; @@ -1703,7 +1716,7 @@ void CRobotMain::StartDisplayVisit(EventType event) } Math::Vector goal = m_displayText->GetVisitGoal(event); - m_visitArrow = CObjectManager::GetInstancePointer()->CreateObject(goal, 0.0f, OBJECT_SHOW, -1.0f, 1.0f, 10.0f); + m_visitArrow = m_objMan->CreateObject(goal, 0.0f, OBJECT_SHOW, -1.0f, 1.0f, 10.0f); m_visitPos = m_visitArrow->GetPosition(0); m_visitPosArrow = m_visitPos; @@ -1799,7 +1812,7 @@ CObject* CRobotMain::GetSelectObject() CObject* CRobotMain::DeselectAll() { CObject* prev = nullptr; - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -1931,9 +1944,9 @@ void CRobotMain::DeleteAllObjects() for (int i = 0; i < MAXSHOWLIMIT; i++) FlushShowLimit(i); - while(CObjectManager::GetInstancePointer()->GetAllObjects().size() > 0) + while(m_objMan->GetAllObjects().size() > 0) { - CObject* obj = CObjectManager::GetInstancePointer()->GetAllObjects().begin()->second; + CObject* obj = m_objMan->GetAllObjects().begin()->second; obj->DeleteObject(true); // destroys rapidly delete obj; @@ -1949,13 +1962,13 @@ void CRobotMain::SelectHuman() //! Returns the object human CObject* CRobotMain::SearchHuman() { - return CObjectManager::GetInstancePointer()->FindNearest(nullptr, OBJECT_HUMAN); + return m_objMan->FindNearest(nullptr, OBJECT_HUMAN); } //! Returns the object toto CObject* CRobotMain::SearchToto() { - return CObjectManager::GetInstancePointer()->FindNearest(nullptr, OBJECT_TOTO); + return m_objMan->FindNearest(nullptr, OBJECT_TOTO); } //! Returns the nearest selectable object from a given position @@ -1963,7 +1976,7 @@ CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu) { float min = 100000.0f; CObject* best = 0; - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -1987,7 +2000,7 @@ CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu) //! Returns the selected object CObject* CRobotMain::GetSelect() { - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -1999,7 +2012,7 @@ CObject* CRobotMain::GetSelect() CObject* CRobotMain::SearchObject(ObjectType type) { - return CObjectManager::GetInstancePointer()->FindNearest(nullptr, type); + return m_objMan->FindNearest(nullptr, type); } //! Detects the object aimed by the mouse @@ -2007,7 +2020,7 @@ CObject* CRobotMain::DetectObject(Math::Point pos) { int objRank = m_engine->DetectObject(pos); - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -2247,7 +2260,7 @@ void CRobotMain::HiliteClear() int rank = -1; m_engine->SetHighlightRank(&rank); // nothing more selected - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -2407,7 +2420,7 @@ void CRobotMain::HelpObject() //! Change the mode of the camera void CRobotMain::ChangeCamera() { - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -2552,7 +2565,7 @@ void CRobotMain::RemoteCamera(float pan, float zoom, float rTime) //! Cancels the current movie void CRobotMain::AbortMovie() { - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -2812,7 +2825,7 @@ bool CRobotMain::EventObject(const Event &event) m_resetCreate = false; - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -2843,7 +2856,7 @@ void CRobotMain::ScenePerso() DeleteAllObjects(); // removes all the current 3D Scene m_terrain->FlushRelief(); m_engine->DeleteAllObjects(); - Gfx::CModelManager::GetInstancePointer()->DeleteAllModelCopies(); + m_modelManager->DeleteAllModelCopies(); m_terrain->FlushBuildingLevel(); m_terrain->FlushFlyingLimit(); m_lightMan->FlushLights(); @@ -2854,7 +2867,7 @@ void CRobotMain::ScenePerso() iMan->Flush(CLASS_BRAIN); iMan->Flush(CLASS_PYRO); - CObjectManager::GetInstancePointer()->Flush(); + m_objMan->Flush(); ChangeColor(); @@ -3468,7 +3481,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (line->GetCommand() == "MissionController" && read[0] == 0) { - m_controller = CObjectManager::GetInstancePointer()->CreateObject(Math::Vector(0.0f, 0.0f, 0.0f), 0.0f, OBJECT_CONTROLLER, 100.0f); + m_controller = m_objMan->CreateObject(Math::Vector(0.0f, 0.0f, 0.0f), 0.0f, OBJECT_CONTROLLER, 100.0f); m_controller->SetMagnifyDamage(100.0f); m_controller->SetIgnoreBuildCheck(true); CBrain* brain = m_controller->GetBrain(); @@ -3523,7 +3536,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) Math::Vector pos = line->GetParam("pos")->AsPoint()*g_unit; float dirAngle = line->GetParam("dir")->AsFloat(0.0f)*Math::PI; bool trainer; - CObject* obj = CObjectManager::GetInstancePointer()->CreateObject( + CObject* obj = m_objMan->CreateObject( pos, dirAngle, type, line->GetParam("power")->AsFloat(1.0f), @@ -4211,7 +4224,7 @@ bool CRobotMain::TestGadgetQuantity(int rank) float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu) { float min = 100000.0f; - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -4361,7 +4374,7 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* truck) // Calculates the maximum radius possible depending on other items. float oMax = 30.0f; // radius to build the biggest building float tMax; - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -4695,7 +4708,7 @@ void CRobotMain::LoadFileScript(CObject *obj, const char* filename, int objRank, //! Saves all programs of all the robots void CRobotMain::SaveAllScript() { - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -4848,7 +4861,7 @@ bool CRobotMain::IsBusy() { if (CScriptFunctions::m_CompteurFileOpen > 0) return true; - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -4979,7 +4992,7 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char * } int objRank = 0; - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -5030,7 +5043,7 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char * fWrite(&version, sizeof(long), 1, file); // version of CBOT objRank = 0; - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -5063,7 +5076,7 @@ CObject* CRobotMain::IOReadObject(CLevelParserLine *line, const char* filename, bool toy = line->GetParam("toy")->AsBool(false); int option = line->GetParam("option")->AsInt(0); - CObject* obj = CObjectManager::GetInstancePointer()->CreateObject(pos, dir.y, type, 0.0f, 1.0f, 0.0f, trainer, toy, option); + CObject* obj = m_objMan->CreateObject(pos, dir.y, type, 0.0f, 1.0f, 0.0f, trainer, toy, option); obj->SetDefRank(objRank); obj->SetPosition(0, pos); obj->SetAngle(0, dir); @@ -5433,7 +5446,7 @@ void CRobotMain::ResetCreate() iMan->Flush(CLASS_BRAIN); iMan->Flush(CLASS_PYRO); - CObjectManager::GetInstancePointer()->Flush(); + m_objMan->Flush(); m_camera->SetType(Gfx::CAM_TYPE_DIALOG); @@ -5442,7 +5455,7 @@ void CRobotMain::ResetCreate() if (!GetNiceReset()) return; - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -5474,7 +5487,7 @@ void CRobotMain::UpdateAudio(bool frame) Math::Vector oPos; int nb = 0; - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -5599,7 +5612,7 @@ Error CRobotMain::CheckEndMission(bool frame) Math::Vector oPos; int nb = 0; - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; @@ -5879,7 +5892,7 @@ bool CRobotMain::GetRadar() if (m_cheatRadar) return true; - for(auto it : CObjectManager::GetInstancePointer()->GetAllObjects()) + for(auto it : m_objMan->GetAllObjects()) { CObject* obj = it.second; diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 78940d2f..d083e4de 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -79,6 +79,7 @@ class CEventQueue; class CSoundInterface; class CLevelParserLine; class CInput; +class CObjectManager; namespace Gfx { class CEngine; @@ -395,6 +396,7 @@ protected: protected: CController* m_ctrl; CApplication* m_app; + CObjectManager* m_objMan; CEventQueue* m_eventQueue; CMainMovie* m_movie; Gfx::CEngine* m_engine; @@ -403,6 +405,7 @@ protected: Gfx::CCloud* m_cloud; Gfx::CLightning* m_lightning; Gfx::CPlanet* m_planet; + Gfx::CModelManager* m_modelManager; Gfx::CLightManager* m_lightMan; Gfx::CTerrain* m_terrain; Gfx::CCamera* m_camera; diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp index 1a8ddcad..c74e2394 100644 --- a/src/object/task/taskbuild.cpp +++ b/src/object/task/taskbuild.cpp @@ -78,13 +78,8 @@ CTaskBuild::~CTaskBuild() bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle) { - m_building = new CObject(); - if ( !m_building->CreateBuilding(pos, angle, 0.0f, m_type, 0.0f) ) - { - delete m_building; - m_building = 0; - return false; - } + float power = 0.0f; + m_building = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, m_type, power); m_building->UpdateMapping(); m_building->SetLock(true); // not yet usable diff --git a/src/object/task/taskflag.cpp b/src/object/task/taskflag.cpp index 6d794043..617e72f7 100644 --- a/src/object/task/taskflag.cpp +++ b/src/object/task/taskflag.cpp @@ -185,15 +185,7 @@ int CTaskFlag::CountObject(ObjectType type) Error CTaskFlag::CreateFlag(int rank) { - CObject* pObj; - CObject* pNew; - Gfx::CPyro* pyro; - Math::Matrix* mat; - Math::Vector pos; - float dist; - int i; - - ObjectType table[5] = + ObjectType table[5] = { OBJECT_FLAGb, OBJECT_FLAGr, @@ -202,35 +194,31 @@ Error CTaskFlag::CreateFlag(int rank) OBJECT_FLAGv, }; - mat = m_object->GetWorldMatrix(0); - pos = Transform(*mat, Math::Vector(4.0f, 0.0f, 0.0f)); + Math::Matrix* mat = m_object->GetWorldMatrix(0); + Math::Vector pos = Transform(*mat, Math::Vector(4.0f, 0.0f, 0.0f)); - pObj = SearchNearest(pos, OBJECT_NULL); - if ( pObj != 0 ) + CObject* pObj = SearchNearest(pos, OBJECT_NULL); + if ( pObj != nullptr ) { - dist = Math::Distance(pos, pObj->GetPosition(0)); + float dist = Math::Distance(pos, pObj->GetPosition(0)); if ( dist < 10.0f ) { return ERR_FLAG_PROXY; } } - i = rank; - if ( CountObject(table[i]) >= 5 ) + ObjectType type = table[rank]; + if ( CountObject(type) >= 5 ) { return ERR_FLAG_CREATE; } - pNew = new CObject(); - if ( !pNew->CreateFlag(pos, 0.0f, table[i]) ) - { - delete pNew; - return ERR_TOOMANY; - } + float angle = 0.0f; + CObject* pNew = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, type); //pNew->SetZoom(0, 0.0f); m_sound->Play(SOUND_WAYPOINT, pos); - pyro = new Gfx::CPyro(); + Gfx::CPyro* pyro = new Gfx::CPyro(); pyro->Create(Gfx::PT_FLCREATE, pNew); return ERR_OK; diff --git a/src/object/task/taskrecover.cpp b/src/object/task/taskrecover.cpp index ea5e9044..f67948d0 100644 --- a/src/object/task/taskrecover.cpp +++ b/src/object/task/taskrecover.cpp @@ -302,16 +302,7 @@ Error CTaskRecover::IsEnded() if ( m_phase == TRP_DOWN ) { - m_metal = new CObject(); - if ( !m_metal->CreateResource(m_recoverPos, 0.0f, OBJECT_METAL) ) - { - delete m_metal; - m_metal = 0; - Abort(); - m_bError = true; - m_main->DisplayError(ERR_TOOMANY, m_object); - return ERR_STOP; - } + m_metal = CObjectManager::GetInstancePointer()->CreateObject(m_recoverPos, 0.0f, OBJECT_METAL); m_metal->SetLock(true); // metal not yet usable m_metal->SetZoom(0, 0.0f); diff --git a/src/object/task/tasksearch.cpp b/src/object/task/tasksearch.cpp index dedcb084..9514bdab 100644 --- a/src/object/task/tasksearch.cpp +++ b/src/object/task/tasksearch.cpp @@ -25,11 +25,11 @@ #include "math/geometry.h" -#include "physics/physics.h" - #include "object/objman.h" #include "object/robotmain.h" +#include "physics/physics.h" + // Object's constructor. @@ -235,21 +235,15 @@ bool CTaskSearch::Abort() bool CTaskSearch::CreateMark() { - CObject* fret; - ObjectType type; - Math::Matrix* mat; - Math::Vector pos; - Gfx::TerrainRes res; - Error info; - - mat = m_object->GetWorldMatrix(0); - pos = Math::Vector(7.5f, 0.0f, 0.0f); + Math::Matrix* mat = m_object->GetWorldMatrix(0); + Math::Vector pos = Math::Vector(7.5f, 0.0f, 0.0f); pos = Math::Transform(*mat, pos); // sensor position - res = m_terrain->GetResource(pos); + Gfx::TerrainRes res = m_terrain->GetResource(pos); if ( res == Gfx::TR_NULL ) return false; - type = OBJECT_NULL; + ObjectType type = OBJECT_NULL; + Error info = ERR_OK; if ( res == Gfx::TR_STONE ) { type = OBJECT_MARKSTONE; @@ -289,13 +283,7 @@ bool CTaskSearch::CreateMark() //? DeleteMark(type); - fret = new CObject(); - if ( !fret->CreateResource(pos, 0.0f, type) ) - { - delete fret; - m_main->DisplayError(ERR_TOOMANY, m_object); - return false; - } + CObjectManager::GetInstancePointer()->CreateObject(pos, 0.0f, type); m_main->DisplayError(info, pos, 5.0f, 50.0f); // displays the message diff --git a/src/script/scriptfunc.cpp b/src/script/scriptfunc.cpp index 2da058ca..18bdc73a 100644 --- a/src/script/scriptfunc.cpp +++ b/src/script/scriptfunc.cpp @@ -1675,48 +1675,46 @@ CBotTypResult CScriptFunctions::cProduce(CBotVar* &var, void* user) bool CScriptFunctions::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user) { CScript* script = (static_cast(user))->GetRunScript(); - CObject* object; CObject* me = (static_cast(user)); - CBotString cbs; - const char* name; - Math::Vector pos; - float angle; - ObjectType type; - float power; - + const char* name = ""; + Math::Vector pos; + float angle = 0.0f; + ObjectType type = OBJECT_NULL; + float power = 0.0f; + if ( var->GetType() <= CBotTypDouble ) { type = static_cast(var->GetValInt()); var = var->GetNext(); - + pos = me->GetPosition(0); - + Math::Vector rotation = me->GetAngle(0) + me->GetInclinaison(); angle = rotation.y; - - if( var != 0 ) + + if( var != nullptr ) power = var->GetValFloat(); else power = -1.0f; - + name = ""; } else { if ( !GetPoint(var, exception, pos) ) return true; - + angle = var->GetValFloat()*Math::PI/180.0f; var = var->GetNext(); - + type = static_cast(var->GetValInt()); var = var->GetNext(); - - if ( var != 0 ) + + if ( var != nullptr ) { - cbs = var->GetValString(); + CBotString cbs = var->GetValString(); name = cbs; var = var->GetNext(); - if ( var != 0 ) + if ( var != nullptr ) { power = var->GetValFloat(); } @@ -1731,30 +1729,24 @@ bool CScriptFunctions::rProduce(CBotVar* var, CBotVar* result, int& exception, v power = -1.0f; } } - + + CObject* object = nullptr; + if ( type == OBJECT_ANT || type == OBJECT_SPIDER || type == OBJECT_BEE || type == OBJECT_WORM ) { - CObject* egg; - - object = new CObject(); - if ( !object->CreateInsect(pos, angle, type) ) - { - delete object; - result->SetValInt(1); // error - return true; - } - - egg = new CObject(); - if ( !egg->CreateResource(pos, angle, OBJECT_EGG, 0.0f) ) - { - delete egg; - } + CObject* object = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, type); + CObjectManager::GetInstancePointer()->CreateObject(pos, angle, OBJECT_EGG, 0.0f); object->SetActivity(false); - } else { - if ((type == OBJECT_POWER || type == OBJECT_ATOMIC) && power == -1.0f) power = 1.0f; + } + else + { + if ((type == OBJECT_POWER || type == OBJECT_ATOMIC) && power == -1.0f) + { + power = 1.0f; + } object = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, type, power); if ( object == nullptr ) { @@ -1763,7 +1755,7 @@ bool CScriptFunctions::rProduce(CBotVar* var, CBotVar* result, int& exception, v } script->m_main->CreateShortcuts(); } - + if (name[0] != 0) { std::string name2 = CPathManager::InjectLevelDir(name, "ai"); @@ -1775,7 +1767,7 @@ bool CScriptFunctions::rProduce(CBotVar* var, CBotVar* result, int& exception, v brain->RunProgram(program); } } - + result->SetValInt(0); // no error return true; }