summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/common/logger.cpp24
-rw-r--r--src/common/logger.h22
-rw-r--r--src/graphics/core/material.h10
-rw-r--r--src/graphics/core/texture.h27
-rw-r--r--src/graphics/engine/cloud.cpp16
-rw-r--r--src/graphics/engine/cloud.h2
-rw-r--r--src/graphics/engine/engine.cpp1478
-rw-r--r--src/graphics/engine/engine.h398
-rw-r--r--src/graphics/engine/lightning.cpp20
-rw-r--r--src/graphics/engine/particle.cpp86
-rw-r--r--src/graphics/engine/planet.h2
-rw-r--r--src/graphics/engine/pyro.cpp50
-rw-r--r--src/graphics/engine/terrain.cpp118
-rw-r--r--src/graphics/engine/terrain.h4
-rw-r--r--src/graphics/engine/text.cpp2
-rw-r--r--src/graphics/engine/water.cpp61
-rw-r--r--src/graphics/engine/water.h4
-rw-r--r--src/graphics/opengl/gldevice.cpp7
18 files changed, 1745 insertions, 586 deletions
diff --git a/src/common/logger.cpp b/src/common/logger.cpp
index be73ec7..ed8df8c 100644
--- a/src/common/logger.cpp
+++ b/src/common/logger.cpp
@@ -43,8 +43,10 @@ void CLogger::Log(LogType type, const char *str, va_list args)
return;
switch (type) {
- case LOG_WARN: fprintf(IsOpened() ? mFile : stderr, "[WARN]: "); break;
- case LOG_INFO: fprintf(IsOpened() ? mFile : stderr, "[INFO]: "); break;
+ case LOG_TRACE: fprintf(IsOpened() ? mFile : stderr, "[TRACE]: "); break;
+ case LOG_DEBUG: fprintf(IsOpened() ? mFile : stderr, "[DEBUG]: "); break;
+ case LOG_WARN: fprintf(IsOpened() ? mFile : stderr, "[WARN]: "); break;
+ case LOG_INFO: fprintf(IsOpened() ? mFile : stderr, "[INFO]: "); break;
case LOG_ERROR: fprintf(IsOpened() ? mFile : stderr, "[ERROR]: "); break;
default: break;
}
@@ -53,6 +55,24 @@ void CLogger::Log(LogType type, const char *str, va_list args)
}
+void CLogger::Trace(const char *str, ...)
+{
+ va_list args;
+ va_start(args, str);
+ Log(LOG_TRACE, str, args);
+ va_end(args);
+}
+
+
+void CLogger::Debug(const char *str, ...)
+{
+ va_list args;
+ va_start(args, str);
+ Log(LOG_DEBUG, str, args);
+ va_end(args);
+}
+
+
void CLogger::Info(const char *str, ...)
{
va_list args;
diff --git a/src/common/logger.h b/src/common/logger.h
index f126e52..fc43735 100644
--- a/src/common/logger.h
+++ b/src/common/logger.h
@@ -38,10 +38,12 @@
**/
enum LogType
{
- LOG_INFO = 1, /*!< lowest level, information */
- LOG_WARN = 2, /*!< warning */
- LOG_ERROR = 3, /*!< error */
- LOG_NONE = 4 /*!< none level, used for custom messages */
+ LOG_TRACE = 1, /*!< lowest level, execution tracing */
+ LOG_DEBUG = 2, /*!< debugging messages */
+ LOG_INFO = 3, /*!< information */
+ LOG_WARN = 4, /*!< warning */
+ LOG_ERROR = 5, /*!< error */
+ LOG_NONE = 6 /*!< none level, used for custom messages */
};
@@ -63,6 +65,18 @@ class CLogger : public CSingleton<CLogger>
*/
void Message(const char *str, ...);
+ /** Write message to console or file with LOG_TRACE level
+ * @param str - message to write
+ * @param ... - additional arguments
+ */
+ void Trace(const char *str, ...);
+
+ /** Write message to console or file with LOG_DEBUG level
+ * @param str - message to write
+ * @param ... - additional arguments
+ */
+ void Debug(const char *str, ...);
+
/** Write message to console or file with LOG_INFO level
* @param str - message to write
* @param ... - additional arguments
diff --git a/src/graphics/core/material.h b/src/graphics/core/material.h
index eb73c50..156ff36 100644
--- a/src/graphics/core/material.h
+++ b/src/graphics/core/material.h
@@ -45,6 +45,16 @@ struct Material
Gfx::Color ambient;
//! Specular color
Gfx::Color specular;
+
+ bool operator==(const Gfx::Material &mat) const
+ {
+ return diffuse == mat.diffuse && ambient == mat.ambient && specular == mat.specular;
+ }
+
+ bool operator!=(const Gfx::Material &mat) const
+ {
+ return ! operator==(mat);
+ }
};
}; // namespace Gfx
diff --git a/src/graphics/core/texture.h b/src/graphics/core/texture.h
index c36b6c6..8abe86a 100644
--- a/src/graphics/core/texture.h
+++ b/src/graphics/core/texture.h
@@ -192,9 +192,7 @@ struct TextureStageParams
Also contains some additional data. */
struct Texture
{
- //! Whether the texture (ID) is valid
- bool valid;
- //! ID of the texture in graphics engine
+ //! ID of the texture in graphics engine; 0 = invalid texture
unsigned int id;
//! Size of texture
Math::IntPoint size;
@@ -203,23 +201,34 @@ struct Texture
Texture()
{
- valid = false;
id = 0;
alpha = false;
}
+ //! Returns whether the texture is valid (ID != 0)
+ bool Valid() const
+ {
+ return id != 0;
+ }
+
+ //! Sets the ID to invalid value (0)
+ void SetInvalid()
+ {
+ id = 0;
+ }
+
//! Comparator for use in texture maps and sets
inline bool operator<(const Gfx::Texture &other) const
{
// Invalid textures are always "less than" every other texture
- if ( (!valid) && (!other.valid) )
+ if ( (! Valid()) && (! other.Valid()) )
return false;
- if (!valid)
+ if (! Valid())
return true;
- if (!other.valid)
+ if (! other.Valid())
return false;
return id < other.id;
@@ -228,9 +237,9 @@ struct Texture
//! Comparator
inline bool operator==(const Gfx::Texture &other) const
{
- if (valid != other.valid)
+ if (Valid() != other.Valid())
return false;
- if ( (!valid) && (!other.valid) )
+ if ( (! Valid()) && (! other.Valid()) )
return true;
return id == other.id;
diff --git a/src/graphics/engine/cloud.cpp b/src/graphics/engine/cloud.cpp
index f3c0002..d7bac0f 100644
--- a/src/graphics/engine/cloud.cpp
+++ b/src/graphics/engine/cloud.cpp
@@ -43,7 +43,7 @@ Gfx::CCloud::CCloud(CInstanceManager* iMan, Gfx::CEngine* engine)
m_subdiv = 8;
m_enable = true;
- m_line.reserve(CLOUD_LINE_PREALLOCATE_COUNT);
+ m_lines.reserve(CLOUD_LINE_PREALLOCATE_COUNT);
}
Gfx::CCloud::~CCloud()
@@ -107,7 +107,7 @@ void Gfx::CCloud::Draw()
if ( !m_enable ) return;
if ( m_level == 0.0f ) return;
- if ( m_lineUsed == 0 ) return;
+ if ( m_linesUsed == 0 ) return;
vertex = (D3DVERTEX2*)malloc(sizeof(D3DVERTEX2)*(m_brick+2)*2);
@@ -155,11 +155,11 @@ void Gfx::CCloud::Draw()
n = Math::Vector(0.0f, -1.0f, 0.0f);
// Draws all the lines.
- for ( i=0 ; i<m_lineUsed ; i++ )
+ for ( i=0 ; i<m_linesUsed ; i++ )
{
pos.y = m_level;
- pos.z = m_line[i].pz;
- pos.x = m_line[i].px1;
+ pos.z = m_lines[i].pz;
+ pos.x = m_lines[i].px1;
u = 0;
p.x = pos.x-size;
@@ -174,7 +174,7 @@ void Gfx::CCloud::Draw()
AdjustLevel(p, eye, deep, uv1, uv2);
vertex[u++] = D3DVERTEX2(p, n, uv1.x,uv1.y, uv2.x,uv2.y);
- for ( j=0 ; j<m_line[i].len ; j++ )
+ for ( j=0 ; j<m_lines[i].len ; j++ )
{
p.x = pos.x+size;
p.z = pos.z+size;
@@ -216,7 +216,7 @@ void Gfx::CCloud::CreateLine(int x, int y, int len)
line.px2 = m_size*(line.x+line.len) - offset;
line.pz = m_size* line.y - offset;
- m_line.push_back(line);
+ m_lines.push_back(line);
}
void Gfx::CCloud::Create(const std::string& fileName,
@@ -247,7 +247,7 @@ void Gfx::CCloud::Create(const std::string& fileName,
if (m_level == 0.0f)
return;
- m_line.clear();
+ m_lines.clear();
for (int y = 0; y < m_brick; y++)
CreateLine(0, y, m_brick);
diff --git a/src/graphics/engine/cloud.h b/src/graphics/engine/cloud.h
index 881a598..079f77b 100644
--- a/src/graphics/engine/cloud.h
+++ b/src/graphics/engine/cloud.h
@@ -114,7 +114,7 @@ protected:
//! Size of a brick element
float m_size;
- std::vector<Gfx::CloudLine> m_line;
+ std::vector<Gfx::CloudLine> m_lines;
bool m_enable;
};
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp
index 644ecaf..ddc6b23 100644
--- a/src/graphics/engine/engine.cpp
+++ b/src/graphics/engine/engine.cpp
@@ -47,9 +47,46 @@ const int GROUNDSPOT_PREALLOCATE_COUNT = 100;
const int LEVEL1_PREALLOCATE_COUNT = 50;
const int LEVEL2_PREALLOCATE_COUNT = 100;
const int LEVEL3_PREALLOCATE_COUNT = 5;
-const int LEVEL4_PREALLOCATE_COUNT = 10;
-const int LEVEL5_PREALLOCATE_COUNT = 100;
-const int LEVEL5_VERTEX_PREALLOCATE_COUNT = 200;
+const int LEVEL4_PREALLOCATE_COUNT = 100;
+const int LEVEL4_VERTEX_PREALLOCATE_COUNT = 200;
+
+
+Gfx::EngineObjLevel1::EngineObjLevel1(bool used, const std::string& tex1Name, const std::string& tex2Name)
+{
+ this->used = used;
+ this->tex1Name = tex1Name;
+ this->tex2Name = tex2Name;
+
+ next.reserve(LEVEL2_PREALLOCATE_COUNT);
+}
+
+Gfx::EngineObjLevel2::EngineObjLevel2(bool used, int objRank)
+{
+ this->used = used;
+ this->objRank = objRank;
+
+ next.reserve(LEVEL3_PREALLOCATE_COUNT);
+}
+
+Gfx::EngineObjLevel3::EngineObjLevel3(bool used, float min, float max)
+{
+ this->used = used;
+ this->min = min;
+ this->max = max;
+
+ next.reserve(LEVEL4_PREALLOCATE_COUNT);
+}
+
+Gfx::EngineObjLevel4::EngineObjLevel4(bool used, Gfx::EngineTriangleType type, const Gfx::Material& material, int state)
+{
+ this->used = used;
+ this->type = type;
+ this->material = material;
+ this->state = state;
+
+ vertices.reserve(LEVEL4_VERTEX_PREALLOCATE_COUNT);
+}
+
// TODO: temporary stub for CInterface
@@ -247,7 +284,7 @@ bool Gfx::CEngine::Create()
params.minFilter = Gfx::TEX_MIN_FILTER_NEAREST;
params.magFilter = Gfx::TEX_MAG_FILTER_NEAREST;
params.mipmap = false;
- m_miceTexture = CreateTexture("mouse.png", params);
+ m_miceTexture = LoadTexture("mouse.png", params);
return true;
}
@@ -301,22 +338,13 @@ bool Gfx::CEngine::ProcessEvent(const Event &event)
}
else if (event.key.key == KEY(F3))
{
- m_backgroundQuarter = !m_backgroundQuarter;
- if (m_backgroundQuarter)
- {
- m_backgroundFull = true;
- m_backgroundName = "geneda.png";
- }
- else
- {
- m_backgroundFull = false;
- m_backgroundName = "";
- }
+ bool bq = !m_backgroundQuarter;
+ SetBackground(bq ? "geneda.png" : "", Gfx::Color(), Gfx::Color(), Gfx::Color(), Gfx::Color(), true, bq);
}
else if (event.key.key == KEY(F4))
{
- m_backForce = !m_backForce;
- if (m_backForce)
+ m_skyMode = !m_skyMode;
+ if (! m_skyMode)
{
m_backgroundColorDown = Gfx::Color(0.2f, 0.2f, 0.2f);
m_backgroundColorUp = Gfx::Color(0.8f, 0.8f, 0.8f);
@@ -386,19 +414,20 @@ void Gfx::CEngine::StepSimulation(float rTime)
bool Gfx::CEngine::WriteScreenShot(const std::string& fileName, int width, int height)
{
- // TODO!
+ // TODO write screenshot: not very important for now
+ GetLogger()->Trace("CEngine::WriteSceenShot(): stub!\n");
return true;
}
bool Gfx::CEngine::ReadSettings()
{
- // TODO!
+ // TODO: when INI reading is completed
return true;
}
bool Gfx::CEngine::WriteSettings()
{
- // TODO!
+ // TODO: when INI writing is completed
return true;
}
@@ -496,207 +525,898 @@ int Gfx::CEngine::GetStatisticTriangle()
int Gfx::CEngine::CreateObject()
{
- // TODO!
- return 0;
+ int i = 0;
+ for ( ; i < static_cast<int>( m_objects.size() ); i++)
+ {
+ if (! m_objects[i].used)
+ {
+ m_objects[i].LoadDefault();
+ break;
+ }
+ }
+
+ if (i == static_cast<int>( m_objects.size() ))
+ m_objects.push_back(Gfx::EngineObject());
+
+
+ m_objects[i].used = true;
+
+ Math::Matrix mat;
+ mat.LoadIdentity();
+ SetObjectTransform(i, mat);
+
+ m_objects[i].drawWorld = true;
+ m_objects[i].distance = 0.0f;
+ m_objects[i].bboxMin = Math::Vector(0.0f, 0.0f, 0.0f);
+ m_objects[i].bboxMax = Math::Vector(0.0f, 0.0f, 0.0f);
+ m_objects[i].shadowRank = -1;
+
+ return i;
}
void Gfx::CEngine::FlushObject()
{
- // TODO!
+ m_objectTree.clear();
+ m_objects.clear();
+
+ m_shadows.clear();
+
+ FlushGroundSpot();
}
bool Gfx::CEngine::DeleteObject(int objRank)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ // Delete object's triangles
+ for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ {
+ Gfx::EngineObjLevel1& p1 = m_objectTree[l1];
+ if (! p1.used) continue;
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ Gfx::EngineObjLevel2& p2 = p1.next[l2];
+ if (! p2.used) continue;
+
+ if (p2.objRank == objRank)
+ {
+ p2.used = false;
+ p2.next.clear();
+ }
+ }
+ }
+
+ // Mark object as deleted
+ m_objects[objRank].used = false;
+
+ // Delete associated shadows
+ DeleteShadow(objRank);
+
return true;
}
-bool Gfx::CEngine::SetDrawWorld(int objRank, bool draw)
+bool Gfx::CEngine::SetObjectType(int objRank, Gfx::EngineObjectType type)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ m_objects[objRank].type = type;
return true;
}
-bool Gfx::CEngine::SetDrawFront(int objRank, bool draw)
+Gfx::EngineObjectType Gfx::CEngine::GetObjectType(int objRank)
{
- // TODO!
- return true;
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return Gfx::ENG_OBJTYPE_NULL;
+
+ return m_objects[objRank].type;
}
-bool Gfx::CEngine::AddTriangle(int objRank, Gfx::VertexTex2* vertex, int nb,
- const Gfx::Material& mat, int state,
- std::string texName1, std::string texName2,
- float min, float max, bool globalUpdate)
+
+bool Gfx::CEngine::SetObjectTransform(int objRank, const Math::Matrix& transform)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ m_objects[objRank].transform = transform;
return true;
}
-bool Gfx::CEngine::AddSurface(int objRank, Gfx::VertexTex2* vertex, int nb,
- const Gfx::Material& mat, int state,
- std::string texName1, std::string texName2,
- float min, float max, bool globalUpdate)
+bool Gfx::CEngine::GetObjectTransform(int objRank, Math::Matrix& transform)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ transform = m_objects[objRank].transform;
return true;
}
-bool Gfx::CEngine::AddQuick(int objRank, const Gfx::EngineObjLevel5& buffer,
- std::string texName1, std::string texName2,
- float min, float max, bool globalUpdate)
+bool Gfx::CEngine::SetObjectDrawWorld(int objRank, bool draw)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ m_objects[objRank].drawWorld = draw;
return true;
}
-Gfx::EngineObjLevel5* Gfx::CEngine::SearchTriangle(int objRank, const Gfx::Material& mat,
- int state, std::string texName1,
- std::string texName2, float min, float max)
+bool Gfx::CEngine::SetObjectDrawFront(int objRank, bool draw)
{
- // TODO!
- return nullptr;
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ m_objects[objRank].drawFront = draw;
+ return true;
}
-void Gfx::CEngine::ChangeLOD()
+bool Gfx::CEngine::SetObjectTransparency(int objRank, float value)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ m_objects[objRank].transparency = value;
+ return true;
}
-bool Gfx::CEngine::ChangeSecondTexture(int objRank, const std::string& texName2)
+bool Gfx::CEngine::GetObjectBBox(int objRank, Math::Vector& min, Math::Vector& max)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return 0;
+
+ min = m_objects[objRank].bboxMin;
+ max = m_objects[objRank].bboxMax;
return true;
}
-int Gfx::CEngine::GetTotalTriangles(int objRank)
+
+int Gfx::CEngine::GetObjectTotalTriangles(int objRank)
{
- // TODO!
- return 0;
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return 0;
+
+ return m_objects[objRank].totalTriangles;
}
-int Gfx::CEngine::GetTriangles(int objRank, float min, float max, Gfx::EngineTriangle* buffer, int size, float percent)
+
+Gfx::EngineObjLevel1& Gfx::CEngine::AddLevel1(const std::string& tex1Name, const std::string& tex2Name)
{
- // TODO!
- return 0;
+ bool unusedPresent = false;
+ for (int i = 0; i < static_cast<int>( m_objectTree.size() ); i++)
+ {
+ if (! m_objectTree[i].used)
+ {
+ unusedPresent = true;
+ continue;
+ }
+
+ if (m_objectTree[i].tex1Name == tex1Name && m_objectTree[i].tex2Name == tex2Name)
+ return m_objectTree[i];
+ }
+
+ if (unusedPresent)
+ {
+ for (int i = 0; i < static_cast<int>( m_objectTree.size() ); i++)
+ {
+ if (! m_objectTree[i].used)
+ {
+ m_objectTree[i].used = true;
+ m_objectTree[i].tex1Name = tex1Name;
+ m_objectTree[i].tex2Name = tex2Name;
+ return m_objectTree[i];
+ }
+ }
+ }
+
+ m_objectTree.push_back(Gfx::EngineObjLevel1(true, tex1Name, tex2Name));
+ return m_objectTree.back();
}
-bool Gfx::CEngine::GetBBox(int objRank, Math::Vector& min, Math::Vector& max)
+Gfx::EngineObjLevel2& Gfx::CEngine::AddLevel2(Gfx::EngineObjLevel1& p1, int objRank)
{
- // TODO!
- return true;
+ bool unusedPresent = false;
+ for (int i = 0; i < static_cast<int>( p1.next.size() ); i++)
+ {
+ if (! p1.next[i].used)
+ {
+ unusedPresent = true;
+ continue;
+ }
+
+ if (p1.next[i].objRank == objRank)
+ return p1.next[i];
+ }
+
+ if (unusedPresent)
+ {
+ for (int i = 0; i < static_cast<int>( p1.next.size() ); i++)
+ {
+ if (! p1.next[i].used)
+ {
+ p1.next[i].used = true;
+ p1.next[i].objRank = objRank;
+ return p1.next[i];
+ }
+ }
+ }
+
+ p1.next.push_back(Gfx::EngineObjLevel2(true, objRank));
+ return p1.next.back();
}
-bool Gfx::CEngine::ChangeTextureMapping(int objRank, const Gfx::Material& mat, int state,
- const std::string& texName1, const std::string& texName2,
- float min, float max, Gfx::EngineTextureMapping mode,
- float au, float bu, float av, float bv)
+Gfx::EngineObjLevel3& Gfx::CEngine::AddLevel3(Gfx::EngineObjLevel2& p2, float min, float max)
{
- // TODO!
- return true;
+ bool unusedPresent = false;
+ for (int i = 0; i < static_cast<int>( p2.next.size() ); i++)
+ {
+ if (! p2.next[i].used)
+ {
+ unusedPresent = true;
+ continue;
+ }
+
+ if ( (p2.next[i].min == min) && (p2.next[i].max == max) )
+ return p2.next[i];
+ }
+
+ if (unusedPresent)
+ {
+ for (int i = 0; i < static_cast<int>( p2.next.size() ); i++)
+ {
+ if (! p2.next[i].used)
+ {
+ p2.next[i].used = true;
+ p2.next[i].min = min;
+ p2.next[i].max = max;
+ return p2.next[i];
+ }
+ }
+ }
+
+ p2.next.push_back(Gfx::EngineObjLevel3(true, min, max));
+ return p2.next.back();
}
-bool Gfx::CEngine::TrackTextureMapping(int objRank, const Gfx::Material& mat, int state,
- const std::string& texName1, const std::string& texName2,
- float min, float max, Gfx::EngineTextureMapping mode,
- float pos, float factor, float tl, float ts, float tt)
+Gfx::EngineObjLevel4& Gfx::CEngine::AddLevel4(Gfx::EngineObjLevel3& p3, Gfx::EngineTriangleType type,
+ const Gfx::Material& material, int state)
{
- // TODO!
+ bool unusedPresent = false;
+ for (int i = 0; i < static_cast<int>( p3.next.size() ); i++)
+ {
+ if (! p3.next[i].used)
+ {
+ unusedPresent = true;
+ continue;
+ }
+
+ if ( (p3.next[i].type == type) && (p3.next[i].material == material) && (p3.next[i].state == state) )
+ return p3.next[i];
+ }
+
+ if (unusedPresent)
+ {
+ for (int i = 0; i < static_cast<int>( p3.next.size() ); i++)
+ {
+ if (! p3.next[i].used)
+ {
+ p3.next[i].used = true;
+ p3.next[i].type = type;
+ p3.next[i].material = material;
+ p3.next[i].state = state;
+ return p3.next[i];
+ }
+ }
+ }
+
+ p3.next.push_back(Gfx::EngineObjLevel4(true, type, material, state));
+ return p3.next.back();
+}
+
+bool Gfx::CEngine::AddTriangles(int objRank, const std::vector<Gfx::VertexTex2>& vertices,
+ const Gfx::Material& material, int state,
+ std::string tex1Name, std::string tex2Name,
+ float min, float max, bool globalUpdate)
+{
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ {
+ GetLogger()->Error("AddTriangle(): invalid object rank %d\n", objRank);
+ return false;
+ }
+
+ m_lastSize = m_size;
+ m_lastObjectDetail = m_objectDetail;
+ m_lastClippingDistance = m_clippingDistance;
+
+ Gfx::EngineObjLevel1& p1 = AddLevel1(tex1Name, tex2Name);
+ Gfx::EngineObjLevel2& p2 = AddLevel2(p1, objRank);
+ Gfx::EngineObjLevel3& p3 = AddLevel3(p2, min, max);
+ Gfx::EngineObjLevel4& p4 = AddLevel4(p3, Gfx::ENG_TRIANGLE_TYPE_TRIANGLES, material, state);
+
+ p4.vertices.insert(p4.vertices.end(), vertices.begin(), vertices.end());
+
+ if (globalUpdate)
+ {
+ m_updateGeometry = true;
+ }
+ else
+ {
+ for (int i = 0; i < static_cast<int>( vertices.size() ); i++)
+ {
+ m_objects[objRank].bboxMin.x = Math::Min(vertices[i].coord.x, m_objects[objRank].bboxMin.x);
+ m_objects[objRank].bboxMin.y = Math::Min(vertices[i].coord.y, m_objects[objRank].bboxMin.y);
+ m_objects[objRank].bboxMin.z = Math::Min(vertices[i].coord.z, m_objects[objRank].bboxMin.z);
+ m_objects[objRank].bboxMax.x = Math::Max(vertices[i].coord.x, m_objects[objRank].bboxMax.x);
+ m_objects[objRank].bboxMax.y = Math::Max(vertices[i].coord.y, m_objects[objRank].bboxMax.y);
+ m_objects[objRank].bboxMax.z = Math::Max(vertices[i].coord.z, m_objects[objRank].bboxMax.z);
+ }
+
+ m_objects[objRank].radius = Math::Max(m_objects[objRank].bboxMin.Length(),
+ m_objects[objRank].bboxMax.Length());
+ }
+
+ m_objects[objRank].totalTriangles += vertices.size() / 3;
+
return true;
}
-bool Gfx::CEngine::SetObjectTransform(int objRank, const Math::Matrix& transform)
+bool Gfx::CEngine::AddSurface(int objRank, const std::vector<Gfx::VertexTex2>& vertices,
+ const Gfx::Material& material, int state,
+ std::string tex1Name, std::string tex2Name,
+ float min, float max, bool globalUpdate)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ {
+ GetLogger()->Error("AddSurface(): invalid object rank %d\n", objRank);
+ return false;
+ }
+
+ m_lastSize = m_size;
+ m_lastObjectDetail = m_objectDetail;
+ m_lastClippingDistance = m_clippingDistance;
+
+ Gfx::EngineObjLevel1& p1 = AddLevel1(tex1Name, tex2Name);
+ Gfx::EngineObjLevel2& p2 = AddLevel2(p1, objRank);
+ Gfx::EngineObjLevel3& p3 = AddLevel3(p2, min, max);
+ Gfx::EngineObjLevel4& p4 = AddLevel4(p3, Gfx::ENG_TRIANGLE_TYPE_SURFACE, material, state);
+
+ p4.vertices.insert(p4.vertices.end(), vertices.begin(), vertices.end());
+
+ if (globalUpdate)
+ {
+ m_updateGeometry = true;
+ }
+ else
+ {
+ for (int i = 0; i < static_cast<int>( vertices.size() ); i++)
+ {
+ m_objects[objRank].bboxMin.x = Math::Min(vertices[i].coord.x, m_objects[objRank].bboxMin.x);
+ m_objects[objRank].bboxMin.y = Math::Min(vertices[i].coord.y, m_objects[objRank].bboxMin.y);
+ m_objects[objRank].bboxMin.z = Math::Min(vertices[i].coord.z, m_objects[objRank].bboxMin.z);
+ m_objects[objRank].bboxMax.x = Math::Max(vertices[i].coord.x, m_objects[objRank].bboxMax.x);
+ m_objects[objRank].bboxMax.y = Math::Max(vertices[i].coord.y, m_objects[objRank].bboxMax.y);
+ m_objects[objRank].bboxMax.z = Math::Max(vertices[i].coord.z, m_objects[objRank].bboxMax.z);
+ }
+
+ m_objects[objRank].radius = Math::Max(m_objects[objRank].bboxMin.Length(),
+ m_objects[objRank].bboxMax.Length());
+ }
+
+ m_objects[objRank].totalTriangles += vertices.size() - 2;
+
return true;
}
-bool Gfx::CEngine::GetObjectTransform(int objRank, Math::Matrix& transform)
+bool Gfx::CEngine::AddQuick(int objRank, const Gfx::EngineObjLevel4& buffer,
+ std::string tex1Name, std::string tex2Name,
+ float min, float max, bool globalUpdate)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ {
+ GetLogger()->Error("AddQuick(): invalid object rank %d\n", objRank);
+ return false;
+ }
+
+ Gfx::EngineObjLevel1& p1 = AddLevel1(tex1Name, tex2Name);
+ Gfx::EngineObjLevel2& p2 = AddLevel2(p1, objRank);
+ Gfx::EngineObjLevel3& p3 = AddLevel3(p2, min, max);
+
+ p3.next.push_back(buffer);
+ p3.next.back().used = true; // ensure that it is used
+
+ if (globalUpdate)
+ {
+ m_updateGeometry = true;
+ }
+ else
+ {
+ for (int i = 0; i < static_cast<int>( buffer.vertices.size() ); i++)
+ {
+ m_objects[objRank].bboxMin.x = Math::Min(buffer.vertices[i].coord.x, m_objects[objRank].bboxMin.x);
+ m_objects[objRank].bboxMin.y = Math::Min(buffer.vertices[i].coord.y, m_objects[objRank].bboxMin.y);
+ m_objects[objRank].bboxMin.z = Math::Min(buffer.vertices[i].coord.z, m_objects[objRank].bboxMin.z);
+ m_objects[objRank].bboxMax.x = Math::Max(buffer.vertices[i].coord.x, m_objects[objRank].bboxMax.x);
+ m_objects[objRank].bboxMax.y = Math::Max(buffer.vertices[i].coord.y, m_objects[objRank].bboxMax.y);
+ m_objects[objRank].bboxMax.z = Math::Max(buffer.vertices[i].coord.z, m_objects[objRank].bboxMax.z);
+ }
+
+ m_objects[objRank].radius = Math::Max(m_objects[objRank].bboxMin.Length(),
+ m_objects[objRank].bboxMax.Length());
+ }
+
+ if (buffer.type == Gfx::ENG_TRIANGLE_TYPE_TRIANGLES)
+ m_objects[objRank].totalTriangles += buffer.vertices.size() / 3;
+ else // surfaces
+ m_objects[objRank].totalTriangles += buffer.vertices.size() - 2;
+
return true;
}
-bool Gfx::CEngine::SetObjectType(int objRank, Gfx::EngineObjectType type)
+Gfx::EngineObjLevel4* Gfx::CEngine::FindTriangles(int objRank, const Gfx::Material& material,
+ int state, std::string tex1Name,
+ std::string tex2Name, float min, float max)
+{
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ {
+ GetLogger()->Error("FindTriangles(): invalid object rank %d\n", objRank);
+ return nullptr;
+ }
+
+ for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ {
+ Gfx::EngineObjLevel1& p1 = m_objectTree[l1];
+ if (! p1.used) continue;
+
+ if (p1.tex1Name != tex1Name) continue;
+ // TODO: tex2Name compare?
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ Gfx::EngineObjLevel2& p2 = p1.next[l2];
+ if (! p2.used) continue;
+
+ if (p2.objRank != objRank) continue;
+
+ for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
+ {
+ Gfx::EngineObjLevel3& p3 = p2.next[l1];
+ if (! p3.used) continue;
+
+ if (p3.min != min || p3.max != max) continue;
+
+ for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
+ {
+ Gfx::EngineObjLevel4& p4 = p3.next[l4];
+ if (! p4.used) continue;
+
+ if ( (p4.state & (~(Gfx::ENG_RSTATE_DUAL_BLACK|Gfx::ENG_RSTATE_DUAL_WHITE))) != state ||
+ p4.material != material )
+ continue;
+
+ return &p4;
+ }
+ }
+ }
+ }
+
+ return nullptr;
+}
+
+int Gfx::CEngine::GetPartialTriangles(int objRank, float min, float max, float percent, int maxCount,
+ std::vector<Gfx::EngineTriangle>& triangles)
+{
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ {
+ GetLogger()->Error("GetPartialTriangles(): invalid object rank %d\n", objRank);
+ return 0;
+ }
+
+ int total = m_objects[objRank].totalTriangles;
+ int expectedCount = static_cast<int>(percent * total);
+ triangles.reserve(Math::Min(maxCount, expectedCount));
+
+ int actualCount = 0;
+
+ for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ {
+ Gfx::EngineObjLevel1& p1 = m_objectTree[l1];
+ if (! p1.used) continue;
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ Gfx::EngineObjLevel2& p2 = p1.next[l2];
+ if (! p2.used) continue;
+
+ if (p2.objRank != objRank) continue;
+
+ for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
+ {
+ Gfx::EngineObjLevel3& p3 = p2.next[l1];
+ if (! p3.used) continue;
+
+ if (p3.min != min || p3.max != max) continue;
+
+ for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
+ {
+ Gfx::EngineObjLevel4& p4 = p3.next[l4];
+ if (! p4.used) continue;
+
+ if (p4.type == Gfx::ENG_TRIANGLE_TYPE_TRIANGLES)
+ {
+ for (int i = 0; i < static_cast<int>( p4.vertices.size() ); i += 3)
+ {
+ if (static_cast<float>(actualCount) / total >= percent)
+ break;
+
+ if (actualCount >= maxCount)
+ break;
+
+ Gfx::EngineTriangle t;
+ t.triangle[0] = p4.vertices[i];
+ t.triangle[1] = p4.vertices[i+1];
+ t.triangle[2] = p4.vertices[i+2];
+ t.material = p4.material;
+ t.state = p4.state;
+ t.tex1Name = p1.tex1Name;
+ t.tex2Name = p1.tex2Name;
+
+ triangles.push_back(t);
+
+ ++actualCount;
+ }
+ }
+ else if (p4.type == Gfx::ENG_TRIANGLE_TYPE_SURFACE)
+ {
+ for (int i = 0; i < static_cast<int>( p4.vertices.size() ); i += 1)
+ {
+ if (static_cast<float>(actualCount) / total >= percent)
+ break;
+
+ if (actualCount >= maxCount)
+ break;
+
+ Gfx::EngineTriangle t;
+ t.triangle[0] = p4.vertices[i];
+ t.triangle[1] = p4.vertices[i+1];
+ t.triangle[2] = p4.vertices[i+2];
+ t.material = p4.material;
+ t.state = p4.state;
+ t.tex1Name = p1.tex1Name;
+ t.tex2Name = p1.tex2Name;
+
+ triangles.push_back(t);
+
+ ++actualCount;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return actualCount;
+}
+
+void Gfx::CEngine::ChangeLOD()
{
- // TODO!
+ float oldLimit[2] =
+ {
+ GetLimitLOD(0, true),
+ GetLimitLOD(1, true)
+ };
+
+ float newLimit[2] =
+ {
+ GetLimitLOD(0, false),
+ GetLimitLOD(1, false)
+ };
+
+ float oldTerrain = m_terrainVision * m_lastClippingDistance;
+ float newTerrain = m_terrainVision * m_clippingDistance;
+
+ for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ {
+ Gfx::EngineObjLevel1& p1 = m_objectTree[l1];
+ if (! p1.used) continue;
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ Gfx::EngineObjLevel2& p2 = p1.next[l2];
+ if (! p2.used) continue;
+
+ for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
+ {
+ Gfx::EngineObjLevel3& p3 = p2.next[l1];
+ if (! p3.used) continue;
+
+ if ( Math::IsEqual(p3.min, 0.0f ) &&
+ Math::IsEqual(p3.max, oldLimit[0]) )
+ {
+ p3.max = newLimit[0];
+ }
+ else if ( Math::IsEqual(p3.min, oldLimit[0]) &&
+ Math::IsEqual(p3.max, oldLimit[1]) )
+ {
+ p3.min = newLimit[0];
+ p3.max = newLimit[1];
+ }
+ else if ( Math::IsEqual(p3.min, oldLimit[1]) &&
+ Math::IsEqual(p3.max, 1000000.0f ) )
+ {
+ p3.min = newLimit[1];
+ }
+ else if ( Math::IsEqual(p3.min, 0.0f ) &&
+ Math::IsEqual(p3.max, oldTerrain) )
+ {
+ p3.max = newTerrain;
+ }
+ }
+ }
+ }
+
+ m_lastSize = m_size;
+ m_lastObjectDetail = m_objectDetail;
+ m_lastClippingDistance = m_clippingDistance;
+}
+
+bool Gfx::CEngine::ChangeSecondTexture(int objRank, const std::string& tex2Name)
+{
+ for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ {
+ Gfx::EngineObjLevel1& p1 = m_objectTree[l1];
+ if (! p1.used) continue;
+
+ if (p1.tex2Name == tex2Name) continue; // already new
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ Gfx::EngineObjLevel2& p2 = p1.next[l2];
+ if (! p2.used) continue;
+
+ if (p2.objRank != objRank) continue;
+
+ Gfx::EngineObjLevel1& newP1 = AddLevel1(p1.tex1Name, tex2Name);
+
+ newP1.next.push_back(Gfx::EngineObjLevel2(true, objRank));
+
+ Gfx::EngineObjLevel2& newP2 = newP1.next.back();
+ newP2.next.swap(p2.next);
+
+ p2.used = false;
+ }
+ }
return true;
}
-Gfx::EngineObjectType Gfx::CEngine::GetObjectType(int objRank)
+bool Gfx::CEngine::ChangeTextureMapping(int objRank, const Gfx::Material& mat, int state,
+ const std::string& tex1Name, const std::string& tex2Name,
+ float min, float max, Gfx::EngineTextureMapping mode,
+ float au, float bu, float av, float bv)
{
- // TODO!
- return Gfx::ENG_OBJTYPE_FIX;
+ Gfx::EngineObjLevel4* p4 = FindTriangles(objRank, mat, state, tex1Name, tex2Name, min, max);
+ if (p4 == nullptr)
+ return false;
+
+ int nb = p4->vertices.size();
+
+ if (mode == Gfx::ENG_TEX_MAPPING_X)
+ {
+ for (int i = 0; i < nb; i++)
+ {
+ p4->vertices[i].texCoord.x = p4->vertices[i].coord.z * au + bu;
+ p4->vertices[i].texCoord.y = p4->vertices[i].coord.y * av + bv;
+ }
+ }
+ else if (mode == Gfx::ENG_TEX_MAPPING_Y)
+ {
+ for (int i = 0; i < nb; i++)
+ {
+ p4->vertices[i].texCoord.x = p4->vertices[i].coord.x * au + bu;
+ p4->vertices[i].texCoord.y = p4->vertices[i].coord.z * av + bv;
+ }
+ }
+ else if (mode == Gfx::ENG_TEX_MAPPING_Z)
+ {
+ for (int i = 0; i < nb; i++)
+ {
+ p4->vertices[i].texCoord.x = p4->vertices[i].coord.x * au + bu;
+ p4->vertices[i].texCoord.y = p4->vertices[i].coord.y * av + bv;
+ }
+ }
+ else if (mode == Gfx::ENG_TEX_MAPPING_1X)
+ {
+ for (int i = 0; i < nb; i++)
+ {
+ p4->vertices[i].texCoord.x = p4->vertices[i].coord.x * au + bu;
+ }
+ }
+ else if (mode == Gfx::ENG_TEX_MAPPING_1Y)
+ {
+ for (int i = 0; i < nb; i++)
+ {
+ p4->vertices[i].texCoord.y = p4->vertices[i].coord.y * au + bu;
+ }
+ }
+ else if (mode == Gfx::ENG_TEX_MAPPING_1Z)
+ {
+ for (int i = 0; i < nb; i++)
+ {
+ p4->vertices[i].texCoord.x = p4->vertices[i].coord.z * au + bu;
+ }
+ }
+
+ return true;
}
-bool Gfx::CEngine::SetObjectTransparency(int objRank, float value)
+bool Gfx::CEngine::TrackTextureMapping(int objRank, const Gfx::Material& mat, int state,
+ const std::string& tex1Name, const std::string& tex2Name,
+ float min, float max, Gfx::EngineTextureMapping mode,
+ float pos, float factor, float tl, float ts, float tt)
{
- // TODO!
+ // TODO track texture mapping: pretty complex code, so leaving it for now
+ GetLogger()->Trace("CEngine::TrackTextureMapping(): stub!\n");
return true;
}
-bool Gfx::CEngine::ShadowCreate(int objRank)
+
+bool Gfx::CEngine::CreateShadow(int objRank)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ // Already allocated?
+ if (m_objects[objRank].shadowRank != -1) return true;
+
+ int index = 0;
+ for ( ; index < static_cast<int>( m_shadows.size() ); index++)
+ {
+ if (! m_shadows[index].used)
+ {
+ m_shadows[index].LoadDefault();
+ break;
+ }
+ }
+
+ m_shadows.push_back(Gfx::EngineShadow());
+
+ m_shadows[index].used = true;
+ m_shadows[index].objRank = objRank;
+ m_shadows[index].height = 0.0f;
+
+ m_objects[objRank].shadowRank = index;
+
return true;
}
-void Gfx::CEngine::ShadowDelete(int objRank)
+void Gfx::CEngine::DeleteShadow(int objRank)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return;
+
+ int i = m_objects[objRank].shadowRank;
+ if (i == -1)
+ return;
+
+ m_shadows[i].used = false;
+ m_shadows[i].objRank = -1;
+
+ m_objects[objRank].shadowRank = -1;
}
bool Gfx::CEngine::SetObjectShadowHide(int objRank, bool hide)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ int i = m_objects[objRank].shadowRank;
+ if (i == -1)
+ return false;
+
+ m_shadows[i].hide = hide;
return true;
}
bool Gfx::CEngine::SetObjectShadowType(int objRank, Gfx::EngineShadowType type)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ int i = m_objects[objRank].shadowRank;
+ if (i == -1)
+ return false;
+
+ m_shadows[i].type = type;
return true;
}
bool Gfx::CEngine::SetObjectShadowPos(int objRank, const Math::Vector& pos)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ int i = m_objects[objRank].shadowRank;
+ if (i == -1)
+ return false;
+
+ m_shadows[i].pos = pos;
return true;
}
-bool Gfx::CEngine::SetObjectShadowNormal(int objRank, const Math::Vector& n)
+bool Gfx::CEngine::SetObjectShadowNormal(int objRank, const Math::Vector& normal)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ int i = m_objects[objRank].shadowRank;
+ if (i == -1)
+ return false;
+
+ m_shadows[i].normal = normal;
return true;
}
bool Gfx::CEngine::SetObjectShadowAngle(int objRank, float angle)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ int i = m_objects[objRank].shadowRank;
+ if (i == -1)
+ return false;
+
+ m_shadows[i].angle = angle;
return true;
}
bool Gfx::CEngine::SetObjectShadowRadius(int objRank, float radius)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ int i = m_objects[objRank].shadowRank;
+ if (i == -1)
+ return false;
+
+ m_shadows[i].radius = radius;
return true;
}
bool Gfx::CEngine::SetObjectShadowIntensity(int objRank, float intensity)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ int i = m_objects[objRank].shadowRank;
+ if (i == -1)
+ return false;
+
+ m_shadows[i].intensity = intensity;
return true;
}
-bool Gfx::CEngine::SetObjectShadowHeight(int objRank, float h)
+bool Gfx::CEngine::SetObjectShadowHeight(int objRank, float height)
{
- // TODO!
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return false;
+
+ int i = m_objects[objRank].shadowRank;
+ if (i == -1)
+ return false;
+
+ m_shadows[i].height = height;
return true;
}
float Gfx::CEngine::GetObjectShadowRadius(int objRank)
{
- // TODO!
- return 0.0f;
+ if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
+ return 0.0f;
+
+ int i = m_objects[objRank].shadowRank;
+ if (i == -1)
+ return 0.0f;
+
+ return m_shadows[i].radius;
}
bool Gfx::CEngine::GetHighlight(Math::Point &p1, Math::Point &p2)
@@ -752,74 +1472,182 @@ bool Gfx::CEngine::GetBBox2D(int objRank, Math::Point &min, Math::Point &max)
return true;
}
-void Gfx::CEngine::GroundSpotFlush()
+void Gfx::CEngine::FlushGroundSpot()
{
- // TODO
+ m_groundSpots.clear();
+ m_firstGroundSpot = true;
+
+ // TODO: blank all shadow textures
}
-int Gfx::CEngine::GroundSpotCreate()
+int Gfx::CEngine::CreateGroundSpot()
{
- // TODO!
- return 0;
+ int index = 0;
+ for ( ; index < static_cast<int>( m_groundSpots.size() ); index++)
+ {
+ if (! m_groundSpots[index].used)
+ {
+ m_groundSpots[index].LoadDefault();
+ break;
+ }
+ }
+
+ m_groundSpots.push_back(Gfx::EngineGroundSpot());
+
+ m_groundSpots[index].used = true;
+ m_groundSpots[index].smooth = 1.0f;
+
+ return index;
}
-void Gfx::CEngine::GroundSpotDelete(int rank)
+void Gfx::CEngine::DeleteGroundSpot(int rank)
{
- // TODO!
+ m_groundSpots[rank].used = false;
+ m_groundSpots[rank].pos = Math::Vector(0.0f, 0.0f, 0.0f);
}
bool Gfx::CEngine::SetObjectGroundSpotPos(int rank, const Math::Vector& pos)
{
- // TODO!
+ if ( rank < 0 || rank >= static_cast<int>( m_groundSpots.size() ) )
+ return 0.0f;
+
+ m_groundSpots[rank].pos = pos;
return true;
}
bool Gfx::CEngine::SetObjectGroundSpotRadius(int rank, float radius)
{
- // TODO!
+ if ( rank < 0 || rank >= static_cast<int>( m_groundSpots.size() ) )
+ return 0.0f;
+
+ m_groundSpots[rank].radius = radius;
return true;
}
bool Gfx::CEngine::SetObjectGroundSpotColor(int rank, const Gfx::Color& color)
{
- // TODO!
+ if ( rank < 0 || rank >= static_cast<int>( m_groundSpots.size() ) )
+ return 0.0f;
+
+ m_groundSpots[rank].color = color;
return true;
}
bool Gfx::CEngine::SetObjectGroundSpotMinMax(int rank, float min, float max)
{
- // TODO!
+ if ( rank < 0 || rank >= static_cast<int>( m_groundSpots.size() ) )
+ return 0.0f;
+
+ m_groundSpots[rank].min = min;
+ m_groundSpots[rank].max = max;
return true;
}
bool Gfx::CEngine::SetObjectGroundSpotSmooth(int rank, float smooth)
{
- // TODO!
+ if ( rank < 0 || rank >= static_cast<int>( m_groundSpots.size() ) )
+ return 0.0f;
+
+ m_groundSpots[rank].smooth = smooth;
return true;
}
-int Gfx::CEngine::GroundMarkCreate(Math::Vector pos, float radius,
+void Gfx::CEngine::CreateGroundMark(Math::Vector pos, float radius,
float delay1, float delay2, float delay3,
int dx, int dy, char* table)
{
- // TODO!
- return 0;
+ m_groundMark.LoadDefault();
+
+ m_groundMark.phase = Gfx::ENG_GR_MARK_PHASE_INC;
+ m_groundMark.delay[0] = delay1;
+ m_groundMark.delay[1] = delay2;
+ m_groundMark.delay[2] = delay3;
+ m_groundMark.pos = pos;
+ m_groundMark.radius = radius;
+ m_groundMark.intensity = 0.0f;
+ m_groundMark.dx = dx;
+ m_groundMark.dy = dy;
+ m_groundMark.table = table;
}
-bool Gfx::CEngine::GroundMarkDelete(int rank)
+void Gfx::CEngine::DeleteGroundMark(int rank)
{
- // TODO!
- return true;
+ m_groundMark.LoadDefault();
}
void Gfx::CEngine::ComputeDistance()
{
- // TODO!
+ // TODO: s_resol???
+
+ for (int i = 0; i < static_cast<int>( m_objects.size() ); i++)
+ {
+ if (! m_objects[i].used)
+ continue;
+
+ Math::Vector v;
+ v.x = m_eyePt.x - m_objects[i].transform.Get(1, 4);
+ v.y = m_eyePt.y - m_objects[i].transform.Get(2, 4);
+ v.z = m_eyePt.z - m_objects[i].transform.Get(3, 4);
+ m_objects[i].distance = v.Length();
+ }
}
void Gfx::CEngine::UpdateGeometry()
{
- // TODO!
+ if (! m_updateGeometry)
+ return;
+
+ for (int i = 0; i < static_cast<int>( m_objects.size() ); i++)
+ {
+ m_objects[i].bboxMin.x = 0;
+ m_objects[i].bboxMin.y = 0;
+ m_objects[i].bboxMin.z = 0;
+ m_objects[i].bboxMax.x = 0;
+ m_objects[i].bboxMax.y = 0;
+ m_objects[i].bboxMax.z = 0;
+ m_objects[i].radius = 0;
+ }
+
+ for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ {
+ Gfx::EngineObjLevel1& p1 = m_objectTree[l1];
+ if (! p1.used) continue;
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ Gfx::EngineObjLevel2& p2 = p1.next[l2];
+ if (! p2.used) continue;
+
+ for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
+ {
+ Gfx::EngineObjLevel3& p3 = p2.next[l1];
+ if (! p3.used) continue;
+
+ for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
+ {
+ Gfx::EngineObjLevel4& p4 = p3.next[l4];
+ if (! p4.used) continue;
+
+ int objRank = p2.objRank;
+
+ for (int i = 0; i < static_cast<int>( p4.vertices.size() ); i++)
+ {
+ m_objects[objRank].bboxMin.x = Math::Min(p4.vertices[i].coord.x, m_objects[objRank].bboxMin.x);
+ m_objects[objRank].bboxMin.y = Math::Min(p4.vertices[i].coord.y, m_objects[objRank].bboxMin.y);
+ m_objects[objRank].bboxMin.z = Math::Min(p4.vertices[i].coord.z, m_objects[objRank].bboxMin.z);
+ m_objects[objRank].bboxMax.x = Math::Max(p4.vertices[i].coord.x, m_objects[objRank].bboxMax.x);
+ m_objects[objRank].bboxMax.y = Math::Max(p4.vertices[i].coord.y, m_objects[objRank].bboxMax.y);
+ m_objects[objRank].bboxMax.z = Math::Max(p4.vertices[i].coord.z, m_objects[objRank].bboxMax.z);
+ }
+
+ m_objects[objRank].radius = Math::Max(m_objects[objRank].bboxMin.Length(),
+ m_objects[objRank].bboxMax.Length());
+ }
+ }
+ }
+ }
+
+ m_updateGeometry = false;
}
void Gfx::CEngine::Update()
@@ -830,25 +1658,147 @@ void Gfx::CEngine::Update()
bool Gfx::CEngine::DetectBBox(int objRank, Math::Point mouse)
{
- // TODO!
- return true;
+ Math::Point min, max;
+ min.x = 1000000.0f;
+ min.y = 1000000.0f;
+ max.x = -1000000.0f;
+ max.y = -1000000.0f;
+
+ for (int i = 0; i < 8; i++)
+ {
+ Math::Vector p;
+
+ if ( i & (1<<0) ) p.x = m_objects[objRank].bboxMin.x;
+ else p.x = m_objects[objRank].bboxMax.x;
+ if ( i & (1<<1) ) p.y = m_objects[objRank].bboxMin.y;
+ else p.y = m_objects[objRank].bboxMax.y;
+ if ( i & (1<<2) ) p.z = m_objects[objRank].bboxMin.z;
+ else p.z = m_objects[objRank].bboxMax.z;
+
+ Math::Vector pp;
+ if ( TransformPoint(pp, objRank, p) )
+ {
+ if (pp.x < min.x) min.x = pp.x;
+ if (pp.x > max.x) max.x = pp.x;
+ if (pp.y < min.y) min.y = pp.y;
+ if (pp.y > max.y) max.y = pp.y;
+ }
+ }
+
+ return ( mouse.x >= min.x &&
+ mouse.x <= max.x &&
+ mouse.y >= min.y &&
+ mouse.y <= max.y );
}
int Gfx::CEngine::DetectObject(Math::Point mouse)
{
- // TODO!
- return 0;
+ float min = 1000000.0f;
+ int nearest = -1;
+
+ for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ {
+ Gfx::EngineObjLevel1& p1 = m_objectTree[l1];
+ if (! p1.used) continue;
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ Gfx::EngineObjLevel2& p2 = p1.next[l2];
+ if (! p2.used) continue;
+
+ if (m_objects[p2.objRank].type == Gfx::ENG_OBJTYPE_TERRAIN) continue;
+
+ if (! DetectBBox(p2.objRank, mouse)) continue;
+
+ for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
+ {
+ Gfx::EngineObjLevel3& p3 = p2.next[l1];
+ if (! p3.used) continue;
+
+ if (p3.min != 0.0f) continue; // LOD B or C?
+
+ for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
+ {
+ Gfx::EngineObjLevel4& p4 = p3.next[l4];
+ if (! p4.used) continue;
+
+ if (p4.type == Gfx::ENG_TRIANGLE_TYPE_TRIANGLES)
+ {
+ for (int i = 0; i < static_cast<int>( p4.vertices.size() ); i += 3)
+ {
+ float dist = 0.0f;
+ if (DetectTriangle(mouse, &p4.vertices[i], p2.objRank, dist) && dist < min)
+ {
+ min = dist;
+ nearest = p2.objRank;
+ }
+ }
+ }
+ else if (p4.type == Gfx::ENG_TRIANGLE_TYPE_SURFACE)
+ {
+ for (int i = 0; i < static_cast<int>( p4.vertices.size() ) - 2; i += 1)
+ {
+ float dist = 0.0f;
+ if (DetectTriangle(mouse, &p4.vertices[i], p2.objRank, dist) && dist < min)
+ {
+ min = dist;
+ nearest = p2.objRank;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return nearest;
}
bool Gfx::CEngine::DetectTriangle(Math::Point mouse, Gfx::VertexTex2* triangle, int objRank, float& dist)
{
- // TODO!
+ Math::Vector p2D[3], p3D;
+
+ for (int i = 0; i < 3; i++)
+ {
+ p3D.x = triangle[i].coord.x;
+ p3D.y = triangle[i].coord.y;
+ p3D.z = triangle[i].coord.z;
+
+ if (! TransformPoint(p2D[i], objRank, p3D))
+ return false;
+ }
+
+ if ( mouse.x < p2D[0].x &&
+ mouse.x < p2D[1].x &&
+ mouse.x < p2D[2].x ) return false;
+ if ( mouse.x > p2D[0].x &&
+ mouse.x > p2D[1].x &&
+ mouse.x > p2D[2].x ) return false;
+ if ( mouse.y < p2D[0].y &&
+ mouse.y < p2D[1].y &&
+ mouse.y < p2D[2].y ) return false;
+ if ( mouse.y > p2D[0].y &&
+ mouse.y > p2D[1].y &&
+ mouse.y > p2D[2].y ) return false;
+
+ Math::Point a, b, c;
+ a.x = p2D[0].x;
+ a.y = p2D[0].y;
+ b.x = p2D[1].x;
+ b.y = p2D[1].y;
+ c.x = p2D[2].x;
+ c.y = p2D[2].y;
+
+ if (! Math::IsInsideTriangle(a, b, c, mouse))
+ return false;
+
+ dist = (p2D[0].z + p2D[1].z + p2D[2].z) / 3.0f;
return true;
}
bool Gfx::CEngine::IsVisible(int objRank)
{
- // TODO!
+ // TODO: use ComputeSphereVisiblity() after tested OK
return true;
}
@@ -1130,7 +2080,7 @@ void Gfx::CEngine::SetState(int state, const Gfx::Color& color)
m_device->SetGlobalAmbient(m_ambientColor[m_rankView]);
}
-void Gfx::CEngine::SetMaterial(const Gfx::Material &mat)
+void Gfx::CEngine::SetMaterial(const Gfx::Material& mat)
{
m_lastMaterial = mat;
m_device->SetMaterial(mat);
@@ -1152,7 +2102,7 @@ void Gfx::CEngine::SetViewParams(const Math::Vector& eyePt, const Math::Vector&
m_sound->SetListener(eyePt, lookatPt);
}
-Gfx::Texture Gfx::CEngine::CreateTexture(const std::string &texName, const Gfx::TextureCreateParams &params)
+Gfx::Texture Gfx::CEngine::CreateTexture(const std::string& texName, const Gfx::TextureCreateParams& params)
{
if (m_texBlacklist.find(texName) != m_texBlacklist.end())
return Gfx::Texture(); // invalid texture
@@ -1169,72 +2119,45 @@ Gfx::Texture Gfx::CEngine::CreateTexture(const std::string &texName, const Gfx::
return Gfx::Texture(); // invalid texture
}
- Gfx::Texture result = m_device->CreateTexture(&img, params);
+ Gfx::Texture tex = m_device->CreateTexture(&img, params);
- if (! result.valid)
+ if (! tex.Valid())
{
std::string error = m_device->GetError();
GetLogger()->Error("Couldn't load texture '%s': %s\n", texName.c_str(), error.c_str());
GetLogger()->Error("Blacklisting texture '%s'\n", texName.c_str());
m_texBlacklist.insert(texName);
- return result;
+ return tex;
}
- m_texNameMap[texName] = result;
- m_revTexNameMap[result] = texName;
+ m_texNameMap[texName] = tex;
+ m_revTexNameMap[tex] = texName;
- return result;
+ return tex;
}
-Gfx::Texture Gfx::CEngine::CreateTexture(const std::string &texName)
+Gfx::Texture Gfx::CEngine::LoadTexture(const std::string& name)
{
- return CreateTexture(texName, m_defaultTexParams);
+ return LoadTexture(name, m_defaultTexParams);
}
-void Gfx::CEngine::DestroyTexture(const std::string &texName)
-{
- std::map<std::string, Gfx::Texture>::iterator it = m_texNameMap.find(texName);
- if (it == m_texNameMap.end())
- return;
-
- std::map<Gfx::Texture, std::string>::iterator revIt = m_revTexNameMap.find((*it).second);
-
- m_device->DestroyTexture((*it).second);
-
- m_revTexNameMap.erase(revIt);
- m_texNameMap.erase(it);
-}
-
-bool Gfx::CEngine::LoadTexture(const std::string& name)
+Gfx::Texture Gfx::CEngine::LoadTexture(const std::string& name, const Gfx::TextureCreateParams& params)
{
if (m_texBlacklist.find(name) != m_texBlacklist.end())
- return false;
+ return Gfx::Texture();
std::map<std::string, Gfx::Texture>::iterator it = m_texNameMap.find(name);
if (it != m_texNameMap.end())
- return true;
+ return (*it).second;
- Gfx::Texture tex = CreateTexture(name);
- return tex.valid;
-}
-
-// TODO: create separate variables for 4 quarter names
-void QuarterName(std::string& buffer, const std::string& name, int quarter)
-{
- size_t pos = name.find('.');
- if (pos == std::string::npos)
- {
- buffer = name;
- return;
- }
-
- buffer = name.substr(0, pos) + std::string(1, static_cast<char>('a' + quarter)) + name.substr(pos);
+ Gfx::Texture tex = CreateTexture(name, params);
+ return tex;
}
bool Gfx::CEngine::LoadAllTextures()
{
LoadTexture("text.png");
- LoadTexture("mouse.png");
+ m_miceTexture = LoadTexture("mouse.png");
LoadTexture("button1.png");
LoadTexture("button2.png");
LoadTexture("button3.png");
@@ -1243,53 +2166,88 @@ bool Gfx::CEngine::LoadAllTextures()
LoadTexture("effect02.png");
LoadTexture("map.png");
- if (! m_backgroundName.empty())
+ if (m_backgroundQuarter) // image into 4 pieces?
{
- if (m_backgroundQuarter) // image into 4 pieces?
+ if (! m_backgroundName.empty())
{
for (int i = 0; i < 4; i++)
- {
- std::string name;
- QuarterName(name, m_backgroundName, i);
- LoadTexture(name);
- }
+ m_backgroundQuarterTexs[i] = LoadTexture(m_backgroundQuarterNames[i]);
}
else
{
- LoadTexture(m_backgroundName);
+ for (int i = 0; i < 4; i++)
+ m_backgroundQuarterTexs[i].SetInvalid();
}
}
+ else
+ {
+ if (! m_backgroundName.empty())
+ m_backgroundFullTex = LoadTexture(m_backgroundName);
+ else
+ m_backgroundFullTex.SetInvalid();
+ }
if (! m_foregroundName.empty())
- LoadTexture(m_foregroundName);
+ m_foregroundTex = LoadTexture(m_foregroundName);
+ else
+ m_foregroundTex.SetInvalid();
m_planet->LoadTexture();
bool ok = true;
- /* TODO
- D3DObjLevel1* p1;
- D3DObjLevel2* p2;
- int l1;
- p1 = m_objectPointer;
- for ( l1=0 ; l1<p1->totalUsed ; l1++ )
+ for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
{
- p2 = p1->table[l1];
+ Gfx::EngineObjLevel1& p1 = m_objectTree[l1];
+ if (! p1.used) continue;
- if ( p2 == 0 || p2->texName1[0] != 0 )
+ if (! p1.tex1Name.empty())
{
- if ( !LoadTexture(p2->texName1) ) ok = false;
+ if (! LoadTexture(p1.tex1Name).Valid())
+ ok = false;
}
- if ( p2 == 0 || p2->texName2[0] != 0 )
+ if (! p1.tex2Name.empty())
{
- if ( !LoadTexture(p2->texName2) ) ok = false;
+ if (! LoadTexture(p1.tex2Name).Valid())
+ ok = false;
}
- }*/
+ }
return ok;
}
+void Gfx::CEngine::DeleteTexture(const std::string& texName)
+{
+ auto it = m_texNameMap.find(texName);
+ if (it == m_texNameMap.end())
+ return;
+
+ auto revIt = m_revTexNameMap.find((*it).second);
+
+ m_device->DestroyTexture((*it).second);
+
+ m_revTexNameMap.erase(revIt);
+ m_texNameMap.erase(it);
+}
+
+void Gfx::CEngine::DeleteTexture(const Gfx::Texture& tex)
+{
+ if (! tex.Valid())
+ return;
+
+ auto revIt = m_revTexNameMap.find(tex);
+ if (revIt == m_revTexNameMap.end())
+ return;
+
+ m_device->DestroyTexture(tex);
+
+ auto it = m_texNameMap.find((*revIt).second);
+
+ m_revTexNameMap.erase(revIt);
+ m_texNameMap.erase(it);
+}
+
bool Gfx::CEngine::SetTexture(const std::string& name, int stage)
{
auto it = m_texNameMap.find(name);
@@ -1299,7 +2257,7 @@ bool Gfx::CEngine::SetTexture(const std::string& name, int stage)
return true;
}
- if (! LoadTexture(name))
+ if (! LoadTexture(name).Valid())
{
m_device->SetTexture(stage, 0); // invalid texture
return false;
@@ -1316,6 +2274,11 @@ bool Gfx::CEngine::SetTexture(const std::string& name, int stage)
return false; // should not happen normally
}
+void Gfx::CEngine::SetTexture(const Gfx::Texture& tex, int stage)
+{
+ m_device->SetTexture(stage, tex);
+}
+
void Gfx::CEngine::SetLimitLOD(int rank, float limit)
{
m_limitLOD[rank] = limit;
@@ -1499,10 +2462,31 @@ float Gfx::CEngine::GetFogStart(int rank)
return m_fogStart[rank];
}
+std::string QuarterName(const std::string& name, int quarter)
+{
+ size_t pos = name.find('.');
+ if (pos == std::string::npos)
+ return name;
+
+ return name.substr(0, pos) + std::string(1, static_cast<char>('a' + quarter)) + name.substr(pos);
+}
+
void Gfx::CEngine::SetBackground(const std::string& name, Gfx::Color up, Gfx::Color down,
Gfx::Color cloudUp, Gfx::Color cloudDown,
bool full, bool quarter)
{
+ if (m_backgroundFullTex.Valid())
+ {
+ DeleteTexture(m_backgroundFullTex);
+ m_backgroundFullTex.SetInvalid();
+ }
+
+ for (int i = 0; i < 4; i++)
+ {
+ DeleteTexture(m_backgroundQuarterTexs[i]);
+ m_backgroundQuarterTexs[i].SetInvalid();
+ }
+
m_backgroundName = name;
m_backgroundColorUp = up;
m_backgroundColorDown = down;
@@ -1510,6 +2494,22 @@ void Gfx::CEngine::SetBackground(const std::string& name, Gfx::Color up, Gfx::Co
m_backgroundCloudDown = cloudDown;
m_backgroundFull = full;
m_backgroundQuarter = quarter;
+
+ if (! m_backgroundName.empty())
+ {
+ if (m_backgroundQuarter)
+ {
+ for (int i = 0; i < 4; i++)
+ {
+ m_backgroundQuarterNames[i] = QuarterName(name, i);
+ m_backgroundQuarterTexs[i] = LoadTexture(m_backgroundQuarterNames[i]);
+ }
+ }
+ else
+ {
+ m_backgroundFullTex = LoadTexture(m_backgroundName);
+ }
+ }
}
void Gfx::CEngine::GetBackground(std::string& name, Gfx::Color& up, Gfx::Color& down,
@@ -1527,10 +2527,16 @@ void Gfx::CEngine::GetBackground(std::string& name, Gfx::Color& up, Gfx::Color&
void Gfx::CEngine::SetForegroundName(const std::string& name)
{
- if (! m_foregroundName.empty())
- DestroyTexture(m_foregroundName);
+ if (m_foregroundTex.Valid())
+ {
+ DeleteTexture(m_foregroundTex);
+ m_foregroundTex.SetInvalid();
+ }
m_foregroundName = name;
+
+ if (! m_foregroundName.empty())
+ m_foregroundTex = LoadTexture(m_foregroundName);
}
void Gfx::CEngine::SetOverFront(bool front)
@@ -1901,29 +2907,29 @@ void Gfx::CEngine::Draw3DScene()
{
p2 = p1->table[l1];
if ( p2 == 0 ) continue;
- SetTexture(p2->texName1, 0);
- SetTexture(p2->texName2, 1);
+ SetTexture(p2->tex1Name, 0);
+ SetTexture(p2->tex2Name, 1);
for ( l2=0 ; l2<p2->totalUsed ; l2++ )
{
p3 = p2->table[l2];
if ( p3 == 0 ) continue;
objRank = p3->objRank;
- if ( m_objectParam[objRank].type != TYPETERRAIN ) continue;
- if ( !m_objectParam[objRank].bDrawWorld ) continue;
+ if ( m_objects[objRank].type != TYPETERRAIN ) continue;
+ if ( !m_objects[objRank].bDrawWorld ) continue;
{
- D3DMATRIX mat = MAT_TO_D3DMAT(m_objectParam[objRank].transform);
+ D3DMATRIX mat = MAT_TO_D3DMAT(m_objects[objRank].transform);
m_pD3DDevice->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
}
if ( !IsVisible(objRank) ) continue;
- m_light->LightUpdate(m_objectParam[objRank].type);
+ m_light->LightUpdate(m_objects[objRank].type);
for ( l3=0 ; l3<p3->totalUsed ; l3++ )
{
p4 = p3->table[l3];
if ( p4 == 0 ) continue;
- if ( m_objectParam[objRank].distance < p4->min ||
- m_objectParam[objRank].distance >= p4->max ) continue;
+ if ( m_objects[objRank].distance < p4->min ||
+ m_objects[objRank].distance >= p4->max ) continue;
for ( l4=0 ; l4<p4->totalUsed ; l4++ )
{
p5 = p4->table[l4];
@@ -1970,29 +2976,29 @@ void Gfx::CEngine::Draw3DScene()
{
p2 = p1->table[l1];
if ( p2 == 0 ) continue;
- SetTexture(p2->texName1, 0);
- SetTexture(p2->texName2, 1);
+ SetTexture(p2->tex1Name, 0);
+ SetTexture(p2->tex2Name, 1);
for ( l2=0 ; l2<p2->totalUsed ; l2++ )
{
p3 = p2->table[l2];
if ( p3 == 0 ) continue;
objRank = p3->objRank;
- if ( m_bShadow && m_objectParam[objRank].type == TYPETERRAIN ) continue;
- if ( !m_objectParam[objRank].bDrawWorld ) continue;
+ if ( m_bShadow && m_objects[objRank].type == TYPETERRAIN ) continue;
+ if ( !m_objects[objRank].bDrawWorld ) continue;
{
- D3DMATRIX mat = MAT_TO_D3DMAT(m_objectParam[objRank].transform);
+ D3DMATRIX mat = MAT_TO_D3DMAT(m_objects[objRank].transform);
m_pD3DDevice->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
}
if ( !IsVisible(objRank) ) continue;
- m_light->LightUpdate(m_objectParam[objRank].type);
+ m_light->LightUpdate(m_objects[objRank].type);
for ( l3=0 ; l3<p3->totalUsed ; l3++ )
{
p4 = p3->table[l3];
if ( p4 == 0 ) continue;
- if ( m_objectParam[objRank].distance < p4->min ||
- m_objectParam[objRank].distance >= p4->max ) continue;
+ if ( m_objects[objRank].distance < p4->min ||
+ m_objects[objRank].distance >= p4->max ) continue;
for ( l4=0 ; l4<p4->totalUsed ; l4++ )
{
p5 = p4->table[l4];
@@ -2002,7 +3008,7 @@ void Gfx::CEngine::Draw3DScene()
p6 = p5->table[l5];
if ( p6 == 0 ) continue;
SetMaterial(p6->material);
- if ( m_objectParam[objRank].transparency != 0.0f ) // transparent ?
+ if ( m_objects[objRank].transparency != 0.0f ) // transparent ?
{
transparent = true;
continue;
@@ -2054,29 +3060,29 @@ void Gfx::CEngine::Draw3DScene()
{
p2 = p1->table[l1];
if ( p2 == 0 ) continue;
- SetTexture(p2->texName1, 0);
- SetTexture(p2->texName2, 1);
+ SetTexture(p2->tex1Name, 0);
+ SetTexture(p2->tex2Name, 1);
for ( l2=0 ; l2<p2->totalUsed ; l2++ )
{
p3 = p2->table[l2];
if ( p3 == 0 ) continue;
objRank = p3->objRank;
- if ( m_bShadow && m_objectParam[objRank].type == TYPETERRAIN ) continue;
- if ( !m_objectParam[objRank].bDrawWorld ) continue;
+ if ( m_bShadow && m_objects[objRank].type == TYPETERRAIN ) continue;
+ if ( !m_objects[objRank].bDrawWorld ) continue;
{
- D3DMATRIX mat = MAT_TO_D3DMAT(m_objectParam[objRank].transform);
+ D3DMATRIX mat = MAT_TO_D3DMAT(m_objects[objRank].transform);
m_pD3DDevice->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
}
if ( !IsVisible(objRank) ) continue;
- m_light->LightUpdate(m_objectParam[objRank].type);
+ m_light->LightUpdate(m_objects[objRank].type);
for ( l3=0 ; l3<p3->totalUsed ; l3++ )
{
p4 = p3->table[l3];
if ( p4 == 0 ) continue;
- if ( m_objectParam[objRank].distance < p4->min ||
- m_objectParam[objRank].distance >= p4->max ) continue;
+ if ( m_objects[objRank].distance < p4->min ||
+ m_objects[objRank].distance >= p4->max ) continue;
for ( l4=0 ; l4<p4->totalUsed ; l4++ )
{
p5 = p4->table[l4];
@@ -2086,7 +3092,7 @@ void Gfx::CEngine::Draw3DScene()
p6 = p5->table[l5];
if ( p6 == 0 ) continue;
SetMaterial(p6->material);
- if ( m_objectParam[objRank].transparency == 0.0f ) continue;
+ if ( m_objects[objRank].transparency == 0.0f ) continue;
SetState(tState, tColor);
if ( p6->type == D3DTYPE6T )
{
@@ -2166,28 +3172,28 @@ void Gfx::CEngine::DrawInterface()
Gfx::EngineObjLevel1* p1 = &m_objectTree[l1];
p2 = p1->table[l1];
if ( p2 == 0 ) continue;
- SetTexture(p2->texName1, 0);
- SetTexture(p2->texName2, 1);
+ SetTexture(p2->tex1Name, 0);
+ SetTexture(p2->tex2Name, 1);
for ( l2=0 ; l2<p2->totalUsed ; l2++ )
{
p3 = p2->table[l2];
if ( p3 == 0 ) continue;
objRank = p3->objRank;
- if ( !m_objectParam[objRank].bDrawFront ) continue;
+ if ( !m_objects[objRank].bDrawFront ) continue;
{
- D3DMATRIX mat = MAT_TO_D3DMAT(m_objectParam[objRank].transform);
+ D3DMATRIX mat = MAT_TO_D3DMAT(m_objects[objRank].transform);
m_pD3DDevice->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
}
if ( !IsVisible(objRank) ) continue;
- m_light->LightUpdate(m_objectParam[objRank].type);
+ m_light->LightUpdate(m_objects[objRank].type);
for ( l3=0 ; l3<p3->totalUsed ; l3++ )
{
p4 = p3->table[l3];
if ( p4 == 0 ) continue;
- if ( m_objectParam[objRank].distance < p4->min ||
- m_objectParam[objRank].distance >= p4->max ) continue;
+ if ( m_objects[objRank].distance < p4->min ||
+ m_objects[objRank].distance >= p4->max ) continue;
for ( l4=0 ; l4<p4->totalUsed ; l4++ )
{
p5 = p4->table[l4];
@@ -2245,7 +3251,7 @@ void Gfx::CEngine::DrawInterface()
void Gfx::CEngine::UpdateGroundSpotTextures()
{
// TODO the original code modifying the textures is very complex, so stub for now
- GetLogger()->Info("CEngine::UpdateGroundSpotTextures(): stub!\n");
+ GetLogger()->Trace("CEngine::UpdateGroundSpotTextures(): stub!\n");
}
void Gfx::CEngine::DrawShadow()
@@ -2494,7 +3500,7 @@ void Gfx::CEngine::DrawBackgroundGradient(const Gfx::Color& up, const Gfx::Color
}
// Status: PART_TESTED
-void Gfx::CEngine::DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, const std::string& name)
+void Gfx::CEngine::DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, const Gfx::Texture &tex)
{
Math::Vector n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
@@ -2529,7 +3535,7 @@ void Gfx::CEngine::DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, co
v2 = v1+h;
}
- SetTexture(name);
+ SetTexture(tex);
SetState(Gfx::ENG_RSTATE_OPAQUE_TEXTURE | Gfx::ENG_RSTATE_WRAP);
m_device->SetTransform(Gfx::TRANSFORM_VIEW, m_matViewInterface);
@@ -2560,29 +3566,25 @@ void Gfx::CEngine::DrawBackgroundImage()
p1.y = 0.5f;
p2.x = 0.5f;
p2.y = 1.0f;
- QuarterName(name, m_backgroundName, 0);
- DrawBackgroundImageQuarter(p1, p2, name);
+ DrawBackgroundImageQuarter(p1, p2, m_backgroundQuarterTexs[0]);
p1.x = 0.5f;
p1.y = 0.5f;
p2.x = 1.0f;
p2.y = 1.0f;
- QuarterName(name, m_backgroundName, 1);
- DrawBackgroundImageQuarter(p1, p2, name);
+ DrawBackgroundImageQuarter(p1, p2, m_backgroundQuarterTexs[1]);
p1.x = 0.0f;
p1.y = 0.0f;
p2.x = 0.5f;
p2.y = 0.5f;
- QuarterName(name, m_backgroundName, 2);
- DrawBackgroundImageQuarter(p1, p2, name);
+ DrawBackgroundImageQuarter(p1, p2, m_backgroundQuarterTexs[2]);
p1.x = 0.5f;
p1.y = 0.0f;
p2.x = 1.0f;
p2.y = 0.5f;
- QuarterName(name, m_backgroundName, 3);
- DrawBackgroundImageQuarter(p1, p2, name);
+ DrawBackgroundImageQuarter(p1, p2, m_backgroundQuarterTexs[3]);
}
else
{
@@ -2590,7 +3592,7 @@ void Gfx::CEngine::DrawBackgroundImage()
p1.y = 0.0f;
p2.x = 1.0f;
p2.y = 1.0f;
- DrawBackgroundImageQuarter(p1, p2, m_backgroundName);
+ DrawBackgroundImageQuarter(p1, p2, m_backgroundFullTex);
}
}
@@ -2634,7 +3636,7 @@ void Gfx::CEngine::DrawForegroundImage()
Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(u2, v1))
};
- SetTexture(m_foregroundName);
+ SetTexture(m_foregroundTex);
SetState(Gfx::ENG_RSTATE_CLAMP | Gfx::ENG_RSTATE_TTEXTURE_BLACK);
m_device->SetTransform(Gfx::TRANSFORM_VIEW, m_matViewInterface);
diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h
index 5a64e4e..3f21e0d 100644
--- a/src/graphics/engine/engine.h
+++ b/src/graphics/engine/engine.h
@@ -60,14 +60,69 @@ class CTerrain;
/**
+ \enum EngineRenderState
+ \brief Render state of graphics engine
+
+ States are used for settings certain modes, for instance texturing and blending.
+ The enum is a bitmask and some of the states can be OR'd together. */
+enum EngineRenderState
+{
+ //! Normal opaque materials
+ ENG_RSTATE_NORMAL = 0,
+ //! The transparent texture (black = no)
+ ENG_RSTATE_TTEXTURE_BLACK = (1<<0),
+ //! The transparent texture (white = no)
+ ENG_RSTATE_TTEXTURE_WHITE = (1<<1),
+ //! The transparent diffuse color
+ ENG_RSTATE_TDIFFUSE = (1<<2),
+ //! Texture wrap
+ ENG_RSTATE_WRAP = (1<<3),
+ //! Texture borders with solid color
+ ENG_RSTATE_CLAMP = (1<<4),
+ //! Light texture (ambient max)
+ ENG_RSTATE_LIGHT = (1<<5),
+ //! Double black texturing
+ ENG_RSTATE_DUAL_BLACK = (1<<6),
+ //! Double white texturing
+ ENG_RSTATE_DUAL_WHITE = (1<<7),
+ //! Part 1 (no change in. MOD!)
+ ENG_RSTATE_PART1 = (1<<8),
+ //! Part 2
+ ENG_RSTATE_PART2 = (1<<9),
+ //! Part 3
+ ENG_RSTATE_PART3 = (1<<10),
+ //! Part 4
+ ENG_RSTATE_PART4 = (1<<11),
+ //! Double-sided face
+ ENG_RSTATE_2FACE = (1<<12),
+ //! Image using alpha channel
+ ENG_RSTATE_ALPHA = (1<<13),
+ //! Always use 2nd floor texturing
+ ENG_RSTATE_SECOND = (1<<14),
+ //! Causes the fog
+ ENG_RSTATE_FOG = (1<<15),
+ //! The transparent color (black = no)
+ ENG_RSTATE_TCOLOR_BLACK = (1<<16),
+ //! The transparent color (white = no)
+ ENG_RSTATE_TCOLOR_WHITE = (1<<17),
+ //! Mode for rendering text
+ ENG_RSTATE_TEXT = (1<<18),
+ //! Only opaque texture, no blending, etc.
+ ENG_RSTATE_OPAQUE_TEXTURE = (1<<19),
+ //! Only opaque color, no texture, blending, etc.
+ ENG_RSTATE_OPAQUE_COLOR = (1<<20)
+};
+
+
+/**
\enum EngineTriangleType
\brief Type of triangles drawn for engine objects */
enum EngineTriangleType
{
//! Triangles
- ENG_TRIANGLE_TYPE_6T = 1,
+ ENG_TRIANGLE_TYPE_TRIANGLES = 1,
//! Surfaces
- ENG_TRIANGLE_TYPE_6S = 2
+ ENG_TRIANGLE_TYPE_SURFACE = 2
};
/**
@@ -82,13 +137,13 @@ struct EngineTriangle
//! Render state
int state;
//! 1st texture
- Gfx::Texture tex1;
+ std::string tex1Name;
//! 2nd texture
- Gfx::Texture tex2;
+ std::string tex2Name;
EngineTriangle()
{
- state = 0;
+ state = Gfx::ENG_RSTATE_NORMAL;
}
};
@@ -118,6 +173,8 @@ enum EngineObjectType
\brief Object drawn by the graphics engine */
struct EngineObject
{
+ //! If true, object is valid in objects vector
+ bool used;
//! If true, the object is drawn
bool visible;
//! If true, object is behind the 2D interface
@@ -130,7 +187,7 @@ struct EngineObject
Gfx::EngineObjectType type;
//! Transformation matrix
Math::Matrix transform;
- //! Distance view - origin (TODO: ?)
+ //! Distance to object from eye point
float distance;
//! Bounding box min (origin 0,0,0 always included)
Math::Vector bboxMin;
@@ -143,15 +200,27 @@ struct EngineObject
//! Transparency of the object [0, 1]
float transparency;
+ //! Calls LoadDefault()
EngineObject()
{
+ LoadDefault();
+ }
+
+ //! Loads default values
+ inline void LoadDefault()
+ {
+ used = false;
visible = false;
drawWorld = false;
drawFront = false;
totalTriangles = 0;
+ type = Gfx::ENG_OBJTYPE_NULL;
+ transform.LoadIdentity();
+ bboxMax.LoadZero();
+ bboxMin.LoadZero();
distance = 0.0f;
radius = 0.0f;
- shadowRank = 0;
+ shadowRank = -1;
transparency = 0.0f;
}
};
@@ -160,37 +229,22 @@ struct EngineObjLevel1;
struct EngineObjLevel2;
struct EngineObjLevel3;
struct EngineObjLevel4;
-struct EngineObjLevel5;
-
-/**
- \struct EngineObjLevel5
- \brief Tier 5 of object tree */
-struct EngineObjLevel5
-{
- Gfx::Material material;
- int state;
- Gfx::EngineTriangleType type;
- std::vector<Gfx::VertexTex2> vertices;
-
- EngineObjLevel5()
- {
- state = 0;
- }
-};
/**
\struct EngineObjLevel4
\brief Tier 4 of object tree */
struct EngineObjLevel4
{
- int reserved;
- std::vector<Gfx::EngineObjLevel5> up;
- Gfx::EngineObjLevel3* down;
+ bool used;
+ Gfx::EngineTriangleType type;
+ Gfx::Material material;
+ int state;
+ std::vector<Gfx::VertexTex2> vertices;
- EngineObjLevel4()
- {
- reserved = 0;
- }
+ EngineObjLevel4(bool used = false,
+ Gfx::EngineTriangleType type = Gfx::ENG_TRIANGLE_TYPE_TRIANGLES,
+ const Gfx::Material& material = Gfx::Material(),
+ int state = Gfx::ENG_RSTATE_NORMAL);
};
/**
@@ -198,15 +252,12 @@ struct EngineObjLevel4
\brief Tier 3 of object tree */
struct EngineObjLevel3
{
+ bool used;
float min;
float max;
- std::vector<Gfx::EngineObjLevel4> up;
- Gfx::EngineObjLevel2* down;
+ std::vector<Gfx::EngineObjLevel4> next;
- EngineObjLevel3()
- {
- min = max = 0.0f;
- }
+ EngineObjLevel3(bool used = false, float min = 0.0f, float max = 0.0f);
};
/**
@@ -214,14 +265,11 @@ struct EngineObjLevel3
\brief Tier 2 of object tree */
struct EngineObjLevel2
{
+ bool used;
int objRank;
- std::vector<Gfx::EngineObjLevel3> up;
- Gfx::EngineObjLevel1* down;
+ std::vector<Gfx::EngineObjLevel3> next;
- EngineObjLevel2()
- {
- objRank = 0;
- }
+ EngineObjLevel2(bool used = false, int objRank = -1);
};
/**
@@ -229,11 +277,15 @@ struct EngineObjLevel2
\brief Tier 1 of object tree */
struct EngineObjLevel1
{
+ bool used;
+ std::string tex1Name;
Gfx::Texture tex1;
+ std::string tex2Name;
Gfx::Texture tex2;
- std::vector<Gfx::EngineObjLevel2> up;
+ std::vector<Gfx::EngineObjLevel2> next;
- EngineObjLevel1() {}
+ EngineObjLevel1(bool used = false, const std::string& tex1Name = "",
+ const std::string& tex2Name = "");
};
/**
@@ -252,6 +304,8 @@ enum EngineShadowType
\brief Shadow drawn by the graphics engine */
struct EngineShadow
{
+ //! If true, shadow is valid
+ bool used;
//! If true, shadow is invisible (object being carried for example)
bool hide;
//! Rank of the associated object
@@ -273,8 +327,17 @@ struct EngineShadow
EngineShadow()
{
+ LoadDefault();
+ }
+
+ void LoadDefault()
+ {
+ used = false;
hide = false;
objRank = 0;
+ type = Gfx::ENG_SHADOW_NORM;
+ pos.LoadZero();
+ normal.LoadZero();
angle = radius = intensity = height = 0.0f;
}
};
@@ -284,6 +347,8 @@ struct EngineShadow
\brief A spot (large shadow) drawn on the ground by the graphics engine */
struct EngineGroundSpot
{
+ //! If true, ground spot is valid
+ bool used;
//! Color of the shadow
Gfx::Color color;
//! Min altitude
@@ -303,6 +368,15 @@ struct EngineGroundSpot
EngineGroundSpot()
{
+ LoadDefault();
+ }
+
+ void LoadDefault()
+ {
+ used = false;
+ color = Gfx::Color();
+ pos.LoadZero();
+ drawPos.LoadZero();
min = max = smooth = radius = drawRadius = 0.0f;
}
};
@@ -356,11 +430,19 @@ struct EngineGroundMark
EngineGroundMark()
{
+ LoadDefault();
+ }
+
+ void LoadDefault()
+ {
draw = false;
+ phase = ENG_GR_MARK_PHASE_NULL;
+ pos = Math::Vector();
+ drawPos = Math::Vector();
delay[0] = delay[1] = delay[2] = 0.0f;
fix = radius = intensity = drawRadius = drawIntensity = 0.0f;
dx = dy = 0;
- table = NULL;
+ table = nullptr;
}
};
@@ -380,61 +462,6 @@ enum EngineTextureMapping
/**
- \enum EngineRenderState
- \brief Render state of graphics engine
-
- States are used for settings certain modes, for instance texturing and blending.
- The enum is a bitmask and some of the states can be OR'd together. */
-enum EngineRenderState
-{
- //! Normal opaque materials
- ENG_RSTATE_NORMAL = 0,
- //! The transparent texture (black = no)
- ENG_RSTATE_TTEXTURE_BLACK = (1<<0),
- //! The transparent texture (white = no)
- ENG_RSTATE_TTEXTURE_WHITE = (1<<1),
- //! The transparent diffuse color
- ENG_RSTATE_TDIFFUSE = (1<<2),
- //! Texture wrap
- ENG_RSTATE_WRAP = (1<<3),
- //! Texture borders with solid color
- ENG_RSTATE_CLAMP = (1<<4),
- //! Light texture (ambient max)
- ENG_RSTATE_LIGHT = (1<<5),
- //! Double black texturing
- ENG_RSTATE_DUAL_BLACK = (1<<6),
- //! Double white texturing
- ENG_RSTATE_DUAL_WHITE = (1<<7),
- //! Part 1 (no change in. MOD!)
- ENG_RSTATE_PART1 = (1<<8),
- //! Part 2
- ENG_RSTATE_PART2 = (1<<9),
- //! Part 3
- ENG_RSTATE_PART3 = (1<<10),
- //! Part 4
- ENG_RSTATE_PART4 = (1<<11),
- //! Double-sided face
- ENG_RSTATE_2FACE = (1<<12),
- //! Image using alpha channel
- ENG_RSTATE_ALPHA = (1<<13),
- //! Always use 2nd floor texturing
- ENG_RSTATE_SECOND = (1<<14),
- //! Causes the fog
- ENG_RSTATE_FOG = (1<<15),
- //! The transparent color (black = no)
- ENG_RSTATE_TCOLOR_BLACK = (1<<16),
- //! The transparent color (white = no)
- ENG_RSTATE_TCOLOR_WHITE = (1<<17),
- //! Mode for rendering text
- ENG_RSTATE_TEXT = (1<<18),
- //! Only opaque texture, no blending, etc.
- ENG_RSTATE_OPAQUE_TEXTURE = (1<<19),
- //! Only opaque color, no texture, blending, etc.
- ENG_RSTATE_OPAQUE_COLOR = (1<<20)
-};
-
-
-/**
\enum EngineMouseType
\brief Type of mouse cursor displayed in-game */
enum EngineMouseType
@@ -524,7 +551,7 @@ struct EngineMouse
The 3D scene is composed of objects which are basically collections of triangles forming
a surface or simply independent triangles in space. Objects are stored in the engine
- as a tree structure which is composed of 5 tiers (EngineObjLevel1, EngineObjLevel2 and so on).
+ as a tree structure which is composed of 4 tiers (EngineObjLevel1, EngineObjLevel2 and so on).
Each tier stores some data about object triangle, like textures or materials used.
Additional information on objects stored are in EngineObject structure.
Each object is uniquely identified by its rank.
@@ -632,74 +659,129 @@ public:
/* *************** Object management *************** */
+ //! Creates a new object and returns its rank
int CreateObject();
+ //! Deletes all objects, shadows and ground spots
void FlushObject();
+ //! Deletes the given object
bool DeleteObject(int objRank);
- bool SetDrawWorld(int objRank, bool draw);
- bool SetDrawFront(int objRank, bool draw);
-
- bool AddTriangle(int objRank, Gfx::VertexTex2* vertex, int nb, const Gfx::Material& mat,
- int state, std::string texName1, std::string texName2,
- float min, float max, bool globalUpdate);
- bool AddSurface(int objRank, Gfx::VertexTex2* vertex, int nb, const Gfx::Material& mat,
- int state, std::string texName1, std::string texName2,
+
+ //@{
+ //! Management of engine object type
+ bool SetObjectType(int objRank, Gfx::EngineObjectType type);
+ Gfx::EngineObjectType GetObjectType(int objRank);
+ //@}
+
+ //@{
+ //! Management of object transform
+ bool SetObjectTransform(int objRank, const Math::Matrix& transform);
+ bool GetObjectTransform(int objRank, Math::Matrix& transform);
+ //@}
+
+ //! Sets drawWorld for given object
+ bool SetObjectDrawWorld(int objRank, bool draw);
+ //! Sets drawFront for given object
+ bool SetObjectDrawFront(int objRank, bool draw);
+
+ //! Sets the transparency level for given object
+ bool SetObjectTransparency(int objRank, float value);
+
+ //! Returns the bounding box for an object
+ bool GetObjectBBox(int objRank, Math::Vector& min, Math::Vector& max);
+
+ //! Returns the total number of triangles of given object
+ int GetObjectTotalTriangles(int objRank);
+
+ //! Adds triangles to given object with the specified params
+ bool AddTriangles(int objRank, const std::vector<Gfx::VertexTex2>& vertices,
+ const Gfx::Material& material, int state,
+ std::string tex1Name, std::string tex2Name,
+ float min, float max, bool globalUpdate);
+
+ //! Adds a surface to given object with the specified params
+ bool AddSurface(int objRank, const std::vector<Gfx::VertexTex2>& vertices,
+ const Gfx::Material& material, int state,
+ std::string tex1Name, std::string tex2Name,
float min, float max, bool globalUpdate);
- bool AddQuick(int objRank, const Gfx::EngineObjLevel5& buffer,
- std::string texName1, std::string texName2,
+
+ //! Adds a tier 4 engine object directly
+ bool AddQuick(int objRank, const Gfx::EngineObjLevel4& buffer,
+ std::string tex1Name, std::string tex2Name,
float min, float max, bool globalUpdate);
- Gfx::EngineObjLevel5* SearchTriangle(int objRank, const Gfx::Material& mat,
- int state, std::string texName1, std::string texName2,
- float min, float max);
+ //! Returns the first found tier 4 engine object for the given params or nullptr if not found
+ Gfx::EngineObjLevel4* FindTriangles(int objRank, const Gfx::Material& material,
+ int state, std::string tex1Name, std::string tex2Name,
+ float min, float max);
+
+ //! Returns a partial list of triangles for given object
+ int GetPartialTriangles(int objRank, float min, float max, float percent, int maxCount,
+ std::vector<Gfx::EngineTriangle>& triangles);
+
+ //! Updates LOD after parameter or resolution change
void ChangeLOD();
- bool ChangeSecondTexture(int objRank, const std::string& texName2);
- int GetTotalTriangles(int objRank);
- int GetTriangles(int objRank, float min, float max, Gfx::EngineTriangle* buffer, int size, float percent);
- bool GetBBox(int objRank, Math::Vector& min, Math::Vector& max);
+
+ //! Changes the 2nd texure for given object
+ bool ChangeSecondTexture(int objRank, const std::string& tex2Name);
+
+ //! Changes (recalculates) texture mapping for given object
bool ChangeTextureMapping(int objRank, const Gfx::Material& mat, int state,
- const std::string& texName1, const std::string& texName2,
+ const std::string& tex1Name, const std::string& tex2Name,
float min, float max, Gfx::EngineTextureMapping mode,
float au, float bu, float av, float bv);
+
+ //! Changes texture mapping for robot tracks
bool TrackTextureMapping(int objRank, const Gfx::Material& mat, int state,
- const std::string& texName1, const std::string& texName2,
+ const std::string& tex1Name, const std::string& tex2Name,
float min, float max, Gfx::EngineTextureMapping mode,
float pos, float factor, float tl, float ts, float tt);
- bool SetObjectTransform(int objRank, const Math::Matrix& transform);
- bool GetObjectTransform(int objRank, Math::Matrix& transform);
- bool SetObjectType(int objRank, Gfx::EngineObjectType type);
- Gfx::EngineObjectType GetObjectType(int objRank);
- bool SetObjectTransparency(int objRank, float value);
- bool ShadowCreate(int objRank);
- void ShadowDelete(int objRank);
+
+ //! Creates a shadow for the given object
+ bool CreateShadow(int objRank);
+ //! Deletes the shadow for given object
+ void DeleteShadow(int objRank);
+
+ //@{
+ //! Management of different shadow params
bool SetObjectShadowHide(int objRank, bool hide);
bool SetObjectShadowType(int objRank, Gfx::EngineShadowType type);
bool SetObjectShadowPos(int objRank, const Math::Vector& pos);
- bool SetObjectShadowNormal(int objRank, const Math::Vector& n);
+ bool SetObjectShadowNormal(int objRank, const Math::Vector& normal);
bool SetObjectShadowAngle(int objRank, float angle);
bool SetObjectShadowRadius(int objRank, float radius);
bool SetObjectShadowIntensity(int objRank, float intensity);
- bool SetObjectShadowHeight(int objRank, float h);
+ bool SetObjectShadowHeight(int objRank, float height);
float GetObjectShadowRadius(int objRank);
+ //@}
//! Lists the ranks of objects and subobjects selected
void SetHighlightRank(int* rankList);
//! Returns the highlighted rectangle
bool GetHighlight(Math::Point& p1, Math::Point& p2);
- void GroundSpotFlush();
- int GroundSpotCreate();
- void GroundSpotDelete(int rank);
+ //! Deletes all ground spots
+ void FlushGroundSpot();
+ //! Creates a new ground spot and returns its rank
+ int CreateGroundSpot();
+ //! Deletes the given ground spot
+ void DeleteGroundSpot(int rank);
+
+ //@{
+ //! Management of different ground spot params
bool SetObjectGroundSpotPos(int rank, const Math::Vector& pos);
bool SetObjectGroundSpotRadius(int rank, float radius);
bool SetObjectGroundSpotColor(int rank, const Gfx::Color& color);
bool SetObjectGroundSpotMinMax(int rank, float min, float max);
bool SetObjectGroundSpotSmooth(int rank, float smooth);
+ //@}
- int GroundMarkCreate(Math::Vector pos, float radius,
+ //! Creates the ground mark with the given params
+ void CreateGroundMark(Math::Vector pos, float radius,
float delay1, float delay2, float delay3,
int dx, int dy, char* table);
- bool GroundMarkDelete(int rank);
+ //! Deletes the ground mark
+ void DeleteGroundMark(int rank);
//! Updates the state after creating objects
void Update();
@@ -717,22 +799,23 @@ public:
void SetViewParams(const Math::Vector& eyePt, const Math::Vector& lookatPt,
const Math::Vector& upVec, float eyeDistance);
- //! Creates texture with the specified params
- Gfx::Texture CreateTexture(const std::string& texName,
- const Gfx::TextureCreateParams& params);
- //! Creates texture
- Gfx::Texture CreateTexture(const std::string& texName);
-
- //! Destroys texture, unloading it and removing from cache
- void DestroyTexture(const std::string& texName);
-
//! Loads texture, creating it if not already present
- bool LoadTexture(const std::string& name);
+ Gfx::Texture LoadTexture(const std::string& name);
+ //! Loads texture, creating it with given params if not already present
+ Gfx::Texture LoadTexture(const std::string& name, const Gfx::TextureCreateParams& params);
//! Loads all necessary textures
bool LoadAllTextures();
//! Sets texture for given stage; if not present in cache, the texture is loaded
+ /** If loading fails, returns false. */
bool SetTexture(const std::string& name, int stage = 0);
+ //! Sets texture for given stage
+ void SetTexture(const Gfx::Texture& tex, int stage = 0);
+
+ //! Deletes the given texture, unloading it and removing from cache
+ void DeleteTexture(const std::string& name);
+ //! Deletes the given texture, unloading it and removing from cache
+ void DeleteTexture(const Gfx::Texture& tex);
//@{
//! Border management (distance limits) depends of the resolution (LOD = level-of-detail)
@@ -1005,7 +1088,7 @@ protected:
//! Draws the gradient background
void DrawBackgroundGradient(const Gfx::Color& up, const Gfx::Color& down);
//! Draws a portion of the image background
- void DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, const std::string& name);
+ void DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, const Gfx::Texture &tex);
//! Draws the image background
void DrawBackgroundImage();
//! Draws all the planets
@@ -1021,6 +1104,19 @@ protected:
//! Draw part of mouse cursor sprite
void DrawMouseSprite(Math::Point pos, Math::Point dim, int icon);
+ //! Creates new tier 1 object
+ Gfx::EngineObjLevel1& AddLevel1(const std::string& tex1Name, const std::string& tex2Name);
+ //! Creates a new tier 2 object
+ Gfx::EngineObjLevel2& AddLevel2(Gfx::EngineObjLevel1 &p1, int objRank);
+ //! Creates a new tier 3 object
+ Gfx::EngineObjLevel3& AddLevel3(Gfx::EngineObjLevel2 &p2, float min, float max);
+ //! Creates a new tier 4 object
+ Gfx::EngineObjLevel4& AddLevel4(Gfx::EngineObjLevel3 &p3, Gfx::EngineTriangleType type,
+ const Gfx::Material& mat, int state);
+
+ //! Create texture and add it to cache
+ Gfx::Texture CreateTexture(const std::string &texName, const Gfx::TextureCreateParams &params);
+
//! Tests whether the given object is visible
bool IsVisible(int objRank);
@@ -1044,7 +1140,7 @@ protected:
//! Calculates the distances between the viewpoint and the origin of different objects
void ComputeDistance();
- //! Updates all the geometric parameters of objects
+ //! Updates geometric parameters of objects (bounding box and radius)
void UpdateGeometry();
protected:
@@ -1130,17 +1226,21 @@ protected:
bool m_fog;
bool m_firstGroundSpot;
int m_secondTexNum;
+ bool m_backgroundFull;
+ bool m_backgroundQuarter;
std::string m_backgroundName;
+ std::string m_backgroundQuarterNames[4];
+ Gfx::Texture m_backgroundFullTex;
+ Gfx::Texture m_backgroundQuarterTexs[4];
Gfx::Color m_backgroundColorUp;
Gfx::Color m_backgroundColorDown;
Gfx::Color m_backgroundCloudUp;
Gfx::Color m_backgroundCloudDown;
- bool m_backgroundFull;
- bool m_backgroundQuarter;
bool m_overFront;
Gfx::Color m_overColor;
int m_overMode;
std::string m_foregroundName;
+ Gfx::Texture m_foregroundTex;
bool m_drawWorld;
bool m_drawFront;
float m_limitLOD[2];
diff --git a/src/graphics/engine/lightning.cpp b/src/graphics/engine/lightning.cpp
index 4ecdb3c..b6b111a 100644
--- a/src/graphics/engine/lightning.cpp
+++ b/src/graphics/engine/lightning.cpp
@@ -24,66 +24,66 @@
Gfx::CLightning::CLightning(CInstanceManager* iMan, Gfx::CEngine* engine)
{
- GetLogger()->Info("CLightning::CLightning() stub!\n");
+ GetLogger()->Trace("CLightning::CLightning() stub!\n");
// TODO!
}
Gfx::CLightning::~CLightning()
{
- GetLogger()->Info("CLightning::~CLightning() stub!\n");
+ GetLogger()->Trace("CLightning::~CLightning() stub!\n");
// TODO!
}
void Gfx::CLightning::Flush()
{
- GetLogger()->Info("CLightning::Flush() stub!\n");
+ GetLogger()->Trace("CLightning::Flush() stub!\n");
// TODO!
}
bool Gfx::CLightning::EventProcess(const Event &event)
{
- GetLogger()->Info("CLightning::EventProcess() stub!\n");
+ GetLogger()->Trace("CLightning::EventProcess() stub!\n");
// TODO!
return true;
}
bool Gfx::CLightning::Create(float sleep, float delay, float magnetic)
{
- GetLogger()->Info("CLightning::Create() stub!\n");
+ GetLogger()->Trace("CLightning::Create() stub!\n");
// TODO!
return true;
}
bool Gfx::CLightning::GetStatus(float &sleep, float &delay, float &magnetic, float &progress)
{
- GetLogger()->Info("CLightning::GetStatus() stub!\n");
+ GetLogger()->Trace("CLightning::GetStatus() stub!\n");
// TODO!
return true;
}
bool Gfx::CLightning::SetStatus(float sleep, float delay, float magnetic, float progress)
{
- GetLogger()->Info("CLightning::SetStatus() stub!\n");
+ GetLogger()->Trace("CLightning::SetStatus() stub!\n");
// TODO!
return true;
}
void Gfx::CLightning::Draw()
{
- GetLogger()->Info("CLightning::Draw() stub!\n");
+ GetLogger()->Trace("CLightning::Draw() stub!\n");
// TODO!
}
bool Gfx::CLightning::EventFrame(const Event &event)
{
- GetLogger()->Info("CLightning::EventFrame() stub!\n");
+ GetLogger()->Trace("CLightning::EventFrame() stub!\n");
// TODO!
return true;
}
CObject* Gfx::CLightning::SearchObject(Math::Vector pos)
{
- GetLogger()->Info("CLightning::SearchObject() stub!\n");
+ GetLogger()->Trace("CLightning::SearchObject() stub!\n");
// TODO!
return nullptr;
}
diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp
index 9a21fe0..37a3975 100644
--- a/src/graphics/engine/particle.cpp
+++ b/src/graphics/engine/particle.cpp
@@ -24,31 +24,31 @@
Gfx::CParticle::CParticle(CInstanceManager* iMan, Gfx::CEngine* engine)
{
- GetLogger()->Info("CParticle::CParticle() stub!\n");
+ GetLogger()->Trace("CParticle::CParticle() stub!\n");
// TODO!
}
Gfx::CParticle::~CParticle()
{
- GetLogger()->Info("CParticle::~CParticle() stub!\n");
+ GetLogger()->Trace("CParticle::~CParticle() stub!\n");
// TODO!
}
void Gfx::CParticle::SetDevice(Gfx::CDevice* device)
{
- GetLogger()->Info("CParticle::SetDevice() stub!\n");
+ GetLogger()->Trace("CParticle::SetDevice() stub!\n");
// TODO!
}
void Gfx::CParticle::FlushParticle()
{
- GetLogger()->Info("CParticle::FlushParticle() stub!\n");
+ GetLogger()->Trace("CParticle::FlushParticle() stub!\n");
// TODO!
}
void Gfx::CParticle::FlushParticle(int sheet)
{
- GetLogger()->Info("CParticle::FlushParticle() stub!\n");
+ GetLogger()->Trace("CParticle::FlushParticle() stub!\n");
// TODO!
}
@@ -56,7 +56,7 @@ int Gfx::CParticle::CreateParticle(Math::Vector pos, Math::Vector speed, Math::P
Gfx::ParticleType type, float duration, float mass,
float windSensitivity, int sheet)
{
- GetLogger()->Info("CParticle::CreateParticle() stub!\n");
+ GetLogger()->Trace("CParticle::CreateParticle() stub!\n");
// TODO!
return 0;
}
@@ -65,7 +65,7 @@ int Gfx::CParticle::CreateFrag(Math::Vector pos, Math::Vector speed, Gfx::Engine
Gfx::ParticleType type, float duration, float mass,
float windSensitivity, int sheet)
{
- GetLogger()->Info("CParticle::CreateFrag() stub!\n");
+ GetLogger()->Trace("CParticle::CreateFrag() stub!\n");
// TODO!
return 0;
}
@@ -74,7 +74,7 @@ int Gfx::CParticle::CreatePart(Math::Vector pos, Math::Vector speed, Gfx::Partic
float duration, float mass, float weight,
float windSensitivity, int sheet)
{
- GetLogger()->Info("CParticle::CreatePart() stub!\n");
+ GetLogger()->Trace("CParticle::CreatePart() stub!\n");
// TODO!
return 0;
}
@@ -82,7 +82,7 @@ int Gfx::CParticle::CreatePart(Math::Vector pos, Math::Vector speed, Gfx::Partic
int Gfx::CParticle::CreateRay(Math::Vector pos, Math::Vector goal, Gfx::ParticleType type, Math::Point dim,
float duration, int sheet)
{
- GetLogger()->Info("CParticle::CreateRay() stub!\n");
+ GetLogger()->Trace("CParticle::CreateRay() stub!\n");
// TODO!
return 0;
}
@@ -90,7 +90,7 @@ int Gfx::CParticle::CreateRay(Math::Vector pos, Math::Vector goal, Gfx::Particle
int Gfx::CParticle::CreateTrack(Math::Vector pos, Math::Vector speed, Math::Point dim, Gfx::ParticleType type,
float duration, float mass, float length, float width)
{
- GetLogger()->Info("CParticle::CreateTrack() stub!\n");
+ GetLogger()->Trace("CParticle::CreateTrack() stub!\n");
// TODO!
return 0;
}
@@ -98,205 +98,205 @@ int Gfx::CParticle::CreateTrack(Math::Vector pos, Math::Vector speed, Math::Poin
void Gfx::CParticle::CreateWheelTrace(const Math::Vector &p1, const Math::Vector &p2, const Math::Vector &p3,
const Math::Vector &p4, Gfx::ParticleType type)
{
- GetLogger()->Info("CParticle::CreateWheelTrace() stub!\n");
+ GetLogger()->Trace("CParticle::CreateWheelTrace() stub!\n");
// TODO!
}
void Gfx::CParticle::DeleteParticle(Gfx::ParticleType type)
{
- GetLogger()->Info("CParticle::DeleteParticle() stub!\n");
+ GetLogger()->Trace("CParticle::DeleteParticle() stub!\n");
// TODO!
}
void Gfx::CParticle::DeleteParticle(int channel)
{
- GetLogger()->Info("CParticle::DeleteParticle() stub!\n");
+ GetLogger()->Trace("CParticle::DeleteParticle() stub!\n");
// TODO!
}
void Gfx::CParticle::SetObjectLink(int channel, CObject *object)
{
- GetLogger()->Info("CParticle::SetObjectLink() stub!\n");
+ GetLogger()->Trace("CParticle::SetObjectLink() stub!\n");
// TODO!
}
void Gfx::CParticle::SetObjectFather(int channel, CObject *object)
{
- GetLogger()->Info("CParticle::SetObjectFather() stub!\n");
+ GetLogger()->Trace("CParticle::SetObjectFather() stub!\n");
// TODO!
}
void Gfx::CParticle::SetPosition(int channel, Math::Vector pos)
{
- GetLogger()->Info("CParticle::SetPosition() stub!\n");
+ GetLogger()->Trace("CParticle::SetPosition() stub!\n");
// TODO!
}
void Gfx::CParticle::SetDimension(int channel, Math::Point dim)
{
- GetLogger()->Info("CParticle::SetDimension() stub!\n");
+ GetLogger()->Trace("CParticle::SetDimension() stub!\n");
// TODO!
}
void Gfx::CParticle::SetZoom(int channel, float zoom)
{
- GetLogger()->Info("CParticle::SetZoom() stub!\n");
+ GetLogger()->Trace("CParticle::SetZoom() stub!\n");
// TODO!
}
void Gfx::CParticle::SetAngle(int channel, float angle)
{
- GetLogger()->Info("CParticle::SetAngle() stub!\n");
+ GetLogger()->Trace("CParticle::SetAngle() stub!\n");
// TODO!
}
void Gfx::CParticle::SetIntensity(int channel, float intensity)
{
- GetLogger()->Info("CParticle::SetIntensity() stub!\n");
+ GetLogger()->Trace("CParticle::SetIntensity() stub!\n");
// TODO!
}
void Gfx::CParticle::SetParam(int channel, Math::Vector pos, Math::Point dim, float zoom, float angle, float intensity)
{
- GetLogger()->Info("CParticle::SetParam() stub!\n");
+ GetLogger()->Trace("CParticle::SetParam() stub!\n");
// TODO!
}
void Gfx::CParticle::SetPhase(int channel, Gfx::ParticlePhase phase, float duration)
{
- GetLogger()->Info("CParticle::SetPhase() stub!\n");
+ GetLogger()->Trace("CParticle::SetPhase() stub!\n");
// TODO!
}
bool Gfx::CParticle::GetPosition(int channel, Math::Vector &pos)
{
- GetLogger()->Info("CParticle::GetPosition() stub!\n");
+ GetLogger()->Trace("CParticle::GetPosition() stub!\n");
// TODO!
return true;
}
Gfx::Color Gfx::CParticle::GetFogColor(Math::Vector pos)
{
- GetLogger()->Info("CParticle::GetFogColor() stub!\n");
+ GetLogger()->Trace("CParticle::GetFogColor() stub!\n");
// TODO!
return Gfx::Color();
}
void Gfx::CParticle::SetFrameUpdate(int sheet, bool update)
{
- GetLogger()->Info("CParticle::SetFrameUpdate() stub!\n");
+ GetLogger()->Trace("CParticle::SetFrameUpdate() stub!\n");
// TODO!
}
void Gfx::CParticle::FrameParticle(float rTime)
{
- GetLogger()->Info("CParticle::FrameParticle() stub!\n");
+ GetLogger()->Trace("CParticle::FrameParticle() stub!\n");
// TODO!
}
void Gfx::CParticle::DrawParticle(int sheet)
{
- GetLogger()->Info("CParticle::DrawParticle() stub!\n");
+ GetLogger()->Trace("CParticle::DrawParticle() stub!\n");
// TODO!
}
bool Gfx::CParticle::WriteWheelTrace(char *filename, int width, int height, Math::Vector dl, Math::Vector ur)
{
- GetLogger()->Info("CParticle::WriteWheelTrace() stub!\n");
+ GetLogger()->Trace("CParticle::WriteWheelTrace() stub!\n");
// TODO!
return true;
}
void Gfx::CParticle::DeleteRank(int rank)
{
- GetLogger()->Info("CParticle::DeleteRank() stub!\n");
+ GetLogger()->Trace("CParticle::DeleteRank() stub!\n");
// TODO!
}
bool Gfx::CParticle::CheckChannel(int &channel)
{
- GetLogger()->Info("CParticle::CheckChannel() stub!\n");
+ GetLogger()->Trace("CParticle::CheckChannel() stub!\n");
// TODO!
return true;
}
void Gfx::CParticle::DrawParticleTriangle(int i)
{
- GetLogger()->Info("CParticle::DrawParticleTriangle() stub!\n");
+ GetLogger()->Trace("CParticle::DrawParticleTriangle() stub!\n");
// TODO!
}
void Gfx::CParticle::DrawParticleNorm(int i)
{
- GetLogger()->Info("CParticle::DrawParticleNorm() stub!\n");
+ GetLogger()->Trace("CParticle::DrawParticleNorm() stub!\n");
// TODO!
}
void Gfx::CParticle::DrawParticleFlat(int i)
{
- GetLogger()->Info("CParticle::DrawParticleFlat() stub!\n");
+ GetLogger()->Trace("CParticle::DrawParticleFlat() stub!\n");
// TODO!
}
void Gfx::CParticle::DrawParticleFog(int i)
{
- GetLogger()->Info("CParticle::DrawParticleFog() stub!\n");
+ GetLogger()->Trace("CParticle::DrawParticleFog() stub!\n");
// TODO!
}
void Gfx::CParticle::DrawParticleRay(int i)
{
- GetLogger()->Info("CParticle::DrawParticleRay() stub!\n");
+ GetLogger()->Trace("CParticle::DrawParticleRay() stub!\n");
// TODO!
}
void Gfx::CParticle::DrawParticleSphere(int i)
{
- GetLogger()->Info("CParticle::DrawParticleSphere() stub!\n");
+ GetLogger()->Trace("CParticle::DrawParticleSphere() stub!\n");
// TODO!
}
void Gfx::CParticle::DrawParticleCylinder(int i)
{
- GetLogger()->Info("CParticle::DrawParticleCylinder() stub!\n");
+ GetLogger()->Trace("CParticle::DrawParticleCylinder() stub!\n");
// TODO!
}
void Gfx::CParticle::DrawParticleWheel(int i)
{
- GetLogger()->Info("CParticle::DrawParticleWheel() stub!\n");
+ GetLogger()->Trace("CParticle::DrawParticleWheel() stub!\n");
// TODO!
}
CObject* Gfx::CParticle::SearchObjectGun(Math::Vector old, Math::Vector pos, Gfx::ParticleType type, CObject *father)
{
- GetLogger()->Info("CParticle::SearchObjectGun() stub!\n");
+ GetLogger()->Trace("CParticle::SearchObjectGun() stub!\n");
// TODO!
return nullptr;
}
CObject* Gfx::CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal, Gfx::ParticleType type, CObject *father)
{
- GetLogger()->Info("CParticle::SearchObjectRay() stub!\n");
+ GetLogger()->Trace("CParticle::SearchObjectRay() stub!\n");
// TODO!
return nullptr;
}
void Gfx::CParticle::Play(Sound sound, Math::Vector pos, float amplitude)
{
- GetLogger()->Info("CParticle::Play() stub!\n");
+ GetLogger()->Trace("CParticle::Play() stub!\n");
// TODO!
}
bool Gfx::CParticle::TrackMove(int i, Math::Vector pos, float progress)
{
- GetLogger()->Info("CParticle::TrackMove() stub!\n");
+ GetLogger()->Trace("CParticle::TrackMove() stub!\n");
// TODO!
return true;
}
void Gfx::CParticle::TrackDraw(int i, Gfx::ParticleType type)
{
- GetLogger()->Info("CParticle::TrackDraw() stub!\n");
+ GetLogger()->Trace("CParticle::TrackDraw() stub!\n");
// TODO!
}
diff --git a/src/graphics/engine/planet.h b/src/graphics/engine/planet.h
index 54d8b55..e859cd7 100644
--- a/src/graphics/engine/planet.h
+++ b/src/graphics/engine/planet.h
@@ -51,6 +51,8 @@ struct Planet
std::string name;
//! Texture mapping
Math::Point uv1, uv2;
+
+ // TODO: make all textures transparent?
//! Transparent texture
bool transparent;
diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp
index 327befa..c97131e 100644
--- a/src/graphics/engine/pyro.cpp
+++ b/src/graphics/engine/pyro.cpp
@@ -24,156 +24,156 @@
Gfx::CPyro::CPyro(CInstanceManager* iMan)
{
- GetLogger()->Info("CParticle::CPyro() stub!\n");
+ GetLogger()->Trace("CParticle::CPyro() stub!\n");
// TODO!
}
Gfx::CPyro::~CPyro()
{
- GetLogger()->Info("CPyro::~CPyro() stub!");
+ GetLogger()->Trace("CPyro::~CPyro() stub!");
// TODO!
}
void Gfx::CPyro::DeleteObject(bool all)
{
- GetLogger()->Info("CPyro::DeleteObject() stub!");
+ GetLogger()->Trace("CPyro::DeleteObject() stub!");
// TODO!
}
bool Gfx::CPyro::Create(Gfx::PyroType type, CObject* pObj, float force)
{
- GetLogger()->Info("CPyro::Create() stub!");
+ GetLogger()->Trace("CPyro::Create() stub!");
// TODO!
return true;
}
bool Gfx::CPyro::EventProcess(const Event &event)
{
- GetLogger()->Info("CPyro::EventProcess() stub!\n");
+ GetLogger()->Trace("CPyro::EventProcess() stub!\n");
// TODO!
return true;
}
Error Gfx::CPyro::IsEnded()
{
- GetLogger()->Info("CPyro::IsEnded() stub!\n");
+ GetLogger()->Trace("CPyro::IsEnded() stub!\n");
// TODO!
return ERR_OK;
}
void Gfx::CPyro::CutObjectLink(CObject* pObj)
{
- GetLogger()->Info("CPyro::CutObjectLink() stub!\n");
+ GetLogger()->Trace("CPyro::CutObjectLink() stub!\n");
// TODO!
}
void Gfx::CPyro::DisplayError(PyroType type, CObject* pObj)
{
- GetLogger()->Info("CPyro::DisplayError() stub!\n");
+ GetLogger()->Trace("CPyro::DisplayError() stub!\n");
// TODO!
}
bool Gfx::CPyro::CreateLight(Math::Vector pos, float height)
{
- GetLogger()->Info("CPyro::CreateLight() stub!\n");
+ GetLogger()->Trace("CPyro::CreateLight() stub!\n");
// TODO!
return true;
}
void Gfx::CPyro::DeleteObject(bool primary, bool secondary)
{
- GetLogger()->Info("CPyro::DeleteObject() stub!\n");
+ GetLogger()->Trace("CPyro::DeleteObject() stub!\n");
// TODO!
}
void Gfx::CPyro::CreateTriangle(CObject* pObj, ObjectType oType, int part)
{
- GetLogger()->Info("CPyro::CreateTriangle() stub!\n");
+ GetLogger()->Trace("CPyro::CreateTriangle() stub!\n");
// TODO!
}
void Gfx::CPyro::ExploStart()
{
- GetLogger()->Info("CPyro::ExploStart() stub!\n");
+ GetLogger()->Trace("CPyro::ExploStart() stub!\n");
// TODO!
}
void Gfx::CPyro::ExploTerminate()
{
- GetLogger()->Info("CPyro::ExploTerminate() stub!\n");
+ GetLogger()->Trace("CPyro::ExploTerminate() stub!\n");
// TODO!
}
void Gfx::CPyro::BurnStart()
{
- GetLogger()->Info("CPyro::BurnStart() stub!\n");
+ GetLogger()->Trace("CPyro::BurnStart() stub!\n");
// TODO!
}
void Gfx::CPyro::BurnAddPart(int part, Math::Vector pos, Math::Vector angle)
{
- GetLogger()->Info("CPyro::BurnAddPart() stub!\n");
+ GetLogger()->Trace("CPyro::BurnAddPart() stub!\n");
// TODO!
}
void Gfx::CPyro::BurnProgress()
{
- GetLogger()->Info("CPyro::BurnProgress() stub!\n");
+ GetLogger()->Trace("CPyro::BurnProgress() stub!\n");
// TODO!
}
bool Gfx::CPyro::BurnIsKeepPart(int part)
{
- GetLogger()->Info("CPyro::BurnIsKeepPart() stub!\n");
+ GetLogger()->Trace("CPyro::BurnIsKeepPart() stub!\n");
// TODO!
return true;
}
void Gfx::CPyro::BurnTerminate()
{
- GetLogger()->Info("CPyro::BurnTerminate() stub!\n");
+ GetLogger()->Trace("CPyro::BurnTerminate() stub!\n");
// TODO!
}
void Gfx::CPyro::FallStart()
{
- GetLogger()->Info("CPyro::FallStart() stub!\n");
+ GetLogger()->Trace("CPyro::FallStart() stub!\n");
// TODO!
}
CObject* Gfx::CPyro::FallSearchBeeExplo()
{
- GetLogger()->Info("CPyro::FallSearchBeeExplo() stub!\n");
+ GetLogger()->Trace("CPyro::FallSearchBeeExplo() stub!\n");
// TODO!
return nullptr;
}
void Gfx::CPyro::FallProgress(float rTime)
{
- GetLogger()->Info("CPyro::FallProgress() stub!\n");
+ GetLogger()->Trace("CPyro::FallProgress() stub!\n");
// TODO!
}
Error Gfx::CPyro::FallIsEnded()
{
- GetLogger()->Info("CPyro::FallIsEnded() stub!\n");
+ GetLogger()->Trace("CPyro::FallIsEnded() stub!\n");
// TODO!
return ERR_OK;
}
void Gfx::CPyro::LightOperFlush()
{
- GetLogger()->Info("CPyro::LightOperFlush() stub!\n");
+ GetLogger()->Trace("CPyro::LightOperFlush() stub!\n");
// TODO!
}
void Gfx::CPyro::LightOperAdd(float progress, float intensity, float r, float g, float b)
{
- GetLogger()->Info("CPyro::LightOperAdd() stub!\n");
+ GetLogger()->Trace("CPyro::LightOperAdd() stub!\n");
// TODO!
}
void Gfx::CPyro::LightOperFrame(float rTime)
{
- GetLogger()->Info("CPyro::LightOperFrame() stub!\n");
+ GetLogger()->Trace("CPyro::LightOperFrame() stub!\n");
// TODO!
}
diff --git a/src/graphics/engine/terrain.cpp b/src/graphics/engine/terrain.cpp
index 6d4fcd3..6b26281 100644
--- a/src/graphics/engine/terrain.cpp
+++ b/src/graphics/engine/terrain.cpp
@@ -58,7 +58,7 @@ Gfx::CTerrain::CTerrain(CInstanceManager* iMan)
m_wind = Math::Vector(0.0f, 0.0f, 0.0f);
m_defHardness = 0.5f;
- m_levelMat.reserve(LEVEL_MAT_PREALLOCATE_COUNT);
+ m_levelMats.reserve(LEVEL_MAT_PREALLOCATE_COUNT);
m_flyingLimits.reserve(FLYING_LIMIT_PREALLOCATE_COUNT);
m_buildingLevels.reserve(BUILDING_LEVEL_PREALLOCATE_COUNT);
}
@@ -174,7 +174,7 @@ bool Gfx::CTerrain::InitTextures(const std::string& baseName, int* table, int dx
void Gfx::CTerrain::LevelFlush()
{
- m_levelMat.clear();
+ m_levelMats.clear();
m_levelMatMax = 0;
m_levelID = 1000;
LevelCloseTable();
@@ -200,7 +200,7 @@ void Gfx::CTerrain::LevelMaterial(int id, std::string& baseName, float u, float
tm.mat[3] = left;
tm.hardness = hardness;
- m_levelMat.push_back(tm);
+ m_levelMats.push_back(tm);
if (m_levelMatMax < up+1 ) m_levelMatMax = up+1;
if (m_levelMatMax < right+1) m_levelMatMax = right+1;
@@ -583,10 +583,10 @@ bool Gfx::CTerrain::CreateMosaic(int ox, int oy, int step, int objRank,
for (int y = 0; y < brick; y += step)
{
- Gfx::EngineObjLevel5 buffer;
+ Gfx::EngineObjLevel4 buffer;
buffer.vertices.reserve(total);
- buffer.type = Gfx::ENG_TRIANGLE_TYPE_6S;
+ buffer.type = Gfx::ENG_TRIANGLE_TYPE_SURFACE;
buffer.material = mat;
buffer.state = Gfx::ENG_RSTATE_WRAP;
@@ -695,10 +695,10 @@ bool Gfx::CTerrain::CreateMosaic(int ox, int oy, int step, int objRank,
Gfx::TerrainMaterial* Gfx::CTerrain::LevelSearchMat(int id)
{
- for (int i = 0; i < static_cast<int>( m_levelMat.size() ); i++)
+ for (int i = 0; i < static_cast<int>( m_levelMats.size() ); i++)
{
- if (id == m_levelMat[i].id)
- return &m_levelMat[i];
+ if (id == m_levelMats[i].id)
+ return &m_levelMats[i];
}
return nullptr;
@@ -709,7 +709,7 @@ void Gfx::CTerrain::LevelTextureName(int x, int y, std::string& name, Math::Poin
x /= m_brick/m_subdivMapping;
y /= m_brick/m_subdivMapping;
- TerrainMaterial* tm = LevelSearchMat(m_levelDot[x+y*m_levelDotSize].id);
+ TerrainMaterial* tm = LevelSearchMat(m_levelDots[x+y*m_levelDotSize].id);
if (tm == nullptr)
{
name = "xxx.png";
@@ -777,16 +777,16 @@ bool Gfx::CTerrain::LevelGetDot(int x, int y, float min, float max, float slope)
}
-/** Returns the index within m_levelMat or -1 if there is not.
- m_levelMat[i].id gives the identifier. */
+/** Returns the index within m_levelMats or -1 if there is not.
+ m_levelMats[i].id gives the identifier. */
int Gfx::CTerrain::LevelTestMat(char *mat)
{
- for (int i = 0; i < static_cast<int>( m_levelMat.size() ); i++)
+ for (int i = 0; i < static_cast<int>( m_levelMats.size() ); i++)
{
- if ( m_levelMat[i].mat[0] == mat[0] &&
- m_levelMat[i].mat[1] == mat[1] &&
- m_levelMat[i].mat[2] == mat[2] &&
- m_levelMat[i].mat[3] == mat[3] ) return i;
+ if ( m_levelMats[i].mat[0] == mat[0] &&
+ m_levelMats[i].mat[1] == mat[1] &&
+ m_levelMats[i].mat[2] == mat[2] &&
+ m_levelMats[i].mat[3] == mat[3] ) return i;
}
return -1;
@@ -804,27 +804,27 @@ void Gfx::CTerrain::LevelSetDot(int x, int y, int id, char *mat)
{
int ii = LevelTestMat(mat);
if (ii == -1) return;
- id = m_levelMat[ii].id; // looking for a id compatible with mat
+ id = m_levelMats[ii].id; // looking for a id compatible with mat
}
// Changes the point
- m_levelDot[x+y*m_levelDotSize].id = id;
- m_levelDot[x+y*m_levelDotSize].mat[0] = mat[0];
- m_levelDot[x+y*m_levelDotSize].mat[1] = mat[1];
- m_levelDot[x+y*m_levelDotSize].mat[2] = mat[2];
- m_levelDot[x+y*m_levelDotSize].mat[3] = mat[3];
+ m_levelDots[x+y*m_levelDotSize].id = id;
+ m_levelDots[x+y*m_levelDotSize].mat[0] = mat[0];
+ m_levelDots[x+y*m_levelDotSize].mat[1] = mat[1];
+ m_levelDots[x+y*m_levelDotSize].mat[2] = mat[2];
+ m_levelDots[x+y*m_levelDotSize].mat[3] = mat[3];
// Changes the lower neighbor
if ( (x+0) >= 0 && (x+0) < m_levelDotSize &&
(y-1) >= 0 && (y-1) < m_levelDotSize )
{
int i = (x+0)+(y-1)*m_levelDotSize;
- if (m_levelDot[i].mat[0] != mat[2])
+ if (m_levelDots[i].mat[0] != mat[2])
{
- m_levelDot[i].mat[0] = mat[2];
- int ii = LevelTestMat(m_levelDot[i].mat);
+ m_levelDots[i].mat[0] = mat[2];
+ int ii = LevelTestMat(m_levelDots[i].mat);
if (ii != -1)
- m_levelDot[i].id = m_levelMat[ii].id;
+ m_levelDots[i].id = m_levelMats[ii].id;
}
}
@@ -833,12 +833,12 @@ void Gfx::CTerrain::LevelSetDot(int x, int y, int id, char *mat)
(y+0) >= 0 && (y+0) < m_levelDotSize )
{
int i = (x-1)+(y+0)*m_levelDotSize;
- if (m_levelDot[i].mat[1] != mat[3])
+ if (m_levelDots[i].mat[1] != mat[3])
{
- m_levelDot[i].mat[1] = mat[3];
- int ii = LevelTestMat(m_levelDot[i].mat);
+ m_levelDots[i].mat[1] = mat[3];
+ int ii = LevelTestMat(m_levelDots[i].mat);
if (ii != -1)
- m_levelDot[i].id = m_levelMat[ii].id;
+ m_levelDots[i].id = m_levelMats[ii].id;
}
}
@@ -847,12 +847,12 @@ void Gfx::CTerrain::LevelSetDot(int x, int y, int id, char *mat)
(y+1) >= 0 && (y+1) < m_levelDotSize )
{
int i = (x+0)+(y+1)*m_levelDotSize;
- if (m_levelDot[i].mat[2] != mat[0])
+ if (m_levelDots[i].mat[2] != mat[0])
{
- m_levelDot[i].mat[2] = mat[0];
- int ii = LevelTestMat(m_levelDot[i].mat);
+ m_levelDots[i].mat[2] = mat[0];
+ int ii = LevelTestMat(m_levelDots[i].mat);
if (ii != -1)
- m_levelDot[i].id = m_levelMat[ii].id;
+ m_levelDots[i].id = m_levelMats[ii].id;
}
}
@@ -861,12 +861,12 @@ void Gfx::CTerrain::LevelSetDot(int x, int y, int id, char *mat)
(y+0) >= 0 && (y+0) < m_levelDotSize )
{
int i = (x+1)+(y+0)*m_levelDotSize;
- if ( m_levelDot[i].mat[3] != mat[1] )
+ if ( m_levelDots[i].mat[3] != mat[1] )
{
- m_levelDot[i].mat[3] = mat[1];
- int ii = LevelTestMat(m_levelDot[i].mat);
+ m_levelDots[i].mat[3] = mat[1];
+ int ii = LevelTestMat(m_levelDots[i].mat);
if (ii != -1)
- m_levelDot[i].id = m_levelMat[ii].id;
+ m_levelDots[i].id = m_levelMats[ii].id;
}
}
}
@@ -880,9 +880,9 @@ bool Gfx::CTerrain::LevelIfDot(int x, int y, int id, char *mat)
y-1 >= 0 && y-1 < m_levelDotSize )
{
test[0] = mat[2];
- test[1] = m_levelDot[(x+0)+(y-1)*m_levelDotSize].mat[1];
- test[2] = m_levelDot[(x+0)+(y-1)*m_levelDotSize].mat[2];
- test[3] = m_levelDot[(x+0)+(y-1)*m_levelDotSize].mat[3];
+ test[1] = m_levelDots[(x+0)+(y-1)*m_levelDotSize].mat[1];
+ test[2] = m_levelDots[(x+0)+(y-1)*m_levelDotSize].mat[2];
+ test[3] = m_levelDots[(x+0)+(y-1)*m_levelDotSize].mat[3];
if ( LevelTestMat(test) == -1 ) return false;
}
@@ -891,10 +891,10 @@ bool Gfx::CTerrain::LevelIfDot(int x, int y, int id, char *mat)
if ( x-1 >= 0 && x-1 < m_levelDotSize &&
y+0 >= 0 && y+0 < m_levelDotSize )
{
- test[0] = m_levelDot[(x-1)+(y+0)*m_levelDotSize].mat[0];
+ test[0] = m_levelDots[(x-1)+(y+0)*m_levelDotSize].mat[0];
test[1] = mat[3];
- test[2] = m_levelDot[(x-1)+(y+0)*m_levelDotSize].mat[2];
- test[3] = m_levelDot[(x-1)+(y+0)*m_levelDotSize].mat[3];
+ test[2] = m_levelDots[(x-1)+(y+0)*m_levelDotSize].mat[2];
+ test[3] = m_levelDots[(x-1)+(y+0)*m_levelDotSize].mat[3];
if ( LevelTestMat(test) == -1 ) return false;
}
@@ -903,10 +903,10 @@ bool Gfx::CTerrain::LevelIfDot(int x, int y, int id, char *mat)
if ( x+0 >= 0 && x+0 < m_levelDotSize &&
y+1 >= 0 && y+1 < m_levelDotSize )
{
- test[0] = m_levelDot[(x+0)+(y+1)*m_levelDotSize].mat[0];
- test[1] = m_levelDot[(x+0)+(y+1)*m_levelDotSize].mat[1];
+ test[0] = m_levelDots[(x+0)+(y+1)*m_levelDotSize].mat[0];
+ test[1] = m_levelDots[(x+0)+(y+1)*m_levelDotSize].mat[1];
test[2] = mat[0];
- test[3] = m_levelDot[(x+0)+(y+1)*m_levelDotSize].mat[3];
+ test[3] = m_levelDots[(x+0)+(y+1)*m_levelDotSize].mat[3];
if ( LevelTestMat(test) == -1 ) return false;
}
@@ -915,9 +915,9 @@ bool Gfx::CTerrain::LevelIfDot(int x, int y, int id, char *mat)
if ( x+1 >= 0 && x+1 < m_levelDotSize &&
y+0 >= 0 && y+0 < m_levelDotSize )
{
- test[0] = m_levelDot[(x+1)+(y+0)*m_levelDotSize].mat[0];
- test[1] = m_levelDot[(x+1)+(y+0)*m_levelDotSize].mat[1];
- test[2] = m_levelDot[(x+1)+(y+0)*m_levelDotSize].mat[2];
+ test[0] = m_levelDots[(x+1)+(y+0)*m_levelDotSize].mat[0];
+ test[1] = m_levelDots[(x+1)+(y+0)*m_levelDotSize].mat[1];
+ test[2] = m_levelDots[(x+1)+(y+0)*m_levelDotSize].mat[2];
test[3] = mat[1];
if ( LevelTestMat(test) == -1 ) return false;
@@ -1094,10 +1094,10 @@ bool Gfx::CTerrain::LevelInit(int id)
for (int i = 0; i < m_levelDotSize*m_levelDotSize; i++)
{
- m_levelDot[i].id = id;
+ m_levelDots[i].id = id;
for (int j = 0; j < 4; j++)
- m_levelDot[i].mat[j] = tm->mat[j];
+ m_levelDots[i].mat[j] = tm->mat[j];
}
return true;
@@ -1186,21 +1186,21 @@ bool Gfx::CTerrain::LevelGenerate(int *id, float min, float max,
void Gfx::CTerrain::LevelOpenTable()
{
if (! m_levelText) return;
- if (! m_levelDot.empty()) return; // already allocated
+ if (! m_levelDots.empty()) return; // already allocated
m_levelDotSize = (m_mosaic*m_brick)/(m_brick/m_subdivMapping)+1;
- std::vector<Gfx::DotLevel>(m_levelDotSize*m_levelDotSize).swap(m_levelDot);
+ std::vector<Gfx::DotLevel>(m_levelDotSize*m_levelDotSize).swap(m_levelDots);
for (int i = 0; i < m_levelDotSize * m_levelDotSize; i++)
{
for (int j = 0; j < 4; j++)
- m_levelDot[i].mat[j] = 0;
+ m_levelDots[i].mat[j] = 0;
}
}
void Gfx::CTerrain::LevelCloseTable()
{
- m_levelDot.clear();
+ m_levelDots.clear();
}
bool Gfx::CTerrain::CreateSquare(bool multiRes, int x, int y)
@@ -1673,7 +1673,7 @@ float Gfx::CTerrain::GetHardness(const Math::Vector &p)
float factor = GetBuildingFactor(p);
if (factor != 1.0f) return 1.0f; // on building
- if (m_levelDot.empty()) return m_defHardness;
+ if (m_levelDots.empty()) return m_defHardness;
float dim = (m_mosaic*m_brick*m_size)/2.0f;
@@ -1691,7 +1691,7 @@ float Gfx::CTerrain::GetHardness(const Math::Vector &p)
if ( x < 0 || x >= m_levelDotSize ||
y < 0 || y >= m_levelDotSize ) return m_defHardness;
- int id = m_levelDot[x+y*m_levelDotSize].id;
+ int id = m_levelDots[x+y*m_levelDotSize].id;
TerrainMaterial* tm = LevelSearchMat(id);
if (tm == nullptr) return m_defHardness;
@@ -1729,7 +1729,7 @@ void Gfx::CTerrain::GroundFlat(Math::Vector pos)
}
}
- m_engine->GroundMarkCreate(pos, 40.0f, 0.001f, 15.0f, 0.001f, 41, 41, table);
+ m_engine->CreateGroundMark(pos, 40.0f, 0.001f, 15.0f, 0.001f, 41, 41, table);
}
float Gfx::CTerrain::GetFlatZoneRadius(Math::Vector center, float max)
diff --git a/src/graphics/engine/terrain.h b/src/graphics/engine/terrain.h
index 41d4bbb..0c7e3cf 100644
--- a/src/graphics/engine/terrain.h
+++ b/src/graphics/engine/terrain.h
@@ -273,8 +273,8 @@ protected:
std::string m_texBaseExt;
float m_defHardness;
- std::vector<TerrainMaterial> m_levelMat;
- std::vector<Gfx::DotLevel> m_levelDot;
+ std::vector<TerrainMaterial> m_levelMats;
+ std::vector<Gfx::DotLevel> m_levelDots;
int m_levelMatMax;
int m_levelID;
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index 82abd62..19ef57b 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -788,7 +788,7 @@ Gfx::CharTexture Gfx::CText::CreateCharTexture(Gfx::UTF8Char ch, Gfx::CachedFont
SDL_FreeSurface(textSurface);
SDL_FreeSurface(textureSurface);
- if (! tex.valid)
+ if (! tex.Valid())
{
m_error = "Texture create error";
return texture;
diff --git a/src/graphics/engine/water.cpp b/src/graphics/engine/water.cpp
index 8fbd1ae..2a7c6d2 100644
--- a/src/graphics/engine/water.cpp
+++ b/src/graphics/engine/water.cpp
@@ -20,8 +20,10 @@
#include "graphics/engine/water.h"
#include "common/iman.h"
+#include "common/logger.h"
#include "graphics/engine/engine.h"
#include "graphics/engine/terrain.h"
+#include "object/object.h"
#include "sound/sound.h"
@@ -49,9 +51,9 @@ Gfx::CWater::CWater(CInstanceManager* iMan, Gfx::CEngine* engine)
m_color = 0xffffffff;
m_subdiv = 4;
- m_line.reserve(WATERLINE_PREALLOCATE_COUNT);
+ m_lines.reserve(WATERLINE_PREALLOCATE_COUNT);
- std::vector<Gfx::WaterVapor>(VAPOR_SIZE).swap(m_vapor);
+ std::vector<Gfx::WaterVapor>(VAPOR_SIZE).swap(m_vapors);
}
Gfx::CWater::~CWater()
@@ -91,7 +93,7 @@ void Gfx::CWater::LavaFrame(float rTime)
if (m_particule == nullptr)
m_particule = static_cast<Gfx::CParticle*>( m_iMan->SearchInstance(CLASS_PARTICULE) );
- for (int i = 0; i < static_cast<int>( m_vapor.size() ); i++)
+ for (int i = 0; i < static_cast<int>( m_vapors.size() ); i++)
VaporFrame(i, rTime);
if (m_time - m_lastLava >= 0.1f)
@@ -138,26 +140,26 @@ void Gfx::CWater::LavaFrame(float rTime)
void Gfx::CWater::VaporFlush()
{
- m_vapor.clear();
+ m_vapors.clear();
}
bool Gfx::CWater::VaporCreate(Gfx::ParticleType type, Math::Vector pos, float delay)
{
- for (int i = 0; i < static_cast<int>( m_vapor.size() ); i++)
+ for (int i = 0; i < static_cast<int>( m_vapors.size() ); i++)
{
- if (! m_vapor[i].used)
+ if (! m_vapors[i].used)
{
- m_vapor[i].used = true;
- m_vapor[i].type = type;
- m_vapor[i].pos = pos;
- m_vapor[i].delay = delay;
- m_vapor[i].time = 0.0f;
- m_vapor[i].last = 0.0f;
-
- if (m_vapor[i].type == PARTIFIRE)
+ m_vapors[i].used = true;
+ m_vapors[i].type = type;
+ m_vapors[i].pos = pos;
+ m_vapors[i].delay = delay;
+ m_vapors[i].time = 0.0f;
+ m_vapors[i].last = 0.0f;
+
+ if (m_vapors[i].type == PARTIFIRE)
m_sound->Play(SOUND_BLUP, pos, 1.0f, 1.0f-Math::Rand()*0.5f);
- if (m_vapor[i].type == PARTIVAPOR)
+ if (m_vapors[i].type == PARTIVAPOR)
m_sound->Play(SOUND_PSHHH, pos, 0.3f, 2.0f);
return true;
@@ -169,22 +171,22 @@ bool Gfx::CWater::VaporCreate(Gfx::ParticleType type, Math::Vector pos, float de
void Gfx::CWater::VaporFrame(int i, float rTime)
{
- m_vapor[i].time += rTime;
+ m_vapors[i].time += rTime;
if (m_sound == nullptr)
m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
- if (m_vapor[i].time <= m_vapor[i].delay)
+ if (m_vapors[i].time <= m_vapors[i].delay)
{
- if (m_time-m_vapor[i].last >= m_engine->ParticleAdapt(0.02f))
+ if (m_time-m_vapors[i].last >= m_engine->ParticleAdapt(0.02f))
{
- m_vapor[i].last = m_time;
+ m_vapors[i].last = m_time;
- if (m_vapor[i].type == PARTIFIRE)
+ if (m_vapors[i].type == PARTIFIRE)
{
for (int j = 0; j < 10; j++)
{
- Math::Vector pos = m_vapor[i].pos;
+ Math::Vector pos = m_vapors[i].pos;
pos.x += (Math::Rand()-0.5f)*2.0f;
pos.z += (Math::Rand()-0.5f)*2.0f;
pos.y -= 1.0f;
@@ -198,9 +200,9 @@ void Gfx::CWater::VaporFrame(int i, float rTime)
m_particule->CreateParticle(pos, speed, dim, PARTIERROR, 2.0f, 10.0f);
}
}
- else if (m_vapor[i].type == PARTIFLAME)
+ else if (m_vapors[i].type == PARTIFLAME)
{
- Math::Vector pos = m_vapor[i].pos;
+ Math::Vector pos = m_vapors[i].pos;
pos.x += (Math::Rand()-0.5f)*8.0f;
pos.z += (Math::Rand()-0.5f)*8.0f;
pos.y -= 2.0f;
@@ -215,7 +217,7 @@ void Gfx::CWater::VaporFrame(int i, float rTime)
}
else
{
- Math::Vector pos = m_vapor[i].pos;
+ Math::Vector pos = m_vapors[i].pos;
pos.x += (Math::Rand()-0.5f)*4.0f;
pos.z += (Math::Rand()-0.5f)*4.0f;
pos.y -= 2.0f;
@@ -232,7 +234,7 @@ void Gfx::CWater::VaporFrame(int i, float rTime)
}
else
{
- m_vapor[i].used = false;
+ m_vapors[i].used = false;
}
}
@@ -256,6 +258,7 @@ void Gfx::CWater::AdjustLevel(Math::Vector &pos, Math::Vector &norm,
/** This surface prevents to see the sky (background) underwater! */
void Gfx::CWater::DrawBack()
{
+ GetLogger()->Trace("CWater::DrawBack(): stub!\n");
/* TODO!
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[4]; // 2 triangles
@@ -336,6 +339,7 @@ void Gfx::CWater::DrawBack()
void Gfx::CWater::DrawSurf()
{
+ GetLogger()->Trace("CWater::DrawSurf(): stub!\n");
/* TODO!
LPDIRECT3DDEVICE7 device;
D3DVERTEX2* vertex; // triangles
@@ -498,7 +502,7 @@ void Gfx::CWater::CreateLine(int x, int y, int len)
line.px2 = m_size*(line.x+line.len) - offset;
line.pz = m_size* line.y - offset;
- m_line.push_back(line);
+ m_lines.push_back(line);
}
void Gfx::CWater::Create(Gfx::WaterType type1, Gfx::WaterType type2, const std::string& fileName,
@@ -533,7 +537,7 @@ void Gfx::CWater::Create(Gfx::WaterType type1, Gfx::WaterType type2, const std::
if (m_type[0] == WATER_NULL)
return;
- m_line.clear();
+ m_lines.clear();
for (int y = 0; y < m_brick; y++)
{
@@ -586,7 +590,6 @@ float Gfx::CWater::GetLevel()
float Gfx::CWater::GetLevel(CObject* object)
{
- /* TODO!
ObjectType type = object->GetType();
if ( type == OBJECT_HUMAN ||
@@ -625,7 +628,7 @@ float Gfx::CWater::GetLevel(CObject* object)
{
return m_level-2.0f;
}
-*/
+
return m_level;
}
diff --git a/src/graphics/engine/water.h b/src/graphics/engine/water.h
index b051889..f20f992 100644
--- a/src/graphics/engine/water.h
+++ b/src/graphics/engine/water.h
@@ -165,8 +165,8 @@ protected:
//! Size of a item in an brick
float m_size;
- std::vector<WaterLine> m_line;
- std::vector<WaterVapor> m_vapor;
+ std::vector<WaterLine> m_lines;
+ std::vector<WaterVapor> m_vapors;
bool m_draw;
bool m_lava;
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index caa79ee..3526b13 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -396,7 +396,6 @@ Gfx::Texture Gfx::CGLDevice::CreateTexture(ImageData *data, const Gfx::TextureCr
{
Gfx::Texture result;
- result.valid = true;
result.size.x = data->surface->w;
result.size.y = data->surface->h;
@@ -463,7 +462,7 @@ Gfx::Texture Gfx::CGLDevice::CreateTexture(ImageData *data, const Gfx::TextureCr
// Restore the previous state of 1st stage
- if (m_currentTextures[0].valid)
+ if (m_currentTextures[0].Valid())
glBindTexture(GL_TEXTURE_2D, m_currentTextures[0].id);
else
glBindTexture(GL_TEXTURE_2D, 0);
@@ -518,7 +517,7 @@ void Gfx::CGLDevice::SetTexture(int index, const Gfx::Texture &texture)
m_currentTextures[index] = texture; // remember the change
- if (! texture.valid)
+ if (! texture.Valid())
{
glBindTexture(GL_TEXTURE_2D, 0); // unbind texture
}
@@ -596,7 +595,7 @@ void Gfx::CGLDevice::SetTextureStageParams(int index, const Gfx::TextureStagePar
m_textureStageParams[index] = params;
// Don't actually do anything if texture not set
- if (! m_currentTextures[index].valid)
+ if (! m_currentTextures[index].Valid())
return;
// Enable the given stage