Refactored Math::Point in CPlanet, CTerrain, CWater and CLevelParserParam
parent
498f15cc92
commit
07d3d79e8d
|
@ -113,7 +113,7 @@ void CPlanet::Draw()
|
|||
else
|
||||
m_engine->SetState(ENG_RSTATE_WRAP | ENG_RSTATE_TTEXTURE_BLACK);
|
||||
|
||||
Math::Point p1, p2;
|
||||
glm::vec2 p1, p2;
|
||||
|
||||
// Determine the 2D coordinates of the centre of the planet.
|
||||
|
||||
|
@ -141,10 +141,10 @@ void CPlanet::Draw()
|
|||
|
||||
Vertex quad[4] =
|
||||
{
|
||||
{ Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(u1, v2) },
|
||||
{ Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(u1, v1) },
|
||||
{ Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(u2, v2) },
|
||||
{ Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(u2, v1) }
|
||||
{ Math::Vector(p1.x, p1.y, 0.0f), n, { u1, v2 } },
|
||||
{ Math::Vector(p1.x, p2.y, 0.0f), n, { u1, v1 } },
|
||||
{ Math::Vector(p2.x, p1.y, 0.0f), n, { u2, v2 } },
|
||||
{ Math::Vector(p2.x, p2.y, 0.0f), n, { u2, v1 } }
|
||||
};
|
||||
|
||||
device->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, quad, 4);
|
||||
|
@ -152,8 +152,8 @@ void CPlanet::Draw()
|
|||
}
|
||||
}
|
||||
|
||||
void CPlanet::Create(PlanetType type, Math::Point start, float dim, float speed,
|
||||
float dir, const std::string& name, Math::Point uv1, Math::Point uv2,
|
||||
void CPlanet::Create(PlanetType type, const glm::vec2& start, float dim, float speed,
|
||||
float dir, const std::string& name, const glm::vec2& uv1, const glm::vec2& uv2,
|
||||
bool transparent)
|
||||
{
|
||||
Planet planet;
|
||||
|
|
|
@ -26,8 +26,9 @@
|
|||
|
||||
#include "graphics/engine/planet_type.h"
|
||||
|
||||
#include "math/point.h"
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct Event;
|
||||
|
@ -57,8 +58,8 @@ public:
|
|||
//! Management of an event
|
||||
bool EventProcess(const Event &event);
|
||||
//! Creates a new planet
|
||||
void Create(PlanetType type, Math::Point start, float dim, float speed, float dir,
|
||||
const std::string& name, Math::Point uv1, Math::Point uv2,
|
||||
void Create(PlanetType type, const glm::vec2& start, float dim, float speed, float dir,
|
||||
const std::string& name, const glm::vec2& uv1, const glm::vec2& uv2,
|
||||
bool transparent);
|
||||
//! Indicates if there is at least one planet
|
||||
bool PlanetExist();
|
||||
|
@ -88,9 +89,9 @@ protected:
|
|||
//! Type of planet
|
||||
PlanetType type = PlanetType::Sky;
|
||||
//! Initial position in degrees
|
||||
Math::Point start;
|
||||
glm::vec2 start;
|
||||
//! Current position in degrees
|
||||
Math::Point angle;
|
||||
glm::vec2 angle;
|
||||
//! Dimensions (0..1)
|
||||
float dim = 0.0f;
|
||||
//! Speed
|
||||
|
@ -100,7 +101,7 @@ protected:
|
|||
//! Name of the texture
|
||||
std::string name;
|
||||
//! Texture mapping
|
||||
Math::Point uv1, uv2;
|
||||
glm::vec2 uv1, uv2;
|
||||
|
||||
// TODO: make all textures transparent?
|
||||
//! Transparent texture
|
||||
|
|
|
@ -161,7 +161,7 @@ void CTerrain::FlushMaterials()
|
|||
FlushMaterialPoints();
|
||||
}
|
||||
|
||||
void CTerrain::AddMaterial(int id, const std::string& texName, const Math::Point &uv,
|
||||
void CTerrain::AddMaterial(int id, const std::string& texName, const glm::vec2& uv,
|
||||
int up, int right, int down, int left,
|
||||
float hardness)
|
||||
{
|
||||
|
@ -754,7 +754,7 @@ CTerrain::TerrainMaterial* CTerrain::FindMaterial(int id)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void CTerrain::GetTexture(int x, int y, std::string& name, Math::Point &uv)
|
||||
void CTerrain::GetTexture(int x, int y, std::string& name, glm::vec2&uv)
|
||||
{
|
||||
x /= m_brickCount/m_textureSubdivCount;
|
||||
y /= m_brickCount/m_textureSubdivCount;
|
||||
|
@ -1807,7 +1807,7 @@ float CTerrain::GetFlatZoneRadius(Math::Vector center, float max)
|
|||
return 0.0f;
|
||||
|
||||
float ref = GetFloorLevel(center, true);
|
||||
Math::Point c(center.x, center.z);
|
||||
glm::vec2 c = { center.x, center.z };
|
||||
float radius = 1.0f;
|
||||
|
||||
while (radius <= max)
|
||||
|
@ -1816,10 +1816,10 @@ float CTerrain::GetFlatZoneRadius(Math::Vector center, float max)
|
|||
int nb = static_cast<int>(2.0f*Math::PI*radius);
|
||||
if (nb < 8) nb = 8;
|
||||
|
||||
Math::Point p (center.x+radius, center.z);
|
||||
glm::vec2 p = { center.x + radius, center.z };
|
||||
for (int i = 0; i < nb; i++)
|
||||
{
|
||||
Math::Point result = Math::RotatePoint(c, angle, p);
|
||||
glm::vec2 result = Math::RotatePoint(c, angle, p);
|
||||
Math::Vector pos;
|
||||
pos.x = result.x;
|
||||
pos.z = result.y;
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "graphics/core/vertex.h"
|
||||
|
||||
#include "math/const.h"
|
||||
#include "math/point.h"
|
||||
#include "math/vector.h"
|
||||
|
||||
#include <string>
|
||||
|
@ -159,7 +158,7 @@ public:
|
|||
//! Clears all terrain materials
|
||||
void FlushMaterials();
|
||||
//! Adds a terrain material the names of textures to use for the land
|
||||
void AddMaterial(int id, const std::string& texName, const Math::Point& uv,
|
||||
void AddMaterial(int id, const std::string& texName, const glm::vec2& uv,
|
||||
int up, int right, int down, int left, float hardness);
|
||||
//! Initializes all the ground with one material
|
||||
bool InitMaterials(int id);
|
||||
|
@ -266,7 +265,7 @@ protected:
|
|||
//! Seeks a material based on neighbor values
|
||||
int FindMaterialByNeighbors(char *mat);
|
||||
//! Returns the texture name and UV coords to use for a given square
|
||||
void GetTexture(int x, int y, std::string& name, Math::Point& uv);
|
||||
void GetTexture(int x, int y, std::string& name, glm::vec2& uv);
|
||||
//! Returns the height of the terrain
|
||||
float GetHeight(int x, int y);
|
||||
//! Decide whether a point is using the materials
|
||||
|
@ -334,7 +333,7 @@ protected:
|
|||
//! Texture
|
||||
std::string texName;
|
||||
//! UV texture coordinates
|
||||
Math::Point uv;
|
||||
glm::vec2 uv;
|
||||
//! Terrain hardness (defines e.g. sound of walking)
|
||||
float hardness = 0.0f;
|
||||
//! IDs of neighbor materials: up, right, down, left
|
||||
|
|
|
@ -191,7 +191,7 @@ void CWater::VaporFrame(int i, float rTime)
|
|||
speed.x = (Math::Rand()-0.5f)*6.0f;
|
||||
speed.z = (Math::Rand()-0.5f)*6.0f;
|
||||
speed.y = 8.0f+Math::Rand()*5.0f;
|
||||
Math::Point dim;
|
||||
glm::vec2 dim;
|
||||
dim.x = Math::Rand()*1.5f+1.5f;
|
||||
dim.y = dim.x;
|
||||
m_particle->CreateParticle(pos, speed, dim, PARTIERROR, 2.0f, 10.0f);
|
||||
|
@ -207,7 +207,7 @@ void CWater::VaporFrame(int i, float rTime)
|
|||
speed.x = (Math::Rand()-0.5f)*2.0f;
|
||||
speed.z = (Math::Rand()-0.5f)*2.0f;
|
||||
speed.y = 4.0f+Math::Rand()*4.0f;
|
||||
Math::Point dim;
|
||||
glm::vec2 dim;
|
||||
dim.x = Math::Rand()*2.0f+2.0f;
|
||||
dim.y = dim.x;
|
||||
m_particle->CreateParticle(pos, speed, dim, PARTIFLAME);
|
||||
|
@ -222,7 +222,7 @@ void CWater::VaporFrame(int i, float rTime)
|
|||
speed.x = (Math::Rand()-0.5f)*2.0f;
|
||||
speed.z = (Math::Rand()-0.5f)*2.0f;
|
||||
speed.y = 8.0f+Math::Rand()*8.0f;
|
||||
Math::Point dim;
|
||||
glm::vec2 dim;
|
||||
dim.x = Math::Rand()*1.0f+1.0f;
|
||||
dim.y = dim.x;
|
||||
m_particle->CreateParticle(pos, speed, dim, PARTIVAPOR);
|
||||
|
@ -236,7 +236,7 @@ void CWater::VaporFrame(int i, float rTime)
|
|||
}
|
||||
|
||||
void CWater::AdjustLevel(Math::Vector &pos, Math::Vector &norm,
|
||||
Math::Point &uv1, Math::Point &uv2)
|
||||
glm::vec2& uv1, glm::vec2& uv2)
|
||||
{
|
||||
float t1 = m_time*1.5f + pos.x*0.1f * pos.z*0.2f;
|
||||
pos.y += sinf(t1)*m_eddy.y;
|
||||
|
@ -384,7 +384,7 @@ void CWater::DrawSurf()
|
|||
|
||||
int vertexIndex = 0;
|
||||
|
||||
Math::Point uv1, uv2;
|
||||
glm::vec2 uv1, uv2;
|
||||
Math::Vector n;
|
||||
|
||||
p.x = pos.x-size;
|
||||
|
|
|
@ -108,7 +108,7 @@ protected:
|
|||
//! Makes evolve the steam jets on the lava
|
||||
void LavaFrame(float rTime);
|
||||
//! Adjusts the position to normal, to imitate reflections on an expanse of water at rest
|
||||
void AdjustLevel(Math::Vector &pos, Math::Vector &norm, Math::Point &uv1, Math::Point &uv2);
|
||||
void AdjustLevel(Math::Vector &pos, Math::Vector &norm, glm::vec2& uv1, glm::vec2& uv2);
|
||||
//! Indicates if there is water in a given position
|
||||
bool GetWater(int x, int y);
|
||||
//! Updates the positions, relative to the ground
|
||||
|
|
|
@ -73,7 +73,7 @@ CLevelParserParam::CLevelParserParam(Gfx::Color value)
|
|||
LoadArray();
|
||||
}
|
||||
|
||||
CLevelParserParam::CLevelParserParam(Math::Point value)
|
||||
CLevelParserParam::CLevelParserParam(glm::vec2 value)
|
||||
{
|
||||
m_array.push_back(MakeUnique<CLevelParserParam>(value.x));
|
||||
m_array.push_back(MakeUnique<CLevelParserParam>(value.y));
|
||||
|
|
|
@ -33,13 +33,13 @@
|
|||
|
||||
#include "level/scoreboard.h"
|
||||
|
||||
#include "math/point.h"
|
||||
|
||||
#include "object/drive_type.h"
|
||||
#include "object/mission_type.h"
|
||||
#include "object/object_type.h"
|
||||
#include "object/tool_type.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
@ -60,7 +60,7 @@ public:
|
|||
CLevelParserParam(std::string value);
|
||||
CLevelParserParam(bool value);
|
||||
CLevelParserParam(Gfx::Color value);
|
||||
CLevelParserParam(Math::Point value);
|
||||
CLevelParserParam(glm::vec2 value);
|
||||
CLevelParserParam(Math::Vector value);
|
||||
CLevelParserParam(ObjectType value);
|
||||
CLevelParserParam(Gfx::CameraType value);
|
||||
|
|
Loading…
Reference in New Issue