CStaticObject subclass using new model framework
* added reading/writing working version of new model format V3 * added CStaticObject with minial interface intended for non-interactive static objects like trees * converted first model, tree0, to new formatmaster
parent
639de56e6c
commit
e8582d214c
2
data
2
data
|
@ -1 +1 @@
|
|||
Subproject commit 57478f17b86736c8a8b6e132eed529b853241462
|
||||
Subproject commit 408e599635b117fdb92e63f75b249d9f2c8d5161
|
|
@ -167,6 +167,7 @@ set(BASE_SOURCES
|
|||
object/object_factory.cpp
|
||||
object/object_manager.cpp
|
||||
object/old_object.cpp
|
||||
object/old_object_interface.cpp
|
||||
object/robotmain.cpp
|
||||
object/scene_conditions.cpp
|
||||
object/task/task.cpp
|
||||
|
@ -193,6 +194,7 @@ set(BASE_SOURCES
|
|||
object/task/taskwait.cpp
|
||||
object/tool_type.cpp
|
||||
object/subclass/exchange_post.cpp
|
||||
object/subclass/static_object.cpp
|
||||
physics/physics.cpp
|
||||
script/cbottoken.cpp
|
||||
script/script.cpp
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "common/event.h"
|
||||
#include "common/global.h"
|
||||
#include "common/singleton.h"
|
||||
#include "common/profile.h"
|
||||
|
|
|
@ -40,6 +40,9 @@
|
|||
#include "graphics/engine/text.h"
|
||||
#include "graphics/engine/water.h"
|
||||
|
||||
#include "graphics/model/model_mesh.h"
|
||||
#include "graphics/model/model_shadow_spot.h"
|
||||
|
||||
#include "math/geometry.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
@ -706,45 +709,33 @@ void CEngine::CopyBaseObject(int sourceBaseObjRank, int destBaseObjRank)
|
|||
}
|
||||
|
||||
void CEngine::AddBaseObjTriangles(int baseObjRank, const std::vector<VertexTex2>& vertices,
|
||||
EngineTriangleType triangleType,
|
||||
const Material& material, int state,
|
||||
std::string tex1Name, std::string tex2Name,
|
||||
bool globalUpdate)
|
||||
std::string tex1Name, std::string tex2Name)
|
||||
{
|
||||
assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
|
||||
|
||||
EngineBaseObject& p1 = m_baseObjects[baseObjRank];
|
||||
EngineBaseObjTexTier& p2 = AddLevel2(p1, tex1Name, tex2Name);
|
||||
EngineBaseObjDataTier& p3 = AddLevel3(p2, triangleType, material, state);
|
||||
EngineBaseObjDataTier& p3 = AddLevel3(p2, ENG_TRIANGLE_TYPE_TRIANGLES, material, state);
|
||||
|
||||
p3.vertices.insert(p3.vertices.end(), vertices.begin(), vertices.end());
|
||||
|
||||
p3.updateStaticBuffer = true;
|
||||
m_updateStaticBuffers = true;
|
||||
|
||||
if (globalUpdate)
|
||||
for (int i = 0; i < static_cast<int>( vertices.size() ); i++)
|
||||
{
|
||||
m_updateGeometry = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < static_cast<int>( vertices.size() ); i++)
|
||||
{
|
||||
p1.bboxMin.x = Math::Min(vertices[i].coord.x, p1.bboxMin.x);
|
||||
p1.bboxMin.y = Math::Min(vertices[i].coord.y, p1.bboxMin.y);
|
||||
p1.bboxMin.z = Math::Min(vertices[i].coord.z, p1.bboxMin.z);
|
||||
p1.bboxMax.x = Math::Max(vertices[i].coord.x, p1.bboxMax.x);
|
||||
p1.bboxMax.y = Math::Max(vertices[i].coord.y, p1.bboxMax.y);
|
||||
p1.bboxMax.z = Math::Max(vertices[i].coord.z, p1.bboxMax.z);
|
||||
}
|
||||
|
||||
p1.radius = Math::Max(p1.bboxMin.Length(), p1.bboxMax.Length());
|
||||
p1.bboxMin.x = Math::Min(vertices[i].coord.x, p1.bboxMin.x);
|
||||
p1.bboxMin.y = Math::Min(vertices[i].coord.y, p1.bboxMin.y);
|
||||
p1.bboxMin.z = Math::Min(vertices[i].coord.z, p1.bboxMin.z);
|
||||
p1.bboxMax.x = Math::Max(vertices[i].coord.x, p1.bboxMax.x);
|
||||
p1.bboxMax.y = Math::Max(vertices[i].coord.y, p1.bboxMax.y);
|
||||
p1.bboxMax.z = Math::Max(vertices[i].coord.z, p1.bboxMax.z);
|
||||
}
|
||||
|
||||
if (triangleType == ENG_TRIANGLE_TYPE_TRIANGLES)
|
||||
p1.totalTriangles += vertices.size() / 3;
|
||||
else
|
||||
p1.totalTriangles += vertices.size() - 2;
|
||||
p1.radius = Math::Max(p1.bboxMin.Length(), p1.bboxMax.Length());
|
||||
|
||||
p1.totalTriangles += vertices.size() / 3;
|
||||
}
|
||||
|
||||
void CEngine::AddBaseObjQuick(int baseObjRank, const EngineBaseObjDataTier& buffer,
|
||||
|
@ -1386,19 +1377,6 @@ void CEngine::SetObjectShadowPos(int objRank, const Math::Vector& pos)
|
|||
m_shadows[shadowRank].pos = pos;
|
||||
}
|
||||
|
||||
void CEngine::SetObjectShadowNormal(int objRank, const Math::Vector& normal)
|
||||
{
|
||||
assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
|
||||
|
||||
int shadowRank = m_objects[objRank].shadowRank;
|
||||
if (shadowRank == -1)
|
||||
return;
|
||||
|
||||
assert(shadowRank >= 0 && shadowRank < static_cast<int>( m_shadows.size() ));
|
||||
|
||||
m_shadows[shadowRank].normal = normal;
|
||||
}
|
||||
|
||||
void CEngine::SetObjectShadowAngle(int objRank, float angle)
|
||||
{
|
||||
assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
|
||||
|
@ -1451,19 +1429,6 @@ void CEngine::SetObjectShadowHeight(int objRank, float height)
|
|||
m_shadows[shadowRank].height = height;
|
||||
}
|
||||
|
||||
float CEngine::GetObjectShadowRadius(int objRank)
|
||||
{
|
||||
assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
|
||||
|
||||
int shadowRank = m_objects[objRank].shadowRank;
|
||||
if (shadowRank == -1)
|
||||
return 0.0f;
|
||||
|
||||
assert(shadowRank >= 0 && shadowRank < static_cast<int>( m_shadows.size() ));
|
||||
|
||||
return m_shadows[shadowRank].radius;
|
||||
}
|
||||
|
||||
bool CEngine::GetHighlight(Math::Point &p1, Math::Point &p2)
|
||||
{
|
||||
p1 = m_highlightP1;
|
||||
|
@ -3233,7 +3198,7 @@ void CEngine::Draw3DScene()
|
|||
UseShadowMapping(false);
|
||||
|
||||
// Draws the shadows , if shadows enabled
|
||||
if (m_shadowVisible)
|
||||
if (m_shadowVisible)
|
||||
DrawShadow();
|
||||
|
||||
|
||||
|
@ -4943,6 +4908,229 @@ void CEngine::DrawTimer()
|
|||
m_text->DrawText(m_timerText, FONT_COLOBOT, 15.0f, pos, 1.0f, TEXT_ALIGN_RIGHT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
}
|
||||
|
||||
void CEngine::AddBaseObjTriangles(int baseObjRank, const std::vector<Gfx::ModelTriangle>& triangles)
|
||||
{
|
||||
std::vector<VertexTex2> vs(3, VertexTex2());
|
||||
|
||||
for (const auto& triangle : triangles)
|
||||
{
|
||||
vs[0] = triangle.p1;
|
||||
vs[1] = triangle.p2;
|
||||
vs[2] = triangle.p3;
|
||||
|
||||
Material material;
|
||||
material.ambient = triangle.ambient;
|
||||
material.diffuse = triangle.diffuse;
|
||||
material.specular = triangle.specular;
|
||||
|
||||
int state = GetEngineState(triangle);
|
||||
|
||||
std::string tex1Name;
|
||||
if (!triangle.tex1Name.empty())
|
||||
tex1Name = "objects/" + triangle.tex1Name;
|
||||
|
||||
std::string tex2Name;
|
||||
if (triangle.variableTex2)
|
||||
tex2Name = GetSecondTexture();
|
||||
else
|
||||
tex2Name = triangle.tex2Name;
|
||||
|
||||
AddBaseObjTriangles(baseObjRank, vs, material, state, tex1Name, tex2Name);
|
||||
}
|
||||
}
|
||||
|
||||
int CEngine::GetEngineState(const ModelTriangle& triangle)
|
||||
{
|
||||
int state = 0;
|
||||
|
||||
if (!triangle.tex2Name.empty() || triangle.variableTex2)
|
||||
state |= ENG_RSTATE_DUAL_BLACK;
|
||||
|
||||
switch (triangle.transparentMode)
|
||||
{
|
||||
case ModelTransparentMode::None:
|
||||
break;
|
||||
|
||||
case ModelTransparentMode::AlphaChannel:
|
||||
state |= ENG_RSTATE_ALPHA;
|
||||
break;
|
||||
|
||||
case ModelTransparentMode::MapBlackToAlpha:
|
||||
state |= ENG_RSTATE_TTEXTURE_BLACK;
|
||||
break;
|
||||
|
||||
case ModelTransparentMode::MapWhiteToAlpha:
|
||||
state |= ENG_RSTATE_TTEXTURE_WHITE;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (triangle.specialMark)
|
||||
{
|
||||
case ModelSpecialMark::None:
|
||||
break;
|
||||
|
||||
case ModelSpecialMark::Part1:
|
||||
state |= ENG_RSTATE_PART1;
|
||||
break;
|
||||
|
||||
case ModelSpecialMark::Part2:
|
||||
state |= ENG_RSTATE_PART2;
|
||||
break;
|
||||
|
||||
case ModelSpecialMark::Part3:
|
||||
state |= ENG_RSTATE_PART3;
|
||||
break;
|
||||
}
|
||||
|
||||
if (triangle.doubleSided)
|
||||
state |= ENG_RSTATE_2FACE;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
void CEngine::UpdateObjectShadowNormal(int rank)
|
||||
{
|
||||
assert(rank >= 0 && rank < static_cast<int>( m_objects.size() ));
|
||||
|
||||
int shadowRank = m_objects[rank].shadowRank;
|
||||
if (shadowRank == -1)
|
||||
return;
|
||||
|
||||
assert(shadowRank >= 0 && shadowRank < static_cast<int>( m_shadows.size() ));
|
||||
|
||||
// Calculating the normal to the ground in nine strategic locations,
|
||||
// then perform a weighted average (the dots in the center are more important).
|
||||
|
||||
Math::Vector pos = m_shadows[shadowRank].pos;
|
||||
float radius = m_shadows[shadowRank].radius;
|
||||
|
||||
Math::Vector n[20];
|
||||
Math::Vector norm;
|
||||
int i = 0;
|
||||
|
||||
m_terrain->GetNormal(norm, pos);
|
||||
n[i++] = norm;
|
||||
n[i++] = norm;
|
||||
n[i++] = norm;
|
||||
|
||||
Math::Vector shPos = pos;
|
||||
shPos.x += radius*0.6f;
|
||||
shPos.z += radius*0.6f;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x -= radius*0.6f;
|
||||
shPos.z += radius*0.6f;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x += radius*0.6f;
|
||||
shPos.z -= radius*0.6f;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x -= radius*0.6f;
|
||||
shPos.z -= radius*0.6f;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x += radius;
|
||||
shPos.z += radius;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x -= radius;
|
||||
shPos.z += radius;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x += radius;
|
||||
shPos.z -= radius;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x -= radius;
|
||||
shPos.z -= radius;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
|
||||
norm.LoadZero();
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
norm += n[j];
|
||||
}
|
||||
norm /= static_cast<float>(i); // average vector
|
||||
|
||||
m_shadows[shadowRank].normal = norm;
|
||||
}
|
||||
|
||||
int CEngine::AddStaticMesh(const std::string& key, const CModelMesh* mesh, const Math::Matrix& worldMatrix)
|
||||
{
|
||||
int baseObjRank = -1;
|
||||
|
||||
auto it = m_staticMeshBaseObjects.find(key);
|
||||
if (it == m_staticMeshBaseObjects.end())
|
||||
{
|
||||
baseObjRank = CreateBaseObject();
|
||||
AddBaseObjTriangles(baseObjRank, mesh->GetTriangles());
|
||||
m_staticMeshBaseObjects[key] = baseObjRank;
|
||||
}
|
||||
else
|
||||
{
|
||||
baseObjRank = it->second;
|
||||
}
|
||||
|
||||
int objRank = CreateObject();
|
||||
SetObjectBaseRank(objRank, baseObjRank);
|
||||
SetObjectTransform(objRank, worldMatrix);
|
||||
SetObjectType(objRank, ENG_OBJTYPE_FIX);
|
||||
|
||||
return objRank;
|
||||
}
|
||||
|
||||
void CEngine::AddStaticMeshShadowSpot(int meshHandle, const ModelShadowSpot& shadowSpot)
|
||||
{
|
||||
int objRank = meshHandle;
|
||||
|
||||
CreateShadow(objRank);
|
||||
SetObjectShadowRadius(objRank, shadowSpot.radius);
|
||||
SetObjectShadowIntensity(objRank, shadowSpot.intensity);
|
||||
SetObjectShadowType(objRank, ENG_SHADOW_NORM);
|
||||
SetObjectShadowHeight(objRank, 0.0f);
|
||||
SetObjectShadowAngle(objRank, 0.0f);
|
||||
UpdateObjectShadowNormal(objRank);
|
||||
}
|
||||
|
||||
void CEngine::DeleteStaticMesh(int meshHandle)
|
||||
{
|
||||
int objRank = meshHandle;
|
||||
|
||||
DeleteShadow(objRank);
|
||||
DeleteObject(objRank);
|
||||
}
|
||||
|
||||
const Math::Matrix& CEngine::GetStaticMeshWorldMatrix(int meshHandle)
|
||||
{
|
||||
int objRank = meshHandle;
|
||||
return m_objects[objRank].transform;
|
||||
}
|
||||
|
||||
void CEngine::SetStaticMeshTransparency(int meshHandle, float value)
|
||||
{
|
||||
int objRank = meshHandle;
|
||||
SetObjectTransparency(objRank, value);
|
||||
}
|
||||
|
||||
} // namespace Gfx
|
||||
|
||||
|
|
|
@ -24,10 +24,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "app/system.h"
|
||||
|
||||
#include "common/event.h"
|
||||
#include "common/singleton.h"
|
||||
|
||||
#include "graphics/core/color.h"
|
||||
|
@ -46,6 +44,7 @@
|
|||
#include <map>
|
||||
#include <set>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
|
||||
class CApplication;
|
||||
|
@ -53,6 +52,7 @@ class CObject;
|
|||
class CSoundInterface;
|
||||
class CImage;
|
||||
class CPauseManager;
|
||||
struct Event;
|
||||
|
||||
|
||||
// Graphics module namespace
|
||||
|
@ -70,6 +70,9 @@ class CLightning;
|
|||
class CPlanet;
|
||||
class CTerrain;
|
||||
class CPyroManager;
|
||||
class CModelMesh;
|
||||
struct ModelShadowSpot;
|
||||
struct ModelTriangle;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -765,14 +768,39 @@ public:
|
|||
void AddStatisticTriangle(int nb);
|
||||
//! Returns the number of triangles in current frame
|
||||
int GetStatisticTriangle();
|
||||
|
||||
|
||||
//! Sets the coordinates to display in stats window
|
||||
void SetStatisticPos(Math::Vector pos);
|
||||
|
||||
|
||||
//! Sets text to display as mission timer
|
||||
void SetTimerDisplay(const std::string& text);
|
||||
|
||||
|
||||
/* *************** New mesh interface *************** */
|
||||
//! Add new instance of static mesh
|
||||
/**
|
||||
* Static meshes never change their geometry or texture mapping,
|
||||
* so specific instances can share mesh data.
|
||||
*
|
||||
* @param mesh mesh data
|
||||
* @param key key unique per object class
|
||||
* @return mesh instance handle
|
||||
*/
|
||||
int AddStaticMesh(const std::string& key, const Gfx::CModelMesh* mesh, const Math::Matrix& worldMatrix);
|
||||
|
||||
//! Removes given static mesh
|
||||
void DeleteStaticMesh(int meshHandle);
|
||||
|
||||
//! Adds a shadow spot to mesh
|
||||
void AddStaticMeshShadowSpot(int meshHandle, const Gfx::ModelShadowSpot& shadowSpot);
|
||||
|
||||
//! Returns static mesh world matrix
|
||||
const Math::Matrix& GetStaticMeshWorldMatrix(int meshHandle);
|
||||
|
||||
//! Sets transparency for static mesh
|
||||
void SetStaticMeshTransparency(int meshHandle, float value);
|
||||
|
||||
|
||||
/* *************** Object management *************** */
|
||||
|
||||
// Base objects
|
||||
|
@ -788,11 +816,7 @@ public:
|
|||
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,
|
||||
bool globalUpdate);
|
||||
void AddBaseObjTriangles(int baseObjRank, const std::vector<Gfx::ModelTriangle>& triangles);
|
||||
|
||||
//! Adds a tier 4 engine object directly
|
||||
void AddBaseObjQuick(int baseObjRank, const EngineBaseObjDataTier& buffer,
|
||||
|
@ -880,12 +904,11 @@ public:
|
|||
void SetObjectShadowHide(int objRank, bool hide);
|
||||
void SetObjectShadowType(int objRank, EngineShadowType type);
|
||||
void SetObjectShadowPos(int objRank, const Math::Vector& pos);
|
||||
void SetObjectShadowNormal(int objRank, const Math::Vector& normal);
|
||||
void SetObjectShadowAngle(int objRank, float angle);
|
||||
void SetObjectShadowRadius(int objRank, float radius);
|
||||
void SetObjectShadowIntensity(int objRank, float intensity);
|
||||
void SetObjectShadowHeight(int objRank, float height);
|
||||
float GetObjectShadowRadius(int objRank);
|
||||
void UpdateObjectShadowNormal(int objRank);
|
||||
//@}
|
||||
|
||||
//! Lists the ranks of objects and subobjects selected
|
||||
|
@ -1314,6 +1337,12 @@ protected:
|
|||
//! Updates static buffers of changed objects
|
||||
void UpdateStaticBuffers();
|
||||
|
||||
void AddBaseObjTriangles(int baseObjRank, const std::vector<VertexTex2>& vertices,
|
||||
const Material& material, int state,
|
||||
std::string tex1Name, std::string tex2Name);
|
||||
|
||||
int GetEngineState(const ModelTriangle& triangle);
|
||||
|
||||
protected:
|
||||
CApplication* m_app;
|
||||
CSoundInterface* m_sound;
|
||||
|
@ -1509,6 +1538,8 @@ protected:
|
|||
bool m_debugDumpLights;
|
||||
|
||||
std::string m_timerText;
|
||||
|
||||
std::unordered_map<std::string, int> m_staticMeshBaseObjects;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -75,34 +75,7 @@ bool COldModelManager::LoadModel(const std::string& fileName, bool mirrored)
|
|||
FileInfo fileInfo(fileName, mirrored);
|
||||
m_models[fileInfo] = modelInfo;
|
||||
|
||||
std::vector<VertexTex2> vs(3, VertexTex2());
|
||||
|
||||
for (const auto& triangle : modelInfo.triangles)
|
||||
{
|
||||
vs[0] = triangle.p1;
|
||||
vs[1] = triangle.p2;
|
||||
vs[2] = triangle.p3;
|
||||
|
||||
Material material;
|
||||
material.ambient = triangle.ambient;
|
||||
material.diffuse = triangle.diffuse;
|
||||
material.specular = triangle.specular;
|
||||
|
||||
int state = GetEngineState(triangle);
|
||||
|
||||
std::string tex1Name;
|
||||
if (!triangle.tex1Name.empty())
|
||||
tex1Name = "objects/" + triangle.tex1Name;
|
||||
|
||||
std::string tex2Name;
|
||||
if (triangle.variableTex2)
|
||||
tex2Name = m_engine->GetSecondTexture();
|
||||
else
|
||||
tex2Name = triangle.tex2Name;
|
||||
|
||||
m_engine->AddBaseObjTriangles(modelInfo.baseObjRank, vs, ENG_TRIANGLE_TYPE_TRIANGLES,
|
||||
material, state, tex1Name, tex2Name, false);
|
||||
}
|
||||
m_engine->AddBaseObjTriangles(modelInfo.baseObjRank, modelInfo.triangles);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -204,54 +177,5 @@ void COldModelManager::Mirror(std::vector<ModelTriangle>& triangles)
|
|||
}
|
||||
}
|
||||
|
||||
int COldModelManager::GetEngineState(const ModelTriangle& triangle)
|
||||
{
|
||||
int state = 0;
|
||||
|
||||
if (!triangle.tex2Name.empty() || triangle.variableTex2)
|
||||
state |= ENG_RSTATE_DUAL_BLACK;
|
||||
|
||||
switch (triangle.transparentMode)
|
||||
{
|
||||
case ModelTransparentMode::None:
|
||||
break;
|
||||
|
||||
case ModelTransparentMode::AlphaChannel:
|
||||
state |= ENG_RSTATE_ALPHA;
|
||||
break;
|
||||
|
||||
case ModelTransparentMode::MapBlackToAlpha:
|
||||
state |= ENG_RSTATE_TTEXTURE_BLACK;
|
||||
break;
|
||||
|
||||
case ModelTransparentMode::MapWhiteToAlpha:
|
||||
state |= ENG_RSTATE_TTEXTURE_WHITE;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (triangle.specialMark)
|
||||
{
|
||||
case ModelSpecialMark::None:
|
||||
break;
|
||||
|
||||
case ModelSpecialMark::Part1:
|
||||
state |= ENG_RSTATE_PART1;
|
||||
break;
|
||||
|
||||
case ModelSpecialMark::Part2:
|
||||
state |= ENG_RSTATE_PART2;
|
||||
break;
|
||||
|
||||
case ModelSpecialMark::Part3:
|
||||
state |= ENG_RSTATE_PART3;
|
||||
break;
|
||||
}
|
||||
|
||||
if (triangle.doubleSided)
|
||||
state |= ENG_RSTATE_2FACE;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -84,9 +84,6 @@ protected:
|
|||
//! Mirrors the model along the Z axis
|
||||
void Mirror(std::vector<ModelTriangle>& triangles);
|
||||
|
||||
//! Converts from model to engine rendering state
|
||||
int GetEngineState(const ModelTriangle& triangle);
|
||||
|
||||
private:
|
||||
struct ModelInfo
|
||||
{
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#include "graphics/model/model.h"
|
||||
|
||||
#include "common/logger.h"
|
||||
|
@ -37,9 +56,19 @@ void CModel::AddMesh(const std::string& name, CModelMesh&& mesh)
|
|||
m_meshes[name] = mesh;
|
||||
}
|
||||
|
||||
const boost::optional<ModelShadowSpot>& CModel::GetShadowSpot() const
|
||||
std::vector<std::string> CModel::GetMeshNames() const
|
||||
{
|
||||
return m_shadowSpot;
|
||||
std::vector<std::string> meshNames;
|
||||
|
||||
for (const auto& v : m_meshes)
|
||||
meshNames.push_back(v.first);
|
||||
|
||||
return meshNames;
|
||||
}
|
||||
|
||||
const ModelShadowSpot& CModel::GetShadowSpot() const
|
||||
{
|
||||
return *m_shadowSpot;
|
||||
}
|
||||
|
||||
void CModel::SetShadowSpot(const ModelShadowSpot& shadowSpot)
|
||||
|
@ -47,6 +76,11 @@ void CModel::SetShadowSpot(const ModelShadowSpot& shadowSpot)
|
|||
m_shadowSpot = shadowSpot;
|
||||
}
|
||||
|
||||
bool CModel::HasShadowSpot() const
|
||||
{
|
||||
return m_shadowSpot.is_initialized();
|
||||
}
|
||||
|
||||
const std::vector<ModelCrashSphere>& CModel::GetCrashSpheres() const
|
||||
{
|
||||
return m_crashSpheres;
|
||||
|
@ -57,4 +91,24 @@ void CModel::AddCrashSphere(const ModelCrashSphere& crashSphere)
|
|||
m_crashSpheres.push_back(crashSphere);
|
||||
}
|
||||
|
||||
int CModel::GetCrashSphereCount() const
|
||||
{
|
||||
return m_crashSpheres.size();
|
||||
}
|
||||
|
||||
const Math::Sphere& CModel::GetCameraCollisionSphere() const
|
||||
{
|
||||
return *m_cameraCollisionSphere;
|
||||
}
|
||||
|
||||
void CModel::SetCameraCollisionSphere(const Math::Sphere& sphere)
|
||||
{
|
||||
m_cameraCollisionSphere = sphere;
|
||||
}
|
||||
|
||||
bool CModel::HasCameraCollisionSphere() const
|
||||
{
|
||||
return m_cameraCollisionSphere.is_initialized();
|
||||
}
|
||||
|
||||
} // namespace Gfx
|
||||
|
|
|
@ -1,9 +1,30 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "graphics/model/model_crash_sphere.h"
|
||||
#include "graphics/model/model_mesh.h"
|
||||
#include "graphics/model/model_shadow_spot.h"
|
||||
|
||||
#include "math/sphere.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -26,21 +47,35 @@ public:
|
|||
const CModelMesh* GetMesh(const std::string& name) const;
|
||||
//! Add new \a mesh with given \a name
|
||||
void AddMesh(const std::string& name, CModelMesh&& mesh);
|
||||
|
||||
//! Returns the optional shadow spot associated with model
|
||||
const boost::optional<ModelShadowSpot>& GetShadowSpot() const;
|
||||
//! Sets the shadow spot associated with model
|
||||
void SetShadowSpot(const ModelShadowSpot& shadowSpot);
|
||||
//! Returns list of mesh names
|
||||
std::vector<std::string> GetMeshNames() const;
|
||||
|
||||
//! Returns the model's crash spheres
|
||||
const std::vector<ModelCrashSphere>& GetCrashSpheres() const;
|
||||
//! Adds a new crash sphere
|
||||
void AddCrashSphere(const ModelCrashSphere& crashSphere);
|
||||
//! Returns number of crash spheres
|
||||
int GetCrashSphereCount() const;
|
||||
|
||||
//! Returns the shadow spot associated with model (assumes it is present)
|
||||
const ModelShadowSpot& GetShadowSpot() const;
|
||||
//! Sets the shadow spot associated with model
|
||||
void SetShadowSpot(const ModelShadowSpot& shadowSpot);
|
||||
//! Returns whether there is shadow spot
|
||||
bool HasShadowSpot() const;
|
||||
|
||||
//! Returns the optional shadow spot associated with model (assumes it is present)
|
||||
const Math::Sphere& GetCameraCollisionSphere() const;
|
||||
//! Sets the shadow spot associated with model
|
||||
void SetCameraCollisionSphere(const Math::Sphere& sphere);
|
||||
//! Returns whether there is camera collision sphere
|
||||
bool HasCameraCollisionSphere() const;
|
||||
|
||||
private:
|
||||
std::map<std::string, CModelMesh> m_meshes;
|
||||
boost::optional<ModelShadowSpot> m_shadowSpot;
|
||||
std::vector<ModelCrashSphere> m_crashSpheres;
|
||||
boost::optional<ModelShadowSpot> m_shadowSpot;
|
||||
boost::optional<Math::Sphere> m_cameraCollisionSphere;
|
||||
};
|
||||
|
||||
} // namespace Gfx
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "math/vector.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Gfx {
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#include "graphics/model/model_input.h"
|
||||
|
||||
#include "common/ioutils.h"
|
||||
|
@ -20,7 +39,10 @@ namespace ModelInput
|
|||
{
|
||||
void ReadTextModel(CModel &model, std::istream &stream);
|
||||
void ReadTextModelV1AndV2(CModel &model, std::istream &stream);
|
||||
|
||||
void ReadTextModelV3(CModel &model, std::istream &stream);
|
||||
ModelHeaderV3 ReadTextHeader(std::istream &stream);
|
||||
CModelMesh ReadTextMesh(std::istream &stream);
|
||||
|
||||
void ReadBinaryModel(CModel &model, std::istream &stream);
|
||||
void ReadBinaryModelV1AndV2(CModel &model, std::istream &stream);
|
||||
|
@ -36,8 +58,15 @@ namespace ModelInput
|
|||
Material ReadBinaryMaterial(std::istream& stream);
|
||||
|
||||
std::string ReadLineString(std::istream& stream, const std::string& prefix);
|
||||
void ReadValuePrefix(std::istream& stream, const std::string& prefix);
|
||||
VertexTex2 ParseVertexTex2(const std::string& text);
|
||||
Material ParseTextMaterial(const std::string& text);
|
||||
Material ParseMaterial(const std::string& text);
|
||||
Math::Vector ParseVector(const std::string& text);
|
||||
ModelCrashSphere ParseCrashSphere(const std::string& text);
|
||||
ModelShadowSpot ParseShadowSpot(const std::string& text);
|
||||
Math::Sphere ParseCameraCollisionSphere(const std::string& text);
|
||||
ModelTransparentMode ParseTransparentMode(const std::string& text);
|
||||
ModelSpecialMark ParseSpecialMark(const std::string& text);
|
||||
|
||||
void ConvertOldTex1Name(ModelTriangle& triangle, const char* tex1Name);
|
||||
void ConvertFromOldRenderState(ModelTriangle& triangle, int state);
|
||||
|
@ -217,7 +246,7 @@ void ModelInput::ReadTextModelV1AndV2(CModel &model, std::istream &stream)
|
|||
t.p3 = ParseVertexTex2(p3Text);
|
||||
|
||||
std::string matText = ReadLineString(stream, "mat");
|
||||
t.material = ParseTextMaterial(matText);
|
||||
t.material = ParseMaterial(matText);
|
||||
|
||||
t.tex1Name = ReadLineString(stream, "tex1");
|
||||
t.tex2Name = ReadLineString(stream, "tex2");
|
||||
|
@ -253,7 +282,94 @@ void ModelInput::ReadTextModelV1AndV2(CModel &model, std::istream &stream)
|
|||
|
||||
void ModelInput::ReadTextModelV3(CModel &model, std::istream &stream)
|
||||
{
|
||||
// TODO...
|
||||
ModelHeaderV3 header;
|
||||
|
||||
try
|
||||
{
|
||||
header = ReadTextHeader(stream);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
throw CModelIOException(std::string("Error reading model header: ") + e.what());
|
||||
}
|
||||
|
||||
for (int i = 0; i < header.totalCrashSpheres; ++i)
|
||||
{
|
||||
auto crashSphere = ParseCrashSphere(ReadLineString(stream, "crash_sphere"));
|
||||
model.AddCrashSphere(crashSphere);
|
||||
}
|
||||
|
||||
if (header.hasShadowSpot)
|
||||
{
|
||||
auto shadowSpot = ParseShadowSpot(ReadLineString(stream, "shadow_spot"));
|
||||
model.SetShadowSpot(shadowSpot);
|
||||
}
|
||||
|
||||
if (header.hasCameraCollisionSphere)
|
||||
{
|
||||
auto sphere = ParseCameraCollisionSphere(ReadLineString(stream, "camera_collision_sphere"));
|
||||
model.SetCameraCollisionSphere(sphere);
|
||||
}
|
||||
|
||||
for (int i = 0; i < header.totalMeshes; ++i)
|
||||
{
|
||||
std::string meshName = ReadLineString(stream, "mesh");
|
||||
CModelMesh mesh = ReadTextMesh(stream);
|
||||
model.AddMesh(meshName, std::move(mesh));
|
||||
}
|
||||
}
|
||||
|
||||
ModelHeaderV3 ModelInput::ReadTextHeader(std::istream &stream)
|
||||
{
|
||||
ModelHeaderV3 header;
|
||||
header.version = boost::lexical_cast<int>(ReadLineString(stream, "version"));
|
||||
header.totalCrashSpheres = boost::lexical_cast<int>(ReadLineString(stream, "total_crash_spheres"));
|
||||
header.hasShadowSpot = ReadLineString(stream, "has_shadow_spot") == std::string("Y");
|
||||
header.hasCameraCollisionSphere = ReadLineString(stream, "has_camera_collision_sphere") == std::string("Y");
|
||||
header.totalMeshes = boost::lexical_cast<int>(ReadLineString(stream, "total_meshes"));
|
||||
return header;
|
||||
}
|
||||
|
||||
CModelMesh ModelInput::ReadTextMesh(std::istream& stream)
|
||||
{
|
||||
CModelMesh mesh;
|
||||
|
||||
mesh.SetPosition(ParseVector(ReadLineString(stream, "position")));
|
||||
mesh.SetRotation(ParseVector(ReadLineString(stream, "rotation")));
|
||||
mesh.SetScale(ParseVector(ReadLineString(stream, "scale")));
|
||||
mesh.SetParent(ReadLineString(stream, "parent"));
|
||||
|
||||
int totalTriangles = boost::lexical_cast<int>(ReadLineString(stream, "total_triangles"));
|
||||
|
||||
for (int i = 0; i < totalTriangles; ++i)
|
||||
{
|
||||
ModelTriangleV3 t;
|
||||
|
||||
std::string p1Text = ReadLineString(stream, "p1");
|
||||
t.p1 = ParseVertexTex2(p1Text);
|
||||
std::string p2Text = ReadLineString(stream, "p2");
|
||||
t.p2 = ParseVertexTex2(p2Text);
|
||||
std::string p3Text = ReadLineString(stream, "p3");
|
||||
t.p3 = ParseVertexTex2(p3Text);
|
||||
|
||||
std::string matText = ReadLineString(stream, "mat");
|
||||
Material mat = ParseMaterial(matText);
|
||||
t.ambient = mat.ambient;
|
||||
t.diffuse = mat.diffuse;
|
||||
t.specular = mat.specular;
|
||||
|
||||
t.tex1Name = ReadLineString(stream, "tex1");
|
||||
t.tex2Name = ReadLineString(stream, "tex2");
|
||||
t.variableTex2 = ReadLineString(stream, "var_tex2") == std::string("Y");
|
||||
|
||||
t.transparentMode = ParseTransparentMode(ReadLineString(stream, "trans_mode"));
|
||||
t.specialMark = ParseSpecialMark(ReadLineString(stream, "mark"));
|
||||
t.doubleSided = ReadLineString(stream, "dbl_side") == std::string("Y");
|
||||
|
||||
mesh.AddTriangle(t);
|
||||
}
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
||||
void ModelInput::ReadOldModel(CModel &model, std::istream &stream)
|
||||
|
@ -592,6 +708,14 @@ std::string ModelInput::ReadLineString(std::istream& stream, const std::string&
|
|||
return value;
|
||||
}
|
||||
|
||||
void ModelInput::ReadValuePrefix(std::istream& stream, const std::string& expectedPrefix)
|
||||
{
|
||||
std::string prefix;
|
||||
stream >> prefix;
|
||||
if (prefix != expectedPrefix)
|
||||
throw CModelIOException(std::string("Unexpected prefix: '") + prefix + "', expected was: '" + expectedPrefix + "'");
|
||||
}
|
||||
|
||||
VertexTex2 ModelInput::ParseVertexTex2(const std::string& text)
|
||||
{
|
||||
VertexTex2 vertex;
|
||||
|
@ -599,66 +723,41 @@ VertexTex2 ModelInput::ParseVertexTex2(const std::string& text)
|
|||
std::stringstream stream;
|
||||
stream.str(text);
|
||||
|
||||
std::string prefix;
|
||||
|
||||
stream >> prefix;
|
||||
if (prefix != "c")
|
||||
throw CModelIOException(std::string("Unexpected prefix: '") + prefix + "'");
|
||||
|
||||
ReadValuePrefix(stream, "c");
|
||||
stream >> vertex.coord.x >> vertex.coord.y >> vertex.coord.z;
|
||||
|
||||
stream >> prefix;
|
||||
if (prefix != "n")
|
||||
throw CModelIOException(std::string("Unexpected prefix: '") + prefix + "'");
|
||||
|
||||
ReadValuePrefix(stream, "n");
|
||||
stream >> vertex.normal.x >> vertex.normal.y >> vertex.normal.z;
|
||||
|
||||
stream >> prefix;
|
||||
if (prefix != "t1")
|
||||
throw CModelIOException(std::string("Unexpected prefix: '") + prefix + "'");
|
||||
|
||||
ReadValuePrefix(stream, "t1");
|
||||
stream >> vertex.texCoord.x >> vertex.texCoord.y;
|
||||
|
||||
stream >> prefix;
|
||||
if (prefix != "t2")
|
||||
throw CModelIOException(std::string("Unexpected prefix: '") + prefix + "'");
|
||||
|
||||
ReadValuePrefix(stream, "t2");
|
||||
stream >> vertex.texCoord2.x >> vertex.texCoord2.y;
|
||||
|
||||
return vertex;
|
||||
}
|
||||
|
||||
Material ModelInput::ParseTextMaterial(const std::string& text)
|
||||
Material ModelInput::ParseMaterial(const std::string& text)
|
||||
{
|
||||
Material material;
|
||||
|
||||
std::stringstream stream;
|
||||
stream.str(text);
|
||||
|
||||
std::string prefix;
|
||||
|
||||
stream >> prefix;
|
||||
if (prefix != "dif")
|
||||
throw CModelIOException(std::string("Unexpected prefix: '") + prefix + "'");
|
||||
|
||||
ReadValuePrefix(stream, "dif");
|
||||
stream >> material.diffuse.r
|
||||
>> material.diffuse.g
|
||||
>> material.diffuse.b
|
||||
>> material.diffuse.a;
|
||||
|
||||
stream >> prefix;
|
||||
if (prefix != "amb")
|
||||
throw CModelIOException(std::string("Unexpected prefix: '") + prefix + "'");
|
||||
|
||||
ReadValuePrefix(stream, "amb");
|
||||
stream >> material.ambient.r
|
||||
>> material.ambient.g
|
||||
>> material.ambient.b
|
||||
>> material.ambient.a;
|
||||
|
||||
stream >> prefix;
|
||||
if (prefix != "spc")
|
||||
throw CModelIOException(std::string("Unexpected prefix: '") + prefix + "'");
|
||||
|
||||
ReadValuePrefix(stream, "spc");
|
||||
stream >> material.specular.r
|
||||
>> material.specular.g
|
||||
>> material.specular.b
|
||||
|
@ -667,4 +766,102 @@ Material ModelInput::ParseTextMaterial(const std::string& text)
|
|||
return material;
|
||||
}
|
||||
|
||||
Math::Vector ModelInput::ParseVector(const std::string& text)
|
||||
{
|
||||
Math::Vector vector;
|
||||
|
||||
std::stringstream stream;
|
||||
stream.str(text);
|
||||
|
||||
stream >> vector.x >> vector.y >> vector.z;
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
ModelCrashSphere ModelInput::ParseCrashSphere(const std::string& text)
|
||||
{
|
||||
ModelCrashSphere crashSphere;
|
||||
|
||||
std::stringstream stream;
|
||||
stream.str(text);
|
||||
|
||||
ReadValuePrefix(stream, "pos");
|
||||
stream >> crashSphere.position.x
|
||||
>> crashSphere.position.y
|
||||
>> crashSphere.position.z;
|
||||
|
||||
ReadValuePrefix(stream, "rad");
|
||||
stream >> crashSphere.radius;
|
||||
|
||||
ReadValuePrefix(stream, "sound");
|
||||
stream >> crashSphere.sound;
|
||||
|
||||
ReadValuePrefix(stream, "hard");
|
||||
stream >> crashSphere.hardness;
|
||||
|
||||
return crashSphere;
|
||||
}
|
||||
|
||||
ModelShadowSpot ModelInput::ParseShadowSpot(const std::string& text)
|
||||
{
|
||||
ModelShadowSpot shadowSpot;
|
||||
|
||||
std::stringstream stream;
|
||||
stream.str(text);
|
||||
|
||||
ReadValuePrefix(stream, "rad");
|
||||
stream >> shadowSpot.radius;
|
||||
|
||||
ReadValuePrefix(stream, "int");
|
||||
stream >> shadowSpot.intensity;
|
||||
|
||||
return shadowSpot;
|
||||
}
|
||||
|
||||
Math::Sphere ModelInput::ParseCameraCollisionSphere(const std::string& text)
|
||||
{
|
||||
Math::Sphere sphere;
|
||||
|
||||
std::stringstream stream;
|
||||
stream.str(text);
|
||||
|
||||
ReadValuePrefix(stream, "pos");
|
||||
stream >> sphere.pos.x
|
||||
>> sphere.pos.y
|
||||
>> sphere.pos.z;
|
||||
|
||||
ReadValuePrefix(stream, "rad");
|
||||
stream >> sphere.radius;
|
||||
|
||||
return sphere;
|
||||
}
|
||||
|
||||
ModelTransparentMode ModelInput::ParseTransparentMode(const std::string& text)
|
||||
{
|
||||
if (text == "none")
|
||||
return ModelTransparentMode::None;
|
||||
else if (text == "alpha")
|
||||
return ModelTransparentMode::AlphaChannel;
|
||||
else if (text == "map_black")
|
||||
return ModelTransparentMode::MapBlackToAlpha;
|
||||
else if (text == "map_white")
|
||||
return ModelTransparentMode::MapWhiteToAlpha;
|
||||
else
|
||||
throw CModelIOException(std::string("Unexpected transparent mode: '") + text + "'");
|
||||
}
|
||||
|
||||
ModelSpecialMark ModelInput::ParseSpecialMark(const std::string& text)
|
||||
{
|
||||
if (text == "none")
|
||||
return ModelSpecialMark::None;
|
||||
else if (text == "part1")
|
||||
return ModelSpecialMark::Part1;
|
||||
else if (text == "part2")
|
||||
return ModelSpecialMark::Part2;
|
||||
else if (text == "part3")
|
||||
return ModelSpecialMark::Part3;
|
||||
else
|
||||
throw CModelIOException(std::string("Unexpected special mark: '") + text + "'");
|
||||
}
|
||||
|
||||
} // namespace Gfx
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "graphics/model/model.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "graphics/core/material.h"
|
||||
|
@ -92,12 +111,14 @@ struct ModelHeaderV3
|
|||
{
|
||||
//! File version (1, 2, ...)
|
||||
int version = 0;
|
||||
//! Total number of meshes
|
||||
int totalMeshes = 0;
|
||||
//! Total number of crash spheres
|
||||
int totalCrashSpheres = 0;
|
||||
//! Whether model has shadow spot
|
||||
bool shadowSpot = false;
|
||||
bool hasShadowSpot = false;
|
||||
//! Whether model has camera collision sphere
|
||||
bool hasCameraCollisionSphere = false;
|
||||
//! Total number of meshes
|
||||
int totalMeshes = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#include "graphics/model/model_manager.h"
|
||||
|
||||
#include "common/resources/inputstream.h"
|
||||
|
@ -7,21 +26,21 @@
|
|||
|
||||
namespace Gfx {
|
||||
|
||||
CModel& CModelManager::GetModel(const std::string& fileName)
|
||||
CModel& CModelManager::GetModel(const std::string& modelName)
|
||||
{
|
||||
auto it = m_models.find(fileName);
|
||||
auto it = m_models.find(modelName);
|
||||
if (it != m_models.end())
|
||||
return it->second;
|
||||
|
||||
CInputStream stream;
|
||||
stream.open("models-new/" + fileName);
|
||||
stream.open("models-new/" + modelName + ".txt");
|
||||
if (!stream.is_open())
|
||||
throw CModelIOException(std::string("Could not open file '") + fileName + "'");
|
||||
throw CModelIOException(std::string("Could not open file '") + modelName + "'");
|
||||
|
||||
CModel model = ModelInput::Read(stream, ModelFormat::Text);
|
||||
m_models[fileName] = model;
|
||||
m_models[modelName] = model;
|
||||
|
||||
return m_models[fileName];
|
||||
return m_models[modelName];
|
||||
}
|
||||
|
||||
void CModelManager::ClearCache()
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "graphics/model/model.h"
|
||||
|
@ -14,9 +33,9 @@ namespace Gfx {
|
|||
class CModelManager
|
||||
{
|
||||
public:
|
||||
//! Returns a model read from \a fileName
|
||||
//! Returns a model named \a modelName
|
||||
/** @throws CModelIOException on read error */
|
||||
CModel& GetModel(const std::string& fileName);
|
||||
CModel& GetModel(const std::string& modelName);
|
||||
|
||||
//! Clears cached models
|
||||
void ClearCache();
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#include "graphics/model/model_mesh.h"
|
||||
|
||||
namespace Gfx {
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "math/vector.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#include "graphics/model/model_output.h"
|
||||
|
||||
#include "common/ioutils.h"
|
||||
|
@ -15,6 +34,14 @@ namespace Gfx {
|
|||
namespace ModelOutput
|
||||
{
|
||||
void WriteTextModel(const CModel& model, std::ostream &stream);
|
||||
void WriteTextHeader(const ModelHeaderV3& header, std::ostream &stream);
|
||||
void WriteCrashSphere(const ModelCrashSphere& crashSphere, std::ostream &stream);
|
||||
void WriteShadowSpot(const ModelShadowSpot& shadowSpot, std::ostream &stream);
|
||||
void WriteCameraCollisionSphere(const Math::Sphere& sphere, std::ostream &stream);
|
||||
void WriteTextMesh(const CModelMesh* mesh, const std::string& meshName, std::ostream &stream);
|
||||
std::string VectorToString(const Math::Vector& vector);
|
||||
std::string TransparentModeToString(ModelTransparentMode mode);
|
||||
std::string SpecialMarkToString(ModelSpecialMark specialMark);
|
||||
|
||||
void WriteBinaryModel(const CModel& model, std::ostream &stream);
|
||||
|
||||
|
@ -64,38 +91,94 @@ void ModelOutput::Write(const CModel& model, std::ostream &stream, ModelFormat f
|
|||
|
||||
void ModelOutput::WriteTextModel(const CModel& model, std::ostream &stream)
|
||||
{
|
||||
const CModelMesh* mesh = model.GetMesh("main");
|
||||
if (mesh == nullptr)
|
||||
throw CModelIOException("No main mesh found in model");
|
||||
ModelHeaderV3 header;
|
||||
header.version = 3;
|
||||
header.totalCrashSpheres = model.GetCrashSphereCount();
|
||||
header.hasShadowSpot = model.HasShadowSpot();
|
||||
header.hasCameraCollisionSphere = model.HasCameraCollisionSphere();
|
||||
header.totalMeshes = model.GetMeshCount();
|
||||
WriteTextHeader(header, stream);
|
||||
|
||||
ModelHeaderV1AndV2 header;
|
||||
stream << "# MODEL PROPERTIES" << std::endl;
|
||||
|
||||
header.version = 2;
|
||||
header.totalTriangles = mesh->GetTriangleCount();
|
||||
for (const auto& crashSphere : model.GetCrashSpheres())
|
||||
WriteCrashSphere(crashSphere, stream);
|
||||
|
||||
if (model.HasShadowSpot())
|
||||
WriteShadowSpot(model.GetShadowSpot(), stream);
|
||||
|
||||
if (model.HasCameraCollisionSphere())
|
||||
WriteCameraCollisionSphere(model.GetCameraCollisionSphere(), stream);
|
||||
|
||||
stream << std::endl;
|
||||
|
||||
for (const std::string& meshName : model.GetMeshNames())
|
||||
{
|
||||
const CModelMesh* mesh = model.GetMesh(meshName);
|
||||
assert(mesh != nullptr);
|
||||
WriteTextMesh(mesh, meshName, stream);
|
||||
}
|
||||
}
|
||||
|
||||
void ModelOutput::WriteTextHeader(const ModelHeaderV3& header, std::ostream &stream)
|
||||
{
|
||||
stream << "# Colobot text model" << std::endl;
|
||||
stream << std::endl;
|
||||
stream << "### HEAD" << std::endl;
|
||||
stream << "version " << header.version << std::endl;
|
||||
stream << "total_triangles " << header.totalTriangles << std::endl;
|
||||
stream << "total_crash_spheres " << header.totalCrashSpheres << std::endl;
|
||||
stream << "has_shadow_spot " << (header.hasShadowSpot ? "Y" : "N") << std::endl;
|
||||
stream << "has_camera_collision_sphere " << (header.hasCameraCollisionSphere ? "Y" : "N") << std::endl;
|
||||
stream << "total_meshes " << header.totalMeshes << std::endl;
|
||||
stream << std::endl;
|
||||
stream << "### TRIANGLES" << std::endl;
|
||||
}
|
||||
|
||||
for (const ModelTriangle& triangle : mesh->GetTriangles())
|
||||
void ModelOutput::WriteCrashSphere(const ModelCrashSphere& crashSphere, std::ostream &stream)
|
||||
{
|
||||
stream << "crash_sphere";
|
||||
stream << " pos"
|
||||
<< " " << crashSphere.position.x
|
||||
<< " " << crashSphere.position.y
|
||||
<< " " << crashSphere.position.z;
|
||||
stream << " rad " << crashSphere.radius;
|
||||
stream << " sound " << crashSphere.sound;
|
||||
stream << " hard " << crashSphere.hardness;
|
||||
stream << std::endl;
|
||||
}
|
||||
|
||||
void ModelOutput::WriteShadowSpot(const ModelShadowSpot& shadowSpot, std::ostream &stream)
|
||||
{
|
||||
stream << "shadow_spot";
|
||||
stream << " rad " << shadowSpot.radius;
|
||||
stream << " int " << shadowSpot.intensity;
|
||||
stream << std::endl;
|
||||
}
|
||||
|
||||
void ModelOutput::WriteCameraCollisionSphere(const Math::Sphere& sphere, std::ostream &stream)
|
||||
{
|
||||
stream << "camera_collision_sphere ";
|
||||
stream << " pos "
|
||||
<< sphere.pos.x
|
||||
<< sphere.pos.y
|
||||
<< sphere.pos.z;
|
||||
stream << " rad " << sphere.radius;
|
||||
stream << std::endl;
|
||||
}
|
||||
|
||||
void ModelOutput::WriteTextMesh(const CModelMesh* mesh, const std::string& meshName, std::ostream &stream)
|
||||
{
|
||||
stream << "### MESH" << std::endl;
|
||||
stream << "mesh " << meshName << std::endl;
|
||||
stream << "position " << VectorToString(mesh->GetPosition()) << std::endl;
|
||||
stream << "rotation " << VectorToString(mesh->GetRotation()) << std::endl;
|
||||
stream << "scale " << VectorToString(mesh->GetScale()) << std::endl;
|
||||
stream << "parent " << mesh->GetParent() << std::endl;
|
||||
stream << "total_triangles " << mesh->GetTriangleCount() << std::endl;
|
||||
stream << std::endl;
|
||||
|
||||
stream << "### MESH TRIANGLES" << std::endl;
|
||||
for (const ModelTriangle& t : mesh->GetTriangles())
|
||||
{
|
||||
ModelTriangleV1AndV2 t;
|
||||
|
||||
t.p1 = triangle.p1;
|
||||
t.p2 = triangle.p2;
|
||||
t.p3 = triangle.p3;
|
||||
t.material.ambient = triangle.ambient;
|
||||
t.material.diffuse = triangle.diffuse;
|
||||
t.material.specular = triangle.specular;
|
||||
t.tex1Name = triangle.tex1Name;
|
||||
t.tex2Name = triangle.tex2Name;
|
||||
t.variableTex2 = triangle.variableTex2;
|
||||
t.state = ConvertToOldState(triangle);
|
||||
|
||||
stream << "p1 ";
|
||||
WriteTextVertexTex2(t.p1, stream);
|
||||
stream << "p2 ";
|
||||
|
@ -103,17 +186,66 @@ void ModelOutput::WriteTextModel(const CModel& model, std::ostream &stream)
|
|||
stream << "p3 ";
|
||||
WriteTextVertexTex2(t.p3, stream);
|
||||
stream << "mat ";
|
||||
WriteTextMaterial(t.material, stream);
|
||||
Material material;
|
||||
material.ambient = t.ambient;
|
||||
material.diffuse = t.diffuse;
|
||||
material.specular = t.specular;
|
||||
WriteTextMaterial(material, stream);
|
||||
|
||||
stream << "tex1 " << t.tex1Name << std::endl;
|
||||
stream << "tex2 " << t.tex2Name << std::endl;
|
||||
stream << "var_tex2 " << (t.variableTex2 ? 'Y' : 'N') << std::endl;
|
||||
stream << "state " << t.state << std::endl;
|
||||
stream << "trans_mode " << TransparentModeToString(t.transparentMode) << std::endl;
|
||||
stream << "mark " << SpecialMarkToString(t.specialMark) << std::endl;
|
||||
stream << "dbl_side " << (t.doubleSided ? 'Y' : 'N') << std::endl;
|
||||
|
||||
stream << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::string ModelOutput::VectorToString(const Math::Vector& vector)
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << vector.x << " " << vector.y << " " << vector.z;
|
||||
return str.str();
|
||||
}
|
||||
|
||||
std::string ModelOutput::TransparentModeToString(ModelTransparentMode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case ModelTransparentMode::None:
|
||||
return "none";
|
||||
|
||||
case ModelTransparentMode::AlphaChannel:
|
||||
return "alpha";
|
||||
|
||||
case ModelTransparentMode::MapBlackToAlpha:
|
||||
return "map_black";
|
||||
|
||||
case ModelTransparentMode::MapWhiteToAlpha:
|
||||
return "map_white";
|
||||
}
|
||||
}
|
||||
|
||||
std::string ModelOutput::SpecialMarkToString(ModelSpecialMark specialMark)
|
||||
{
|
||||
switch (specialMark)
|
||||
{
|
||||
case ModelSpecialMark::None:
|
||||
return "none";
|
||||
|
||||
case ModelSpecialMark::Part1:
|
||||
return "part1";
|
||||
|
||||
case ModelSpecialMark::Part2:
|
||||
return "part2";
|
||||
|
||||
case ModelSpecialMark::Part3:
|
||||
return "part3";
|
||||
}
|
||||
}
|
||||
|
||||
void ModelOutput::WriteBinaryModel(const CModel& model, std::ostream &stream)
|
||||
{
|
||||
const CModelMesh* mesh = model.GetMesh("main");
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "graphics/model/model_format.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Gfx {
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "graphics/core/color.h"
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#include "object/object.h"
|
||||
|
||||
#include "graphics/model/model_crash_sphere.h"
|
||||
|
||||
|
||||
CObject::CObject(int id, ObjectType type)
|
||||
: m_id(id)
|
||||
, m_type(type)
|
||||
|
@ -11,6 +14,16 @@ CObject::~CObject()
|
|||
{
|
||||
}
|
||||
|
||||
void CObject::SetCrashSpheres(const std::vector<Gfx::ModelCrashSphere>& crashSpheres)
|
||||
{
|
||||
for (const auto& crashSphere : crashSpheres)
|
||||
{
|
||||
SoundType sound = ParseSoundType(crashSphere.sound);
|
||||
CrashSphere objectCrashSphere(crashSphere.position, crashSphere.radius, sound, crashSphere.hardness);
|
||||
AddCrashSphere(objectCrashSphere);
|
||||
}
|
||||
}
|
||||
|
||||
void CObject::AddCrashSphere(const CrashSphere& crashSphere)
|
||||
{
|
||||
m_crashSpheres.push_back(crashSphere);
|
||||
|
|
|
@ -28,6 +28,11 @@
|
|||
#include "object/object_interface_type.h"
|
||||
#include "object/old_object_interface.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Gfx {
|
||||
struct ModelCrashSphere;
|
||||
} // namespace Gfx
|
||||
|
||||
/**
|
||||
* \class CObject
|
||||
|
@ -74,13 +79,14 @@ public:
|
|||
//! Reads object properties from line in level file
|
||||
virtual void Read(CLevelParserLine* line) = 0;
|
||||
|
||||
|
||||
//! Check if object implements the given type of interface
|
||||
inline bool Implements(ObjectInterfaceType type) const
|
||||
{
|
||||
return m_implementedInterfaces[static_cast<int>(type)];
|
||||
}
|
||||
|
||||
//! Sets crash spheres for object
|
||||
void SetCrashSpheres(const std::vector<Gfx::ModelCrashSphere>& crashSpheres);
|
||||
//! Adds a new crash sphere
|
||||
/** Crash sphere position is given in object coordinates */
|
||||
void AddCrashSphere(const CrashSphere& crashSphere);
|
||||
|
@ -101,6 +107,9 @@ public:
|
|||
// TODO: remove from here once no longer necessary
|
||||
void SetCameraCollisionSphere(const Math::Sphere& sphere);
|
||||
|
||||
//! Sets the transparency of object
|
||||
virtual void SetTransparency(float value) = 0;
|
||||
|
||||
protected:
|
||||
//! Transform crash sphere by object's world matrix
|
||||
virtual void TransformCrashSphere(Math::Sphere& crashSphere) = 0;
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "object/object_type.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
class CObjectCreateException : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit CObjectCreateException(const std::string& error, ObjectType type)
|
||||
: std::runtime_error("Error creating object type " + boost::lexical_cast<std::string>(type))
|
||||
{}
|
||||
explicit CObjectCreateException(const std::string& error, ObjectType type, const std::string& modelName)
|
||||
: std::runtime_error("Error creating object type " +
|
||||
boost::lexical_cast<std::string>(type) +
|
||||
" from model " + modelName + ": " + error)
|
||||
{}
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -33,6 +33,7 @@
|
|||
namespace Gfx {
|
||||
class CEngine;
|
||||
class COldModelManager;
|
||||
class CModelManager;
|
||||
class CParticle;
|
||||
class CTerrain;
|
||||
} // namespace Gfx
|
||||
|
@ -48,7 +49,8 @@ class CObjectFactory
|
|||
public:
|
||||
CObjectFactory(Gfx::CEngine* engine,
|
||||
Gfx::CTerrain* terrain,
|
||||
Gfx::COldModelManager* modelManager,
|
||||
Gfx::COldModelManager* oldModelManager,
|
||||
Gfx::CModelManager* modelManager,
|
||||
Gfx::CParticle* particle);
|
||||
|
||||
CObjectUPtr CreateObject(const ObjectCreateParams& params);
|
||||
|
@ -72,6 +74,7 @@ private:
|
|||
private:
|
||||
Gfx::CEngine* m_engine;
|
||||
Gfx::CTerrain* m_terrain;
|
||||
Gfx::COldModelManager* m_modelManager;
|
||||
Gfx::COldModelManager* m_oldModelManager;
|
||||
Gfx::CModelManager* m_modelManager;
|
||||
Gfx::CParticle* m_particle;
|
||||
};
|
||||
|
|
|
@ -38,6 +38,7 @@ enum class ObjectInterfaceType
|
|||
Jostleable, //!< object that can be jostled
|
||||
Carrier, //!< object that can carry other objects
|
||||
Powered, //!< object powered with power cell
|
||||
Old, //!< old objects, TODO: remove once no longer necessary
|
||||
Max //!< maximum value (for getting number of items in enum)
|
||||
};
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "object/object.h"
|
||||
#include "object/object_create_params.h"
|
||||
#include "object/object_create_exception.h"
|
||||
#include "object/object_factory.h"
|
||||
#include "object/old_object.h"
|
||||
#include "object/auto/auto.h"
|
||||
|
@ -38,9 +39,10 @@ template<> CObjectManager* CSingleton<CObjectManager>::m_instance = nullptr;
|
|||
|
||||
CObjectManager::CObjectManager(Gfx::CEngine* engine,
|
||||
Gfx::CTerrain* terrain,
|
||||
Gfx::COldModelManager* modelManager,
|
||||
Gfx::COldModelManager* oldModelManager,
|
||||
Gfx::CModelManager* modelManager,
|
||||
Gfx::CParticle* particle)
|
||||
: m_objectFactory(new CObjectFactory(engine, terrain, modelManager, particle))
|
||||
: m_objectFactory(new CObjectFactory(engine, terrain, oldModelManager, modelManager, particle))
|
||||
, m_nextId(0)
|
||||
{
|
||||
}
|
||||
|
@ -132,6 +134,10 @@ CObject* CObjectManager::CreateObject(Math::Vector pos,
|
|||
params.id = id;
|
||||
|
||||
auto objectUPtr = m_objectFactory->CreateObject(params);
|
||||
|
||||
if (objectUPtr == nullptr)
|
||||
throw CObjectCreateException("Something went wrong in CObjectFactory", type);
|
||||
|
||||
CObject* objectPtr = objectUPtr.get();
|
||||
|
||||
m_objects[id] = std::move(objectUPtr);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
namespace Gfx {
|
||||
class CEngine;
|
||||
class CModelManager;
|
||||
class COldModelManager;
|
||||
class CParticle;
|
||||
class CTerrain;
|
||||
|
@ -121,7 +122,8 @@ class CObjectManager : public CSingleton<CObjectManager>
|
|||
public:
|
||||
CObjectManager(Gfx::CEngine* engine,
|
||||
Gfx::CTerrain* terrain,
|
||||
Gfx::COldModelManager* modelManager,
|
||||
Gfx::COldModelManager* oldModelManager,
|
||||
Gfx::CModelManager* modelManager,
|
||||
Gfx::CParticle* particle);
|
||||
virtual ~CObjectManager();
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
|
||||
/**
|
||||
* \enum ObjectType
|
||||
* \brief Type of game object
|
||||
|
@ -191,3 +193,11 @@ enum ObjectType
|
|||
|
||||
OBJECT_MAX = 1000 //! < number of values
|
||||
};
|
||||
|
||||
struct ObjectTypeHash
|
||||
{
|
||||
inline std::size_t operator()(ObjectType t) const
|
||||
{
|
||||
return std::hash<int>()(t);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -203,6 +203,8 @@ COldObject::COldObject(int id)
|
|||
// Another hack
|
||||
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Jostleable)] = false;
|
||||
|
||||
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Old)] = true;
|
||||
|
||||
m_sound = CApplication::GetInstancePointer()->GetSound();
|
||||
m_engine = Gfx::CEngine::GetInstancePointer();
|
||||
m_lightMan = m_engine->GetLightManager();
|
||||
|
@ -941,6 +943,8 @@ void COldObject::Write(CLevelParserLine* line)
|
|||
if ( m_virusTime != 0.0f )
|
||||
line->AddParam("virusTime", CLevelParserParamUPtr{new CLevelParserParam(m_virusTime)});
|
||||
|
||||
line->AddParam("ignoreBuildCheck", CLevelParserParamUPtr{new CLevelParserParam(GetIgnoreBuildCheck())});
|
||||
|
||||
// Sets the parameters of the command line.
|
||||
CLevelParserParamVec cmdline;
|
||||
for(float value : m_cmdLine)
|
||||
|
@ -975,14 +979,13 @@ void COldObject::Write(CLevelParserLine* line)
|
|||
|
||||
void COldObject::Read(CLevelParserLine* line)
|
||||
{
|
||||
Math::Vector pos, dir;
|
||||
|
||||
Gfx::CameraType cType = line->GetParam("camera")->AsCameraType(Gfx::CAM_TYPE_NULL);
|
||||
if ( cType != Gfx::CAM_TYPE_NULL )
|
||||
{
|
||||
SetCameraType(cType);
|
||||
}
|
||||
|
||||
SetCameraDist(line->GetParam("cameraDist")->AsFloat(50.0f));
|
||||
SetCameraLock(line->GetParam("cameraLock")->AsBool(false));
|
||||
SetEnergy(line->GetParam("energy")->AsFloat(0.0f));
|
||||
SetCapacity(line->GetParam("capacity")->AsFloat(1.0f));
|
||||
|
@ -1000,6 +1003,7 @@ void COldObject::Read(CLevelParserLine* line)
|
|||
SetTeam(line->GetParam("team")->AsInt(0));
|
||||
SetGunGoalV(line->GetParam("aimV")->AsFloat(0.0f));
|
||||
SetGunGoalH(line->GetParam("aimH")->AsFloat(0.0f));
|
||||
|
||||
SetResetCap(static_cast<ResetCap>(line->GetParam("resetCap")->AsInt(0)));
|
||||
SetResetPosition(line->GetParam("resetPos")->AsPoint(Math::Vector())*g_unit);
|
||||
SetResetAngle(line->GetParam("resetAngle")->AsPoint(Math::Vector())*(Math::PI/180.0f));
|
||||
|
@ -1007,6 +1011,7 @@ void COldObject::Read(CLevelParserLine* line)
|
|||
m_bBurn = line->GetParam("burnMode")->AsBool(false);
|
||||
m_bVirusMode = line->GetParam("virusMode")->AsBool(false);
|
||||
m_virusTime = line->GetParam("virusTime")->AsFloat(0.0f);
|
||||
SetIgnoreBuildCheck(line->GetParam("ignoreBuildCheck")->AsBool(false));
|
||||
|
||||
// Sets the parameters of the command line.
|
||||
if (line->GetParam("cmdline")->IsDefined())
|
||||
|
@ -1028,7 +1033,6 @@ void COldObject::Read(CLevelParserLine* line)
|
|||
{
|
||||
m_brain->Read(line);
|
||||
}
|
||||
|
||||
if ( m_physics != nullptr )
|
||||
{
|
||||
m_physics->Read(line);
|
||||
|
@ -1229,114 +1233,38 @@ Math::Vector COldObject::GetTilt()
|
|||
|
||||
void COldObject::SetPosition(int part, const Math::Vector &pos)
|
||||
{
|
||||
Math::Vector shPos, n[20], norm;
|
||||
float height, radius;
|
||||
int rank, i, j;
|
||||
|
||||
m_objectPart[part].position = pos;
|
||||
m_objectPart[part].bTranslate = true; // it will recalculate the matrices
|
||||
|
||||
if ( part == 0 && !m_bFlat ) // main part?
|
||||
{
|
||||
rank = m_objectPart[0].object;
|
||||
int rank = m_objectPart[0].object;
|
||||
|
||||
shPos = pos;
|
||||
Math::Vector shPos = pos;
|
||||
m_terrain->AdjustToFloor(shPos, true);
|
||||
m_engine->SetObjectShadowPos(rank, shPos);
|
||||
|
||||
float height = 0.0f;
|
||||
if ( m_physics != nullptr && m_physics->GetType() == TYPE_FLYING )
|
||||
{
|
||||
height = pos.y-shPos.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
height = 0.0f;
|
||||
}
|
||||
m_engine->SetObjectShadowHeight(rank, height);
|
||||
|
||||
// Calculating the normal to the ground in nine strategic locations,
|
||||
// then perform a weighted average (the dots in the center are more important).
|
||||
radius = m_engine->GetObjectShadowRadius(rank);
|
||||
i = 0;
|
||||
|
||||
m_terrain->GetNormal(norm, pos);
|
||||
n[i++] = norm;
|
||||
n[i++] = norm;
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x += radius*0.6f;
|
||||
shPos.z += radius*0.6f;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x -= radius*0.6f;
|
||||
shPos.z += radius*0.6f;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x += radius*0.6f;
|
||||
shPos.z -= radius*0.6f;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x -= radius*0.6f;
|
||||
shPos.z -= radius*0.6f;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x += radius;
|
||||
shPos.z += radius;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x -= radius;
|
||||
shPos.z += radius;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x += radius;
|
||||
shPos.z -= radius;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
|
||||
shPos = pos;
|
||||
shPos.x -= radius;
|
||||
shPos.z -= radius;
|
||||
m_terrain->GetNormal(norm, shPos);
|
||||
n[i++] = norm;
|
||||
|
||||
norm.LoadZero();
|
||||
for ( j=0 ; j<i ; j++ )
|
||||
{
|
||||
norm += n[j];
|
||||
}
|
||||
norm /= static_cast<float>(i); // average vector
|
||||
|
||||
m_engine->SetObjectShadowNormal(rank, norm);
|
||||
m_engine->UpdateObjectShadowNormal(rank);
|
||||
|
||||
if ( m_shadowLight != -1 )
|
||||
{
|
||||
shPos = pos;
|
||||
shPos.y += m_shadowHeight;
|
||||
m_lightMan->SetLightPos(m_shadowLight, shPos);
|
||||
Math::Vector lightPos = pos;
|
||||
lightPos.y += m_shadowHeight;
|
||||
m_lightMan->SetLightPos(m_shadowLight, lightPos);
|
||||
}
|
||||
|
||||
if ( m_effectLight != -1 )
|
||||
{
|
||||
shPos = pos;
|
||||
shPos.y += m_effectHeight;
|
||||
m_lightMan->SetLightPos(m_effectLight, shPos);
|
||||
Math::Vector lightPos = pos;
|
||||
lightPos.y += m_effectHeight;
|
||||
m_lightMan->SetLightPos(m_effectLight, lightPos);
|
||||
}
|
||||
|
||||
if ( m_bShowLimit )
|
||||
|
@ -3437,8 +3365,6 @@ void COldObject::SetAuto(std::unique_ptr<CAuto> automat)
|
|||
m_auto = std::move(automat);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Management of the position in the file definition.
|
||||
|
||||
void COldObject::SetDefRank(int rank)
|
||||
|
@ -3451,7 +3377,6 @@ int COldObject::GetDefRank()
|
|||
return m_defRank;
|
||||
}
|
||||
|
||||
|
||||
// Getes the object name for the tooltip.
|
||||
|
||||
bool COldObject::GetTooltipName(std::string& name)
|
||||
|
|
|
@ -0,0 +1,851 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#include "object/old_object_interface.h"
|
||||
|
||||
|
||||
void COldObjectInterface::Simplify()
|
||||
{
|
||||
throw std::logic_error("Simplify: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::ExplodeObject(ExplosionType type, float force, float decay)
|
||||
{
|
||||
throw std::logic_error("ExplodeObject: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::UpdateMapping()
|
||||
{
|
||||
throw std::logic_error("UpdateMapping: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::DeletePart(int part)
|
||||
{
|
||||
throw std::logic_error("DeletePart: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetObjectRank(int part, int objRank)
|
||||
{
|
||||
throw std::logic_error("SetObjectRank: not implemented!");
|
||||
}
|
||||
|
||||
int COldObjectInterface::GetObjectRank(int part)
|
||||
{
|
||||
throw std::logic_error("GetObjectRank: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetObjectParent(int part, int parent)
|
||||
{
|
||||
throw std::logic_error("SetObjectParent: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetType(ObjectType type)
|
||||
{
|
||||
throw std::logic_error("SetType: not implemented!");
|
||||
}
|
||||
|
||||
const char* COldObjectInterface::GetName()
|
||||
{
|
||||
throw std::logic_error("GetName: not implemented!");
|
||||
}
|
||||
|
||||
int COldObjectInterface::GetOption()
|
||||
{
|
||||
throw std::logic_error("GetOption: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetDrawWorld(bool bDraw)
|
||||
{
|
||||
throw std::logic_error("SetDrawWorld: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetDrawFront(bool bDraw)
|
||||
{
|
||||
throw std::logic_error("SetDrawFront: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
bool COldObjectInterface::ReadProgram(Program* program, const char* filename)
|
||||
{
|
||||
throw std::logic_error("ReadProgram: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::WriteProgram(Program* program, const char* filename)
|
||||
{
|
||||
throw std::logic_error("WriteProgram: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
int COldObjectInterface::GetShadowLight()
|
||||
{
|
||||
throw std::logic_error("GetShadowLight: not implemented!");
|
||||
}
|
||||
|
||||
int COldObjectInterface::GetEffectLight()
|
||||
{
|
||||
throw std::logic_error("GetEffectLight: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetShieldRadius(float radius)
|
||||
{
|
||||
throw std::logic_error("SetShieldRadius: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetShieldRadius()
|
||||
{
|
||||
throw std::logic_error("GetShieldRadius: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetFloorHeight(float height)
|
||||
{
|
||||
throw std::logic_error("SetFloorHeight: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::FloorAdjust()
|
||||
{
|
||||
throw std::logic_error("FloorAdjust: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetLinVibration(Math::Vector dir)
|
||||
{
|
||||
throw std::logic_error("SetLinVibration: not implemented!");
|
||||
}
|
||||
|
||||
Math::Vector COldObjectInterface::GetLinVibration()
|
||||
{
|
||||
throw std::logic_error("GetLinVibration: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetCirVibration(Math::Vector dir)
|
||||
{
|
||||
throw std::logic_error("SetCirVibration: not implemented!");
|
||||
}
|
||||
|
||||
Math::Vector COldObjectInterface::GetCirVibration()
|
||||
{
|
||||
throw std::logic_error("GetCirVibration: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetTilt(Math::Vector dir)
|
||||
{
|
||||
throw std::logic_error("SetTilt: not implemented!");
|
||||
}
|
||||
|
||||
Math::Vector COldObjectInterface::GetTilt()
|
||||
{
|
||||
throw std::logic_error("GetTilt: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetPosition(int part, const Math::Vector &pos)
|
||||
{
|
||||
throw std::logic_error("SetPosition: not implemented!");
|
||||
}
|
||||
|
||||
Math::Vector COldObjectInterface::GetPosition(int part)
|
||||
{
|
||||
throw std::logic_error("GetPosition: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetAngle(int part, const Math::Vector &angle)
|
||||
{
|
||||
throw std::logic_error("SetAngle: not implemented!");
|
||||
}
|
||||
|
||||
Math::Vector COldObjectInterface::GetAngle(int part)
|
||||
{
|
||||
throw std::logic_error("GetAngle: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetAngleY(int part, float angle)
|
||||
{
|
||||
throw std::logic_error("SetAngleY: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetAngleX(int part, float angle)
|
||||
{
|
||||
throw std::logic_error("SetAngleX: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetAngleZ(int part, float angle)
|
||||
{
|
||||
throw std::logic_error("SetAngleZ: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetAngleY(int part)
|
||||
{
|
||||
throw std::logic_error("GetAngleY: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetAngleX(int part)
|
||||
{
|
||||
throw std::logic_error("GetAngleX: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetAngleZ(int part)
|
||||
{
|
||||
throw std::logic_error("GetAngleZ: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetZoom(int part, float zoom)
|
||||
{
|
||||
throw std::logic_error("SetZoom: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetZoom(int part, Math::Vector zoom)
|
||||
{
|
||||
throw std::logic_error("SetZoom: not implemented!");
|
||||
}
|
||||
|
||||
Math::Vector COldObjectInterface::GetZoom(int part)
|
||||
{
|
||||
throw std::logic_error("GetZoom: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetZoomX(int part, float zoom)
|
||||
{
|
||||
throw std::logic_error("SetZoomX: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetZoomX(int part)
|
||||
{
|
||||
throw std::logic_error("GetZoomX: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetZoomY(int part, float zoom)
|
||||
{
|
||||
throw std::logic_error("SetZoomY: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetZoomY(int part)
|
||||
{
|
||||
throw std::logic_error("GetZoomY: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetZoomZ(int part, float zoom)
|
||||
{
|
||||
throw std::logic_error("SetZoomZ: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetZoomZ(int part)
|
||||
{
|
||||
throw std::logic_error("GetZoomZ: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetTrainer(bool bEnable)
|
||||
{
|
||||
throw std::logic_error("SetTrainer: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetTrainer()
|
||||
{
|
||||
throw std::logic_error("GetTrainer: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetToy(bool bEnable)
|
||||
{
|
||||
throw std::logic_error("SetToy: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetToy()
|
||||
{
|
||||
throw std::logic_error("GetToy: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetManual(bool bManual)
|
||||
{
|
||||
throw std::logic_error("SetManual: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetManual()
|
||||
{
|
||||
throw std::logic_error("GetManual: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetResetCap(ResetCap cap)
|
||||
{
|
||||
throw std::logic_error("SetResetCap: not implemented!");
|
||||
}
|
||||
|
||||
ResetCap COldObjectInterface::GetResetCap()
|
||||
{
|
||||
throw std::logic_error("GetResetCap: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetResetBusy(bool bBusy)
|
||||
{
|
||||
throw std::logic_error("SetResetBusy: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetResetBusy()
|
||||
{
|
||||
throw std::logic_error("GetResetBusy: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetResetPosition(const Math::Vector &pos)
|
||||
{
|
||||
throw std::logic_error("SetResetPosition: not implemented!");
|
||||
}
|
||||
|
||||
Math::Vector COldObjectInterface::GetResetPosition()
|
||||
{
|
||||
throw std::logic_error("GetResetPosition: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetResetAngle(const Math::Vector &angle)
|
||||
{
|
||||
throw std::logic_error("SetResetAngle: not implemented!");
|
||||
}
|
||||
|
||||
Math::Vector COldObjectInterface::GetResetAngle()
|
||||
{
|
||||
throw std::logic_error("GetResetAngle: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetResetRun(Program* run)
|
||||
{
|
||||
throw std::logic_error("SetResetRun: not implemented!");
|
||||
}
|
||||
|
||||
Program* COldObjectInterface::GetResetRun()
|
||||
{
|
||||
throw std::logic_error("GetResetRun: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetMasterParticle(int part, int parti)
|
||||
{
|
||||
throw std::logic_error("SetMasterParticle: not implemented!");
|
||||
}
|
||||
|
||||
int COldObjectInterface::GetMasterParticle(int part)
|
||||
{
|
||||
throw std::logic_error("GetMasterParticle: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetCmdLine(unsigned int rank, float value)
|
||||
{
|
||||
throw std::logic_error("SetCmdLine: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetCmdLine(unsigned int rank)
|
||||
{
|
||||
throw std::logic_error("GetCmdLine: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
Math::Matrix* COldObjectInterface::GetRotateMatrix(int part)
|
||||
{
|
||||
throw std::logic_error("GetRotateMatrix: not implemented!");
|
||||
}
|
||||
|
||||
Math::Matrix* COldObjectInterface::GetWorldMatrix(int part)
|
||||
{
|
||||
throw std::logic_error("GetWorldMatrix: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV,
|
||||
Math::Vector &lookat, Math::Vector &upVec,
|
||||
Gfx::CameraType type)
|
||||
{
|
||||
throw std::logic_error("SetViewFromHere: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::GetCharacter(Character* character)
|
||||
{
|
||||
throw std::logic_error("GetCharacter: not implemented!");
|
||||
}
|
||||
|
||||
Character* COldObjectInterface::GetCharacter()
|
||||
{
|
||||
throw std::logic_error("GetCharacter: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
float COldObjectInterface::GetAbsTime()
|
||||
{
|
||||
throw std::logic_error("GetAbsTime: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetEnergy(float level)
|
||||
{
|
||||
throw std::logic_error("SetEnergy: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetEnergy()
|
||||
{
|
||||
throw std::logic_error("GetEnergy: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
float COldObjectInterface::GetCapacity()
|
||||
{
|
||||
throw std::logic_error("GetCapacity: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetShield(float level)
|
||||
{
|
||||
throw std::logic_error("SetShield: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetShield()
|
||||
{
|
||||
throw std::logic_error("GetShield: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetRange(float delay)
|
||||
{
|
||||
throw std::logic_error("SetRange: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetRange()
|
||||
{
|
||||
throw std::logic_error("GetRange: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetFixed(bool bFixed)
|
||||
{
|
||||
throw std::logic_error("SetFixed: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetFixed()
|
||||
{
|
||||
throw std::logic_error("GetFixed: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetClip(bool bClip)
|
||||
{
|
||||
throw std::logic_error("SetClip: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetClip()
|
||||
{
|
||||
throw std::logic_error("GetClip: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetTeam(int team)
|
||||
{
|
||||
throw std::logic_error("SetTeam: not implemented!");
|
||||
}
|
||||
|
||||
int COldObjectInterface::GetTeam()
|
||||
{
|
||||
throw std::logic_error("GetTeam: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::StartDetectEffect(CObject *target, bool bFound)
|
||||
{
|
||||
throw std::logic_error("StartDetectEffect: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetVirusMode(bool bEnable)
|
||||
{
|
||||
throw std::logic_error("SetVirusMode: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetVirusMode()
|
||||
{
|
||||
throw std::logic_error("GetVirusMode: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetVirusTime()
|
||||
{
|
||||
throw std::logic_error("GetVirusTime: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetCameraType(Gfx::CameraType type)
|
||||
{
|
||||
throw std::logic_error("SetCameraType: not implemented!");
|
||||
}
|
||||
|
||||
Gfx::CameraType COldObjectInterface::GetCameraType()
|
||||
{
|
||||
throw std::logic_error("GetCameraType: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetCameraDist(float dist)
|
||||
{
|
||||
throw std::logic_error("SetCameraDist: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetCameraDist()
|
||||
{
|
||||
throw std::logic_error("GetCameraDist: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetCameraLock(bool bLock)
|
||||
{
|
||||
throw std::logic_error("SetCameraLock: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetCameraLock()
|
||||
{
|
||||
throw std::logic_error("GetCameraLock: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetHighlight(bool mode)
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return;
|
||||
//throw std::logic_error("SetHighlight: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetSelect(bool bMode, bool bDisplayError)
|
||||
{
|
||||
// TODO: temporary hack
|
||||
//throw std::logic_error("SetSelect: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetSelect(bool bReal)
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return false;
|
||||
//throw std::logic_error("GetSelect: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetSelectable(bool bMode)
|
||||
{
|
||||
throw std::logic_error("SetSelectable: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetSelectable()
|
||||
{
|
||||
throw std::logic_error("GetSelectable: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetActivity(bool bMode)
|
||||
{
|
||||
throw std::logic_error("SetActivity: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetActivity()
|
||||
{
|
||||
throw std::logic_error("GetActivity: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetVisible(bool bVisible)
|
||||
{
|
||||
throw std::logic_error("SetVisible: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetEnable(bool bEnable)
|
||||
{
|
||||
throw std::logic_error("SetEnable: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetEnable()
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return true;
|
||||
//throw std::logic_error("GetEnable: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetCheckToken(bool bMode)
|
||||
{
|
||||
throw std::logic_error("SetCheckToken: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetCheckToken()
|
||||
{
|
||||
throw std::logic_error("GetCheckToken: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetProxyActivate(bool bActivate)
|
||||
{
|
||||
throw std::logic_error("SetProxyActivate: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetProxyActivate()
|
||||
{
|
||||
throw std::logic_error("GetProxyActivate: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetProxyDistance(float distance)
|
||||
{
|
||||
throw std::logic_error("SetProxyDistance: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetMagnifyDamage(float factor)
|
||||
{
|
||||
throw std::logic_error("SetMagnifyDamage: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetMagnifyDamage()
|
||||
{
|
||||
throw std::logic_error("GetMagnifyDamage: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetParam(float value)
|
||||
{
|
||||
throw std::logic_error("SetParam: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetParam()
|
||||
{
|
||||
throw std::logic_error("GetParam: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetIgnoreBuildCheck(bool bIgnoreBuildCheck)
|
||||
{
|
||||
throw std::logic_error("SetIgnoreBuildCheck: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetIgnoreBuildCheck()
|
||||
{
|
||||
throw std::logic_error("GetIgnoreBuildCheck: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetExploding(bool bExplo)
|
||||
{
|
||||
throw std::logic_error("SetExploding: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::IsExploding()
|
||||
{
|
||||
throw std::logic_error("IsExploding: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetLock(bool bLock)
|
||||
{
|
||||
throw std::logic_error("SetLock: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetLock()
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return false;
|
||||
//throw std::logic_error("GetLock: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetSpaceshipCargo(bool bCargo)
|
||||
{
|
||||
throw std::logic_error("SetSpaceshipCargo: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::IsSpaceshipCargo()
|
||||
{
|
||||
throw std::logic_error("IsSpaceshipCargo: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetBurn(bool bBurn)
|
||||
{
|
||||
throw std::logic_error("SetBurn: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetBurn()
|
||||
{
|
||||
throw std::logic_error("GetBurn: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetDead(bool bDead)
|
||||
{
|
||||
throw std::logic_error("SetDead: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetDead()
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return false;
|
||||
//throw std::logic_error("GetDead: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetRuin()
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return false;
|
||||
//throw std::logic_error("GetRuin: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetActive()
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return false;
|
||||
//throw std::logic_error("GetActive: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetGunGoalV(float gunGoal)
|
||||
{
|
||||
throw std::logic_error("SetGunGoalV: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetGunGoalH(float gunGoal)
|
||||
{
|
||||
throw std::logic_error("SetGunGoalH: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetGunGoalV()
|
||||
{
|
||||
throw std::logic_error("GetGunGoalV: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetGunGoalH()
|
||||
{
|
||||
throw std::logic_error("GetGunGoalH: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
bool COldObjectInterface::StartShowLimit()
|
||||
{
|
||||
throw std::logic_error("StartShowLimit: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::StopShowLimit()
|
||||
{
|
||||
throw std::logic_error("StopShowLimit: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
bool COldObjectInterface::IsProgram()
|
||||
{
|
||||
throw std::logic_error("IsProgram: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::CreateSelectParticle()
|
||||
{
|
||||
throw std::logic_error("CreateSelectParticle: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetRunScript(CScript* script)
|
||||
{
|
||||
throw std::logic_error("SetRunScript: not implemented!");
|
||||
}
|
||||
|
||||
CScript* COldObjectInterface::GetRunScript()
|
||||
{
|
||||
throw std::logic_error("GetRunScript: not implemented!");
|
||||
}
|
||||
|
||||
CBotVar* COldObjectInterface::GetBotVar()
|
||||
{
|
||||
throw std::logic_error("GetBotVar: not implemented!");
|
||||
}
|
||||
|
||||
CPhysics* COldObjectInterface::GetPhysics()
|
||||
{
|
||||
throw std::logic_error("GetPhysics: not implemented!");
|
||||
}
|
||||
|
||||
CMotion* COldObjectInterface::GetMotion()
|
||||
{
|
||||
throw std::logic_error("GetMotion: not implemented!");
|
||||
}
|
||||
|
||||
CAuto* COldObjectInterface::GetAuto()
|
||||
{
|
||||
throw std::logic_error("GetAuto: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetDefRank(int rank)
|
||||
{
|
||||
throw std::logic_error("SetDefRank: not implemented!");
|
||||
}
|
||||
|
||||
int COldObjectInterface::GetDefRank()
|
||||
{
|
||||
throw std::logic_error("GetDefRank: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
bool COldObjectInterface::GetTooltipName(std::string& name)
|
||||
{
|
||||
throw std::logic_error("GetTooltipName: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::AddDeselList(CObject* pObj)
|
||||
{
|
||||
throw std::logic_error("AddDeselList: not implemented!");
|
||||
}
|
||||
|
||||
CObject* COldObjectInterface::SubDeselList()
|
||||
{
|
||||
throw std::logic_error("SubDeselList: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::DeleteDeselList(CObject* pObj)
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return;
|
||||
//throw std::logic_error("DeleteDeselList: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
bool COldObjectInterface::CreateShadowCircle(float radius, float intensity, Gfx::EngineShadowType type)
|
||||
{
|
||||
throw std::logic_error("CreateShadowCircle: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::CreateShadowLight(float height, Gfx::Color color)
|
||||
{
|
||||
throw std::logic_error("CreateShadowLight: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::CreateEffectLight(float height, Gfx::Color color)
|
||||
{
|
||||
throw std::logic_error("CreateEffectLight: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::FlatParent()
|
||||
{
|
||||
throw std::logic_error("FlatParent: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetInfoReturn(float value)
|
||||
{
|
||||
throw std::logic_error("SetInfoReturn: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetInfoReturn()
|
||||
{
|
||||
throw std::logic_error("GetInfoReturn: not implemented!");
|
||||
}
|
||||
|
|
@ -76,212 +76,210 @@ class COldObjectInterface
|
|||
public:
|
||||
virtual ~COldObjectInterface() {}
|
||||
|
||||
virtual void Simplify() = 0;
|
||||
virtual bool ExplodeObject(ExplosionType type, float force, float decay=1.0f) = 0;
|
||||
virtual void Simplify();
|
||||
virtual bool ExplodeObject(ExplosionType type, float force, float decay=1.0f);
|
||||
|
||||
virtual void UpdateMapping() = 0;
|
||||
virtual void UpdateMapping();
|
||||
|
||||
virtual void DeletePart(int part) = 0;
|
||||
virtual void SetObjectRank(int part, int objRank) = 0;
|
||||
virtual int GetObjectRank(int part) = 0;
|
||||
virtual void SetObjectParent(int part, int parent) = 0;
|
||||
virtual void SetType(ObjectType type) = 0;
|
||||
virtual const char* GetName() = 0;
|
||||
virtual int GetOption() = 0;
|
||||
virtual void DeletePart(int part);
|
||||
virtual void SetObjectRank(int part, int objRank);
|
||||
virtual int GetObjectRank(int part);
|
||||
virtual void SetObjectParent(int part, int parent);
|
||||
virtual void SetType(ObjectType type);
|
||||
virtual const char* GetName();
|
||||
virtual int GetOption();
|
||||
|
||||
virtual void SetDrawWorld(bool bDraw) = 0;
|
||||
virtual void SetDrawFront(bool bDraw) = 0;
|
||||
virtual void SetDrawWorld(bool bDraw);
|
||||
virtual void SetDrawFront(bool bDraw);
|
||||
|
||||
virtual bool ReadProgram(Program* program, const char* filename) = 0;
|
||||
virtual bool WriteProgram(Program* program, const char* filename) = 0;
|
||||
virtual bool ReadProgram(Program* program, const char* filename);
|
||||
virtual bool WriteProgram(Program* program, const char* filename);
|
||||
|
||||
virtual int GetShadowLight() = 0;
|
||||
virtual int GetEffectLight() = 0;
|
||||
virtual int GetShadowLight();
|
||||
virtual int GetEffectLight();
|
||||
|
||||
virtual void SetShieldRadius(float radius) = 0;
|
||||
virtual float GetShieldRadius() = 0;
|
||||
virtual void SetShieldRadius(float radius);
|
||||
virtual float GetShieldRadius();
|
||||
|
||||
virtual void SetFloorHeight(float height) = 0;
|
||||
virtual void FloorAdjust() = 0;
|
||||
virtual void SetFloorHeight(float height);
|
||||
virtual void FloorAdjust();
|
||||
|
||||
virtual void SetLinVibration(Math::Vector dir) = 0;
|
||||
virtual Math::Vector GetLinVibration() = 0;
|
||||
virtual void SetCirVibration(Math::Vector dir) = 0;
|
||||
virtual Math::Vector GetCirVibration() = 0;
|
||||
virtual void SetTilt(Math::Vector dir) = 0;
|
||||
virtual Math::Vector GetTilt() = 0;
|
||||
virtual void SetLinVibration(Math::Vector dir);
|
||||
virtual Math::Vector GetLinVibration();
|
||||
virtual void SetCirVibration(Math::Vector dir);
|
||||
virtual Math::Vector GetCirVibration();
|
||||
virtual void SetTilt(Math::Vector dir);
|
||||
virtual Math::Vector GetTilt();
|
||||
|
||||
virtual void SetPosition(int part, const Math::Vector &pos) = 0;
|
||||
virtual Math::Vector GetPosition(int part) = 0;
|
||||
virtual void SetAngle(int part, const Math::Vector &angle) = 0;
|
||||
virtual Math::Vector GetAngle(int part) = 0;
|
||||
virtual void SetAngleY(int part, float angle) = 0;
|
||||
virtual void SetAngleX(int part, float angle) = 0;
|
||||
virtual void SetAngleZ(int part, float angle) = 0;
|
||||
virtual float GetAngleY(int part) = 0;
|
||||
virtual float GetAngleX(int part) = 0;
|
||||
virtual float GetAngleZ(int part) = 0;
|
||||
virtual void SetZoom(int part, float zoom) = 0;
|
||||
virtual void SetZoom(int part, Math::Vector zoom) = 0;
|
||||
virtual Math::Vector GetZoom(int part) = 0;
|
||||
virtual void SetZoomX(int part, float zoom) = 0;
|
||||
virtual float GetZoomX(int part) = 0;
|
||||
virtual void SetZoomY(int part, float zoom) = 0;
|
||||
virtual float GetZoomY(int part) = 0;
|
||||
virtual void SetZoomZ(int part, float zoom) = 0;
|
||||
virtual float GetZoomZ(int part) = 0;
|
||||
virtual void SetPosition(int part, const Math::Vector &pos);
|
||||
virtual Math::Vector GetPosition(int part);
|
||||
virtual void SetAngle(int part, const Math::Vector &angle);
|
||||
virtual Math::Vector GetAngle(int part);
|
||||
virtual void SetAngleY(int part, float angle);
|
||||
virtual void SetAngleX(int part, float angle);
|
||||
virtual void SetAngleZ(int part, float angle);
|
||||
virtual float GetAngleY(int part);
|
||||
virtual float GetAngleX(int part);
|
||||
virtual float GetAngleZ(int part);
|
||||
virtual void SetZoom(int part, float zoom);
|
||||
virtual void SetZoom(int part, Math::Vector zoom);
|
||||
virtual Math::Vector GetZoom(int part);
|
||||
virtual void SetZoomX(int part, float zoom);
|
||||
virtual float GetZoomX(int part);
|
||||
virtual void SetZoomY(int part, float zoom);
|
||||
virtual float GetZoomY(int part);
|
||||
virtual void SetZoomZ(int part, float zoom);
|
||||
virtual float GetZoomZ(int part);
|
||||
|
||||
virtual void SetTrainer(bool bEnable) = 0;
|
||||
virtual bool GetTrainer() = 0;
|
||||
virtual void SetTrainer(bool bEnable);
|
||||
virtual bool GetTrainer();
|
||||
|
||||
virtual void SetToy(bool bEnable) = 0;
|
||||
virtual bool GetToy() = 0;
|
||||
virtual void SetToy(bool bEnable);
|
||||
virtual bool GetToy();
|
||||
|
||||
virtual void SetManual(bool bManual) = 0;
|
||||
virtual bool GetManual() = 0;
|
||||
virtual void SetManual(bool bManual);
|
||||
virtual bool GetManual();
|
||||
|
||||
virtual void SetResetCap(ResetCap cap) = 0;
|
||||
virtual ResetCap GetResetCap() = 0;
|
||||
virtual void SetResetBusy(bool bBusy) = 0;
|
||||
virtual bool GetResetBusy() = 0;
|
||||
virtual void SetResetPosition(const Math::Vector &pos) = 0;
|
||||
virtual Math::Vector GetResetPosition() = 0;
|
||||
virtual void SetResetAngle(const Math::Vector &angle) = 0;
|
||||
virtual Math::Vector GetResetAngle() = 0;
|
||||
virtual void SetResetRun(Program* run) = 0;
|
||||
virtual Program* GetResetRun() = 0;
|
||||
virtual void SetResetCap(ResetCap cap);
|
||||
virtual ResetCap GetResetCap();
|
||||
virtual void SetResetBusy(bool bBusy);
|
||||
virtual bool GetResetBusy();
|
||||
virtual void SetResetPosition(const Math::Vector &pos);
|
||||
virtual Math::Vector GetResetPosition();
|
||||
virtual void SetResetAngle(const Math::Vector &angle);
|
||||
virtual Math::Vector GetResetAngle();
|
||||
virtual void SetResetRun(Program* run);
|
||||
virtual Program* GetResetRun();
|
||||
|
||||
virtual void SetMasterParticle(int part, int parti) = 0;
|
||||
virtual int GetMasterParticle(int part) = 0;
|
||||
virtual void SetMasterParticle(int part, int parti);
|
||||
virtual int GetMasterParticle(int part);
|
||||
|
||||
virtual void SetCmdLine(unsigned int rank, float value) = 0;
|
||||
virtual float GetCmdLine(unsigned int rank) = 0;
|
||||
virtual void SetCmdLine(unsigned int rank, float value);
|
||||
virtual float GetCmdLine(unsigned int rank);
|
||||
|
||||
virtual Math::Matrix* GetRotateMatrix(int part) = 0;
|
||||
virtual Math::Matrix* GetWorldMatrix(int part) = 0;
|
||||
virtual Math::Matrix* GetRotateMatrix(int part);
|
||||
virtual Math::Matrix* GetWorldMatrix(int part);
|
||||
|
||||
virtual void SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV,
|
||||
Math::Vector &lookat, Math::Vector &upVec,
|
||||
Gfx::CameraType type) = 0;
|
||||
Gfx::CameraType type);
|
||||
|
||||
virtual void GetCharacter(Character* character) = 0;
|
||||
virtual Character* GetCharacter() = 0;
|
||||
virtual void GetCharacter(Character* character);
|
||||
virtual Character* GetCharacter();
|
||||
|
||||
virtual float GetAbsTime() = 0;
|
||||
virtual float GetAbsTime();
|
||||
|
||||
virtual void SetEnergy(float level) = 0;
|
||||
virtual float GetEnergy() = 0;
|
||||
virtual void SetEnergy(float level);
|
||||
virtual float GetEnergy();
|
||||
|
||||
virtual float GetCapacity() = 0;
|
||||
virtual float GetCapacity();
|
||||
|
||||
virtual void SetShield(float level) = 0;
|
||||
virtual float GetShield() = 0;
|
||||
virtual void SetShield(float level);
|
||||
virtual float GetShield();
|
||||
|
||||
virtual void SetRange(float delay) = 0;
|
||||
virtual float GetRange() = 0;
|
||||
virtual void SetRange(float delay);
|
||||
virtual float GetRange();
|
||||
|
||||
virtual void SetTransparency(float value) = 0;
|
||||
virtual void SetFixed(bool bFixed);
|
||||
virtual bool GetFixed();
|
||||
|
||||
virtual void SetFixed(bool bFixed) = 0;
|
||||
virtual bool GetFixed() = 0;
|
||||
virtual void SetClip(bool bClip);
|
||||
virtual bool GetClip();
|
||||
|
||||
virtual void SetClip(bool bClip) = 0;
|
||||
virtual bool GetClip() = 0;
|
||||
virtual void SetTeam(int team);
|
||||
virtual int GetTeam();
|
||||
|
||||
virtual void SetTeam(int team) = 0;
|
||||
virtual int GetTeam() = 0;
|
||||
virtual void StartDetectEffect(CObject *target, bool bFound);
|
||||
|
||||
virtual void StartDetectEffect(CObject *target, bool bFound) = 0;
|
||||
virtual void SetVirusMode(bool bEnable);
|
||||
virtual bool GetVirusMode();
|
||||
virtual float GetVirusTime();
|
||||
|
||||
virtual void SetVirusMode(bool bEnable) = 0;
|
||||
virtual bool GetVirusMode() = 0;
|
||||
virtual float GetVirusTime() = 0;
|
||||
virtual void SetCameraType(Gfx::CameraType type);
|
||||
virtual Gfx::CameraType GetCameraType();
|
||||
virtual void SetCameraDist(float dist);
|
||||
virtual float GetCameraDist();
|
||||
virtual void SetCameraLock(bool bLock);
|
||||
virtual bool GetCameraLock();
|
||||
|
||||
virtual void SetCameraType(Gfx::CameraType type) = 0;
|
||||
virtual Gfx::CameraType GetCameraType() = 0;
|
||||
virtual void SetCameraDist(float dist) = 0;
|
||||
virtual float GetCameraDist() = 0;
|
||||
virtual void SetCameraLock(bool bLock) = 0;
|
||||
virtual bool GetCameraLock() = 0;
|
||||
virtual void SetHighlight(bool mode);
|
||||
|
||||
virtual void SetHighlight(bool mode) = 0;
|
||||
virtual void SetSelect(bool bMode, bool bDisplayError=true);
|
||||
virtual bool GetSelect(bool bReal=false);
|
||||
|
||||
virtual void SetSelect(bool bMode, bool bDisplayError=true) = 0;
|
||||
virtual bool GetSelect(bool bReal=false) = 0;
|
||||
virtual void SetSelectable(bool bMode);
|
||||
virtual bool GetSelectable();
|
||||
|
||||
virtual void SetSelectable(bool bMode) = 0;
|
||||
virtual bool GetSelectable() = 0;
|
||||
virtual void SetActivity(bool bMode);
|
||||
virtual bool GetActivity();
|
||||
|
||||
virtual void SetActivity(bool bMode) = 0;
|
||||
virtual bool GetActivity() = 0;
|
||||
virtual void SetVisible(bool bVisible);
|
||||
|
||||
virtual void SetVisible(bool bVisible) = 0;
|
||||
virtual void SetEnable(bool bEnable);
|
||||
virtual bool GetEnable();
|
||||
|
||||
virtual void SetEnable(bool bEnable) = 0;
|
||||
virtual bool GetEnable() = 0;
|
||||
virtual void SetCheckToken(bool bMode);
|
||||
virtual bool GetCheckToken();
|
||||
|
||||
virtual void SetCheckToken(bool bMode) = 0;
|
||||
virtual bool GetCheckToken() = 0;
|
||||
virtual void SetProxyActivate(bool bActivate);
|
||||
virtual bool GetProxyActivate();
|
||||
virtual void SetProxyDistance(float distance);
|
||||
|
||||
virtual void SetProxyActivate(bool bActivate) = 0;
|
||||
virtual bool GetProxyActivate() = 0;
|
||||
virtual void SetProxyDistance(float distance) = 0;
|
||||
virtual void SetMagnifyDamage(float factor);
|
||||
virtual float GetMagnifyDamage();
|
||||
|
||||
virtual void SetMagnifyDamage(float factor) = 0;
|
||||
virtual float GetMagnifyDamage() = 0;
|
||||
virtual void SetParam(float value);
|
||||
virtual float GetParam();
|
||||
virtual void SetIgnoreBuildCheck(bool bIgnoreBuildCheck);
|
||||
virtual bool GetIgnoreBuildCheck();
|
||||
|
||||
virtual void SetParam(float value) = 0;
|
||||
virtual float GetParam() = 0;
|
||||
virtual void SetIgnoreBuildCheck(bool bIgnoreBuildCheck) = 0;
|
||||
virtual bool GetIgnoreBuildCheck() = 0;
|
||||
virtual void SetExploding(bool bExplo);
|
||||
virtual bool IsExploding();
|
||||
virtual void SetLock(bool bLock);
|
||||
virtual bool GetLock();
|
||||
virtual void SetSpaceshipCargo(bool bCargo);
|
||||
virtual bool IsSpaceshipCargo();
|
||||
virtual void SetBurn(bool bBurn);
|
||||
virtual bool GetBurn();
|
||||
virtual void SetDead(bool bDead);
|
||||
virtual bool GetDead();
|
||||
virtual bool GetRuin();
|
||||
virtual bool GetActive();
|
||||
|
||||
virtual void SetExploding(bool bExplo) = 0;
|
||||
virtual bool IsExploding() = 0;
|
||||
virtual void SetLock(bool bLock) = 0;
|
||||
virtual bool GetLock() = 0;
|
||||
virtual void SetSpaceshipCargo(bool bCargo) = 0;
|
||||
virtual bool IsSpaceshipCargo() = 0;
|
||||
virtual void SetBurn(bool bBurn) = 0;
|
||||
virtual bool GetBurn() = 0;
|
||||
virtual void SetDead(bool bDead) = 0;
|
||||
virtual bool GetDead() = 0;
|
||||
virtual bool GetRuin() = 0;
|
||||
virtual bool GetActive() = 0;
|
||||
virtual void SetGunGoalV(float gunGoal);
|
||||
virtual void SetGunGoalH(float gunGoal);
|
||||
virtual float GetGunGoalV();
|
||||
virtual float GetGunGoalH();
|
||||
|
||||
virtual void SetGunGoalV(float gunGoal) = 0;
|
||||
virtual void SetGunGoalH(float gunGoal) = 0;
|
||||
virtual float GetGunGoalV() = 0;
|
||||
virtual float GetGunGoalH() = 0;
|
||||
virtual bool StartShowLimit();
|
||||
virtual void StopShowLimit();
|
||||
|
||||
virtual bool StartShowLimit() = 0;
|
||||
virtual void StopShowLimit() = 0;
|
||||
virtual bool IsProgram();
|
||||
virtual void CreateSelectParticle();
|
||||
|
||||
virtual bool IsProgram() = 0;
|
||||
virtual void CreateSelectParticle() = 0;
|
||||
virtual void SetRunScript(CScript* script);
|
||||
virtual CScript* GetRunScript();
|
||||
virtual CBotVar* GetBotVar();
|
||||
virtual CPhysics* GetPhysics();
|
||||
virtual CMotion* GetMotion();
|
||||
virtual CAuto* GetAuto();
|
||||
|
||||
virtual void SetRunScript(CScript* script) = 0;
|
||||
virtual CScript* GetRunScript() = 0;
|
||||
virtual CBotVar* GetBotVar() = 0;
|
||||
virtual CPhysics* GetPhysics() = 0;
|
||||
virtual CMotion* GetMotion() = 0;
|
||||
virtual CAuto* GetAuto() = 0;
|
||||
virtual void SetDefRank(int rank);
|
||||
virtual int GetDefRank();
|
||||
|
||||
virtual void SetDefRank(int rank) = 0;
|
||||
virtual int GetDefRank() = 0;
|
||||
virtual bool GetTooltipName(std::string& name);
|
||||
|
||||
virtual bool GetTooltipName(std::string& name) = 0;
|
||||
virtual void AddDeselList(CObject* pObj);
|
||||
virtual CObject* SubDeselList();
|
||||
virtual void DeleteDeselList(CObject* pObj);
|
||||
|
||||
virtual void AddDeselList(CObject* pObj) = 0;
|
||||
virtual CObject* SubDeselList() = 0;
|
||||
virtual void DeleteDeselList(CObject* pObj) = 0;
|
||||
virtual bool CreateShadowCircle(float radius, float intensity, Gfx::EngineShadowType type = Gfx::ENG_SHADOW_NORM);
|
||||
virtual bool CreateShadowLight(float height, Gfx::Color color);
|
||||
virtual bool CreateEffectLight(float height, Gfx::Color color);
|
||||
|
||||
virtual bool CreateShadowCircle(float radius, float intensity, Gfx::EngineShadowType type = Gfx::ENG_SHADOW_NORM) = 0;
|
||||
virtual bool CreateShadowLight(float height, Gfx::Color color) = 0;
|
||||
virtual bool CreateEffectLight(float height, Gfx::Color color) = 0;
|
||||
virtual void FlatParent();
|
||||
|
||||
virtual void FlatParent() = 0;
|
||||
|
||||
virtual void SetInfoReturn(float value) = 0;
|
||||
virtual float GetInfoReturn() = 0;
|
||||
virtual void SetInfoReturn(float value);
|
||||
virtual float GetInfoReturn();
|
||||
};
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "graphics/engine/terrain.h"
|
||||
#include "graphics/engine/text.h"
|
||||
#include "graphics/engine/water.h"
|
||||
#include "graphics/model/model_manager.h"
|
||||
|
||||
#include "math/const.h"
|
||||
#include "math/geometry.h"
|
||||
|
@ -133,7 +134,8 @@ CRobotMain::CRobotMain(CController* controller)
|
|||
m_sound = nullptr;
|
||||
|
||||
m_engine = nullptr;
|
||||
m_modelManager = nullptr;
|
||||
m_oldModelManager = nullptr;
|
||||
m_modelManager = std::unique_ptr<Gfx::CModelManager>(new Gfx::CModelManager());
|
||||
m_lightMan = nullptr;
|
||||
m_particle = nullptr;
|
||||
m_water = nullptr;
|
||||
|
@ -252,7 +254,7 @@ void CRobotMain::Create(bool loadProfile)
|
|||
m_sound = m_app->GetSound();
|
||||
|
||||
m_engine = Gfx::CEngine::GetInstancePointer();
|
||||
m_modelManager = m_engine->GetModelManager();
|
||||
m_oldModelManager = m_engine->GetModelManager();
|
||||
m_lightMan = m_engine->GetLightManager();
|
||||
m_particle = m_engine->GetParticle();
|
||||
m_water = m_engine->GetWater();
|
||||
|
@ -274,7 +276,8 @@ void CRobotMain::Create(bool loadProfile)
|
|||
|
||||
m_objMan = new CObjectManager(m_engine,
|
||||
m_terrain,
|
||||
m_modelManager,
|
||||
m_oldModelManager,
|
||||
m_modelManager.get(),
|
||||
m_particle);
|
||||
|
||||
m_engine->SetTerrain(m_terrain);
|
||||
|
@ -473,7 +476,7 @@ void CRobotMain::ChangePhase(Phase phase)
|
|||
m_engine->SetRankView(0);
|
||||
m_terrain->FlushRelief();
|
||||
m_engine->DeleteAllObjects();
|
||||
m_modelManager->DeleteAllModelCopies();
|
||||
m_oldModelManager->DeleteAllModelCopies();
|
||||
m_engine->SetWaterAddColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
m_engine->SetBackground("");
|
||||
m_engine->SetBackForce(false);
|
||||
|
@ -2840,7 +2843,7 @@ void CRobotMain::ScenePerso()
|
|||
DeleteAllObjects(); // removes all the current 3D Scene
|
||||
m_terrain->FlushRelief();
|
||||
m_engine->DeleteAllObjects();
|
||||
m_modelManager->DeleteAllModelCopies();
|
||||
m_oldModelManager->DeleteAllModelCopies();
|
||||
m_terrain->FlushBuildingLevel();
|
||||
m_terrain->FlushFlyingLimit();
|
||||
m_lightMan->FlushLights();
|
||||
|
@ -3535,11 +3538,18 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
if (m_phase == PHASE_LOST) motion->SetAction(MHS_LOST, 0.5f);
|
||||
}
|
||||
|
||||
if (obj != nullptr)
|
||||
if (obj->Implements(ObjectInterfaceType::Old)) // TODO: temporary hack
|
||||
{
|
||||
obj->SetDefRank(rankObj);
|
||||
obj->SetDefRank(rankObj); // TODO: do we really need this?
|
||||
|
||||
if (type == OBJECT_BASE) m_base = obj;
|
||||
if (type == OBJECT_BASE)
|
||||
m_base = obj;
|
||||
|
||||
if (line->GetParam("select")->AsBool(false))
|
||||
sel = obj;
|
||||
|
||||
// TODO: everything below should go to CObject::Read() function
|
||||
// In fact, we could give CLevelParserLine as parameter to CreateObject() in the first place
|
||||
|
||||
Gfx::CameraType cType = line->GetParam("camera")->AsCameraType(Gfx::CAM_TYPE_NULL);
|
||||
if (cType != Gfx::CAM_TYPE_NULL)
|
||||
|
@ -3570,11 +3580,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
}
|
||||
}
|
||||
|
||||
if (line->GetParam("select")->AsBool(false))
|
||||
{
|
||||
sel = obj;
|
||||
}
|
||||
|
||||
bool selectable = line->GetParam("selectable")->AsBool(true);
|
||||
obj->SetSelectable(selectable);
|
||||
obj->SetIgnoreBuildCheck(line->GetParam("ignoreBuildCheck")->AsBool(false));
|
||||
|
@ -3597,14 +3602,17 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
if (zoom.x != 0.0f || zoom.y != 0.0f || zoom.z != 0.0f)
|
||||
obj->SetZoom(0, zoom);
|
||||
|
||||
//TODO: I don't remember what this is used for
|
||||
CMotion* motion = obj->GetMotion();
|
||||
if (motion != nullptr && line->GetParam("param")->IsDefined())
|
||||
// only used in AlienWorm lines
|
||||
if (type == OBJECT_WORM)
|
||||
{
|
||||
const auto& p = line->GetParam("param")->AsArray();
|
||||
for (unsigned int i = 0; i < 10 && i < p.size(); i++)
|
||||
CMotion* motion = obj->GetMotion();
|
||||
if (motion != nullptr && line->GetParam("param")->IsDefined())
|
||||
{
|
||||
motion->SetParam(i, p[i]->AsFloat());
|
||||
const auto& p = line->GetParam("param")->AsArray();
|
||||
for (unsigned int i = 0; i < 10 && i < p.size(); i++)
|
||||
{
|
||||
motion->SetParam(i, p[i]->AsFloat());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3669,7 +3677,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
obj->SetResetPosition(obj->GetPosition(0));
|
||||
obj->SetResetAngle(obj->GetAngle(0));
|
||||
obj->SetResetRun(loadedPrograms[run]);
|
||||
|
||||
if (line->GetParam("reset")->AsBool(false))
|
||||
obj->SetResetCap(RESET_MOVE);
|
||||
}
|
||||
|
@ -4855,7 +4862,6 @@ void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj)
|
|||
}
|
||||
|
||||
line->AddParam("trainer", CLevelParserParamUPtr{new CLevelParserParam(obj->GetTrainer())});
|
||||
line->AddParam("ignoreBuildCheck", CLevelParserParamUPtr{new CLevelParserParam(obj->GetIgnoreBuildCheck())});
|
||||
line->AddParam("option", CLevelParserParamUPtr{new CLevelParserParam(obj->GetOption())});
|
||||
if (obj == m_infoObject)
|
||||
line->AddParam("select", CLevelParserParamUPtr{new CLevelParserParam(1)});
|
||||
|
@ -5033,7 +5039,6 @@ CObject* CRobotMain::IOReadObject(CLevelParserLine *line, const char* filename,
|
|||
obj->SetDefRank(objRank);
|
||||
obj->SetPosition(0, pos);
|
||||
obj->SetAngle(0, dir);
|
||||
obj->SetIgnoreBuildCheck(line->GetParam("ignoreBuildCheck")->AsBool(false));
|
||||
|
||||
if (zoom.x != 0.0f || zoom.y != 0.0f || zoom.z != 0.0f)
|
||||
obj->SetZoom(0, zoom);
|
||||
|
|
|
@ -94,6 +94,7 @@ class CCloud;
|
|||
class CLightning;
|
||||
class CPlanet;
|
||||
class CTerrain;
|
||||
class CModelManager;
|
||||
}
|
||||
|
||||
namespace Ui {
|
||||
|
@ -381,7 +382,8 @@ protected:
|
|||
Gfx::CCloud* m_cloud;
|
||||
Gfx::CLightning* m_lightning;
|
||||
Gfx::CPlanet* m_planet;
|
||||
Gfx::COldModelManager* m_modelManager;
|
||||
Gfx::COldModelManager* m_oldModelManager;
|
||||
std::unique_ptr<Gfx::CModelManager> m_modelManager;
|
||||
Gfx::CLightManager* m_lightMan;
|
||||
Gfx::CTerrain* m_terrain;
|
||||
Gfx::CCamera* m_camera;
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#include "object/subclass/static_object.h"
|
||||
|
||||
#include "graphics/engine/terrain.h"
|
||||
#include "graphics/model/model.h"
|
||||
#include "graphics/model/model_io_exception.h"
|
||||
#include "graphics/model/model_manager.h"
|
||||
|
||||
#include "object/object_create_exception.h"
|
||||
|
||||
#include "math/geometry.h"
|
||||
|
||||
|
||||
const std::unordered_map<ObjectType, std::string, ObjectTypeHash> CStaticObject::m_staticModelNames =
|
||||
{
|
||||
{ OBJECT_TREE0, "tree0" }
|
||||
};
|
||||
|
||||
|
||||
CStaticObject::CStaticObject(int id,
|
||||
ObjectType type,
|
||||
const std::string& key,
|
||||
const Math::Vector& position,
|
||||
float angleY,
|
||||
const Gfx::CModel& model,
|
||||
Gfx::CEngine* engine)
|
||||
: CObject(id, type)
|
||||
, m_engine(engine)
|
||||
{
|
||||
const Gfx::CModelMesh* mesh = model.GetMesh("main");
|
||||
assert(mesh != nullptr);
|
||||
|
||||
Math::Matrix worldMatrix = ComputeWorldMatrix(position, angleY);
|
||||
m_meshHandle = m_engine->AddStaticMesh(key, mesh, worldMatrix);
|
||||
|
||||
if (model.HasShadowSpot())
|
||||
m_engine->AddStaticMeshShadowSpot(m_meshHandle, model.GetShadowSpot());
|
||||
|
||||
SetCrashSpheres(model.GetCrashSpheres());
|
||||
|
||||
if (model.HasCameraCollisionSphere())
|
||||
SetCameraCollisionSphere(model.GetCameraCollisionSphere());
|
||||
}
|
||||
|
||||
CStaticObject::~CStaticObject()
|
||||
{
|
||||
m_engine->DeleteStaticMesh(m_meshHandle);
|
||||
}
|
||||
|
||||
Math::Matrix CStaticObject::ComputeWorldMatrix(const Math::Vector& position, float angleY)
|
||||
{
|
||||
Math::Matrix translationMatrix;
|
||||
Math::LoadTranslationMatrix(translationMatrix, position);
|
||||
|
||||
Math::Matrix rotationMatrix;
|
||||
Math::LoadRotationZXYMatrix(rotationMatrix, Math::Vector(0.0f, angleY, 0.0f));
|
||||
|
||||
return Math::MultiplyMatrices(translationMatrix, rotationMatrix);
|
||||
}
|
||||
|
||||
void CStaticObject::Read(CLevelParserLine* line)
|
||||
{
|
||||
}
|
||||
|
||||
void CStaticObject::Write(CLevelParserLine* line)
|
||||
{
|
||||
}
|
||||
|
||||
void CStaticObject::TransformCrashSphere(Math::Sphere& crashSphere)
|
||||
{
|
||||
Math::Matrix worldMatrix = m_engine->GetStaticMeshWorldMatrix(m_meshHandle);
|
||||
Math::Transform(worldMatrix, crashSphere.pos);
|
||||
}
|
||||
|
||||
void CStaticObject::TransformCameraCollisionSphere(Math::Sphere& collisionSphere)
|
||||
{
|
||||
Math::Matrix worldMatrix = m_engine->GetStaticMeshWorldMatrix(m_meshHandle);
|
||||
Math::Transform(worldMatrix, collisionSphere.pos);
|
||||
}
|
||||
|
||||
void CStaticObject::SetTransparency(float value)
|
||||
{
|
||||
m_engine->SetStaticMeshTransparency(m_meshHandle, value);
|
||||
}
|
||||
|
||||
bool CStaticObject::IsStaticObject(ObjectType type)
|
||||
{
|
||||
return m_staticModelNames.count(type) > 0;
|
||||
}
|
||||
|
||||
CStaticObjectUPtr CStaticObject::Create(int id,
|
||||
ObjectType type,
|
||||
const Math::Vector& position,
|
||||
float angleY,
|
||||
float height,
|
||||
Gfx::CEngine* engine,
|
||||
Gfx::CModelManager* modelManager,
|
||||
Gfx::CTerrain* terrain)
|
||||
{
|
||||
auto it = m_staticModelNames.find(type);
|
||||
if (it == m_staticModelNames.end())
|
||||
throw CObjectCreateException("Object type is not static object", type);
|
||||
|
||||
std::string modelFile = it->second;
|
||||
|
||||
Math::Vector adjustedPosition = position;
|
||||
terrain->AdjustToFloor(adjustedPosition);
|
||||
adjustedPosition.y += height;
|
||||
|
||||
try
|
||||
{
|
||||
Gfx::CModel& model = modelManager->GetModel(modelFile);
|
||||
|
||||
if (model.GetMeshCount() != 1 || model.GetMesh("main") == nullptr)
|
||||
throw CObjectCreateException("Unexpected mesh configuration", type, modelFile);
|
||||
|
||||
return CStaticObjectUPtr{new CStaticObject(id, type, modelFile, adjustedPosition, angleY, model, engine)};
|
||||
}
|
||||
catch (const Gfx::CModelIOException& e)
|
||||
{
|
||||
throw CObjectCreateException(std::string("Error loading model file: ") + e.what(), type, modelFile);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "object/object.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Gfx {
|
||||
class CModelManager;
|
||||
class CEngine;
|
||||
class CModel;
|
||||
} // namespace Gfx
|
||||
|
||||
class CStaticObject;
|
||||
using CStaticObjectUPtr = std::unique_ptr<CStaticObject>;
|
||||
|
||||
class CStaticObject : public CObject
|
||||
{
|
||||
protected:
|
||||
CStaticObject(int id,
|
||||
ObjectType type,
|
||||
const std::string& key,
|
||||
const Math::Vector& position,
|
||||
float angleY,
|
||||
const Gfx::CModel& model,
|
||||
Gfx::CEngine* engine);
|
||||
|
||||
public:
|
||||
virtual ~CStaticObject();
|
||||
|
||||
void Read(CLevelParserLine* line) override;
|
||||
void Write(CLevelParserLine* line) override;
|
||||
|
||||
void SetTransparency(float value) override;
|
||||
|
||||
public:
|
||||
static bool IsStaticObject(ObjectType type);
|
||||
|
||||
static CStaticObjectUPtr Create(int id,
|
||||
ObjectType type,
|
||||
const Math::Vector& position,
|
||||
float angleY,
|
||||
float height,
|
||||
Gfx::CEngine* engine,
|
||||
Gfx::CModelManager* modelManager,
|
||||
Gfx::CTerrain* terrain);
|
||||
|
||||
protected:
|
||||
void TransformCrashSphere(Math::Sphere& crashSphere) override;
|
||||
void TransformCameraCollisionSphere(Math::Sphere& collisionSphere) override;
|
||||
|
||||
private:
|
||||
static Math::Matrix ComputeWorldMatrix(const Math::Vector& position,
|
||||
float angleY);
|
||||
|
||||
private:
|
||||
Gfx::CEngine* m_engine;
|
||||
int m_meshHandle;
|
||||
static const std::unordered_map<ObjectType, std::string, ObjectTypeHash> m_staticModelNames;
|
||||
};
|
|
@ -114,7 +114,7 @@ const std::unordered_map<std::string, SoundType> SOUND_STRINGS =
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
SoundType StringToSound(const std::string& str)
|
||||
SoundType ParseSoundType(const std::string& str)
|
||||
{
|
||||
auto it = SOUND_STRINGS.find(str);
|
||||
if (it == SOUND_STRINGS.end())
|
||||
|
|
Loading…
Reference in New Issue