Engine optimization - rewritten model management
- new class CModelManager - rewritten engine object structure in CEngine - created shared model data instead of separate objects per each model instance - minor refactoringdev-ui
parent
f9f15a2f3f
commit
5574eccebd
|
@ -61,6 +61,7 @@ graphics/engine/engine.cpp
|
||||||
graphics/engine/lightman.cpp
|
graphics/engine/lightman.cpp
|
||||||
graphics/engine/lightning.cpp
|
graphics/engine/lightning.cpp
|
||||||
graphics/engine/modelfile.cpp
|
graphics/engine/modelfile.cpp
|
||||||
|
graphics/engine/modelmanager.cpp
|
||||||
graphics/engine/particle.cpp
|
graphics/engine/particle.cpp
|
||||||
graphics/engine/planet.cpp
|
graphics/engine/planet.cpp
|
||||||
graphics/engine/pyro.cpp
|
graphics/engine/pyro.cpp
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "common/image.h"
|
#include "common/image.h"
|
||||||
#include "common/key.h"
|
#include "common/key.h"
|
||||||
|
|
||||||
|
#include "graphics/engine/modelmanager.h"
|
||||||
#include "graphics/opengl/gldevice.h"
|
#include "graphics/opengl/gldevice.h"
|
||||||
|
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
@ -94,6 +95,7 @@ CApplication::CApplication()
|
||||||
|
|
||||||
m_engine = nullptr;
|
m_engine = nullptr;
|
||||||
m_device = nullptr;
|
m_device = nullptr;
|
||||||
|
m_modelManager = nullptr;
|
||||||
m_robotMain = nullptr;
|
m_robotMain = nullptr;
|
||||||
m_sound = nullptr;
|
m_sound = nullptr;
|
||||||
|
|
||||||
|
@ -142,8 +144,6 @@ CApplication::CApplication()
|
||||||
|
|
||||||
m_lowCPU = true;
|
m_lowCPU = true;
|
||||||
|
|
||||||
m_useVbo = false;
|
|
||||||
|
|
||||||
for (int i = 0; i < DIR_MAX; ++i)
|
for (int i = 0; i < DIR_MAX; ++i)
|
||||||
m_dataDirs[i] = nullptr;
|
m_dataDirs[i] = nullptr;
|
||||||
|
|
||||||
|
@ -245,10 +245,6 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
SetDebugMode(true);
|
SetDebugMode(true);
|
||||||
}
|
}
|
||||||
else if (arg == "-vbo")
|
|
||||||
{
|
|
||||||
m_useVbo = true;
|
|
||||||
}
|
|
||||||
else if (arg == "-loglevel")
|
else if (arg == "-loglevel")
|
||||||
{
|
{
|
||||||
waitLogLevel = true;
|
waitLogLevel = true;
|
||||||
|
@ -432,8 +428,6 @@ bool CApplication::Create()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static_cast<Gfx::CGLDevice*>(m_device)->SetUseVbo(m_useVbo);
|
|
||||||
|
|
||||||
// Create the 3D engine
|
// Create the 3D engine
|
||||||
m_engine = new Gfx::CEngine(m_iMan, this);
|
m_engine = new Gfx::CEngine(m_iMan, this);
|
||||||
|
|
||||||
|
@ -446,6 +440,9 @@ bool CApplication::Create()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create model manager
|
||||||
|
m_modelManager = new Gfx::CModelManager(m_engine);
|
||||||
|
|
||||||
// Create the robot application.
|
// Create the robot application.
|
||||||
m_robotMain = new CRobotMain(m_iMan, this);
|
m_robotMain = new CRobotMain(m_iMan, this);
|
||||||
|
|
||||||
|
@ -525,6 +522,12 @@ void CApplication::Destroy()
|
||||||
m_sound = nullptr;
|
m_sound = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_modelManager != nullptr)
|
||||||
|
{
|
||||||
|
delete m_modelManager;
|
||||||
|
m_modelManager = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_engine != nullptr)
|
if (m_engine != nullptr)
|
||||||
{
|
{
|
||||||
m_engine->Destroy();
|
m_engine->Destroy();
|
||||||
|
|
|
@ -42,6 +42,10 @@ class CEventQueue;
|
||||||
class CRobotMain;
|
class CRobotMain;
|
||||||
class CSoundInterface;
|
class CSoundInterface;
|
||||||
|
|
||||||
|
namespace Gfx {
|
||||||
|
class CModelManager;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \struct JoystickDevice
|
* \struct JoystickDevice
|
||||||
* \brief Information about a joystick device
|
* \brief Information about a joystick device
|
||||||
|
@ -369,11 +373,15 @@ protected:
|
||||||
Gfx::CEngine* m_engine;
|
Gfx::CEngine* m_engine;
|
||||||
//! Graphics device
|
//! Graphics device
|
||||||
Gfx::CDevice* m_device;
|
Gfx::CDevice* m_device;
|
||||||
|
//! 3D models manager
|
||||||
|
Gfx::CModelManager* m_modelManager;
|
||||||
//! Sound subsystem
|
//! Sound subsystem
|
||||||
CSoundInterface* m_sound;
|
CSoundInterface* m_sound;
|
||||||
//! Main class of the proper game engine
|
//! Main class of the proper game engine
|
||||||
CRobotMain* m_robotMain;
|
CRobotMain* m_robotMain;
|
||||||
|
//! Plugin manager
|
||||||
CPluginManager* m_pluginManager;
|
CPluginManager* m_pluginManager;
|
||||||
|
//! Profile (INI) reader/writer
|
||||||
CProfile* m_profile;
|
CProfile* m_profile;
|
||||||
|
|
||||||
//! Code to return at exit
|
//! Code to return at exit
|
||||||
|
@ -449,7 +457,5 @@ protected:
|
||||||
|
|
||||||
//! Low cpu mode
|
//! Low cpu mode
|
||||||
bool m_lowCPU;
|
bool m_lowCPU;
|
||||||
|
|
||||||
int m_useVbo; // TODO: temporary
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -317,19 +317,28 @@ public:
|
||||||
virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount) = 0;
|
virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount) = 0;
|
||||||
|
|
||||||
//! Creates a static buffer composed of given primitives with single texture vertices
|
//! Creates a static buffer composed of given primitives with single texture vertices
|
||||||
virtual unsigned int CreateStaticObject(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) = 0;
|
virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) = 0;
|
||||||
|
|
||||||
//! Creates a static buffer composed of given primitives with multitexturing (2 textures)
|
//! Creates a static buffer composed of given primitives with multitexturing
|
||||||
virtual unsigned int CreateStaticObject(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) = 0;
|
virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) = 0;
|
||||||
|
|
||||||
//! Creates a static buffer composed of given primitives with solid color
|
//! Creates a static buffer composed of given primitives with solid color
|
||||||
virtual unsigned int CreateStaticObject(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) = 0;
|
virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) = 0;
|
||||||
|
|
||||||
|
//! Updates the static buffer composed of given primitives with single texture vertices
|
||||||
|
virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) = 0;
|
||||||
|
|
||||||
|
//! Updates the static buffer composed of given primitives with multitexturing
|
||||||
|
virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) = 0;
|
||||||
|
|
||||||
|
//! Updates the static buffer composed of given primitives with solid color
|
||||||
|
virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) = 0;
|
||||||
|
|
||||||
//! Draws a static buffer
|
//! Draws a static buffer
|
||||||
virtual void DrawStaticObject(unsigned int objectId) = 0;
|
virtual void DrawStaticBuffer(unsigned int bufferId) = 0;
|
||||||
|
|
||||||
//! Deletes a static buffer
|
//! Deletes a static buffer
|
||||||
virtual void DestroyStaticObject(unsigned int objectId) = 0;
|
virtual void DestroyStaticBuffer(unsigned int bufferId) = 0;
|
||||||
|
|
||||||
//! Tests whether a sphere is (partially) within the frustum volume
|
//! Tests whether a sphere is (partially) within the frustum volume
|
||||||
//! Returns a mask of frustum planes for which the test is positive
|
//! Returns a mask of frustum planes for which the test is positive
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -151,7 +151,7 @@ struct EngineTriangle
|
||||||
//! 2nd texture
|
//! 2nd texture
|
||||||
std::string tex2Name;
|
std::string tex2Name;
|
||||||
|
|
||||||
EngineTriangle()
|
inline EngineTriangle()
|
||||||
{
|
{
|
||||||
state = ENG_RSTATE_NORMAL;
|
state = ENG_RSTATE_NORMAL;
|
||||||
}
|
}
|
||||||
|
@ -178,6 +178,97 @@ enum EngineObjectType
|
||||||
ENG_OBJTYPE_METAL = 6
|
ENG_OBJTYPE_METAL = 6
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \struct EngineBaseObjDataTier
|
||||||
|
* \brief Tier 4 of object tree (data)
|
||||||
|
*/
|
||||||
|
struct EngineBaseObjDataTier
|
||||||
|
{
|
||||||
|
bool used;
|
||||||
|
EngineTriangleType type;
|
||||||
|
Material material;
|
||||||
|
int state;
|
||||||
|
std::vector<VertexTex2> vertices;
|
||||||
|
unsigned int staticBufferId;
|
||||||
|
bool updateStaticBuffer;
|
||||||
|
|
||||||
|
inline EngineBaseObjDataTier(bool used = false,
|
||||||
|
EngineTriangleType type = ENG_TRIANGLE_TYPE_TRIANGLES,
|
||||||
|
const Material& material = Material(),
|
||||||
|
int state = ENG_RSTATE_NORMAL)
|
||||||
|
: used(used), type(type), material(material), state(state), staticBufferId(0), updateStaticBuffer(false) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \struct EngineBaseObjLODTier
|
||||||
|
* \brief Tier 3 of base object tree (LOD)
|
||||||
|
*/
|
||||||
|
struct EngineBaseObjLODTier
|
||||||
|
{
|
||||||
|
bool used;
|
||||||
|
float min;
|
||||||
|
float max;
|
||||||
|
std::vector<EngineBaseObjDataTier> next;
|
||||||
|
|
||||||
|
inline EngineBaseObjLODTier(bool used = false, float min = 0.0f, float max = 0.0f)
|
||||||
|
: used(used), min(min), max(max) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \struct EngineBaseObjTexTier
|
||||||
|
* \brief Tier 2 of base object tree (textures)
|
||||||
|
*/
|
||||||
|
struct EngineBaseObjTexTier
|
||||||
|
{
|
||||||
|
bool used;
|
||||||
|
std::string tex1Name;
|
||||||
|
Texture tex1;
|
||||||
|
std::string tex2Name;
|
||||||
|
Texture tex2;
|
||||||
|
std::vector<EngineBaseObjLODTier> next;
|
||||||
|
|
||||||
|
inline EngineBaseObjTexTier(bool used = false, const std::string& tex1Name = "",
|
||||||
|
const std::string& tex2Name = "")
|
||||||
|
: used(used), tex1Name(tex1Name), tex2Name(tex2Name) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \struct BaseEngineObject
|
||||||
|
* \brief Base (template) object - geometry for engine objects
|
||||||
|
*
|
||||||
|
* This is also the tier 1 of base object tree.
|
||||||
|
*/
|
||||||
|
struct EngineBaseObject
|
||||||
|
{
|
||||||
|
//! If true, base object is valid in objects vector
|
||||||
|
bool used;
|
||||||
|
//! Number of triangles
|
||||||
|
int totalTriangles;
|
||||||
|
//! Bounding box min (origin 0,0,0 always included)
|
||||||
|
Math::Vector bboxMin;
|
||||||
|
//! bounding box max (origin 0,0,0 always included)
|
||||||
|
Math::Vector bboxMax;
|
||||||
|
//! Radius of the sphere at the origin
|
||||||
|
float radius;
|
||||||
|
//! Next tier (LOD)
|
||||||
|
std::vector<EngineBaseObjTexTier> next;
|
||||||
|
|
||||||
|
inline EngineBaseObject()
|
||||||
|
{
|
||||||
|
LoadDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void LoadDefault()
|
||||||
|
{
|
||||||
|
used = false;
|
||||||
|
totalTriangles = 0;
|
||||||
|
bboxMax.LoadZero();
|
||||||
|
bboxMin.LoadZero();
|
||||||
|
radius = 0.0f;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \struct EngineObject
|
* \struct EngineObject
|
||||||
* \brief Object drawn by the graphics engine
|
* \brief Object drawn by the graphics engine
|
||||||
|
@ -186,35 +277,27 @@ struct EngineObject
|
||||||
{
|
{
|
||||||
//! If true, object is valid in objects vector
|
//! If true, object is valid in objects vector
|
||||||
bool used;
|
bool used;
|
||||||
|
//! Rank of associated base engine object
|
||||||
|
int baseObjRank;
|
||||||
//! If true, the object is drawn
|
//! If true, the object is drawn
|
||||||
bool visible;
|
bool visible;
|
||||||
//! If true, object is behind the 2D interface
|
//! If true, object is behind the 2D interface
|
||||||
bool drawWorld;
|
bool drawWorld;
|
||||||
//! If true, the shape is before the 2D interface
|
//! If true, the shape is before the 2D interface
|
||||||
bool drawFront;
|
bool drawFront;
|
||||||
//! Number of triangles
|
|
||||||
int totalTriangles;
|
|
||||||
//! Type of object
|
//! Type of object
|
||||||
EngineObjectType type;
|
EngineObjectType type;
|
||||||
//! Whether the object is stored and rendered as static buffer
|
|
||||||
bool staticBuffer;
|
|
||||||
//! Transformation matrix
|
//! Transformation matrix
|
||||||
Math::Matrix transform;
|
Math::Matrix transform;
|
||||||
//! Distance to object from eye point
|
//! Distance to object from eye point
|
||||||
float distance;
|
float distance;
|
||||||
//! Bounding box min (origin 0,0,0 always included)
|
|
||||||
Math::Vector bboxMin;
|
|
||||||
//! bounding box max (origin 0,0,0 always included)
|
|
||||||
Math::Vector bboxMax;
|
|
||||||
//! Radius of the sphere at the origin
|
|
||||||
float radius;
|
|
||||||
//! Rank of the associated shadow
|
//! Rank of the associated shadow
|
||||||
int shadowRank;
|
int shadowRank;
|
||||||
//! Transparency of the object [0, 1]
|
//! Transparency of the object [0, 1]
|
||||||
float transparency;
|
float transparency;
|
||||||
|
|
||||||
//! Calls LoadDefault()
|
//! Calls LoadDefault()
|
||||||
EngineObject()
|
inline EngineObject()
|
||||||
{
|
{
|
||||||
LoadDefault();
|
LoadDefault();
|
||||||
}
|
}
|
||||||
|
@ -223,90 +306,18 @@ struct EngineObject
|
||||||
inline void LoadDefault()
|
inline void LoadDefault()
|
||||||
{
|
{
|
||||||
used = false;
|
used = false;
|
||||||
|
baseObjRank = -1;
|
||||||
visible = false;
|
visible = false;
|
||||||
drawWorld = false;
|
drawWorld = false;
|
||||||
drawFront = false;
|
drawFront = false;
|
||||||
totalTriangles = 0;
|
|
||||||
staticBuffer = false;
|
|
||||||
type = ENG_OBJTYPE_NULL;
|
type = ENG_OBJTYPE_NULL;
|
||||||
transform.LoadIdentity();
|
transform.LoadIdentity();
|
||||||
bboxMax.LoadZero();
|
|
||||||
bboxMin.LoadZero();
|
|
||||||
distance = 0.0f;
|
distance = 0.0f;
|
||||||
radius = 0.0f;
|
|
||||||
shadowRank = -1;
|
shadowRank = -1;
|
||||||
transparency = 0.0f;
|
transparency = 0.0f;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EngineObjLevel1;
|
|
||||||
struct EngineObjLevel2;
|
|
||||||
struct EngineObjLevel3;
|
|
||||||
struct EngineObjLevel4;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \struct EngineObjLevel4
|
|
||||||
* \brief Tier 4 of object tree
|
|
||||||
*/
|
|
||||||
struct EngineObjLevel4
|
|
||||||
{
|
|
||||||
bool used;
|
|
||||||
EngineTriangleType type;
|
|
||||||
Material material;
|
|
||||||
int state;
|
|
||||||
std::vector<VertexTex2> vertices;
|
|
||||||
unsigned int staticBufferId;
|
|
||||||
|
|
||||||
EngineObjLevel4(bool used = false,
|
|
||||||
EngineTriangleType type = ENG_TRIANGLE_TYPE_TRIANGLES,
|
|
||||||
const Material& material = Material(),
|
|
||||||
int state = ENG_RSTATE_NORMAL);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \struct EngineObjLevel3
|
|
||||||
* \brief Tier 3 of object tree
|
|
||||||
*/
|
|
||||||
struct EngineObjLevel3
|
|
||||||
{
|
|
||||||
bool used;
|
|
||||||
float min;
|
|
||||||
float max;
|
|
||||||
std::vector<EngineObjLevel4> next;
|
|
||||||
|
|
||||||
EngineObjLevel3(bool used = false, float min = 0.0f, float max = 0.0f);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \struct EngineObjLevel2
|
|
||||||
* \brief Tier 2 of object tree
|
|
||||||
*/
|
|
||||||
struct EngineObjLevel2
|
|
||||||
{
|
|
||||||
bool used;
|
|
||||||
int objRank;
|
|
||||||
std::vector<EngineObjLevel3> next;
|
|
||||||
|
|
||||||
EngineObjLevel2(bool used = false, int objRank = -1);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \struct EngineObjLevel1
|
|
||||||
* \brief Tier 1 of object tree
|
|
||||||
*/
|
|
||||||
struct EngineObjLevel1
|
|
||||||
{
|
|
||||||
bool used;
|
|
||||||
std::string tex1Name;
|
|
||||||
Texture tex1;
|
|
||||||
std::string tex2Name;
|
|
||||||
Texture tex2;
|
|
||||||
std::vector<EngineObjLevel2> next;
|
|
||||||
|
|
||||||
EngineObjLevel1(bool used = false, const std::string& tex1Name = "",
|
|
||||||
const std::string& tex2Name = "");
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \struct EngineShadowType
|
* \struct EngineShadowType
|
||||||
* \brief Type of shadow drawn by the graphics engine
|
* \brief Type of shadow drawn by the graphics engine
|
||||||
|
@ -346,12 +357,12 @@ struct EngineShadow
|
||||||
//! Height from the ground
|
//! Height from the ground
|
||||||
float height;
|
float height;
|
||||||
|
|
||||||
EngineShadow()
|
inline EngineShadow()
|
||||||
{
|
{
|
||||||
LoadDefault();
|
LoadDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadDefault()
|
inline void LoadDefault()
|
||||||
{
|
{
|
||||||
used = false;
|
used = false;
|
||||||
hide = false;
|
hide = false;
|
||||||
|
@ -388,12 +399,12 @@ struct EngineGroundSpot
|
||||||
//! Radius of the shadow drawn
|
//! Radius of the shadow drawn
|
||||||
float drawRadius;
|
float drawRadius;
|
||||||
|
|
||||||
EngineGroundSpot()
|
inline EngineGroundSpot()
|
||||||
{
|
{
|
||||||
LoadDefault();
|
LoadDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadDefault()
|
inline void LoadDefault()
|
||||||
{
|
{
|
||||||
used = false;
|
used = false;
|
||||||
color = Color();
|
color = Color();
|
||||||
|
@ -452,12 +463,12 @@ struct EngineGroundMark
|
||||||
//! Pointer to the table
|
//! Pointer to the table
|
||||||
char* table;
|
char* table;
|
||||||
|
|
||||||
EngineGroundMark()
|
inline EngineGroundMark()
|
||||||
{
|
{
|
||||||
LoadDefault();
|
LoadDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadDefault()
|
inline void LoadDefault()
|
||||||
{
|
{
|
||||||
draw = false;
|
draw = false;
|
||||||
phase = ENG_GR_MARK_PHASE_NULL;
|
phase = ENG_GR_MARK_PHASE_NULL;
|
||||||
|
@ -549,10 +560,10 @@ struct EngineMouse
|
||||||
//! Hot point
|
//! Hot point
|
||||||
Math::Point hotPoint;
|
Math::Point hotPoint;
|
||||||
|
|
||||||
EngineMouse(int icon1 = -1, int icon2 = -1, int iconShadow = -1,
|
inline EngineMouse(int icon1 = -1, int icon2 = -1, int iconShadow = -1,
|
||||||
EngineRenderState mode1 = ENG_RSTATE_NORMAL,
|
EngineRenderState mode1 = ENG_RSTATE_NORMAL,
|
||||||
EngineRenderState mode2 = ENG_RSTATE_NORMAL,
|
EngineRenderState mode2 = ENG_RSTATE_NORMAL,
|
||||||
Math::Point hotPoint = Math::Point())
|
Math::Point hotPoint = Math::Point())
|
||||||
{
|
{
|
||||||
this->icon1 = icon1;
|
this->icon1 = icon1;
|
||||||
this->icon2 = icon2;
|
this->icon2 = icon2;
|
||||||
|
@ -745,64 +756,73 @@ public:
|
||||||
|
|
||||||
/* *************** Object management *************** */
|
/* *************** Object management *************** */
|
||||||
|
|
||||||
|
// Base objects
|
||||||
|
|
||||||
|
//! Creates a base object and returns its rank
|
||||||
|
int CreateBaseObject();
|
||||||
|
//! Deletes a base object
|
||||||
|
void DeleteBaseObject(int baseObjRank);
|
||||||
|
//! Deletes all base objects
|
||||||
|
void DeleteAllBaseObjects();
|
||||||
|
|
||||||
|
//! Copies geometry between two base objects
|
||||||
|
void CopyBaseObject(int sourceBaseObjRank, int destBaseObjRank);
|
||||||
|
|
||||||
|
//! Adds triangles to given object with the specified params
|
||||||
|
void AddBaseObjTriangles(int baseObjRank, const std::vector<VertexTex2>& vertices,
|
||||||
|
EngineTriangleType triangleType,
|
||||||
|
const Material& material, int state,
|
||||||
|
std::string tex1Name, std::string tex2Name,
|
||||||
|
float min, float max, bool globalUpdate);
|
||||||
|
|
||||||
|
//! Adds a tier 4 engine object directly
|
||||||
|
void AddBaseObjQuick(int baseObjRank, const EngineBaseObjDataTier& buffer,
|
||||||
|
std::string tex1Name, std::string tex2Name,
|
||||||
|
float min, float max, bool globalUpdate);
|
||||||
|
|
||||||
|
// Objects
|
||||||
|
|
||||||
//! Creates a new object and returns its rank
|
//! Creates a new object and returns its rank
|
||||||
int CreateObject();
|
int CreateObject();
|
||||||
//! Deletes all objects, shadows and ground spots
|
//! Deletes all objects, shadows and ground spots
|
||||||
void FlushObject();
|
void DeleteAllObjects();
|
||||||
//! Deletes the given object
|
//! Deletes the given object
|
||||||
bool DeleteObject(int objRank);
|
void DeleteObject(int objRank);
|
||||||
|
|
||||||
|
//@{
|
||||||
|
//! Management of the base object rank for engine object
|
||||||
|
void SetObjectBaseRank(int objRank, int baseObjRank);
|
||||||
|
int GetObjectBaseRank(int objRank);
|
||||||
|
//@}
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
//! Management of engine object type
|
//! Management of engine object type
|
||||||
bool SetObjectType(int objRank, EngineObjectType type);
|
void SetObjectType(int objRank, EngineObjectType type);
|
||||||
EngineObjectType GetObjectType(int objRank);
|
EngineObjectType GetObjectType(int objRank);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
//! Management of object transform
|
//! Management of object transform
|
||||||
bool SetObjectTransform(int objRank, const Math::Matrix& transform);
|
void SetObjectTransform(int objRank, const Math::Matrix& transform);
|
||||||
bool GetObjectTransform(int objRank, Math::Matrix& transform);
|
void GetObjectTransform(int objRank, Math::Matrix& transform);
|
||||||
//@}
|
|
||||||
|
|
||||||
//@{
|
|
||||||
//! Management of object static drawing flag
|
|
||||||
void SetObjectStatic(int objRank, bool staticBuffer);
|
|
||||||
bool GetObjectStatic(int objRank);
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//! Sets drawWorld for given object
|
//! Sets drawWorld for given object
|
||||||
bool SetObjectDrawWorld(int objRank, bool draw);
|
void SetObjectDrawWorld(int objRank, bool draw);
|
||||||
//! Sets drawFront for given object
|
//! Sets drawFront for given object
|
||||||
bool SetObjectDrawFront(int objRank, bool draw);
|
void SetObjectDrawFront(int objRank, bool draw);
|
||||||
|
|
||||||
//! Sets the transparency level for given object
|
//! Sets the transparency level for given object
|
||||||
bool SetObjectTransparency(int objRank, float value);
|
void SetObjectTransparency(int objRank, float value);
|
||||||
|
|
||||||
//! Returns the bounding box for an object
|
//! Returns the bounding box for an object
|
||||||
bool GetObjectBBox(int objRank, Math::Vector& min, Math::Vector& max);
|
void GetObjectBBox(int objRank, Math::Vector& min, Math::Vector& max);
|
||||||
|
|
||||||
//! Returns the total number of triangles of given object
|
//! Returns the total number of triangles of given object
|
||||||
int GetObjectTotalTriangles(int objRank);
|
int GetObjectTotalTriangles(int objRank);
|
||||||
|
|
||||||
//! Adds triangles to given object with the specified params
|
|
||||||
bool AddTriangles(int objRank, const std::vector<VertexTex2>& vertices,
|
|
||||||
const Material& material, int state,
|
|
||||||
std::string tex1Name, std::string tex2Name,
|
|
||||||
float min, float max, bool globalUpdate);
|
|
||||||
|
|
||||||
//! Adds a surface to given object with the specified params
|
|
||||||
bool AddSurface(int objRank, const std::vector<VertexTex2>& vertices,
|
|
||||||
const Material& material, int state,
|
|
||||||
std::string tex1Name, std::string tex2Name,
|
|
||||||
float min, float max, bool globalUpdate);
|
|
||||||
|
|
||||||
//! Adds a tier 4 engine object directly
|
|
||||||
bool AddQuick(int objRank, const EngineObjLevel4& buffer,
|
|
||||||
std::string tex1Name, std::string tex2Name,
|
|
||||||
float min, float max, bool globalUpdate);
|
|
||||||
|
|
||||||
//! Returns the first found tier 4 engine object for the given params or nullptr if not found
|
//! Returns the first found tier 4 engine object for the given params or nullptr if not found
|
||||||
EngineObjLevel4* FindTriangles(int objRank, const Material& material,
|
EngineBaseObjDataTier* FindTriangles(int objRank, const Material& material,
|
||||||
int state, std::string tex1Name, std::string tex2Name,
|
int state, std::string tex1Name, std::string tex2Name,
|
||||||
float min, float max);
|
float min, float max);
|
||||||
|
|
||||||
|
@ -814,16 +834,16 @@ public:
|
||||||
void ChangeLOD();
|
void ChangeLOD();
|
||||||
|
|
||||||
//! Changes the 2nd texure for given object
|
//! Changes the 2nd texure for given object
|
||||||
bool ChangeSecondTexture(int objRank, const std::string& tex2Name);
|
void ChangeSecondTexture(int objRank, const std::string& tex2Name);
|
||||||
|
|
||||||
//! Changes (recalculates) texture mapping for given object
|
//! Changes (recalculates) texture mapping for given object
|
||||||
bool ChangeTextureMapping(int objRank, const Material& mat, int state,
|
void ChangeTextureMapping(int objRank, const Material& mat, int state,
|
||||||
const std::string& tex1Name, const std::string& tex2Name,
|
const std::string& tex1Name, const std::string& tex2Name,
|
||||||
float min, float max, EngineTextureMapping mode,
|
float min, float max, EngineTextureMapping mode,
|
||||||
float au, float bu, float av, float bv);
|
float au, float bu, float av, float bv);
|
||||||
|
|
||||||
//! Changes texture mapping for robot tracks
|
//! Changes texture mapping for robot tracks
|
||||||
bool TrackTextureMapping(int objRank, const Material& mat, int state,
|
void TrackTextureMapping(int objRank, const Material& mat, int state,
|
||||||
const std::string& tex1Name, const std::string& tex2Name,
|
const std::string& tex1Name, const std::string& tex2Name,
|
||||||
float min, float max, EngineTextureMapping mode,
|
float min, float max, EngineTextureMapping mode,
|
||||||
float pos, float factor, float tl, float ts, float tt);
|
float pos, float factor, float tl, float ts, float tt);
|
||||||
|
@ -833,20 +853,20 @@ public:
|
||||||
int DetectObject(Math::Point mouse);
|
int DetectObject(Math::Point mouse);
|
||||||
|
|
||||||
//! Creates a shadow for the given object
|
//! Creates a shadow for the given object
|
||||||
bool CreateShadow(int objRank);
|
void CreateShadow(int objRank);
|
||||||
//! Deletes the shadow for given object
|
//! Deletes the shadow for given object
|
||||||
void DeleteShadow(int objRank);
|
void DeleteShadow(int objRank);
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
//! Management of different shadow params
|
//! Management of different shadow params
|
||||||
bool SetObjectShadowHide(int objRank, bool hide);
|
void SetObjectShadowHide(int objRank, bool hide);
|
||||||
bool SetObjectShadowType(int objRank, EngineShadowType type);
|
void SetObjectShadowType(int objRank, EngineShadowType type);
|
||||||
bool SetObjectShadowPos(int objRank, const Math::Vector& pos);
|
void SetObjectShadowPos(int objRank, const Math::Vector& pos);
|
||||||
bool SetObjectShadowNormal(int objRank, const Math::Vector& normal);
|
void SetObjectShadowNormal(int objRank, const Math::Vector& normal);
|
||||||
bool SetObjectShadowAngle(int objRank, float angle);
|
void SetObjectShadowAngle(int objRank, float angle);
|
||||||
bool SetObjectShadowRadius(int objRank, float radius);
|
void SetObjectShadowRadius(int objRank, float radius);
|
||||||
bool SetObjectShadowIntensity(int objRank, float intensity);
|
void SetObjectShadowIntensity(int objRank, float intensity);
|
||||||
bool SetObjectShadowHeight(int objRank, float height);
|
void SetObjectShadowHeight(int objRank, float height);
|
||||||
float GetObjectShadowRadius(int objRank);
|
float GetObjectShadowRadius(int objRank);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
@ -856,7 +876,7 @@ public:
|
||||||
bool GetHighlight(Math::Point& p1, Math::Point& p2);
|
bool GetHighlight(Math::Point& p1, Math::Point& p2);
|
||||||
|
|
||||||
//! Deletes all ground spots
|
//! Deletes all ground spots
|
||||||
void FlushGroundSpot();
|
void DeleteAllGroundSpots();
|
||||||
//! Creates a new ground spot and returns its rank
|
//! Creates a new ground spot and returns its rank
|
||||||
int CreateGroundSpot();
|
int CreateGroundSpot();
|
||||||
//! Deletes the given ground spot
|
//! Deletes the given ground spot
|
||||||
|
@ -864,11 +884,11 @@ public:
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
//! Management of different ground spot params
|
//! Management of different ground spot params
|
||||||
bool SetObjectGroundSpotPos(int rank, const Math::Vector& pos);
|
void SetObjectGroundSpotPos(int rank, const Math::Vector& pos);
|
||||||
bool SetObjectGroundSpotRadius(int rank, float radius);
|
void SetObjectGroundSpotRadius(int rank, float radius);
|
||||||
bool SetObjectGroundSpotColor(int rank, const Color& color);
|
void SetObjectGroundSpotColor(int rank, const Color& color);
|
||||||
bool SetObjectGroundSpotMinMax(int rank, float min, float max);
|
void SetObjectGroundSpotMinMax(int rank, float min, float max);
|
||||||
bool SetObjectGroundSpotSmooth(int rank, float smooth);
|
void SetObjectGroundSpotSmooth(int rank, float smooth);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//! Creates the ground mark with the given params
|
//! Creates the ground mark with the given params
|
||||||
|
@ -1162,7 +1182,7 @@ protected:
|
||||||
//! Prepares the interface for 3D scene
|
//! Prepares the interface for 3D scene
|
||||||
void Draw3DScene();
|
void Draw3DScene();
|
||||||
//! Draw 3D object
|
//! Draw 3D object
|
||||||
void DrawObject(const EngineObjLevel4& obj, bool staticBuffer);
|
void DrawObject(const EngineBaseObjDataTier& p4);
|
||||||
//! Draws the user interface over the scene
|
//! Draws the user interface over the scene
|
||||||
void DrawInterface();
|
void DrawInterface();
|
||||||
|
|
||||||
|
@ -1192,15 +1212,13 @@ protected:
|
||||||
//! Draw statistic texts
|
//! Draw statistic texts
|
||||||
void DrawStats();
|
void DrawStats();
|
||||||
|
|
||||||
//! Creates new tier 1 object
|
//! Creates a new tier 2 object (texture)
|
||||||
EngineObjLevel1& AddLevel1(const std::string& tex1Name, const std::string& tex2Name);
|
EngineBaseObjTexTier& AddLevel2(int baseObjRank, const std::string& tex1Name, const std::string& tex2Name);
|
||||||
//! Creates a new tier 2 object
|
//! Creates a new tier 3 object (LOD)
|
||||||
EngineObjLevel2& AddLevel2(EngineObjLevel1 &p1, int objRank);
|
EngineBaseObjLODTier& AddLevel3(EngineBaseObjTexTier &p2, float min, float max);
|
||||||
//! Creates a new tier 3 object
|
//! Creates a new tier 4 object (data)
|
||||||
EngineObjLevel3& AddLevel3(EngineObjLevel2 &p2, float min, float max);
|
EngineBaseObjDataTier& AddLevel4(EngineBaseObjLODTier &p3, EngineTriangleType type,
|
||||||
//! Creates a new tier 4 object
|
const Material& mat, int state);
|
||||||
EngineObjLevel4& AddLevel4(EngineObjLevel3 &p3, EngineTriangleType type,
|
|
||||||
const Material& mat, int state);
|
|
||||||
|
|
||||||
//! Create texture and add it to cache
|
//! Create texture and add it to cache
|
||||||
Texture CreateTexture(const std::string &texName, const TextureCreateParams ¶ms, CImage* image = nullptr);
|
Texture CreateTexture(const std::string &texName, const TextureCreateParams ¶ms, CImage* image = nullptr);
|
||||||
|
@ -1227,8 +1245,11 @@ protected:
|
||||||
//! Updates geometric parameters of objects (bounding box and radius)
|
//! Updates geometric parameters of objects (bounding box and radius)
|
||||||
void UpdateGeometry();
|
void UpdateGeometry();
|
||||||
|
|
||||||
|
//! Updates a given static buffer
|
||||||
|
void UpdateStaticBuffer(EngineBaseObjDataTier& p4);
|
||||||
|
|
||||||
//! Updates static buffers of changed objects
|
//! Updates static buffers of changed objects
|
||||||
void UpdateStaticObjects();
|
void UpdateStaticBuffers();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CInstanceManager* m_iMan;
|
CInstanceManager* m_iMan;
|
||||||
|
@ -1282,8 +1303,8 @@ protected:
|
||||||
//! Previous size of viewport window
|
//! Previous size of viewport window
|
||||||
Math::IntPoint m_lastSize;
|
Math::IntPoint m_lastSize;
|
||||||
|
|
||||||
//! Root of tree object structure (level 1 list)
|
//! Base objects (also level 1 tier list)
|
||||||
std::vector<EngineObjLevel1> m_objectTree;
|
std::vector<EngineBaseObject> m_baseObjects;
|
||||||
//! Object parameters
|
//! Object parameters
|
||||||
std::vector<EngineObject> m_objects;
|
std::vector<EngineObject> m_objects;
|
||||||
//! Shadow list
|
//! Shadow list
|
||||||
|
@ -1308,7 +1329,7 @@ protected:
|
||||||
Color m_waterAddColor;
|
Color m_waterAddColor;
|
||||||
int m_statisticTriangle;
|
int m_statisticTriangle;
|
||||||
bool m_updateGeometry;
|
bool m_updateGeometry;
|
||||||
bool m_updateStaticObjects;
|
bool m_updateStaticBuffers;
|
||||||
int m_alphaMode;
|
int m_alphaMode;
|
||||||
bool m_groundSpotVisible;
|
bool m_groundSpotVisible;
|
||||||
bool m_shadowVisible;
|
bool m_shadowVisible;
|
||||||
|
|
|
@ -34,22 +34,10 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: #ifndef checking for MODELFILE_NO_ENGINE
|
|
||||||
* is provided in this module to conditionally
|
|
||||||
* disable dependence on CEngine.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// Graphics module namespace
|
// Graphics module namespace
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
|
|
||||||
//! How big the triangle vector is by default
|
|
||||||
const int TRIANGLE_PREALLOCATE_COUNT = 2000;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ReadBinaryVertex(std::istream& stream, Vertex& vertex)
|
bool ReadBinaryVertex(std::istream& stream, Vertex& vertex)
|
||||||
{
|
{
|
||||||
vertex.coord.x = IOUtils::ReadBinaryFloat(stream);
|
vertex.coord.x = IOUtils::ReadBinaryFloat(stream);
|
||||||
|
@ -322,15 +310,8 @@ bool ReadLineString(std::istream& stream, const std::string& prefix, std::string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CModelFile::CModelFile(CInstanceManager* iMan)
|
CModelFile::CModelFile()
|
||||||
{
|
{
|
||||||
m_iMan = iMan;
|
|
||||||
|
|
||||||
#ifndef MODELFILE_NO_ENGINE
|
|
||||||
m_engine = static_cast<CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_triangles.reserve(TRIANGLE_PREALLOCATE_COUNT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CModelFile::~CModelFile()
|
CModelFile::~CModelFile()
|
||||||
|
@ -1155,99 +1136,6 @@ bool CModelFile::WriteBinaryModel(std::ostream& stream)
|
||||||
Other stuff
|
Other stuff
|
||||||
*******************************************************/
|
*******************************************************/
|
||||||
|
|
||||||
#ifndef MODELFILE_NO_ENGINE
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: move the function to CEngine or new class (CModelManager?)
|
|
||||||
* and make models shared static objects.
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool CModelFile::CreateEngineObject(int objRank)
|
|
||||||
{
|
|
||||||
std::vector<VertexTex2> vs(3, VertexTex2());
|
|
||||||
|
|
||||||
m_engine->SetObjectStatic(objRank, true); // TODO: make optional in the future
|
|
||||||
|
|
||||||
float limit[2];
|
|
||||||
limit[0] = m_engine->GetLimitLOD(0); // frontier AB as config
|
|
||||||
limit[1] = m_engine->GetLimitLOD(1); // frontier BC as config
|
|
||||||
|
|
||||||
for (int i = 0; i < static_cast<int>( m_triangles.size() ); i++)
|
|
||||||
{
|
|
||||||
float min = m_triangles[i].min;
|
|
||||||
float max = m_triangles[i].max;
|
|
||||||
|
|
||||||
// Standard frontiers -> config
|
|
||||||
if (min == 0.0f && max == 100.0f) // resolution A ?
|
|
||||||
{
|
|
||||||
max = limit[0];
|
|
||||||
}
|
|
||||||
else if (min == 100.0f && max == 200.0f) // resolution B ?
|
|
||||||
{
|
|
||||||
min = limit[0];
|
|
||||||
max = limit[1];
|
|
||||||
}
|
|
||||||
else if (min == 200.0f && max == 1000000.0f) // resolution C ?
|
|
||||||
{
|
|
||||||
min = limit[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
int state = m_triangles[i].state;
|
|
||||||
std::string tex2Name = m_triangles[i].tex2Name;
|
|
||||||
|
|
||||||
if (m_triangles[i].variableTex2)
|
|
||||||
{
|
|
||||||
int texNum = m_engine->GetSecondTexture();
|
|
||||||
|
|
||||||
if (texNum >= 1 && texNum <= 10)
|
|
||||||
state |= ENG_RSTATE_DUAL_BLACK;
|
|
||||||
|
|
||||||
if (texNum >= 11 && texNum <= 20)
|
|
||||||
state |= ENG_RSTATE_DUAL_WHITE;
|
|
||||||
|
|
||||||
char name[20] = { 0 };
|
|
||||||
sprintf(name, "dirty%.2d.png", texNum);
|
|
||||||
tex2Name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
vs[0] = m_triangles[i].p1;
|
|
||||||
vs[1] = m_triangles[i].p2;
|
|
||||||
vs[2] = m_triangles[i].p3;
|
|
||||||
|
|
||||||
bool ok = m_engine->AddTriangles(objRank, vs,
|
|
||||||
m_triangles[i].material,
|
|
||||||
state,
|
|
||||||
m_triangles[i].tex1Name,
|
|
||||||
tex2Name,
|
|
||||||
min, max, false);
|
|
||||||
if (!ok)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void CModelFile::Mirror()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < static_cast<int>( m_triangles.size() ); i++)
|
|
||||||
{
|
|
||||||
VertexTex2 t = m_triangles[i].p1;
|
|
||||||
m_triangles[i].p1 = m_triangles[i].p2;
|
|
||||||
m_triangles[i].p2 = t;
|
|
||||||
|
|
||||||
m_triangles[i].p1.coord.z = -m_triangles[i].p1.coord.z;
|
|
||||||
m_triangles[i].p2.coord.z = -m_triangles[i].p2.coord.z;
|
|
||||||
m_triangles[i].p3.coord.z = -m_triangles[i].p3.coord.z;
|
|
||||||
|
|
||||||
m_triangles[i].p1.normal.z = -m_triangles[i].p1.normal.z;
|
|
||||||
m_triangles[i].p2.normal.z = -m_triangles[i].p2.normal.z;
|
|
||||||
m_triangles[i].p3.normal.z = -m_triangles[i].p3.normal.z;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<ModelTriangle>& CModelFile::GetTriangles()
|
const std::vector<ModelTriangle>& CModelFile::GetTriangles()
|
||||||
{
|
{
|
||||||
return m_triangles;
|
return m_triangles;
|
||||||
|
@ -1258,28 +1146,6 @@ int CModelFile::GetTriangleCount()
|
||||||
return m_triangles.size();
|
return m_triangles.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
float CModelFile::GetHeight(Math::Vector pos)
|
|
||||||
{
|
|
||||||
float limit = 5.0f;
|
|
||||||
|
|
||||||
for (int i = 0; i < static_cast<int>( m_triangles.size() ); i++)
|
|
||||||
{
|
|
||||||
if ( fabs(pos.x - m_triangles[i].p1.coord.x) < limit &&
|
|
||||||
fabs(pos.z - m_triangles[i].p1.coord.z) < limit )
|
|
||||||
return m_triangles[i].p1.coord.y;
|
|
||||||
|
|
||||||
if ( fabs(pos.x - m_triangles[i].p2.coord.x) < limit &&
|
|
||||||
fabs(pos.z - m_triangles[i].p2.coord.z) < limit )
|
|
||||||
return m_triangles[i].p2.coord.y;
|
|
||||||
|
|
||||||
if ( fabs(pos.x - m_triangles[i].p3.coord.x) < limit &&
|
|
||||||
fabs(pos.z - m_triangles[i].p3.coord.z) < limit )
|
|
||||||
return m_triangles[i].p3.coord.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CModelFile::CreateTriangle(Math::Vector p1, Math::Vector p2, Math::Vector p3, float min, float max)
|
void CModelFile::CreateTriangle(Math::Vector p1, Math::Vector p2, Math::Vector p3, float min, float max)
|
||||||
{
|
{
|
||||||
ModelTriangle triangle;
|
ModelTriangle triangle;
|
||||||
|
|
|
@ -33,14 +33,10 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
class CInstanceManager;
|
|
||||||
|
|
||||||
|
|
||||||
// Graphics module namespace
|
// Graphics module namespace
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
class CEngine;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\struct ModelTriangle
|
\struct ModelTriangle
|
||||||
|
@ -79,14 +75,15 @@ struct ModelTriangle
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class CModelFile
|
* \class CModelFile
|
||||||
\brief Model file reader/writer
|
* \brief Model file reader/writer
|
||||||
|
*
|
||||||
Allows reading and writing model objects. Models are collections of ModelTriangle structs. */
|
* Allows reading and writing model objects. Models are collections of ModelTriangle structs.
|
||||||
|
*/
|
||||||
class CModelFile
|
class CModelFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CModelFile(CInstanceManager* iMan);
|
CModelFile();
|
||||||
~CModelFile();
|
~CModelFile();
|
||||||
|
|
||||||
//! Reads a model in text format from file
|
//! Reads a model in text format from file
|
||||||
|
@ -128,23 +125,11 @@ public:
|
||||||
//! Returns the triangle vector
|
//! Returns the triangle vector
|
||||||
const std::vector<ModelTriangle>& GetTriangles();
|
const std::vector<ModelTriangle>& GetTriangles();
|
||||||
|
|
||||||
//! Returns the height of model -- closest point to X and Z coords of \a pos
|
|
||||||
float GetHeight(Math::Vector pos);
|
|
||||||
|
|
||||||
//! Mirrors the model along the Z axis
|
|
||||||
void Mirror();
|
|
||||||
|
|
||||||
//! Creates an object in the graphics engine from the model
|
|
||||||
bool CreateEngineObject(int objRank);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Adds a triangle to the list
|
//! Adds a triangle to the list
|
||||||
void CreateTriangle(Math::Vector p1, Math::Vector p2, Math::Vector p3, float min, float max);
|
void CreateTriangle(Math::Vector p1, Math::Vector p2, Math::Vector p3, float min, float max);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CInstanceManager* m_iMan;
|
|
||||||
CEngine* m_engine;
|
|
||||||
|
|
||||||
//! Model triangles
|
//! Model triangles
|
||||||
std::vector<ModelTriangle> m_triangles;
|
std::vector<ModelTriangle> m_triangles;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,213 @@
|
||||||
|
#include "graphics/engine/modelmanager.h"
|
||||||
|
|
||||||
|
#include "app/app.h"
|
||||||
|
|
||||||
|
#include "common/logger.h"
|
||||||
|
|
||||||
|
#include "graphics/engine/engine.h"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
namespace Gfx {
|
||||||
|
|
||||||
|
template<> CModelManager* CSingleton<CModelManager>::mInstance = nullptr;
|
||||||
|
|
||||||
|
CModelManager::CModelManager(CEngine* engine)
|
||||||
|
{
|
||||||
|
m_engine = engine;
|
||||||
|
}
|
||||||
|
|
||||||
|
CModelManager::~CModelManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CModelManager::LoadModel(const std::string& fileName, bool mirrored)
|
||||||
|
{
|
||||||
|
GetLogger()->Info("Loading model '%s'\n", fileName.c_str());
|
||||||
|
|
||||||
|
CModelFile modelFile;
|
||||||
|
|
||||||
|
std::string filePath = CApplication::GetInstance().GetDataFilePath(DIR_MODEL, fileName);
|
||||||
|
|
||||||
|
if (!modelFile.ReadModel(filePath))
|
||||||
|
{
|
||||||
|
GetLogger()->Error("Loading model '%s' failed\n", filePath.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ModelInfo modelInfo;
|
||||||
|
modelInfo.baseObjRank = m_engine->CreateBaseObject();
|
||||||
|
modelInfo.triangles = modelFile.GetTriangles();
|
||||||
|
|
||||||
|
if (mirrored)
|
||||||
|
Mirror(modelInfo.triangles);
|
||||||
|
|
||||||
|
FileInfo fileInfo(fileName, mirrored);
|
||||||
|
m_models[fileInfo] = modelInfo;
|
||||||
|
|
||||||
|
std::vector<VertexTex2> vs(3, VertexTex2());
|
||||||
|
|
||||||
|
float limit[2];
|
||||||
|
limit[0] = m_engine->GetLimitLOD(0); // frontier AB as config
|
||||||
|
limit[1] = m_engine->GetLimitLOD(1); // frontier BC as config
|
||||||
|
|
||||||
|
for (int i = 0; i < static_cast<int>( modelInfo.triangles.size() ); i++)
|
||||||
|
{
|
||||||
|
float min = modelInfo.triangles[i].min;
|
||||||
|
float max = modelInfo.triangles[i].max;
|
||||||
|
|
||||||
|
// Standard frontiers -> config
|
||||||
|
if (min == 0.0f && max == 100.0f) // resolution A ?
|
||||||
|
{
|
||||||
|
max = limit[0];
|
||||||
|
}
|
||||||
|
else if (min == 100.0f && max == 200.0f) // resolution B ?
|
||||||
|
{
|
||||||
|
min = limit[0];
|
||||||
|
max = limit[1];
|
||||||
|
}
|
||||||
|
else if (min == 200.0f && max == 1000000.0f) // resolution C ?
|
||||||
|
{
|
||||||
|
min = limit[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
int state = modelInfo.triangles[i].state;
|
||||||
|
std::string tex2Name = modelInfo.triangles[i].tex2Name;
|
||||||
|
|
||||||
|
if (modelInfo.triangles[i].variableTex2)
|
||||||
|
{
|
||||||
|
int texNum = m_engine->GetSecondTexture();
|
||||||
|
|
||||||
|
if (texNum >= 1 && texNum <= 10)
|
||||||
|
state |= ENG_RSTATE_DUAL_BLACK;
|
||||||
|
|
||||||
|
if (texNum >= 11 && texNum <= 20)
|
||||||
|
state |= ENG_RSTATE_DUAL_WHITE;
|
||||||
|
|
||||||
|
char name[20] = { 0 };
|
||||||
|
sprintf(name, "dirty%.2d.png", texNum);
|
||||||
|
tex2Name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
vs[0] = modelInfo.triangles[i].p1;
|
||||||
|
vs[1] = modelInfo.triangles[i].p2;
|
||||||
|
vs[2] = modelInfo.triangles[i].p3;
|
||||||
|
|
||||||
|
m_engine->AddBaseObjTriangles(modelInfo.baseObjRank, vs, ENG_TRIANGLE_TYPE_TRIANGLES,
|
||||||
|
modelInfo.triangles[i].material, state,
|
||||||
|
modelInfo.triangles[i].tex1Name, tex2Name,
|
||||||
|
min, max, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CModelManager::AddModelReference(const std::string& fileName, bool mirrored, int objRank)
|
||||||
|
{
|
||||||
|
auto it = m_models.find(FileInfo(fileName, mirrored));
|
||||||
|
if (it == m_models.end())
|
||||||
|
{
|
||||||
|
if (!LoadModel(fileName, mirrored))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
it = m_models.find(FileInfo(fileName, mirrored));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_engine->SetObjectBaseRank(objRank, (*it).second.baseObjRank);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CModelManager::AddModelCopy(const std::string& fileName, bool mirrored, int objRank)
|
||||||
|
{
|
||||||
|
auto it = m_models.find(FileInfo(fileName, mirrored));
|
||||||
|
if (it == m_models.end())
|
||||||
|
{
|
||||||
|
if (!LoadModel(fileName, mirrored))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
it = m_models.find(FileInfo(fileName, mirrored));
|
||||||
|
}
|
||||||
|
|
||||||
|
int copyBaseObjRank = m_engine->CreateBaseObject();
|
||||||
|
m_engine->CopyBaseObject((*it).second.baseObjRank, copyBaseObjRank);
|
||||||
|
m_engine->SetObjectBaseRank(objRank, copyBaseObjRank);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CModelManager::IsModelLoaded(const std::string& fileName, bool mirrored)
|
||||||
|
{
|
||||||
|
return m_models.count(FileInfo(fileName, mirrored)) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CModelManager::GetModelBaseObjRank(const std::string& fileName, bool mirrored)
|
||||||
|
{
|
||||||
|
auto it = m_models.find(FileInfo(fileName, mirrored));
|
||||||
|
if (it == m_models.end())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return (*it).second.baseObjRank;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModelManager::UnloadModel(const std::string& fileName, bool mirrored)
|
||||||
|
{
|
||||||
|
auto it = m_models.find(FileInfo(fileName, mirrored));
|
||||||
|
if (it == m_models.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_engine->DeleteBaseObject((*it).second.baseObjRank);
|
||||||
|
|
||||||
|
m_models.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModelManager::UnloadAllModels()
|
||||||
|
{
|
||||||
|
for (auto& mf : m_models)
|
||||||
|
m_engine->DeleteBaseObject(mf.second.baseObjRank);
|
||||||
|
|
||||||
|
m_models.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModelManager::Mirror(std::vector<ModelTriangle>& triangles)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < static_cast<int>( triangles.size() ); i++)
|
||||||
|
{
|
||||||
|
VertexTex2 t = triangles[i].p1;
|
||||||
|
triangles[i].p1 = triangles[i].p2;
|
||||||
|
triangles[i].p2 = t;
|
||||||
|
|
||||||
|
triangles[i].p1.coord.z = -triangles[i].p1.coord.z;
|
||||||
|
triangles[i].p2.coord.z = -triangles[i].p2.coord.z;
|
||||||
|
triangles[i].p3.coord.z = -triangles[i].p3.coord.z;
|
||||||
|
|
||||||
|
triangles[i].p1.normal.z = -triangles[i].p1.normal.z;
|
||||||
|
triangles[i].p2.normal.z = -triangles[i].p2.normal.z;
|
||||||
|
triangles[i].p3.normal.z = -triangles[i].p3.normal.z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float CModelManager::GetHeight(std::vector<ModelTriangle>& triangles, Math::Vector pos)
|
||||||
|
{
|
||||||
|
const float limit = 5.0f;
|
||||||
|
|
||||||
|
for (int i = 0; i < static_cast<int>( triangles.size() ); i++)
|
||||||
|
{
|
||||||
|
if ( fabs(pos.x - triangles[i].p1.coord.x) < limit &&
|
||||||
|
fabs(pos.z - triangles[i].p1.coord.z) < limit )
|
||||||
|
return triangles[i].p1.coord.y;
|
||||||
|
|
||||||
|
if ( fabs(pos.x - triangles[i].p2.coord.x) < limit &&
|
||||||
|
fabs(pos.z - triangles[i].p2.coord.z) < limit )
|
||||||
|
return triangles[i].p2.coord.y;
|
||||||
|
|
||||||
|
if ( fabs(pos.x - triangles[i].p3.coord.x) < limit &&
|
||||||
|
fabs(pos.z - triangles[i].p3.coord.z) < limit )
|
||||||
|
return triangles[i].p3.coord.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/singleton.h"
|
||||||
|
|
||||||
|
#include "graphics/engine/modelfile.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
namespace Gfx {
|
||||||
|
|
||||||
|
class CEngine;
|
||||||
|
class CModelFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \class CModelManager
|
||||||
|
* \brief Manager for static models
|
||||||
|
*
|
||||||
|
* The manager allows for loading models as static objects and adding
|
||||||
|
* new instances of models to the engine.
|
||||||
|
*
|
||||||
|
* The models are loaded from stanard application model directory and
|
||||||
|
* they are identified by unique file names.
|
||||||
|
*
|
||||||
|
* The models are loaded by creating (if it doesn't exist yet)
|
||||||
|
* a base engine object from the model geometry. This base object
|
||||||
|
* is then shared among all instances of this model with the instances
|
||||||
|
* being engine objects linked to the shared base object.
|
||||||
|
*
|
||||||
|
* There is also a possibility of creating a copy of model so it has
|
||||||
|
* its own and unique base engine object. This is especially useful
|
||||||
|
* for models where the geometry must be altered.
|
||||||
|
*/
|
||||||
|
class CModelManager : public CSingleton<CModelManager>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CModelManager(CEngine* engine);
|
||||||
|
~CModelManager();
|
||||||
|
|
||||||
|
//! Loads a model from given file
|
||||||
|
bool LoadModel(const std::string& fileName, bool mirrored);
|
||||||
|
|
||||||
|
//! Adds an instance of model to the given object rank as a reference to base object
|
||||||
|
bool AddModelReference(const std::string& fileName, bool mirrored, int objRank);
|
||||||
|
|
||||||
|
//! Adds an instance of model to the given object rank as a copy (copied base object)
|
||||||
|
bool AddModelCopy(const std::string& fileName, bool mirrored, int objRank);
|
||||||
|
|
||||||
|
//! Returns true if given model is loaded
|
||||||
|
bool IsModelLoaded(const std::string& fileName, bool mirrored);
|
||||||
|
|
||||||
|
//! Returns the rank of base engine object of given loaded model
|
||||||
|
int GetModelBaseObjRank(const std::string& fileName, bool mirrored);
|
||||||
|
|
||||||
|
//! Unloads the given model
|
||||||
|
void UnloadModel(const std::string& fileName, bool mirrored);
|
||||||
|
//! Unloads all models
|
||||||
|
void UnloadAllModels();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! Returns the height of model -- closest point to X and Z coords of \a pos
|
||||||
|
float GetHeight(std::vector<ModelTriangle>& triangles, Math::Vector pos);
|
||||||
|
|
||||||
|
//! Mirrors the model along the Z axis
|
||||||
|
void Mirror(std::vector<ModelTriangle>& triangles);
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct ModelInfo
|
||||||
|
{
|
||||||
|
std::vector<ModelTriangle> triangles;
|
||||||
|
int baseObjRank;
|
||||||
|
};
|
||||||
|
struct FileInfo
|
||||||
|
{
|
||||||
|
std::string fileName;
|
||||||
|
bool mirrored;
|
||||||
|
|
||||||
|
inline FileInfo(const std::string& fileName, bool mirrored)
|
||||||
|
: fileName(fileName), mirrored(mirrored) {}
|
||||||
|
|
||||||
|
inline bool operator<(const FileInfo& other) const
|
||||||
|
{
|
||||||
|
int compare = fileName.compare(other.fileName);
|
||||||
|
if (compare < 0)
|
||||||
|
return true;
|
||||||
|
if (compare > 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return !mirrored && mirrored != other.mirrored;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
std::map<FileInfo, ModelInfo> m_models;
|
||||||
|
CEngine* m_engine;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Gfx
|
|
@ -363,7 +363,6 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
|
||||||
m_type == PT_EXPLOW )
|
m_type == PT_EXPLOW )
|
||||||
{
|
{
|
||||||
CreateTriangle(obj, oType, 0);
|
CreateTriangle(obj, oType, 0);
|
||||||
m_engine->SetObjectStatic(m_object->GetObjectRank(0), false);
|
|
||||||
m_engine->DeleteShadow(m_object->GetObjectRank(0));
|
m_engine->DeleteShadow(m_object->GetObjectRank(0));
|
||||||
ExploStart();
|
ExploStart();
|
||||||
}
|
}
|
||||||
|
@ -1398,8 +1397,6 @@ void CPyro::CreateTriangle(CObject* obj, ObjectType oType, int part)
|
||||||
int objRank = obj->GetObjectRank(part);
|
int objRank = obj->GetObjectRank(part);
|
||||||
if (objRank == -1) return;
|
if (objRank == -1) return;
|
||||||
|
|
||||||
m_engine->SetObjectStatic(objRank, false);
|
|
||||||
|
|
||||||
float min = 0.0f;
|
float min = 0.0f;
|
||||||
float max = m_engine->GetLimitLOD(0);
|
float max = m_engine->GetLimitLOD(0);
|
||||||
int total = m_engine->GetObjectTotalTriangles(objRank);
|
int total = m_engine->GetObjectTotalTriangles(objRank);
|
||||||
|
|
|
@ -34,10 +34,6 @@
|
||||||
// Graphics module namespace
|
// Graphics module namespace
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
const int LEVEL_MAT_PREALLOCATE_COUNT = 101;
|
|
||||||
const int FLYING_LIMIT_PREALLOCATE_COUNT = 10;
|
|
||||||
const int BUILDING_LEVEL_PREALLOCATE_COUNT = 101;
|
|
||||||
|
|
||||||
|
|
||||||
CTerrain::CTerrain(CInstanceManager* iMan)
|
CTerrain::CTerrain(CInstanceManager* iMan)
|
||||||
{
|
{
|
||||||
|
@ -60,10 +56,6 @@ CTerrain::CTerrain(CInstanceManager* iMan)
|
||||||
m_defaultHardness = 0.5f;
|
m_defaultHardness = 0.5f;
|
||||||
m_useMaterials = false;
|
m_useMaterials = false;
|
||||||
|
|
||||||
m_materials.reserve(LEVEL_MAT_PREALLOCATE_COUNT);
|
|
||||||
m_flyingLimits.reserve(FLYING_LIMIT_PREALLOCATE_COUNT);
|
|
||||||
m_buildingLevels.reserve(BUILDING_LEVEL_PREALLOCATE_COUNT);
|
|
||||||
|
|
||||||
FlushBuildingLevel();
|
FlushBuildingLevel();
|
||||||
FlushFlyingLimit();
|
FlushFlyingLimit();
|
||||||
FlushMaterials();
|
FlushMaterials();
|
||||||
|
@ -498,6 +490,13 @@ bool CTerrain::CreateMosaic(int ox, int oy, int step, int objRank,
|
||||||
const Material &mat,
|
const Material &mat,
|
||||||
float min, float max)
|
float min, float max)
|
||||||
{
|
{
|
||||||
|
int baseObjRank = m_engine->GetObjectBaseRank(objRank);
|
||||||
|
if (baseObjRank == -1)
|
||||||
|
{
|
||||||
|
baseObjRank = m_engine->CreateBaseObject();
|
||||||
|
m_engine->SetObjectBaseRank(objRank, baseObjRank);
|
||||||
|
}
|
||||||
|
|
||||||
std::string texName1;
|
std::string texName1;
|
||||||
std::string texName2;
|
std::string texName2;
|
||||||
|
|
||||||
|
@ -547,7 +546,7 @@ bool CTerrain::CreateMosaic(int ox, int oy, int step, int objRank,
|
||||||
|
|
||||||
for (int y = 0; y < brick; y += step)
|
for (int y = 0; y < brick; y += step)
|
||||||
{
|
{
|
||||||
EngineObjLevel4 buffer;
|
EngineBaseObjDataTier buffer;
|
||||||
buffer.vertices.reserve(total);
|
buffer.vertices.reserve(total);
|
||||||
|
|
||||||
buffer.type = ENG_TRIANGLE_TYPE_SURFACE;
|
buffer.type = ENG_TRIANGLE_TYPE_SURFACE;
|
||||||
|
@ -640,7 +639,8 @@ bool CTerrain::CreateMosaic(int ox, int oy, int step, int objRank,
|
||||||
buffer.vertices.push_back(p1);
|
buffer.vertices.push_back(p1);
|
||||||
buffer.vertices.push_back(p2);
|
buffer.vertices.push_back(p2);
|
||||||
}
|
}
|
||||||
m_engine->AddQuick(objRank, buffer, texName1, texName2, min, max, true);
|
|
||||||
|
m_engine->AddBaseObjQuick(baseObjRank, buffer, texName1, texName2, min, max, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1168,10 +1168,6 @@ bool CTerrain::CreateSquare(int x, int y)
|
||||||
int objRank = m_engine->CreateObject();
|
int objRank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(objRank, ENG_OBJTYPE_TERRAIN);
|
m_engine->SetObjectType(objRank, ENG_OBJTYPE_TERRAIN);
|
||||||
|
|
||||||
// TODO: create a static object, but not split into squares, but a single object for all terrain
|
|
||||||
// Squares should be sub-objects accessing parts of triangle list
|
|
||||||
// m_engine->SetObjectStatic(objRank, true);
|
|
||||||
|
|
||||||
m_objRanks[x+y*m_mosaicCount] = objRank;
|
m_objRanks[x+y*m_mosaicCount] = objRank;
|
||||||
|
|
||||||
float min = 0.0f;
|
float min = 0.0f;
|
||||||
|
@ -1278,7 +1274,10 @@ bool CTerrain::Terraform(const Math::Vector &p1, const Math::Vector &p2, float h
|
||||||
{
|
{
|
||||||
for (int x = pp1.x; x <= pp2.x; x++)
|
for (int x = pp1.x; x <= pp2.x; x++)
|
||||||
{
|
{
|
||||||
m_engine->DeleteObject(m_objRanks[x+y*m_mosaicCount]);
|
int objRank = m_objRanks[x+y*m_mosaicCount];
|
||||||
|
int baseObjRank = m_engine->GetObjectBaseRank(objRank);
|
||||||
|
m_engine->DeleteBaseObject(baseObjRank);
|
||||||
|
m_engine->DeleteObject(objRank);
|
||||||
CreateSquare(x, y); // recreates the square
|
CreateSquare(x, y); // recreates the square
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,7 +328,7 @@ protected:
|
||||||
//! Calculates a vector of the terrain
|
//! Calculates a vector of the terrain
|
||||||
Math::Vector GetVector(int x, int y);
|
Math::Vector GetVector(int x, int y);
|
||||||
//! Calculates a vertex of the terrain
|
//! Calculates a vertex of the terrain
|
||||||
VertexTex2 GetVertex(int x, int y, int step);
|
VertexTex2 GetVertex(int x, int y, int step);
|
||||||
//! Creates all objects of a mosaic
|
//! Creates all objects of a mosaic
|
||||||
bool CreateMosaic(int ox, int oy, int step, int objRank, const Material& mat, float min, float max);
|
bool CreateMosaic(int ox, int oy, int step, int objRank, const Material& mat, float min, float max);
|
||||||
//! Creates all objects in a mesh square ground
|
//! Creates all objects in a mesh square ground
|
||||||
|
|
|
@ -8,7 +8,6 @@ modelfile_test.cpp
|
||||||
../modelfile.cpp
|
../modelfile.cpp
|
||||||
../../../common/logger.cpp
|
../../../common/logger.cpp
|
||||||
../../../common/stringutils.cpp
|
../../../common/stringutils.cpp
|
||||||
../../../common/iman.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_definitions(-DMODELFILE_NO_ENGINE)
|
add_definitions(-DMODELFILE_NO_ENGINE)
|
||||||
|
|
|
@ -15,12 +15,11 @@
|
||||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||||
|
|
||||||
|
|
||||||
#include "common/iman.h"
|
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
#include "graphics/engine/modelfile.h"
|
#include "graphics/engine/modelfile.h"
|
||||||
#include "math/func.h"
|
#include "math/func.h"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -190,8 +189,7 @@ TEST(ModelFileTest, RWTxtModel)
|
||||||
std::stringstream str;
|
std::stringstream str;
|
||||||
str.str(TEXT_MODEL);
|
str.str(TEXT_MODEL);
|
||||||
|
|
||||||
CInstanceManager iMan;
|
Gfx::CModelFile modelFile;
|
||||||
Gfx::CModelFile modelFile(&iMan);
|
|
||||||
|
|
||||||
EXPECT_TRUE(modelFile.ReadTextModel(str));
|
EXPECT_TRUE(modelFile.ReadTextModel(str));
|
||||||
|
|
||||||
|
@ -216,8 +214,7 @@ TEST(ModelFileTest, RWBinModel)
|
||||||
std::stringstream str;
|
std::stringstream str;
|
||||||
str.str(TEXT_MODEL);
|
str.str(TEXT_MODEL);
|
||||||
|
|
||||||
CInstanceManager iMan;
|
Gfx::CModelFile modelFile;
|
||||||
Gfx::CModelFile modelFile(&iMan);
|
|
||||||
|
|
||||||
EXPECT_TRUE(modelFile.ReadTextModel(str));
|
EXPECT_TRUE(modelFile.ReadTextModel(str));
|
||||||
|
|
||||||
|
@ -242,8 +239,7 @@ TEST(ModelFileTest, RWOldModel)
|
||||||
std::stringstream str;
|
std::stringstream str;
|
||||||
str.str(TEXT_MODEL);
|
str.str(TEXT_MODEL);
|
||||||
|
|
||||||
CInstanceManager iMan;
|
Gfx::CModelFile modelFile;
|
||||||
Gfx::CModelFile modelFile(&iMan);
|
|
||||||
|
|
||||||
EXPECT_TRUE(modelFile.ReadTextModel(str));
|
EXPECT_TRUE(modelFile.ReadTextModel(str));
|
||||||
|
|
||||||
|
|
|
@ -949,7 +949,7 @@ void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int
|
||||||
glDisableClientState(GL_COLOR_ARRAY);
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CGLDevice::CreateStaticObject(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||||
{
|
{
|
||||||
unsigned int id = 0;
|
unsigned int id = 0;
|
||||||
if (m_useVbo)
|
if (m_useVbo)
|
||||||
|
@ -983,7 +983,7 @@ unsigned int CGLDevice::CreateStaticObject(PrimitiveType primitiveType, const Ve
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CGLDevice::CreateStaticObject(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
|
unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
|
||||||
{
|
{
|
||||||
unsigned int id = 0;
|
unsigned int id = 0;
|
||||||
if (m_useVbo)
|
if (m_useVbo)
|
||||||
|
@ -1017,7 +1017,7 @@ unsigned int CGLDevice::CreateStaticObject(PrimitiveType primitiveType, const Ve
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CGLDevice::CreateStaticObject(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
|
unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
|
||||||
{
|
{
|
||||||
unsigned int id = 0;
|
unsigned int id = 0;
|
||||||
if (m_useVbo)
|
if (m_useVbo)
|
||||||
|
@ -1051,11 +1051,92 @@ unsigned int CGLDevice::CreateStaticObject(PrimitiveType primitiveType, const Ve
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGLDevice::DrawStaticObject(unsigned int objectId)
|
void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||||
{
|
{
|
||||||
if (m_useVbo)
|
if (m_useVbo)
|
||||||
{
|
{
|
||||||
auto it = m_vboObjects.find(objectId);
|
auto it = m_vboObjects.find(bufferId);
|
||||||
|
if (it == m_vboObjects.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
VboObjectInfo& info = (*it).second;
|
||||||
|
info.primitiveType = primitiveType;
|
||||||
|
info.vertexType = VERTEX_TYPE_NORMAL;
|
||||||
|
info.vertexCount = vertexCount;
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, info.bufferId);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(Vertex), vertices, GL_STATIC_DRAW);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glNewList(bufferId, GL_COMPILE);
|
||||||
|
|
||||||
|
DrawPrimitive(primitiveType, vertices, vertexCount);
|
||||||
|
|
||||||
|
glEndList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
|
||||||
|
{
|
||||||
|
if (m_useVbo)
|
||||||
|
{
|
||||||
|
auto it = m_vboObjects.find(bufferId);
|
||||||
|
if (it == m_vboObjects.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
VboObjectInfo& info = (*it).second;
|
||||||
|
info.primitiveType = primitiveType;
|
||||||
|
info.vertexType = VERTEX_TYPE_TEX2;
|
||||||
|
info.vertexCount = vertexCount;
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, info.bufferId);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(VertexTex2), vertices, GL_STATIC_DRAW);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glNewList(bufferId, GL_COMPILE);
|
||||||
|
|
||||||
|
DrawPrimitive(primitiveType, vertices, vertexCount);
|
||||||
|
|
||||||
|
glEndList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
|
||||||
|
{
|
||||||
|
if (m_useVbo)
|
||||||
|
{
|
||||||
|
auto it = m_vboObjects.find(bufferId);
|
||||||
|
if (it == m_vboObjects.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
VboObjectInfo& info = (*it).second;
|
||||||
|
info.primitiveType = primitiveType;
|
||||||
|
info.vertexType = VERTEX_TYPE_COL;
|
||||||
|
info.vertexCount = vertexCount;
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, info.bufferId);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(VertexCol), vertices, GL_STATIC_DRAW);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glNewList(bufferId, GL_COMPILE);
|
||||||
|
|
||||||
|
DrawPrimitive(primitiveType, vertices, vertexCount);
|
||||||
|
|
||||||
|
glEndList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGLDevice::DrawStaticBuffer(unsigned int bufferId)
|
||||||
|
{
|
||||||
|
if (m_useVbo)
|
||||||
|
{
|
||||||
|
auto it = m_vboObjects.find(bufferId);
|
||||||
if (it == m_vboObjects.end())
|
if (it == m_vboObjects.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1127,15 +1208,15 @@ void CGLDevice::DrawStaticObject(unsigned int objectId)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glCallList(objectId);
|
glCallList(bufferId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGLDevice::DestroyStaticObject(unsigned int objectId)
|
void CGLDevice::DestroyStaticBuffer(unsigned int bufferId)
|
||||||
{
|
{
|
||||||
if (m_useVbo)
|
if (m_useVbo)
|
||||||
{
|
{
|
||||||
auto it = m_vboObjects.find(objectId);
|
auto it = m_vboObjects.find(bufferId);
|
||||||
if (it == m_vboObjects.end())
|
if (it == m_vboObjects.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1145,7 +1226,7 @@ void CGLDevice::DestroyStaticObject(unsigned int objectId)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glDeleteLists(objectId, 1);
|
glDeleteLists(bufferId, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,11 +129,14 @@ public:
|
||||||
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f));
|
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||||
virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount);
|
virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount);
|
||||||
|
|
||||||
virtual unsigned int CreateStaticObject(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount);
|
virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount);
|
||||||
virtual unsigned int CreateStaticObject(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount);
|
virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount);
|
||||||
virtual unsigned int CreateStaticObject(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount);
|
virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount);
|
||||||
virtual void DrawStaticObject(unsigned int objectId);
|
virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount);
|
||||||
virtual void DestroyStaticObject(unsigned int objectId);
|
virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount);
|
||||||
|
virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount);
|
||||||
|
virtual void DrawStaticBuffer(unsigned int bufferId);
|
||||||
|
virtual void DestroyStaticBuffer(unsigned int bufferId);
|
||||||
|
|
||||||
virtual int ComputeSphereVisibility(const Math::Vector ¢er, float radius);
|
virtual int ComputeSphereVisibility(const Math::Vector ¢er, float radius);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "graphics/engine/modelfile.h"
|
#include "graphics/engine/modelmanager.h"
|
||||||
#include "graphics/engine/particle.h"
|
#include "graphics/engine/particle.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
@ -69,12 +69,8 @@ void CMotionAnt::DeleteObject(bool bAll)
|
||||||
bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
|
bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
float power)
|
float power)
|
||||||
{
|
{
|
||||||
Gfx::CModelFile* pModFile;
|
Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
|
||||||
int rank;
|
int rank;
|
||||||
|
|
||||||
// if ( m_engine->GetRestCreate() < 3+18 ) return false;
|
|
||||||
|
|
||||||
pModFile = new Gfx::CModelFile(m_iMan);
|
|
||||||
|
|
||||||
m_object->SetType(type);
|
m_object->SetType(type);
|
||||||
|
|
||||||
|
@ -82,10 +78,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
||||||
m_object->SetObjectRank(0, rank);
|
m_object->SetObjectRank(0, rank);
|
||||||
|
modelManager->AddModelReference("ant1.mod", false, rank);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant1.mod"));
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
|
|
||||||
m_object->SetPosition(0, pos);
|
m_object->SetPosition(0, pos);
|
||||||
m_object->SetAngleY(0, angle);
|
m_object->SetAngleY(0, angle);
|
||||||
|
|
||||||
|
@ -96,29 +89,26 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
|
|
||||||
// Creates the head.
|
// Creates the head.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(1, rank);
|
m_object->SetObjectRank(1, rank);
|
||||||
m_object->SetObjectParent(1, 0);
|
m_object->SetObjectParent(1, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant2.mod"));
|
modelManager->AddModelReference("ant2.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(1, Math::Vector(2.0f, 0.0f, 0.0f));
|
m_object->SetPosition(1, Math::Vector(2.0f, 0.0f, 0.0f));
|
||||||
|
|
||||||
// Creates the tail.
|
// Creates the tail.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(2, rank);
|
m_object->SetObjectRank(2, rank);
|
||||||
m_object->SetObjectParent(2, 0);
|
m_object->SetObjectParent(2, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant3.mod"));
|
modelManager->AddModelReference("ant3.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(2, Math::Vector(-1.0f, 0.0f, 0.0f));
|
m_object->SetPosition(2, Math::Vector(-1.0f, 0.0f, 0.0f));
|
||||||
|
|
||||||
// Creates a right-back thigh.
|
// Creates a right-back thigh.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(3, rank);
|
m_object->SetObjectRank(3, rank);
|
||||||
m_object->SetObjectParent(3, 0);
|
m_object->SetObjectParent(3, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
|
modelManager->AddModelReference("ant4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(3, Math::Vector(-0.4f, -0.1f, -0.3f));
|
m_object->SetPosition(3, Math::Vector(-0.4f, -0.1f, -0.3f));
|
||||||
|
|
||||||
// Creates a right-back leg.
|
// Creates a right-back leg.
|
||||||
|
@ -126,161 +116,135 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(4, rank);
|
m_object->SetObjectRank(4, rank);
|
||||||
m_object->SetObjectParent(4, 3);
|
m_object->SetObjectParent(4, 3);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
|
modelManager->AddModelReference("ant5.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(4, Math::Vector(0.0f, 0.0f, -1.0f));
|
m_object->SetPosition(4, Math::Vector(0.0f, 0.0f, -1.0f));
|
||||||
|
|
||||||
// Creates a right-back foot.
|
// Creates a right-back foot.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(5, rank);
|
m_object->SetObjectRank(5, rank);
|
||||||
m_object->SetObjectParent(5, 4);
|
m_object->SetObjectParent(5, 4);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
|
modelManager->AddModelReference("ant6.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -2.0f));
|
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -2.0f));
|
||||||
|
|
||||||
// Creates two middle-right thighs.
|
// Creates two middle-right thighs.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(6, rank);
|
m_object->SetObjectRank(6, rank);
|
||||||
m_object->SetObjectParent(6, 0);
|
m_object->SetObjectParent(6, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
|
modelManager->AddModelReference("ant4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(6, Math::Vector(0.1f, -0.1f, -0.4f));
|
m_object->SetPosition(6, Math::Vector(0.1f, -0.1f, -0.4f));
|
||||||
|
|
||||||
// Creates two middle-right legs.
|
// Creates two middle-right legs.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(7, rank);
|
m_object->SetObjectRank(7, rank);
|
||||||
m_object->SetObjectParent(7, 6);
|
m_object->SetObjectParent(7, 6);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
|
modelManager->AddModelReference("ant5.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(7, Math::Vector(0.0f, 0.0f, -1.0f));
|
m_object->SetPosition(7, Math::Vector(0.0f, 0.0f, -1.0f));
|
||||||
|
|
||||||
// Creates two middle-right foots.
|
// Creates two middle-right foots.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(8, rank);
|
m_object->SetObjectRank(8, rank);
|
||||||
m_object->SetObjectParent(8, 7);
|
m_object->SetObjectParent(8, 7);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
|
modelManager->AddModelReference("ant6.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(8, Math::Vector(0.0f, 0.0f, -2.0f));
|
m_object->SetPosition(8, Math::Vector(0.0f, 0.0f, -2.0f));
|
||||||
|
|
||||||
// Creates the right front thigh.
|
// Creates the right front thigh.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(9, rank);
|
m_object->SetObjectRank(9, rank);
|
||||||
m_object->SetObjectParent(9, 0);
|
m_object->SetObjectParent(9, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
|
modelManager->AddModelReference("ant4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(9, Math::Vector(1.4f, -0.1f, -0.6f));
|
m_object->SetPosition(9, Math::Vector(1.4f, -0.1f, -0.6f));
|
||||||
|
|
||||||
// Creates the right front leg.
|
// Creates the right front leg.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(10, rank);
|
m_object->SetObjectRank(10, rank);
|
||||||
m_object->SetObjectParent(10, 9);
|
m_object->SetObjectParent(10, 9);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
|
modelManager->AddModelReference("ant5.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(10, Math::Vector(0.0f, 0.0f, -1.0f));
|
m_object->SetPosition(10, Math::Vector(0.0f, 0.0f, -1.0f));
|
||||||
|
|
||||||
// Creates the right front foot.
|
// Creates the right front foot.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(11, rank);
|
m_object->SetObjectRank(11, rank);
|
||||||
m_object->SetObjectParent(11, 10);
|
m_object->SetObjectParent(11, 10);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
|
modelManager->AddModelReference("ant6.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, -2.0f));
|
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, -2.0f));
|
||||||
|
|
||||||
// Creates a left-back thigh.
|
// Creates a left-back thigh.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(12, rank);
|
m_object->SetObjectRank(12, rank);
|
||||||
m_object->SetObjectParent(12, 0);
|
m_object->SetObjectParent(12, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
|
modelManager->AddModelReference("ant4.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(12, Math::Vector(-0.4f, -0.1f, 0.3f));
|
m_object->SetPosition(12, Math::Vector(-0.4f, -0.1f, 0.3f));
|
||||||
|
|
||||||
// Creates a left-back leg.
|
// Creates a left-back leg.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(13, rank);
|
m_object->SetObjectRank(13, rank);
|
||||||
m_object->SetObjectParent(13, 12);
|
m_object->SetObjectParent(13, 12);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
|
modelManager->AddModelReference("ant5.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(13, Math::Vector(0.0f, 0.0f, 1.0f));
|
m_object->SetPosition(13, Math::Vector(0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
// Creates a left-back foot.
|
// Creates a left-back foot.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(14, rank);
|
m_object->SetObjectRank(14, rank);
|
||||||
m_object->SetObjectParent(14, 13);
|
m_object->SetObjectParent(14, 13);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
|
modelManager->AddModelReference("ant6.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(14, Math::Vector(0.0f, 0.0f, 2.0f));
|
m_object->SetPosition(14, Math::Vector(0.0f, 0.0f, 2.0f));
|
||||||
|
|
||||||
// Creates two middle-left thighs.
|
// Creates two middle-left thighs.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(15, rank);
|
m_object->SetObjectRank(15, rank);
|
||||||
m_object->SetObjectParent(15, 0);
|
m_object->SetObjectParent(15, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
|
modelManager->AddModelReference("ant4.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(15, Math::Vector(0.1f, -0.1f, 0.4f));
|
m_object->SetPosition(15, Math::Vector(0.1f, -0.1f, 0.4f));
|
||||||
|
|
||||||
// Creates two middle-left legs.
|
// Creates two middle-left legs.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(16, rank);
|
m_object->SetObjectRank(16, rank);
|
||||||
m_object->SetObjectParent(16, 15);
|
m_object->SetObjectParent(16, 15);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
|
modelManager->AddModelReference("ant5.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(16, Math::Vector(0.0f, 0.0f, 1.0f));
|
m_object->SetPosition(16, Math::Vector(0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
// Creates two middle-left foot.
|
// Creates two middle-left foot.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(17, rank);
|
m_object->SetObjectRank(17, rank);
|
||||||
m_object->SetObjectParent(17, 16);
|
m_object->SetObjectParent(17, 16);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
|
modelManager->AddModelReference("ant6.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(17, Math::Vector(0.0f, 0.0f, 2.0f));
|
m_object->SetPosition(17, Math::Vector(0.0f, 0.0f, 2.0f));
|
||||||
|
|
||||||
// Creates the left front thigh.
|
// Creates the left front thigh.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(18, rank);
|
m_object->SetObjectRank(18, rank);
|
||||||
m_object->SetObjectParent(18, 0);
|
m_object->SetObjectParent(18, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
|
modelManager->AddModelReference("ant4.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(18, Math::Vector(1.4f, -0.1f, 0.6f));
|
m_object->SetPosition(18, Math::Vector(1.4f, -0.1f, 0.6f));
|
||||||
|
|
||||||
// Creates the left front leg.
|
// Creates the left front leg.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(19, rank);
|
m_object->SetObjectRank(19, rank);
|
||||||
m_object->SetObjectParent(19, 18);
|
m_object->SetObjectParent(19, 18);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
|
modelManager->AddModelReference("ant5.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(19, Math::Vector(0.0f, 0.0f, 1.0f));
|
m_object->SetPosition(19, Math::Vector(0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
// Creates the left front foot.
|
// Creates the left front foot.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(20, rank);
|
m_object->SetObjectRank(20, rank);
|
||||||
m_object->SetObjectParent(20, 19);
|
m_object->SetObjectParent(20, 19);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
|
modelManager->AddModelReference("ant6.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(20, Math::Vector(0.0f, 0.0f, 2.0f));
|
m_object->SetPosition(20, Math::Vector(0.0f, 0.0f, 2.0f));
|
||||||
|
|
||||||
m_object->CreateShadowCircle(4.0f, 0.5f);
|
m_object->CreateShadowCircle(4.0f, 0.5f);
|
||||||
|
@ -293,7 +257,6 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
|
|
||||||
m_engine->LoadAllTextures();
|
m_engine->LoadAllTextures();
|
||||||
|
|
||||||
delete pModFile;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "graphics/engine/modelfile.h"
|
#include "graphics/engine/modelmanager.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
|
||||||
|
@ -67,12 +67,8 @@ void CMotionBee::DeleteObject(bool bAll)
|
||||||
bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
float power)
|
float power)
|
||||||
{
|
{
|
||||||
Gfx::CModelFile* pModFile;
|
Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
|
||||||
int rank;
|
int rank;
|
||||||
|
|
||||||
// if ( m_engine->GetRestCreate() < 3+18+2 ) return false;
|
|
||||||
|
|
||||||
pModFile = new Gfx::CModelFile(m_iMan);
|
|
||||||
|
|
||||||
m_object->SetType(type);
|
m_object->SetType(type);
|
||||||
|
|
||||||
|
@ -80,10 +76,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
||||||
m_object->SetObjectRank(0, rank);
|
m_object->SetObjectRank(0, rank);
|
||||||
|
modelManager->AddModelReference("bee1.mod", false, rank);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee1.mod"));
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
|
|
||||||
m_object->SetPosition(0, pos);
|
m_object->SetPosition(0, pos);
|
||||||
m_object->SetAngleY(0, angle);
|
m_object->SetAngleY(0, angle);
|
||||||
|
|
||||||
|
@ -97,8 +90,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(1, rank);
|
m_object->SetObjectRank(1, rank);
|
||||||
m_object->SetObjectParent(1, 0);
|
m_object->SetObjectParent(1, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee2.mod"));
|
modelManager->AddModelReference("bee2.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(1, Math::Vector(1.6f, 0.3f, 0.0f));
|
m_object->SetPosition(1, Math::Vector(1.6f, 0.3f, 0.0f));
|
||||||
|
|
||||||
// Creates the tail.
|
// Creates the tail.
|
||||||
|
@ -106,8 +98,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(2, rank);
|
m_object->SetObjectRank(2, rank);
|
||||||
m_object->SetObjectParent(2, 0);
|
m_object->SetObjectParent(2, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee3.mod"));
|
modelManager->AddModelReference("bee3.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(2, Math::Vector(-0.8f, 0.0f, 0.0f));
|
m_object->SetPosition(2, Math::Vector(-0.8f, 0.0f, 0.0f));
|
||||||
|
|
||||||
// Creates a right-back thigh.
|
// Creates a right-back thigh.
|
||||||
|
@ -115,8 +106,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(3, rank);
|
m_object->SetObjectRank(3, rank);
|
||||||
m_object->SetObjectParent(3, 0);
|
m_object->SetObjectParent(3, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
|
modelManager->AddModelReference("ant4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(3, Math::Vector(-0.3f, -0.1f, -0.2f));
|
m_object->SetPosition(3, Math::Vector(-0.3f, -0.1f, -0.2f));
|
||||||
|
|
||||||
// Creates a right-back leg.
|
// Creates a right-back leg.
|
||||||
|
@ -124,8 +114,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(4, rank);
|
m_object->SetObjectRank(4, rank);
|
||||||
m_object->SetObjectParent(4, 3);
|
m_object->SetObjectParent(4, 3);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
|
modelManager->AddModelReference("ant5.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(4, Math::Vector(0.0f, 0.0f, -1.0f));
|
m_object->SetPosition(4, Math::Vector(0.0f, 0.0f, -1.0f));
|
||||||
|
|
||||||
// Creates a right-back foot.
|
// Creates a right-back foot.
|
||||||
|
@ -133,8 +122,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(5, rank);
|
m_object->SetObjectRank(5, rank);
|
||||||
m_object->SetObjectParent(5, 4);
|
m_object->SetObjectParent(5, 4);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
|
modelManager->AddModelReference("ant6.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -2.0f));
|
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -2.0f));
|
||||||
|
|
||||||
// Creates two middle-right thighs.
|
// Creates two middle-right thighs.
|
||||||
|
@ -142,8 +130,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(6, rank);
|
m_object->SetObjectRank(6, rank);
|
||||||
m_object->SetObjectParent(6, 0);
|
m_object->SetObjectParent(6, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
|
modelManager->AddModelReference("ant4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(6, Math::Vector(0.3f, -0.1f, -0.4f));
|
m_object->SetPosition(6, Math::Vector(0.3f, -0.1f, -0.4f));
|
||||||
|
|
||||||
// Creates two middle-right legs.
|
// Creates two middle-right legs.
|
||||||
|
@ -151,8 +138,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(7, rank);
|
m_object->SetObjectRank(7, rank);
|
||||||
m_object->SetObjectParent(7, 6);
|
m_object->SetObjectParent(7, 6);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
|
modelManager->AddModelReference("ant5.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(7, Math::Vector(0.0f, 0.0f, -1.0f));
|
m_object->SetPosition(7, Math::Vector(0.0f, 0.0f, -1.0f));
|
||||||
|
|
||||||
// Creates two middle-right feet.
|
// Creates two middle-right feet.
|
||||||
|
@ -160,8 +146,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(8, rank);
|
m_object->SetObjectRank(8, rank);
|
||||||
m_object->SetObjectParent(8, 7);
|
m_object->SetObjectParent(8, 7);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
|
modelManager->AddModelReference("ant6.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(8, Math::Vector(0.0f, 0.0f, -2.0f));
|
m_object->SetPosition(8, Math::Vector(0.0f, 0.0f, -2.0f));
|
||||||
|
|
||||||
// Creates the right front thigh.
|
// Creates the right front thigh.
|
||||||
|
@ -169,8 +154,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(9, rank);
|
m_object->SetObjectRank(9, rank);
|
||||||
m_object->SetObjectParent(9, 0);
|
m_object->SetObjectParent(9, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
|
modelManager->AddModelReference("ant4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(9, Math::Vector(1.0f, -0.1f, -0.7f));
|
m_object->SetPosition(9, Math::Vector(1.0f, -0.1f, -0.7f));
|
||||||
|
|
||||||
// Creates the right front leg.
|
// Creates the right front leg.
|
||||||
|
@ -178,8 +162,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(10, rank);
|
m_object->SetObjectRank(10, rank);
|
||||||
m_object->SetObjectParent(10, 9);
|
m_object->SetObjectParent(10, 9);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
|
modelManager->AddModelReference("ant5.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(10, Math::Vector(0.0f, 0.0f, -1.0f));
|
m_object->SetPosition(10, Math::Vector(0.0f, 0.0f, -1.0f));
|
||||||
|
|
||||||
// Creates the right front foot.
|
// Creates the right front foot.
|
||||||
|
@ -187,8 +170,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(11, rank);
|
m_object->SetObjectRank(11, rank);
|
||||||
m_object->SetObjectParent(11, 10);
|
m_object->SetObjectParent(11, 10);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
|
modelManager->AddModelReference("ant6.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, -2.0f));
|
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, -2.0f));
|
||||||
|
|
||||||
// Creates a left-back thigh.
|
// Creates a left-back thigh.
|
||||||
|
@ -196,8 +178,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(12, rank);
|
m_object->SetObjectRank(12, rank);
|
||||||
m_object->SetObjectParent(12, 0);
|
m_object->SetObjectParent(12, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
|
modelManager->AddModelReference("ant4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(12, Math::Vector(-0.3f, -0.1f, 0.2f));
|
m_object->SetPosition(12, Math::Vector(-0.3f, -0.1f, 0.2f));
|
||||||
m_object->SetAngleY(12, Math::PI);
|
m_object->SetAngleY(12, Math::PI);
|
||||||
|
|
||||||
|
@ -206,8 +187,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(13, rank);
|
m_object->SetObjectRank(13, rank);
|
||||||
m_object->SetObjectParent(13, 12);
|
m_object->SetObjectParent(13, 12);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
|
modelManager->AddModelReference("ant5.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(13, Math::Vector(0.0f, 0.0f, -1.0f));
|
m_object->SetPosition(13, Math::Vector(0.0f, 0.0f, -1.0f));
|
||||||
|
|
||||||
// Creates a left-back foot.
|
// Creates a left-back foot.
|
||||||
|
@ -215,8 +195,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(14, rank);
|
m_object->SetObjectRank(14, rank);
|
||||||
m_object->SetObjectParent(14, 13);
|
m_object->SetObjectParent(14, 13);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
|
modelManager->AddModelReference("ant6.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(14, Math::Vector(0.0f, 0.0f, -2.0f));
|
m_object->SetPosition(14, Math::Vector(0.0f, 0.0f, -2.0f));
|
||||||
|
|
||||||
// Creates two middle-left thigh.
|
// Creates two middle-left thigh.
|
||||||
|
@ -224,8 +203,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(15, rank);
|
m_object->SetObjectRank(15, rank);
|
||||||
m_object->SetObjectParent(15, 0);
|
m_object->SetObjectParent(15, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
|
modelManager->AddModelReference("ant4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(15, Math::Vector(0.3f, -0.1f, 0.4f));
|
m_object->SetPosition(15, Math::Vector(0.3f, -0.1f, 0.4f));
|
||||||
m_object->SetAngleY(15, Math::PI);
|
m_object->SetAngleY(15, Math::PI);
|
||||||
|
|
||||||
|
@ -234,8 +212,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(16, rank);
|
m_object->SetObjectRank(16, rank);
|
||||||
m_object->SetObjectParent(16, 15);
|
m_object->SetObjectParent(16, 15);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
|
modelManager->AddModelReference("ant5.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(16, Math::Vector(0.0f, 0.0f, -1.0f));
|
m_object->SetPosition(16, Math::Vector(0.0f, 0.0f, -1.0f));
|
||||||
|
|
||||||
// Creates two middle-left feet.
|
// Creates two middle-left feet.
|
||||||
|
@ -243,8 +220,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(17, rank);
|
m_object->SetObjectRank(17, rank);
|
||||||
m_object->SetObjectParent(17, 16);
|
m_object->SetObjectParent(17, 16);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
|
modelManager->AddModelReference("ant6.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(17, Math::Vector(0.0f, 0.0f, -2.0f));
|
m_object->SetPosition(17, Math::Vector(0.0f, 0.0f, -2.0f));
|
||||||
|
|
||||||
// Creates front-left thigh.
|
// Creates front-left thigh.
|
||||||
|
@ -252,8 +228,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(18, rank);
|
m_object->SetObjectRank(18, rank);
|
||||||
m_object->SetObjectParent(18, 0);
|
m_object->SetObjectParent(18, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
|
modelManager->AddModelReference("ant4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(18, Math::Vector(1.0f, -0.1f, 0.7f));
|
m_object->SetPosition(18, Math::Vector(1.0f, -0.1f, 0.7f));
|
||||||
m_object->SetAngleY(18, Math::PI);
|
m_object->SetAngleY(18, Math::PI);
|
||||||
|
|
||||||
|
@ -262,8 +237,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(19, rank);
|
m_object->SetObjectRank(19, rank);
|
||||||
m_object->SetObjectParent(19, 18);
|
m_object->SetObjectParent(19, 18);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
|
modelManager->AddModelReference("ant5.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(19, Math::Vector(0.0f, 0.0f, -1.0f));
|
m_object->SetPosition(19, Math::Vector(0.0f, 0.0f, -1.0f));
|
||||||
|
|
||||||
// Creates front-left foot.
|
// Creates front-left foot.
|
||||||
|
@ -271,8 +245,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(20, rank);
|
m_object->SetObjectRank(20, rank);
|
||||||
m_object->SetObjectParent(20, 19);
|
m_object->SetObjectParent(20, 19);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
|
modelManager->AddModelReference("ant6.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(20, Math::Vector(0.0f, 0.0f, -2.0f));
|
m_object->SetPosition(20, Math::Vector(0.0f, 0.0f, -2.0f));
|
||||||
|
|
||||||
// Creates the right wing.
|
// Creates the right wing.
|
||||||
|
@ -280,8 +253,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(21, rank);
|
m_object->SetObjectRank(21, rank);
|
||||||
m_object->SetObjectParent(21, 0);
|
m_object->SetObjectParent(21, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee7.mod"));
|
modelManager->AddModelReference("bee7.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(21, Math::Vector(0.8f, 0.4f, -0.5f));
|
m_object->SetPosition(21, Math::Vector(0.8f, 0.4f, -0.5f));
|
||||||
|
|
||||||
// Creates the left wing.
|
// Creates the left wing.
|
||||||
|
@ -289,9 +261,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(22, rank);
|
m_object->SetObjectRank(22, rank);
|
||||||
m_object->SetObjectParent(22, 0);
|
m_object->SetObjectParent(22, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee7.mod"));
|
modelManager->AddModelReference("bee7.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(22, Math::Vector(0.8f, 0.4f, 0.5f));
|
m_object->SetPosition(22, Math::Vector(0.8f, 0.4f, 0.5f));
|
||||||
|
|
||||||
m_object->CreateShadowCircle(6.0f, 0.5f);
|
m_object->CreateShadowCircle(6.0f, 0.5f);
|
||||||
|
@ -304,7 +274,6 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
|
|
||||||
m_engine->LoadAllTextures();
|
m_engine->LoadAllTextures();
|
||||||
|
|
||||||
delete pModFile;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "graphics/engine/modelfile.h"
|
#include "graphics/engine/modelmanager.h"
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
#include "graphics/engine/water.h"
|
#include "graphics/engine/water.h"
|
||||||
|
|
||||||
|
@ -97,30 +97,22 @@ Error CMotionHuman::SetAction(int action, float time)
|
||||||
bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
float power)
|
float power)
|
||||||
{
|
{
|
||||||
Gfx::CModelFile* pModFile;
|
|
||||||
char filename[100];
|
char filename[100];
|
||||||
int rank, option, face, glasses;
|
int rank, option, face, glasses;
|
||||||
|
|
||||||
// if ( m_engine->GetRestCreate() < 16 ) return false;
|
Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
|
||||||
|
|
||||||
|
|
||||||
pModFile = new Gfx::CModelFile(m_iMan);
|
|
||||||
|
|
||||||
m_object->SetType(type);
|
m_object->SetType(type);
|
||||||
option = m_object->GetOption();
|
option = m_object->GetOption();
|
||||||
|
|
||||||
std::string baseName;
|
|
||||||
|
|
||||||
if ( m_main->GetGamerOnlyHead() )
|
if ( m_main->GetGamerOnlyHead() )
|
||||||
{
|
{
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
||||||
m_object->SetObjectRank(0, rank);
|
m_object->SetObjectRank(0, rank);
|
||||||
face = m_main->GetGamerFace();
|
face = m_main->GetGamerFace();
|
||||||
baseName = m_app->GetDataFilePath(DIR_MODEL, "human2h%d.mod");
|
sprintf(filename, "human2h%d.mod", face+1);
|
||||||
sprintf(filename, baseName.c_str(), face+1);
|
modelManager->AddModelReference(filename, false, rank);
|
||||||
pModFile->ReadModel(filename);
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
|
|
||||||
glasses = m_main->GetGamerGlasses();
|
glasses = m_main->GetGamerGlasses();
|
||||||
if ( glasses != 0 )
|
if ( glasses != 0 )
|
||||||
|
@ -129,10 +121,8 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(1, rank);
|
m_object->SetObjectRank(1, rank);
|
||||||
m_object->SetObjectParent(1, 0);
|
m_object->SetObjectParent(1, 0);
|
||||||
baseName = m_app->GetDataFilePath(DIR_MODEL, "human2g%d.mod");
|
sprintf(filename, "human2g%d.mod", glasses);
|
||||||
sprintf(filename, baseName.c_str(), glasses);
|
modelManager->AddModelReference(filename, false, rank);
|
||||||
pModFile->ReadModel(filename);
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CreatePhysics(type);
|
CreatePhysics(type);
|
||||||
|
@ -140,7 +130,6 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
|
|
||||||
m_engine->LoadAllTextures();
|
m_engine->LoadAllTextures();
|
||||||
|
|
||||||
delete pModFile;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,19 +138,12 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
||||||
m_object->SetObjectRank(0, rank);
|
m_object->SetObjectRank(0, rank);
|
||||||
|
|
||||||
if ( option == 0 ) // head in helmet?
|
if (option == 0) // head in helmet?
|
||||||
{
|
modelManager->AddModelReference("human1c.mod", false, rank);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human1c.mod"));
|
else if (option == 1) // head without helmet?
|
||||||
}
|
modelManager->AddModelReference("human1h.mod", false, rank);
|
||||||
if ( option == 1 ) // head without helmet?
|
else if (option == 2) // without a backpack?
|
||||||
{
|
modelManager->AddModelReference("human1v.mod", false, rank);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human1h.mod"));
|
|
||||||
}
|
|
||||||
if ( option == 2 ) // without a backpack?
|
|
||||||
{
|
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human1v.mod"));
|
|
||||||
}
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
|
|
||||||
m_object->SetPosition(0, pos);
|
m_object->SetPosition(0, pos);
|
||||||
m_object->SetAngleY(0, angle);
|
m_object->SetAngleY(0, angle);
|
||||||
|
@ -178,30 +160,28 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
|
|
||||||
if ( type == OBJECT_HUMAN )
|
if ( type == OBJECT_HUMAN )
|
||||||
{
|
{
|
||||||
if ( option == 0 ) // head in helmet?
|
if (option == 0) // head in helmet?
|
||||||
{
|
{
|
||||||
face = m_main->GetGamerFace();
|
face = m_main->GetGamerFace();
|
||||||
baseName = m_app->GetDataFilePath(DIR_MODEL, "human2c%d.mod");
|
sprintf(filename, "human2c%d.mod", face+1);
|
||||||
sprintf(filename, baseName.c_str(), face+1);
|
modelManager->AddModelReference(filename, false, rank);
|
||||||
pModFile->ReadModel(filename);
|
|
||||||
}
|
}
|
||||||
if ( option == 1 || // head without helmet?
|
else if (option == 1 || // head without helmet?
|
||||||
option == 2 ) // without a backpack?
|
option == 2) // without a backpack?
|
||||||
{
|
{
|
||||||
face = m_main->GetGamerFace();
|
face = m_main->GetGamerFace();
|
||||||
baseName = m_app->GetDataFilePath(DIR_MODEL, "human2h%d.mod");
|
sprintf(filename, "human2h%d.mod", face+1);
|
||||||
sprintf(filename, baseName.c_str(), face+1);
|
modelManager->AddModelReference(filename, false, rank);
|
||||||
pModFile->ReadModel(filename);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( type == OBJECT_TECH )
|
else if (type == OBJECT_TECH)
|
||||||
{
|
{
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human2t.mod"));
|
modelManager->AddModelReference("human2t.mod", false, rank);
|
||||||
}
|
}
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(1, Math::Vector(0.0f, 2.7f, 0.0f));
|
m_object->SetPosition(1, Math::Vector(0.0f, 2.7f, 0.0f));
|
||||||
if ( option == 1 || // head without helmet?
|
if (option == 1 || // head without helmet?
|
||||||
option == 2 ) // without a backpack?
|
option == 2) // without a backpack?
|
||||||
{
|
{
|
||||||
m_object->SetZoom(1, Math::Vector(1.0f, 1.05f, 1.0f));
|
m_object->SetZoom(1, Math::Vector(1.0f, 1.05f, 1.0f));
|
||||||
}
|
}
|
||||||
|
@ -214,10 +194,8 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(15, rank);
|
m_object->SetObjectRank(15, rank);
|
||||||
m_object->SetObjectParent(15, 1);
|
m_object->SetObjectParent(15, 1);
|
||||||
baseName = m_app->GetDataFilePath(DIR_MODEL, "human2g%d.mod");
|
sprintf(filename, "human2g%d.mod", glasses);
|
||||||
sprintf(filename, baseName.c_str(), glasses);
|
modelManager->AddModelReference(filename, false, rank);
|
||||||
pModFile->ReadModel(filename);
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates the right arm.
|
// Creates the right arm.
|
||||||
|
@ -225,8 +203,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(2, rank);
|
m_object->SetObjectRank(2, rank);
|
||||||
m_object->SetObjectParent(2, 0);
|
m_object->SetObjectParent(2, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human3.mod"));
|
modelManager->AddModelReference("human3.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(2, Math::Vector(0.0f, 2.3f, -1.2f));
|
m_object->SetPosition(2, Math::Vector(0.0f, 2.3f, -1.2f));
|
||||||
m_object->SetAngle(2, Math::Vector(90.0f*Math::PI/180.0f, 90.0f*Math::PI/180.0f, -50.0f*Math::PI/180.0f));
|
m_object->SetAngle(2, Math::Vector(90.0f*Math::PI/180.0f, 90.0f*Math::PI/180.0f, -50.0f*Math::PI/180.0f));
|
||||||
|
|
||||||
|
@ -235,8 +212,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(3, rank);
|
m_object->SetObjectRank(3, rank);
|
||||||
m_object->SetObjectParent(3, 2);
|
m_object->SetObjectParent(3, 2);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human4r.mod"));
|
modelManager->AddModelReference("human4r.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(3, Math::Vector(1.3f, 0.0f, 0.0f));
|
m_object->SetPosition(3, Math::Vector(1.3f, 0.0f, 0.0f));
|
||||||
m_object->SetAngle(3, Math::Vector(0.0f*Math::PI/180.0f, -20.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f));
|
m_object->SetAngle(3, Math::Vector(0.0f*Math::PI/180.0f, -20.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f));
|
||||||
|
|
||||||
|
@ -245,8 +221,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(4, rank);
|
m_object->SetObjectRank(4, rank);
|
||||||
m_object->SetObjectParent(4, 3);
|
m_object->SetObjectParent(4, 3);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human5.mod"));
|
modelManager->AddModelReference("human5.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(4, Math::Vector(1.2f, 0.0f, 0.0f));
|
m_object->SetPosition(4, Math::Vector(1.2f, 0.0f, 0.0f));
|
||||||
|
|
||||||
// Creates the right thigh.
|
// Creates the right thigh.
|
||||||
|
@ -254,8 +229,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(5, rank);
|
m_object->SetObjectRank(5, rank);
|
||||||
m_object->SetObjectParent(5, 0);
|
m_object->SetObjectParent(5, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human6.mod"));
|
modelManager->AddModelReference("human6.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -0.7f));
|
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -0.7f));
|
||||||
m_object->SetAngle(5, Math::Vector(10.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
|
m_object->SetAngle(5, Math::Vector(10.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
|
||||||
|
|
||||||
|
@ -264,8 +238,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(6, rank);
|
m_object->SetObjectRank(6, rank);
|
||||||
m_object->SetObjectParent(6, 5);
|
m_object->SetObjectParent(6, 5);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human7.mod"));
|
modelManager->AddModelReference("human7.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(6, Math::Vector(0.0f, -1.5f, 0.0f));
|
m_object->SetPosition(6, Math::Vector(0.0f, -1.5f, 0.0f));
|
||||||
m_object->SetAngle(6, Math::Vector(0.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, -10.0f*Math::PI/180.0f));
|
m_object->SetAngle(6, Math::Vector(0.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, -10.0f*Math::PI/180.0f));
|
||||||
|
|
||||||
|
@ -274,8 +247,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(7, rank);
|
m_object->SetObjectRank(7, rank);
|
||||||
m_object->SetObjectParent(7, 6);
|
m_object->SetObjectParent(7, 6);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human8.mod"));
|
modelManager->AddModelReference("human8.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(7, Math::Vector(0.0f, -1.5f, 0.0f));
|
m_object->SetPosition(7, Math::Vector(0.0f, -1.5f, 0.0f));
|
||||||
m_object->SetAngle(7, Math::Vector(-10.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
|
m_object->SetAngle(7, Math::Vector(-10.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
|
||||||
|
|
||||||
|
@ -284,9 +256,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(8, rank);
|
m_object->SetObjectRank(8, rank);
|
||||||
m_object->SetObjectParent(8, 0);
|
m_object->SetObjectParent(8, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human3.mod"));
|
modelManager->AddModelReference("human3.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(8, Math::Vector(0.0f, 2.3f, 1.2f));
|
m_object->SetPosition(8, Math::Vector(0.0f, 2.3f, 1.2f));
|
||||||
m_object->SetAngle(8, Math::Vector(-90.0f*Math::PI/180.0f, -90.0f*Math::PI/180.0f, -50.0f*Math::PI/180.0f));
|
m_object->SetAngle(8, Math::Vector(-90.0f*Math::PI/180.0f, -90.0f*Math::PI/180.0f, -50.0f*Math::PI/180.0f));
|
||||||
|
|
||||||
|
@ -295,9 +265,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(9, rank);
|
m_object->SetObjectRank(9, rank);
|
||||||
m_object->SetObjectParent(9, 8);
|
m_object->SetObjectParent(9, 8);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human4l.mod"));
|
modelManager->AddModelReference("human4l.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(9, Math::Vector(1.3f, 0.0f, 0.0f));
|
m_object->SetPosition(9, Math::Vector(1.3f, 0.0f, 0.0f));
|
||||||
m_object->SetAngle(9, Math::Vector(0.0f*Math::PI/180.0f, 20.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f));
|
m_object->SetAngle(9, Math::Vector(0.0f*Math::PI/180.0f, 20.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f));
|
||||||
|
|
||||||
|
@ -306,9 +274,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(10, rank);
|
m_object->SetObjectRank(10, rank);
|
||||||
m_object->SetObjectParent(10, 9);
|
m_object->SetObjectParent(10, 9);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human5.mod"));
|
modelManager->AddModelReference("human5.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(10, Math::Vector(1.2f, 0.0f, 0.0f));
|
m_object->SetPosition(10, Math::Vector(1.2f, 0.0f, 0.0f));
|
||||||
|
|
||||||
// Creates the left thigh.
|
// Creates the left thigh.
|
||||||
|
@ -316,9 +282,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(11, rank);
|
m_object->SetObjectRank(11, rank);
|
||||||
m_object->SetObjectParent(11, 0);
|
m_object->SetObjectParent(11, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human6.mod"));
|
modelManager->AddModelReference("human6.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, 0.7f));
|
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, 0.7f));
|
||||||
m_object->SetAngle(11, Math::Vector(-10.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
|
m_object->SetAngle(11, Math::Vector(-10.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
|
||||||
|
|
||||||
|
@ -327,9 +291,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(12, rank);
|
m_object->SetObjectRank(12, rank);
|
||||||
m_object->SetObjectParent(12, 11);
|
m_object->SetObjectParent(12, 11);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human7.mod"));
|
modelManager->AddModelReference("human7.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(12, Math::Vector(0.0f, -1.5f, 0.0f));
|
m_object->SetPosition(12, Math::Vector(0.0f, -1.5f, 0.0f));
|
||||||
m_object->SetAngle(12, Math::Vector(0.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, -10.0f*Math::PI/180.0f));
|
m_object->SetAngle(12, Math::Vector(0.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, -10.0f*Math::PI/180.0f));
|
||||||
|
|
||||||
|
@ -338,9 +300,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(13, rank);
|
m_object->SetObjectRank(13, rank);
|
||||||
m_object->SetObjectParent(13, 12);
|
m_object->SetObjectParent(13, 12);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human8.mod"));
|
modelManager->AddModelReference("human8.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(13, Math::Vector(0.0f, -1.5f, 0.0f));
|
m_object->SetPosition(13, Math::Vector(0.0f, -1.5f, 0.0f));
|
||||||
m_object->SetAngle(13, Math::Vector(10.0f*Math::PI/180.0f, -5.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
|
m_object->SetAngle(13, Math::Vector(10.0f*Math::PI/180.0f, -5.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
|
||||||
|
|
||||||
|
@ -351,8 +311,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(14, rank);
|
m_object->SetObjectRank(14, rank);
|
||||||
m_object->SetObjectParent(14, 0);
|
m_object->SetObjectParent(14, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human9.mod"));
|
modelManager->AddModelReference("human9.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(14, Math::Vector(-1.5f, 0.3f, -1.35f));
|
m_object->SetPosition(14, Math::Vector(-1.5f, 0.3f, -1.35f));
|
||||||
m_object->SetAngleZ(14, Math::PI);
|
m_object->SetAngleZ(14, Math::PI);
|
||||||
}
|
}
|
||||||
|
@ -367,7 +326,6 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
|
|
||||||
m_engine->LoadAllTextures();
|
m_engine->LoadAllTextures();
|
||||||
|
|
||||||
delete pModFile;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "graphics/engine/modelfile.h"
|
#include "graphics/engine/modelmanager.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
|
||||||
|
@ -68,12 +68,8 @@ void CMotionMother::DeleteObject(bool bAll)
|
||||||
bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
float power)
|
float power)
|
||||||
{
|
{
|
||||||
Gfx::CModelFile* pModFile;
|
Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
|
||||||
int rank;
|
int rank;
|
||||||
|
|
||||||
// if ( m_engine->GetRestCreate() < 2+12+6 ) return false;
|
|
||||||
|
|
||||||
pModFile = new Gfx::CModelFile(m_iMan);
|
|
||||||
|
|
||||||
m_object->SetType(type);
|
m_object->SetType(type);
|
||||||
|
|
||||||
|
@ -81,10 +77,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
||||||
m_object->SetObjectRank(0, rank);
|
m_object->SetObjectRank(0, rank);
|
||||||
|
modelManager->AddModelReference("mother1.mod", false, rank);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother1.mod"));
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
|
|
||||||
m_object->SetPosition(0, pos);
|
m_object->SetPosition(0, pos);
|
||||||
m_object->SetAngleY(0, angle);
|
m_object->SetAngleY(0, angle);
|
||||||
|
|
||||||
|
@ -98,8 +91,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(1, rank);
|
m_object->SetObjectRank(1, rank);
|
||||||
m_object->SetObjectParent(1, 0);
|
m_object->SetObjectParent(1, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother2.mod"));
|
modelManager->AddModelReference("mother2.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(1, Math::Vector(16.0f, 3.0f, 0.0f));
|
m_object->SetPosition(1, Math::Vector(16.0f, 3.0f, 0.0f));
|
||||||
|
|
||||||
// Creates a right-back leg.
|
// Creates a right-back leg.
|
||||||
|
@ -107,8 +99,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(2, rank);
|
m_object->SetObjectRank(2, rank);
|
||||||
m_object->SetObjectParent(2, 0);
|
m_object->SetObjectParent(2, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
|
modelManager->AddModelReference("mother3.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(2, Math::Vector(-5.0f, -1.0f, -12.0f));
|
m_object->SetPosition(2, Math::Vector(-5.0f, -1.0f, -12.0f));
|
||||||
|
|
||||||
// Creates a right-back foot.
|
// Creates a right-back foot.
|
||||||
|
@ -116,8 +107,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(3, rank);
|
m_object->SetObjectRank(3, rank);
|
||||||
m_object->SetObjectParent(3, 2);
|
m_object->SetObjectParent(3, 2);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
|
modelManager->AddModelReference("mother4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(3, Math::Vector(0.0f, 0.0f, -8.5f));
|
m_object->SetPosition(3, Math::Vector(0.0f, 0.0f, -8.5f));
|
||||||
|
|
||||||
// Creates a middle-right leg.
|
// Creates a middle-right leg.
|
||||||
|
@ -125,8 +115,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(4, rank);
|
m_object->SetObjectRank(4, rank);
|
||||||
m_object->SetObjectParent(4, 0);
|
m_object->SetObjectParent(4, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
|
modelManager->AddModelReference("mother3.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(4, Math::Vector(3.5f, -1.0f, -12.0f));
|
m_object->SetPosition(4, Math::Vector(3.5f, -1.0f, -12.0f));
|
||||||
|
|
||||||
// Creates a middle-right foot.
|
// Creates a middle-right foot.
|
||||||
|
@ -134,8 +123,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(5, rank);
|
m_object->SetObjectRank(5, rank);
|
||||||
m_object->SetObjectParent(5, 4);
|
m_object->SetObjectParent(5, 4);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
|
modelManager->AddModelReference("mother4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -8.5f));
|
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -8.5f));
|
||||||
|
|
||||||
// Creates a right-front leg.
|
// Creates a right-front leg.
|
||||||
|
@ -143,8 +131,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(6, rank);
|
m_object->SetObjectRank(6, rank);
|
||||||
m_object->SetObjectParent(6, 0);
|
m_object->SetObjectParent(6, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
|
modelManager->AddModelReference("mother3.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(6, Math::Vector(10.0f, -1.0f, -10.0f));
|
m_object->SetPosition(6, Math::Vector(10.0f, -1.0f, -10.0f));
|
||||||
|
|
||||||
// Creates a right-front foot.
|
// Creates a right-front foot.
|
||||||
|
@ -152,8 +139,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(7, rank);
|
m_object->SetObjectRank(7, rank);
|
||||||
m_object->SetObjectParent(7, 6);
|
m_object->SetObjectParent(7, 6);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
|
modelManager->AddModelReference("mother4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(7, Math::Vector(0.0f, 0.0f, -8.5f));
|
m_object->SetPosition(7, Math::Vector(0.0f, 0.0f, -8.5f));
|
||||||
|
|
||||||
// Creates a left-back leg.
|
// Creates a left-back leg.
|
||||||
|
@ -161,8 +147,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(8, rank);
|
m_object->SetObjectRank(8, rank);
|
||||||
m_object->SetObjectParent(8, 0);
|
m_object->SetObjectParent(8, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
|
modelManager->AddModelReference("mother3.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(8, Math::Vector(-5.0f, -1.0f, 12.0f));
|
m_object->SetPosition(8, Math::Vector(-5.0f, -1.0f, 12.0f));
|
||||||
m_object->SetAngleY(8, Math::PI);
|
m_object->SetAngleY(8, Math::PI);
|
||||||
|
|
||||||
|
@ -171,8 +156,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(9, rank);
|
m_object->SetObjectRank(9, rank);
|
||||||
m_object->SetObjectParent(9, 8);
|
m_object->SetObjectParent(9, 8);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
|
modelManager->AddModelReference("mother4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(9, Math::Vector(0.0f, 0.0f, -8.5f));
|
m_object->SetPosition(9, Math::Vector(0.0f, 0.0f, -8.5f));
|
||||||
|
|
||||||
// Creates a middle-left leg.
|
// Creates a middle-left leg.
|
||||||
|
@ -180,8 +164,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(10, rank);
|
m_object->SetObjectRank(10, rank);
|
||||||
m_object->SetObjectParent(10, 0);
|
m_object->SetObjectParent(10, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
|
modelManager->AddModelReference("mother3.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(10, Math::Vector(3.5f, -1.0f, 12.0f));
|
m_object->SetPosition(10, Math::Vector(3.5f, -1.0f, 12.0f));
|
||||||
m_object->SetAngleY(10, Math::PI);
|
m_object->SetAngleY(10, Math::PI);
|
||||||
|
|
||||||
|
@ -190,8 +173,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(11, rank);
|
m_object->SetObjectRank(11, rank);
|
||||||
m_object->SetObjectParent(11, 10);
|
m_object->SetObjectParent(11, 10);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
|
modelManager->AddModelReference("mother4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, -8.5f));
|
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, -8.5f));
|
||||||
|
|
||||||
// Creates a left-front leg.
|
// Creates a left-front leg.
|
||||||
|
@ -199,8 +181,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(12, rank);
|
m_object->SetObjectRank(12, rank);
|
||||||
m_object->SetObjectParent(12, 0);
|
m_object->SetObjectParent(12, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
|
modelManager->AddModelReference("mother3.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(12, Math::Vector(10.0f, -1.0f, 10.0f));
|
m_object->SetPosition(12, Math::Vector(10.0f, -1.0f, 10.0f));
|
||||||
m_object->SetAngleY(12, Math::PI);
|
m_object->SetAngleY(12, Math::PI);
|
||||||
|
|
||||||
|
@ -209,8 +190,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(13, rank);
|
m_object->SetObjectRank(13, rank);
|
||||||
m_object->SetObjectParent(13, 12);
|
m_object->SetObjectParent(13, 12);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
|
modelManager->AddModelReference("mother4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(13, Math::Vector(0.0f, 0.0f, -8.5f));
|
m_object->SetPosition(13, Math::Vector(0.0f, 0.0f, -8.5f));
|
||||||
|
|
||||||
// Creates the right antenna.
|
// Creates the right antenna.
|
||||||
|
@ -218,16 +198,14 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(14, rank);
|
m_object->SetObjectRank(14, rank);
|
||||||
m_object->SetObjectParent(14, 1);
|
m_object->SetObjectParent(14, 1);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother5.mod"));
|
modelManager->AddModelReference("mother5.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(14, Math::Vector(6.0f, 1.0f, -2.5f));
|
m_object->SetPosition(14, Math::Vector(6.0f, 1.0f, -2.5f));
|
||||||
|
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(15, rank);
|
m_object->SetObjectRank(15, rank);
|
||||||
m_object->SetObjectParent(15, 14);
|
m_object->SetObjectParent(15, 14);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother6.mod"));
|
modelManager->AddModelReference("mother6.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(15, Math::Vector(8.0f, 0.0f, 0.0f));
|
m_object->SetPosition(15, Math::Vector(8.0f, 0.0f, 0.0f));
|
||||||
|
|
||||||
// Creates the left antenna.
|
// Creates the left antenna.
|
||||||
|
@ -235,16 +213,14 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(16, rank);
|
m_object->SetObjectRank(16, rank);
|
||||||
m_object->SetObjectParent(16, 1);
|
m_object->SetObjectParent(16, 1);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother5.mod"));
|
modelManager->AddModelReference("mother5.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(16, Math::Vector(6.0f, 1.0f, 2.5f));
|
m_object->SetPosition(16, Math::Vector(6.0f, 1.0f, 2.5f));
|
||||||
|
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(17, rank);
|
m_object->SetObjectRank(17, rank);
|
||||||
m_object->SetObjectParent(17, 16);
|
m_object->SetObjectParent(17, 16);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother6.mod"));
|
modelManager->AddModelReference("mother6.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(17, Math::Vector(8.0f, 0.0f, 0.0f));
|
m_object->SetPosition(17, Math::Vector(8.0f, 0.0f, 0.0f));
|
||||||
|
|
||||||
// Creates the right claw.
|
// Creates the right claw.
|
||||||
|
@ -252,8 +228,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(18, rank);
|
m_object->SetObjectRank(18, rank);
|
||||||
m_object->SetObjectParent(18, 1);
|
m_object->SetObjectParent(18, 1);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother7.mod"));
|
modelManager->AddModelReference("mother7.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(18, Math::Vector(-4.0f, -3.5f, -8.0f));
|
m_object->SetPosition(18, Math::Vector(-4.0f, -3.5f, -8.0f));
|
||||||
m_object->SetZoomX(18, 1.2f);
|
m_object->SetZoomX(18, 1.2f);
|
||||||
|
|
||||||
|
@ -262,9 +237,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(19, rank);
|
m_object->SetObjectRank(19, rank);
|
||||||
m_object->SetObjectParent(19, 1);
|
m_object->SetObjectParent(19, 1);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother7.mod"));
|
modelManager->AddModelReference("mother7.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(19, Math::Vector(-4.0f, -3.5f, 8.0f));
|
m_object->SetPosition(19, Math::Vector(-4.0f, -3.5f, 8.0f));
|
||||||
m_object->SetZoomX(19, 1.2f);
|
m_object->SetZoomX(19, 1.2f);
|
||||||
|
|
||||||
|
@ -278,7 +251,6 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
|
|
||||||
m_engine->LoadAllTextures();
|
m_engine->LoadAllTextures();
|
||||||
|
|
||||||
delete pModFile;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "graphics/engine/modelfile.h"
|
#include "graphics/engine/modelmanager.h"
|
||||||
#include "graphics/engine/particle.h"
|
#include "graphics/engine/particle.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
@ -69,12 +69,9 @@ void CMotionSpider::DeleteObject(bool bAll)
|
||||||
bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
|
bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
float power)
|
float power)
|
||||||
{
|
{
|
||||||
Gfx::CModelFile* pModFile;
|
|
||||||
int rank, i, j, parent;
|
int rank, i, j, parent;
|
||||||
char name[50];
|
char name[50];
|
||||||
|
|
||||||
std::string baseName;
|
|
||||||
|
|
||||||
float table[] =
|
float table[] =
|
||||||
{
|
{
|
||||||
// x y z
|
// x y z
|
||||||
|
@ -99,9 +96,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
0.0f, 0.0f, -2.0f,
|
0.0f, 0.0f, -2.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
// if ( m_engine->GetRestCreate() < 3+32+2 ) return false;
|
Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
|
||||||
|
|
||||||
pModFile = new Gfx::CModelFile(m_iMan);
|
|
||||||
|
|
||||||
m_object->SetType(type);
|
m_object->SetType(type);
|
||||||
|
|
||||||
|
@ -109,8 +104,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
||||||
m_object->SetObjectRank(0, rank);
|
m_object->SetObjectRank(0, rank);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider0.mod")); // doesn't exist
|
modelManager->AddModelReference("spider0.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(0, pos);
|
m_object->SetPosition(0, pos);
|
||||||
m_object->SetAngleY(0, angle);
|
m_object->SetAngleY(0, angle);
|
||||||
|
|
||||||
|
@ -124,8 +118,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(1, rank);
|
m_object->SetObjectRank(1, rank);
|
||||||
m_object->SetObjectParent(1, 0);
|
m_object->SetObjectParent(1, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider1.mod"));
|
modelManager->AddModelReference("spider1.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(1, Math::Vector(1.0f, 0.0f, 0.0f));
|
m_object->SetPosition(1, Math::Vector(1.0f, 0.0f, 0.0f));
|
||||||
|
|
||||||
// Creates the head.
|
// Creates the head.
|
||||||
|
@ -133,8 +126,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(2, rank);
|
m_object->SetObjectRank(2, rank);
|
||||||
m_object->SetObjectParent(2, 0);
|
m_object->SetObjectParent(2, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider2.mod"));
|
modelManager->AddModelReference("spider2.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(2, Math::Vector(1.0f, 0.0f, 0.0f));
|
m_object->SetPosition(2, Math::Vector(1.0f, 0.0f, 0.0f));
|
||||||
|
|
||||||
// Creates legs.
|
// Creates legs.
|
||||||
|
@ -142,8 +134,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
{
|
{
|
||||||
for ( j=0 ; j<4 ; j++ )
|
for ( j=0 ; j<4 ; j++ )
|
||||||
{
|
{
|
||||||
baseName = m_app->GetDataFilePath(DIR_MODEL, "spider%d.mod");
|
sprintf(name, "spider%d.mod", j+3); // 3..6
|
||||||
sprintf(name, baseName.c_str(), j+3); // 3..6
|
|
||||||
|
|
||||||
// Creates the right leg.
|
// Creates the right leg.
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
|
@ -152,8 +143,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
if ( j == 0 ) parent = 0;
|
if ( j == 0 ) parent = 0;
|
||||||
else parent = 3+i*4+j-1;
|
else parent = 3+i*4+j-1;
|
||||||
m_object->SetObjectParent(3+i*4+j, parent);
|
m_object->SetObjectParent(3+i*4+j, parent);
|
||||||
pModFile->ReadModel(name);
|
modelManager->AddModelReference(name, false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
pos.x = table[i*12+j*3+0];
|
pos.x = table[i*12+j*3+0];
|
||||||
pos.y = table[i*12+j*3+1];
|
pos.y = table[i*12+j*3+1];
|
||||||
pos.z = table[i*12+j*3+2];
|
pos.z = table[i*12+j*3+2];
|
||||||
|
@ -166,9 +156,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
if ( j == 0 ) parent = 0;
|
if ( j == 0 ) parent = 0;
|
||||||
else parent = 19+i*4+j-1;
|
else parent = 19+i*4+j-1;
|
||||||
m_object->SetObjectParent(19+i*4+j, parent);
|
m_object->SetObjectParent(19+i*4+j, parent);
|
||||||
pModFile->ReadModel(name);
|
modelManager->AddModelReference(name, true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
pos.x = table[i*12+j*3+0];
|
pos.x = table[i*12+j*3+0];
|
||||||
pos.y = table[i*12+j*3+1];
|
pos.y = table[i*12+j*3+1];
|
||||||
pos.z = -table[i*12+j*3+2];
|
pos.z = -table[i*12+j*3+2];
|
||||||
|
@ -181,8 +169,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(35, rank);
|
m_object->SetObjectRank(35, rank);
|
||||||
m_object->SetObjectParent(35, 1);
|
m_object->SetObjectParent(35, 1);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider7.mod"));
|
modelManager->AddModelReference("spider7.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(35, Math::Vector(0.0f, 0.0f, -0.3f));
|
m_object->SetPosition(35, Math::Vector(0.0f, 0.0f, -0.3f));
|
||||||
|
|
||||||
// Creates the left mandible.
|
// Creates the left mandible.
|
||||||
|
@ -190,9 +177,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(36, rank);
|
m_object->SetObjectRank(36, rank);
|
||||||
m_object->SetObjectParent(36, 1);
|
m_object->SetObjectParent(36, 1);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider7.mod"));
|
modelManager->AddModelReference("spider7.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(36, Math::Vector(0.0f, 0.0f, 0.3f));
|
m_object->SetPosition(36, Math::Vector(0.0f, 0.0f, 0.3f));
|
||||||
|
|
||||||
m_object->CreateShadowCircle(4.0f, 0.5f);
|
m_object->CreateShadowCircle(4.0f, 0.5f);
|
||||||
|
@ -205,7 +190,6 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
|
|
||||||
m_engine->LoadAllTextures();
|
m_engine->LoadAllTextures();
|
||||||
|
|
||||||
delete pModFile;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
#include "graphics/engine/modelmanager.h"
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
#include "graphics/engine/water.h"
|
#include "graphics/engine/water.h"
|
||||||
#include "graphics/engine/modelfile.h"
|
|
||||||
|
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
|
||||||
|
@ -81,12 +81,9 @@ void CMotionToto::DeleteObject(bool bAll)
|
||||||
bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
|
bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
float power)
|
float power)
|
||||||
{
|
{
|
||||||
Gfx::CModelFile* pModFile;
|
Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
|
||||||
int rank;
|
int rank;
|
||||||
|
|
||||||
// if ( m_engine->GetRestCreate() < 10 ) return false;
|
|
||||||
|
|
||||||
pModFile = new Gfx::CModelFile(m_iMan);
|
|
||||||
|
|
||||||
m_object->SetType(type);
|
m_object->SetType(type);
|
||||||
|
|
||||||
|
@ -94,8 +91,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
||||||
m_object->SetObjectRank(0, rank);
|
m_object->SetObjectRank(0, rank);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto1.mod"));
|
modelManager->AddModelReference("toto1.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(0, pos);
|
m_object->SetPosition(0, pos);
|
||||||
m_object->SetAngleY(0, angle);
|
m_object->SetAngleY(0, angle);
|
||||||
|
|
||||||
|
@ -104,8 +100,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(1, rank);
|
m_object->SetObjectRank(1, rank);
|
||||||
m_object->SetObjectParent(1, 0);
|
m_object->SetObjectParent(1, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto2.mod"));
|
modelManager->AddModelReference("toto2.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(1, Math::Vector(1.00f, 0.17f, 0.00f));
|
m_object->SetPosition(1, Math::Vector(1.00f, 0.17f, 0.00f));
|
||||||
|
|
||||||
// Creates the left eye.
|
// Creates the left eye.
|
||||||
|
@ -113,9 +108,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(2, rank);
|
m_object->SetObjectRank(2, rank);
|
||||||
m_object->SetObjectParent(2, 0);
|
m_object->SetObjectParent(2, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto3.mod"));
|
modelManager->AddModelReference("toto3.mod", true, rank);
|
||||||
pModFile->Mirror();
|
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(2, Math::Vector(0.85f, 1.04f, 0.25f));
|
m_object->SetPosition(2, Math::Vector(0.85f, 1.04f, 0.25f));
|
||||||
m_object->SetAngleY(2, -20.0f*Math::PI/180.0f);
|
m_object->SetAngleY(2, -20.0f*Math::PI/180.0f);
|
||||||
|
|
||||||
|
@ -124,8 +117,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(3, rank);
|
m_object->SetObjectRank(3, rank);
|
||||||
m_object->SetObjectParent(3, 0);
|
m_object->SetObjectParent(3, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto3.mod"));
|
modelManager->AddModelReference("toto3.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(3, Math::Vector(0.85f, 1.04f, -0.25f));
|
m_object->SetPosition(3, Math::Vector(0.85f, 1.04f, -0.25f));
|
||||||
m_object->SetAngleY(3, 20.0f*Math::PI/180.0f);
|
m_object->SetAngleY(3, 20.0f*Math::PI/180.0f);
|
||||||
|
|
||||||
|
@ -134,8 +126,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(4, rank);
|
m_object->SetObjectRank(4, rank);
|
||||||
m_object->SetObjectParent(4, 0);
|
m_object->SetObjectParent(4, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto4.mod"));
|
modelManager->AddModelReference("toto4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(4, Math::Vector(0.0f, 1.9f, 0.3f));
|
m_object->SetPosition(4, Math::Vector(0.0f, 1.9f, 0.3f));
|
||||||
m_object->SetAngleX(4, 30.0f*Math::PI/180.0f);
|
m_object->SetAngleX(4, 30.0f*Math::PI/180.0f);
|
||||||
|
|
||||||
|
@ -143,8 +134,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(5, rank);
|
m_object->SetObjectRank(5, rank);
|
||||||
m_object->SetObjectParent(5, 4);
|
m_object->SetObjectParent(5, 4);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto4.mod"));
|
modelManager->AddModelReference("toto4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(5, Math::Vector(0.0f, 0.67f, 0.0f));
|
m_object->SetPosition(5, Math::Vector(0.0f, 0.67f, 0.0f));
|
||||||
m_object->SetAngleX(5, 30.0f*Math::PI/180.0f);
|
m_object->SetAngleX(5, 30.0f*Math::PI/180.0f);
|
||||||
|
|
||||||
|
@ -152,8 +142,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(6, rank);
|
m_object->SetObjectRank(6, rank);
|
||||||
m_object->SetObjectParent(6, 5);
|
m_object->SetObjectParent(6, 5);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto5.mod"));
|
modelManager->AddModelReference("toto5.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(6, Math::Vector(0.0f, 0.70f, 0.0f));
|
m_object->SetPosition(6, Math::Vector(0.0f, 0.70f, 0.0f));
|
||||||
m_object->SetAngleX(6, 30.0f*Math::PI/180.0f);
|
m_object->SetAngleX(6, 30.0f*Math::PI/180.0f);
|
||||||
|
|
||||||
|
@ -162,8 +151,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(7, rank);
|
m_object->SetObjectRank(7, rank);
|
||||||
m_object->SetObjectParent(7, 0);
|
m_object->SetObjectParent(7, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto4.mod"));
|
modelManager->AddModelReference("toto4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(7, Math::Vector(0.0f, 1.9f, -0.3f));
|
m_object->SetPosition(7, Math::Vector(0.0f, 1.9f, -0.3f));
|
||||||
m_object->SetAngleX(7, -30.0f*Math::PI/180.0f);
|
m_object->SetAngleX(7, -30.0f*Math::PI/180.0f);
|
||||||
|
|
||||||
|
@ -171,8 +159,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(8, rank);
|
m_object->SetObjectRank(8, rank);
|
||||||
m_object->SetObjectParent(8, 7);
|
m_object->SetObjectParent(8, 7);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto4.mod"));
|
modelManager->AddModelReference("toto4.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(8, Math::Vector(0.0f, 0.67f, 0.0f));
|
m_object->SetPosition(8, Math::Vector(0.0f, 0.67f, 0.0f));
|
||||||
m_object->SetAngleX(8, -30.0f*Math::PI/180.0f);
|
m_object->SetAngleX(8, -30.0f*Math::PI/180.0f);
|
||||||
|
|
||||||
|
@ -180,8 +167,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(9, rank);
|
m_object->SetObjectRank(9, rank);
|
||||||
m_object->SetObjectParent(9, 8);
|
m_object->SetObjectParent(9, 8);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto5.mod"));
|
modelManager->AddModelReference("toto5.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(9, Math::Vector(0.0f, 0.70f, 0.0f));
|
m_object->SetPosition(9, Math::Vector(0.0f, 0.70f, 0.0f));
|
||||||
m_object->SetAngleX(9, -30.0f*Math::PI/180.0f);
|
m_object->SetAngleX(9, -30.0f*Math::PI/180.0f);
|
||||||
|
|
||||||
|
@ -193,7 +179,6 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
|
|
||||||
m_engine->LoadAllTextures();
|
m_engine->LoadAllTextures();
|
||||||
|
|
||||||
delete pModFile;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "graphics/engine/modelfile.h"
|
#include "graphics/engine/modelmanager.h"
|
||||||
#include "graphics/engine/particle.h"
|
#include "graphics/engine/particle.h"
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
|
|
||||||
|
@ -81,13 +81,10 @@ void CMotionWorm::DeleteObject(bool bAll)
|
||||||
bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
|
bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
float power)
|
float power)
|
||||||
{
|
{
|
||||||
Gfx::CModelFile* pModFile;
|
|
||||||
int rank, i;
|
int rank, i;
|
||||||
float px;
|
float px;
|
||||||
|
|
||||||
// if ( m_engine->GetRestCreate() < 2+WORM_PART+1 ) return false;
|
Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
|
||||||
|
|
||||||
pModFile = new Gfx::CModelFile(m_iMan);
|
|
||||||
|
|
||||||
m_object->SetType(type);
|
m_object->SetType(type);
|
||||||
|
|
||||||
|
@ -95,8 +92,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
rank = m_engine->CreateObject();
|
rank = m_engine->CreateObject();
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
|
||||||
m_object->SetObjectRank(0, rank);
|
m_object->SetObjectRank(0, rank);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm0.mod")); // there is no purpose!
|
modelManager->AddModelReference("worm0.mod", false, rank); // there is no purpose!
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(0, pos);
|
m_object->SetPosition(0, pos);
|
||||||
m_object->SetAngleY(0, angle);
|
m_object->SetAngleY(0, angle);
|
||||||
|
|
||||||
|
@ -111,8 +107,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(1, rank);
|
m_object->SetObjectRank(1, rank);
|
||||||
m_object->SetObjectParent(1, 0);
|
m_object->SetObjectParent(1, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm1.mod"));
|
modelManager->AddModelReference("worm1.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(1, Math::Vector(px, 0.0f, 0.0f));
|
m_object->SetPosition(1, Math::Vector(px, 0.0f, 0.0f));
|
||||||
px -= 1.0f;
|
px -= 1.0f;
|
||||||
|
|
||||||
|
@ -123,8 +118,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(2+i, rank);
|
m_object->SetObjectRank(2+i, rank);
|
||||||
m_object->SetObjectParent(2+i, 0);
|
m_object->SetObjectParent(2+i, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm2.mod"));
|
modelManager->AddModelReference("worm2.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(2+i, Math::Vector(px, 0.0f, 0.0f));
|
m_object->SetPosition(2+i, Math::Vector(px, 0.0f, 0.0f));
|
||||||
px -= 1.0f;
|
px -= 1.0f;
|
||||||
}
|
}
|
||||||
|
@ -134,8 +128,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
|
||||||
m_object->SetObjectRank(2+WORM_PART, rank);
|
m_object->SetObjectRank(2+WORM_PART, rank);
|
||||||
m_object->SetObjectParent(2+WORM_PART, 0);
|
m_object->SetObjectParent(2+WORM_PART, 0);
|
||||||
pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm3.mod"));
|
modelManager->AddModelReference("worm3.mod", false, rank);
|
||||||
pModFile->CreateEngineObject(rank);
|
|
||||||
m_object->SetPosition(2+WORM_PART, Math::Vector(px, 0.0f, 0.0f));
|
m_object->SetPosition(2+WORM_PART, Math::Vector(px, 0.0f, 0.0f));
|
||||||
|
|
||||||
m_object->CreateShadowCircle(0.0f, 1.0f, Gfx::ENG_SHADOW_WORM);
|
m_object->CreateShadowCircle(0.0f, 1.0f, Gfx::ENG_SHADOW_WORM);
|
||||||
|
@ -148,7 +141,6 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
|
||||||
|
|
||||||
m_engine->LoadAllTextures();
|
m_engine->LoadAllTextures();
|
||||||
|
|
||||||
delete pModFile;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1010,7 +1010,7 @@ void CRobotMain::ChangePhase(Phase phase)
|
||||||
ChangePause(false);
|
ChangePause(false);
|
||||||
FlushDisplayInfo();
|
FlushDisplayInfo();
|
||||||
m_engine->SetRankView(0);
|
m_engine->SetRankView(0);
|
||||||
m_engine->FlushObject();
|
m_engine->DeleteAllObjects();
|
||||||
m_engine->SetWaterAddColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f));
|
m_engine->SetWaterAddColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f));
|
||||||
m_engine->SetBackground("");
|
m_engine->SetBackground("");
|
||||||
m_engine->SetBackForce(false);
|
m_engine->SetBackForce(false);
|
||||||
|
@ -3673,7 +3673,7 @@ void CRobotMain::Convert()
|
||||||
void CRobotMain::ScenePerso()
|
void CRobotMain::ScenePerso()
|
||||||
{
|
{
|
||||||
DeleteAllObjects(); // removes all the current 3D Scene
|
DeleteAllObjects(); // removes all the current 3D Scene
|
||||||
m_engine->FlushObject();
|
m_engine->DeleteAllObjects();
|
||||||
m_terrain->FlushRelief(); // all flat
|
m_terrain->FlushRelief(); // all flat
|
||||||
m_terrain->FlushBuildingLevel();
|
m_terrain->FlushBuildingLevel();
|
||||||
m_terrain->FlushFlyingLimit();
|
m_terrain->FlushFlyingLimit();
|
||||||
|
|
|
@ -2669,9 +2669,9 @@ CScript::CScript(CInstanceManager* iMan, CObject* object, CTaskManager** seconda
|
||||||
m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
|
m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
|
||||||
m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
|
m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
|
||||||
m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
|
m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
|
||||||
m_botProg = 0;
|
m_botProg = nullptr;
|
||||||
m_object = object;
|
m_object = object;
|
||||||
m_primaryTask = 0;
|
m_primaryTask = nullptr;
|
||||||
m_secondaryTask = secondaryTask;
|
m_secondaryTask = secondaryTask;
|
||||||
|
|
||||||
m_interface = static_cast<Ui::CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
|
m_interface = static_cast<Ui::CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
|
||||||
|
@ -2680,7 +2680,7 @@ CScript::CScript(CInstanceManager* iMan, CObject* object, CTaskManager** seconda
|
||||||
m_ipf = CBOT_IPF;
|
m_ipf = CBOT_IPF;
|
||||||
m_errMode = ERM_STOP;
|
m_errMode = ERM_STOP;
|
||||||
m_len = 0;
|
m_len = 0;
|
||||||
m_script = 0;
|
m_script = nullptr;
|
||||||
m_bRun = false;
|
m_bRun = false;
|
||||||
m_bStepMode = false;
|
m_bStepMode = false;
|
||||||
m_bCompile = false;
|
m_bCompile = false;
|
||||||
|
@ -2752,10 +2752,22 @@ void CScript::InitFonctions()
|
||||||
|
|
||||||
CScript::~CScript()
|
CScript::~CScript()
|
||||||
{
|
{
|
||||||
delete m_botProg;
|
if (m_botProg != nullptr)
|
||||||
delete m_primaryTask;
|
{
|
||||||
delete m_script;
|
delete m_botProg;
|
||||||
m_script = 0;
|
m_botProg = nullptr;
|
||||||
|
}
|
||||||
|
if (m_primaryTask != nullptr)
|
||||||
|
{
|
||||||
|
delete m_primaryTask;
|
||||||
|
m_primaryTask = nullptr;
|
||||||
|
}
|
||||||
|
if (m_script != nullptr)
|
||||||
|
{
|
||||||
|
delete m_script;
|
||||||
|
m_script = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
m_len = 0;
|
m_len = 0;
|
||||||
|
|
||||||
m_iMan->DeleteInstance(CLASS_SCRIPT, this);
|
m_iMan->DeleteInstance(CLASS_SCRIPT, this);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
set(CONVERT_MODEL_SOURCES
|
set(CONVERT_MODEL_SOURCES
|
||||||
../common/iman.cpp
|
|
||||||
../common/logger.cpp
|
../common/logger.cpp
|
||||||
../common/stringutils.cpp
|
../common/stringutils.cpp
|
||||||
../graphics/engine/modelfile.cpp
|
../graphics/engine/modelfile.cpp
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include "common/iman.h"
|
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
#include "graphics/engine/modelfile.h"
|
#include "graphics/engine/modelfile.h"
|
||||||
|
|
||||||
|
@ -8,11 +7,10 @@
|
||||||
|
|
||||||
bool EndsWith(std::string const &fullString, std::string const &ending)
|
bool EndsWith(std::string const &fullString, std::string const &ending)
|
||||||
{
|
{
|
||||||
if (fullString.length() >= ending.length()) {
|
if (fullString.length() >= ending.length())
|
||||||
return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending));
|
return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending));
|
||||||
} else {
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +18,6 @@ struct Args
|
||||||
{
|
{
|
||||||
bool usage;
|
bool usage;
|
||||||
bool dumpInfo;
|
bool dumpInfo;
|
||||||
bool mirror;
|
|
||||||
std::string inputFile;
|
std::string inputFile;
|
||||||
std::string outputFile;
|
std::string outputFile;
|
||||||
std::string inputFormat;
|
std::string inputFormat;
|
||||||
|
@ -30,7 +27,6 @@ struct Args
|
||||||
{
|
{
|
||||||
usage = false;
|
usage = false;
|
||||||
dumpInfo = false;
|
dumpInfo = false;
|
||||||
mirror = false;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,8 +39,7 @@ void PrintUsage(const std::string& program)
|
||||||
std::cerr << "Usage:" << std::endl;
|
std::cerr << "Usage:" << std::endl;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::cerr << " Convert files:" << std::endl;
|
std::cerr << " Convert files:" << std::endl;
|
||||||
std::cerr << " " << program << " -i input_file -if input_format -o output_file -of output_format [-m]" << std::endl;
|
std::cerr << " " << program << " -i input_file -if input_format -o output_file -of output_format" << std::endl;
|
||||||
std::cerr << " -m => mirror" << std::endl;
|
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::cerr << " Dump info:" << std::endl;
|
std::cerr << " Dump info:" << std::endl;
|
||||||
std::cerr << " " << program << " -d -i input_file -if input_format" << std::endl;
|
std::cerr << " " << program << " -d -i input_file -if input_format" << std::endl;
|
||||||
|
@ -117,10 +112,6 @@ bool ParseArgs(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
ARGS.dumpInfo = true;
|
ARGS.dumpInfo = true;
|
||||||
}
|
}
|
||||||
else if (arg == "-m")
|
|
||||||
{
|
|
||||||
ARGS.mirror = true;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -165,8 +156,7 @@ int main(int argc, char *argv[])
|
||||||
if (ARGS.usage)
|
if (ARGS.usage)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CInstanceManager iMan;
|
Gfx::CModelFile model;
|
||||||
Gfx::CModelFile model(&iMan);
|
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
|
||||||
|
@ -255,9 +245,6 @@ int main(int argc, char *argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ARGS.mirror)
|
|
||||||
model.Mirror();
|
|
||||||
|
|
||||||
if (ARGS.outputFormat == "old")
|
if (ARGS.outputFormat == "old")
|
||||||
{
|
{
|
||||||
ok = model.WriteModel(ARGS.outputFile);
|
ok = model.WriteModel(ARGS.outputFile);
|
||||||
|
|
Loading…
Reference in New Issue