Removed Gfx::VertexTex2
parent
5dacb82b22
commit
c280924c0e
|
@ -53,7 +53,7 @@ struct Light;
|
||||||
struct Material;
|
struct Material;
|
||||||
struct Vertex;
|
struct Vertex;
|
||||||
struct VertexCol;
|
struct VertexCol;
|
||||||
struct VertexTex2;
|
struct Vertex3D;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \struct DeviceConfig
|
* \struct DeviceConfig
|
||||||
|
@ -492,9 +492,6 @@ public:
|
||||||
//! Renders primitive composed of vertices with single texture
|
//! Renders primitive composed of vertices with single texture
|
||||||
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount,
|
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount,
|
||||||
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) = 0;
|
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) = 0;
|
||||||
//! Renders primitive composed of vertices with multitexturing (2 textures)
|
|
||||||
virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount,
|
|
||||||
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) = 0;
|
|
||||||
//! Renders primitive composed of vertices with solid color
|
//! Renders primitive composed of vertices with solid color
|
||||||
virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount) = 0;
|
virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount) = 0;
|
||||||
//! Renders 3D primitive
|
//! Renders 3D primitive
|
||||||
|
@ -504,10 +501,6 @@ public:
|
||||||
virtual void DrawPrimitives(PrimitiveType type, const Vertex *vertices,
|
virtual void DrawPrimitives(PrimitiveType type, const Vertex *vertices,
|
||||||
int first[], int count[], int drawCount,
|
int first[], int count[], int drawCount,
|
||||||
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) = 0;
|
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) = 0;
|
||||||
//! Renders primitives composed of lists of vertices with multitexturing (2 textures)
|
|
||||||
virtual void DrawPrimitives(PrimitiveType type, const VertexTex2 *vertices,
|
|
||||||
int first[], int count[], int drawCount,
|
|
||||||
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) = 0;
|
|
||||||
//! Renders primitives composed of lists of vertices with solid color
|
//! Renders primitives composed of lists of vertices with solid color
|
||||||
virtual void DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
virtual void DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
||||||
int first[], int count[], int drawCount) = 0;
|
int first[], int count[], int drawCount) = 0;
|
||||||
|
|
|
@ -80,32 +80,6 @@ struct VertexCol
|
||||||
Color color = Color();
|
Color color = Color();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* \struct VertexTex2
|
|
||||||
* \brief Vertex with secondary texture coordinates
|
|
||||||
*
|
|
||||||
* In addition to fields from Vector, it contains
|
|
||||||
* secondary texture coordinates (u2, v2) as glm::vec2
|
|
||||||
*/
|
|
||||||
struct VertexTex2
|
|
||||||
{
|
|
||||||
static constexpr VertexType VERTEX_TYPE = VERTEX_TYPE_TEX2;
|
|
||||||
|
|
||||||
glm::vec3 coord = { 0, 0, 0 };
|
|
||||||
glm::vec3 normal = { 0, 0, 0 };
|
|
||||||
glm::vec2 texCoord = { 0, 0 };
|
|
||||||
glm::vec2 texCoord2 = { 0, 0 };
|
|
||||||
|
|
||||||
//! Sets the fields from Vertex with texCoord2 = (0,0)
|
|
||||||
void FromVertex(const Vertex &v)
|
|
||||||
{
|
|
||||||
coord = v.coord;
|
|
||||||
normal = v.normal;
|
|
||||||
texCoord = v.texCoord;
|
|
||||||
texCoord2 = { 0, 0 };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \struct Vertex2D
|
* \struct Vertex2D
|
||||||
* \brief 2D vertex for interface rendering, contains UV and color
|
* \brief 2D vertex for interface rendering, contains UV and color
|
||||||
|
@ -131,6 +105,17 @@ struct Vertex3D
|
||||||
|
|
||||||
Vertex3D() = default;
|
Vertex3D() = default;
|
||||||
|
|
||||||
|
Vertex3D(const glm::vec3& position,
|
||||||
|
glm::u8vec4 color = { 255, 255, 255, 255 },
|
||||||
|
glm::vec2 uv = { 0.0f, 0.0f },
|
||||||
|
glm::vec2 uv2 = { 0.0f, 0.0f },
|
||||||
|
glm::vec3 normal = { 0.0f, 0.0f, 1.0f })
|
||||||
|
: position(position)
|
||||||
|
, color(color)
|
||||||
|
, uv(uv)
|
||||||
|
, uv2(uv2)
|
||||||
|
, normal(normal) {}
|
||||||
|
|
||||||
Vertex3D(const Vertex& vertex)
|
Vertex3D(const Vertex& vertex)
|
||||||
: position(vertex.coord)
|
: position(vertex.coord)
|
||||||
, uv(vertex.texCoord)
|
, uv(vertex.texCoord)
|
||||||
|
@ -139,24 +124,10 @@ struct Vertex3D
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vertex3D(const VertexTex2& vertex)
|
|
||||||
: position(vertex.coord)
|
|
||||||
, uv(vertex.texCoord)
|
|
||||||
, uv2(vertex.texCoord2)
|
|
||||||
, normal(vertex.normal)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
operator Vertex() const
|
operator Vertex() const
|
||||||
{
|
{
|
||||||
return Vertex{ position, normal, uv };
|
return Vertex{ position, normal, uv };
|
||||||
}
|
}
|
||||||
|
|
||||||
operator VertexTex2() const
|
|
||||||
{
|
|
||||||
return VertexTex2{ position, normal, uv, uv2 };
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Gfx
|
} // namespace Gfx
|
||||||
|
|
|
@ -98,7 +98,7 @@ void CCloud::Draw()
|
||||||
if (m_level == 0.0f) return;
|
if (m_level == 0.0f) return;
|
||||||
if (m_lines.empty()) return;
|
if (m_lines.empty()) return;
|
||||||
|
|
||||||
std::vector<VertexTex2> vertices((m_brickCount+2)*2, VertexTex2());
|
std::vector<Vertex3D> vertices((m_brickCount+2)*2, Vertex3D());
|
||||||
|
|
||||||
float iDeep = m_engine->GetDeepView();
|
float iDeep = m_engine->GetDeepView();
|
||||||
float deep = (m_brickCount*m_brickSize)/2.0f;
|
float deep = (m_brickCount*m_brickSize)/2.0f;
|
||||||
|
@ -147,17 +147,19 @@ void CCloud::Draw()
|
||||||
glm::vec3 p{};
|
glm::vec3 p{};
|
||||||
glm::vec2 uv1, uv2;
|
glm::vec2 uv1, uv2;
|
||||||
|
|
||||||
|
glm::u8vec4 white(255);
|
||||||
|
|
||||||
p.x = pos.x-size;
|
p.x = pos.x-size;
|
||||||
p.z = pos.z+size;
|
p.z = pos.z+size;
|
||||||
p.y = pos.y;
|
p.y = pos.y;
|
||||||
AdjustLevel(p, eye, deep, uv1, uv2);
|
AdjustLevel(p, eye, deep, uv1, uv2);
|
||||||
vertices[vertexIndex++] = VertexTex2{ p, n, uv1, uv2 };
|
vertices[vertexIndex++] = Vertex3D{ p, white, uv1, uv2, n };
|
||||||
|
|
||||||
p.x = pos.x-size;
|
p.x = pos.x-size;
|
||||||
p.z = pos.z-size;
|
p.z = pos.z-size;
|
||||||
p.y = pos.y;
|
p.y = pos.y;
|
||||||
AdjustLevel(p, eye, deep, uv1, uv2);
|
AdjustLevel(p, eye, deep, uv1, uv2);
|
||||||
vertices[vertexIndex++] = VertexTex2{ p, n, uv1, uv2 };
|
vertices[vertexIndex++] = Vertex3D{ p, white, uv1, uv2, n };
|
||||||
|
|
||||||
for (int j = 0; j < m_lines[i].len; j++)
|
for (int j = 0; j < m_lines[i].len; j++)
|
||||||
{
|
{
|
||||||
|
@ -165,18 +167,18 @@ void CCloud::Draw()
|
||||||
p.z = pos.z+size;
|
p.z = pos.z+size;
|
||||||
p.y = pos.y;
|
p.y = pos.y;
|
||||||
AdjustLevel(p, eye, deep, uv1, uv2);
|
AdjustLevel(p, eye, deep, uv1, uv2);
|
||||||
vertices[vertexIndex++] = VertexTex2{ p, n, uv1, uv2 };
|
vertices[vertexIndex++] = Vertex3D{ p, white, uv1, uv2, n };
|
||||||
|
|
||||||
p.x = pos.x+size;
|
p.x = pos.x+size;
|
||||||
p.z = pos.z-size;
|
p.z = pos.z-size;
|
||||||
p.y = pos.y;
|
p.y = pos.y;
|
||||||
AdjustLevel(p, eye, deep, uv1, uv2);
|
AdjustLevel(p, eye, deep, uv1, uv2);
|
||||||
vertices[vertexIndex++] = VertexTex2{ p, n, uv1, uv2 };
|
vertices[vertexIndex++] = Vertex3D{ p, white, uv1, uv2, n };
|
||||||
|
|
||||||
pos.x += size*2.0f;
|
pos.x += size*2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
device->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, &vertices[0], vertexIndex);
|
device->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, vertices.data(), vertexIndex);
|
||||||
m_engine->AddStatisticTriangle(vertexIndex - 2);
|
m_engine->AddStatisticTriangle(vertexIndex - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ void COldModelManager::Mirror(std::vector<ModelTriangle>& triangles)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < static_cast<int>( triangles.size() ); i++)
|
for (int i = 0; i < static_cast<int>( triangles.size() ); i++)
|
||||||
{
|
{
|
||||||
VertexTex2 t = triangles[i].p1;
|
Vertex3D t = triangles[i].p1;
|
||||||
triangles[i].p1 = triangles[i].p2;
|
triangles[i].p1 = triangles[i].p2;
|
||||||
triangles[i].p2 = t;
|
triangles[i].p2 = t;
|
||||||
|
|
||||||
|
|
|
@ -513,12 +513,12 @@ glm::vec3 CTerrain::GetVector(int x, int y)
|
||||||
| \| \|
|
| \| \|
|
||||||
+---f---e--> x
|
+---f---e--> x
|
||||||
\endverbatim */
|
\endverbatim */
|
||||||
VertexTex2 CTerrain::GetVertex(int x, int y, int step)
|
Vertex3D CTerrain::GetVertex(int x, int y, int step)
|
||||||
{
|
{
|
||||||
VertexTex2 v;
|
Vertex3D v;
|
||||||
|
|
||||||
glm::vec3 o = GetVector(x, y);
|
glm::vec3 o = GetVector(x, y);
|
||||||
v.coord = o;
|
v.position = o;
|
||||||
|
|
||||||
glm::vec3 a = GetVector(x-step, y );
|
glm::vec3 a = GetVector(x-step, y );
|
||||||
glm::vec3 b = GetVector(x-step, y+step);
|
glm::vec3 b = GetVector(x-step, y+step);
|
||||||
|
@ -553,10 +553,10 @@ VertexTex2 CTerrain::GetVertex(int x, int y, int step)
|
||||||
int brick = m_brickCount/m_textureSubdivCount;
|
int brick = m_brickCount/m_textureSubdivCount;
|
||||||
glm::vec3 oo = GetVector((x/brick)*brick, (y/brick)*brick);
|
glm::vec3 oo = GetVector((x/brick)*brick, (y/brick)*brick);
|
||||||
o = GetVector(x, y);
|
o = GetVector(x, y);
|
||||||
v.texCoord.x = (o.x-oo.x)*m_textureScale*m_textureSubdivCount;
|
v.uv.x = (o.x-oo.x)*m_textureScale*m_textureSubdivCount;
|
||||||
v.texCoord.y = 1.0f - (o.z-oo.z)*m_textureScale*m_textureSubdivCount;
|
v.uv.y = 1.0f - (o.z-oo.z)*m_textureScale*m_textureSubdivCount;
|
||||||
|
|
||||||
v.texCoord2 = v.texCoord;
|
v.uv2 = v.uv;
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -598,7 +598,7 @@ bool CTerrain::CreateMosaic(int ox, int oy, int step, int objRank)
|
||||||
|
|
||||||
int brick = m_brickCount/m_textureSubdivCount;
|
int brick = m_brickCount/m_textureSubdivCount;
|
||||||
|
|
||||||
VertexTex2 o = GetVertex(ox*m_brickCount+m_brickCount/2, oy*m_brickCount+m_brickCount/2, step);
|
Vertex3D o = GetVertex(ox*m_brickCount+m_brickCount/2, oy*m_brickCount+m_brickCount/2, step);
|
||||||
int total = ((brick/step)+1)*2;
|
int total = ((brick/step)+1)*2;
|
||||||
|
|
||||||
float pixel = 1.0f/256.0f; // 1 pixel cover (*)
|
float pixel = 1.0f/256.0f; // 1 pixel cover (*)
|
||||||
|
@ -643,10 +643,10 @@ bool CTerrain::CreateMosaic(int ox, int oy, int step, int objRank)
|
||||||
|
|
||||||
for (int x = 0; x <= brick; x += step)
|
for (int x = 0; x <= brick; x += step)
|
||||||
{
|
{
|
||||||
VertexTex2 p1 = GetVertex(ox*m_brickCount+mx*brick+x, oy*m_brickCount+my*brick+y+0 , step);
|
Vertex3D p1 = GetVertex(ox*m_brickCount+mx*brick+x, oy*m_brickCount+my*brick+y+0 , step);
|
||||||
VertexTex2 p2 = GetVertex(ox*m_brickCount+mx*brick+x, oy*m_brickCount+my*brick+y+step, step);
|
Vertex3D p2 = GetVertex(ox*m_brickCount+mx*brick+x, oy*m_brickCount+my*brick+y+step, step);
|
||||||
p1.coord.x -= o.coord.x; p1.coord.z -= o.coord.z;
|
p1.position.x -= o.position.x; p1.position.z -= o.position.z;
|
||||||
p2.coord.x -= o.coord.x; p2.coord.z -= o.coord.z;
|
p2.position.x -= o.position.x; p2.position.z -= o.position.z;
|
||||||
|
|
||||||
// TODO: Find portable solution
|
// TODO: Find portable solution
|
||||||
//float offset = 0.5f / 256.0f; // Direct3D
|
//float offset = 0.5f / 256.0f; // Direct3D
|
||||||
|
@ -654,55 +654,55 @@ bool CTerrain::CreateMosaic(int ox, int oy, int step, int objRank)
|
||||||
|
|
||||||
if (x == 0)
|
if (x == 0)
|
||||||
{
|
{
|
||||||
p1.texCoord.x = 0.0f + offset;
|
p1.uv.x = 0.0f + offset;
|
||||||
p2.texCoord.x = 0.0f + offset;
|
p2.uv.x = 0.0f + offset;
|
||||||
}
|
}
|
||||||
if (x == brick)
|
if (x == brick)
|
||||||
{
|
{
|
||||||
p1.texCoord.x = 1.0f - offset;
|
p1.uv.x = 1.0f - offset;
|
||||||
p2.texCoord.x = 1.0f - offset;
|
p2.uv.x = 1.0f - offset;
|
||||||
}
|
}
|
||||||
if (y == 0)
|
if (y == 0)
|
||||||
p1.texCoord.y = 1.0f - offset;
|
p1.uv.y = 1.0f - offset;
|
||||||
|
|
||||||
if (y == brick - step)
|
if (y == brick - step)
|
||||||
p2.texCoord.y = 0.0f + offset;
|
p2.uv.y = 0.0f + offset;
|
||||||
|
|
||||||
if (m_useMaterials)
|
if (m_useMaterials)
|
||||||
{
|
{
|
||||||
p1.texCoord.x /= m_textureSubdivCount; // 0..1 -> 0..0.25
|
p1.uv.x /= m_textureSubdivCount; // 0..1 -> 0..0.25
|
||||||
p1.texCoord.y /= m_textureSubdivCount;
|
p1.uv.y /= m_textureSubdivCount;
|
||||||
p2.texCoord.x /= m_textureSubdivCount;
|
p2.uv.x /= m_textureSubdivCount;
|
||||||
p2.texCoord.y /= m_textureSubdivCount;
|
p2.uv.y /= m_textureSubdivCount;
|
||||||
|
|
||||||
if (x == 0)
|
if (x == 0)
|
||||||
{
|
{
|
||||||
p1.texCoord.x = 0.0f+dp;
|
p1.uv.x = 0.0f+dp;
|
||||||
p2.texCoord.x = 0.0f+dp;
|
p2.uv.x = 0.0f+dp;
|
||||||
}
|
}
|
||||||
if (x == brick)
|
if (x == brick)
|
||||||
{
|
{
|
||||||
p1.texCoord.x = (1.0f/m_textureSubdivCount)-dp;
|
p1.uv.x = (1.0f/m_textureSubdivCount)-dp;
|
||||||
p2.texCoord.x = (1.0f/m_textureSubdivCount)-dp;
|
p2.uv.x = (1.0f/m_textureSubdivCount)-dp;
|
||||||
}
|
}
|
||||||
if (y == 0)
|
if (y == 0)
|
||||||
p1.texCoord.y = (1.0f/m_textureSubdivCount)-dp;
|
p1.uv.y = (1.0f/m_textureSubdivCount)-dp;
|
||||||
|
|
||||||
if (y == brick - step)
|
if (y == brick - step)
|
||||||
p2.texCoord.y = 0.0f+dp;
|
p2.uv.y = 0.0f+dp;
|
||||||
|
|
||||||
p1.texCoord.x += uv.x;
|
p1.uv.x += uv.x;
|
||||||
p1.texCoord.y += uv.y;
|
p1.uv.y += uv.y;
|
||||||
p2.texCoord.x += uv.x;
|
p2.uv.x += uv.x;
|
||||||
p2.texCoord.y += uv.y;
|
p2.uv.y += uv.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xx = mx*(m_brickCount/m_textureSubdivCount) + x;
|
int xx = mx*(m_brickCount/m_textureSubdivCount) + x;
|
||||||
int yy = my*(m_brickCount/m_textureSubdivCount) + y;
|
int yy = my*(m_brickCount/m_textureSubdivCount) + y;
|
||||||
p1.texCoord2.x = (static_cast<float>(ox%5)*m_brickCount+xx+0.0f)/(m_brickCount*5);
|
p1.uv2.x = (static_cast<float>(ox%5)*m_brickCount+xx+0.0f)/(m_brickCount*5);
|
||||||
p1.texCoord2.y = (static_cast<float>(oy%5)*m_brickCount+yy+0.0f)/(m_brickCount*5);
|
p1.uv2.y = (static_cast<float>(oy%5)*m_brickCount+yy+0.0f)/(m_brickCount*5);
|
||||||
p2.texCoord2.x = (static_cast<float>(ox%5)*m_brickCount+xx+0.0f)/(m_brickCount*5);
|
p2.uv2.x = (static_cast<float>(ox%5)*m_brickCount+xx+0.0f)/(m_brickCount*5);
|
||||||
p2.texCoord2.y = (static_cast<float>(oy%5)*m_brickCount+yy+1.0f)/(m_brickCount*5);
|
p2.uv2.y = (static_cast<float>(oy%5)*m_brickCount+yy+1.0f)/(m_brickCount*5);
|
||||||
|
|
||||||
// Correction for 1 pixel cover
|
// Correction for 1 pixel cover
|
||||||
// There is 1 pixel cover around each of the 16 surfaces:
|
// There is 1 pixel cover around each of the 16 surfaces:
|
||||||
|
@ -717,10 +717,10 @@ bool CTerrain::CreateMosaic(int ox, int oy, int step, int objRank)
|
||||||
// The uv coordinates used for texturing are between min and max (instead of 0 and 1)
|
// The uv coordinates used for texturing are between min and max (instead of 0 and 1)
|
||||||
// This allows to exclude the pixels situated in a margin of a pixel around the surface
|
// This allows to exclude the pixels situated in a margin of a pixel around the surface
|
||||||
|
|
||||||
p1.texCoord2.x = (p1.texCoord2.x+pixel)*(1.0f-pixel)/(1.0f+pixel);
|
p1.uv2.x = (p1.uv2.x+pixel)*(1.0f-pixel)/(1.0f+pixel);
|
||||||
p1.texCoord2.y = (p1.texCoord2.y+pixel)*(1.0f-pixel)/(1.0f+pixel);
|
p1.uv2.y = (p1.uv2.y+pixel)*(1.0f-pixel)/(1.0f+pixel);
|
||||||
p2.texCoord2.x = (p2.texCoord2.x+pixel)*(1.0f-pixel)/(1.0f+pixel);
|
p2.uv2.x = (p2.uv2.x+pixel)*(1.0f-pixel)/(1.0f+pixel);
|
||||||
p2.texCoord2.y = (p2.texCoord2.y+pixel)*(1.0f-pixel)/(1.0f+pixel);
|
p2.uv2.y = (p2.uv2.y+pixel)*(1.0f-pixel)/(1.0f+pixel);
|
||||||
|
|
||||||
|
|
||||||
buffer.vertices.push_back(p1);
|
buffer.vertices.push_back(p1);
|
||||||
|
@ -733,8 +733,8 @@ bool CTerrain::CreateMosaic(int ox, int oy, int step, int objRank)
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 transform = glm::mat4(1.0f);
|
glm::mat4 transform = glm::mat4(1.0f);
|
||||||
transform[3][0] = o.coord.x;
|
transform[3][0] = o.position.x;
|
||||||
transform[3][2] = o.coord.z;
|
transform[3][2] = o.position.z;
|
||||||
m_engine->SetObjectTransform(objRank, transform);
|
m_engine->SetObjectTransform(objRank, transform);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -40,7 +40,6 @@ namespace Gfx
|
||||||
|
|
||||||
class CEngine;
|
class CEngine;
|
||||||
class CWater;
|
class CWater;
|
||||||
struct Material;
|
|
||||||
|
|
||||||
|
|
||||||
//! Limit of slope considered a flat piece of land
|
//! Limit of slope considered a flat piece of land
|
||||||
|
@ -254,7 +253,7 @@ protected:
|
||||||
//! Calculates a vector of the terrain
|
//! Calculates a vector of the terrain
|
||||||
glm::vec3 GetVector(int x, int y);
|
glm::vec3 GetVector(int x, int y);
|
||||||
//! Calculates a vertex of the terrain
|
//! Calculates a vertex of the terrain
|
||||||
VertexTex2 GetVertex(int x, int y, int step);
|
Vertex3D GetVertex(int x, int y, int step);
|
||||||
//! Creates all objects of a mosaic
|
//! Creates all objects of a mosaic
|
||||||
bool CreateMosaic(int ox, int oy, int step, int objRank);
|
bool CreateMosaic(int ox, int oy, int step, int objRank);
|
||||||
//! Creates all objects in a mesh square ground
|
//! Creates all objects in a mesh square ground
|
||||||
|
|
|
@ -57,12 +57,12 @@ namespace ModelInput
|
||||||
std::vector<ModelTriangle> ReadOldModelV3(std::istream &stream, int totalTriangles);
|
std::vector<ModelTriangle> ReadOldModelV3(std::istream &stream, int totalTriangles);
|
||||||
|
|
||||||
Vertex ReadBinaryVertex(std::istream& stream);
|
Vertex ReadBinaryVertex(std::istream& stream);
|
||||||
VertexTex2 ReadBinaryVertexTex2(std::istream& stream);
|
Vertex3D ReadBinaryVertexTex2(std::istream& stream);
|
||||||
Material ReadBinaryMaterial(std::istream& stream);
|
Material ReadBinaryMaterial(std::istream& stream);
|
||||||
|
|
||||||
std::string ReadLineString(std::istream& stream, const std::string& expectedPrefix);
|
std::string ReadLineString(std::istream& stream, const std::string& expectedPrefix);
|
||||||
void ReadValuePrefix(std::istream& stream, const std::string& expectedPrefix);
|
void ReadValuePrefix(std::istream& stream, const std::string& expectedPrefix);
|
||||||
VertexTex2 ParseVertexTex2(const std::string& text);
|
Vertex3D ParseVertexTex2(const std::string& text);
|
||||||
Material ParseMaterial(const std::string& text);
|
Material ParseMaterial(const std::string& text);
|
||||||
glm::vec3 ParseVector(const std::string& text);
|
glm::vec3 ParseVector(const std::string& text);
|
||||||
ModelCrashSphere ParseCrashSphere(const std::string& text);
|
ModelCrashSphere ParseCrashSphere(const std::string& text);
|
||||||
|
@ -656,23 +656,23 @@ Vertex ModelInput::ReadBinaryVertex(std::istream& stream)
|
||||||
return vertex;
|
return vertex;
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexTex2 ModelInput::ReadBinaryVertexTex2(std::istream& stream)
|
Vertex3D ModelInput::ReadBinaryVertexTex2(std::istream& stream)
|
||||||
{
|
{
|
||||||
VertexTex2 vertex;
|
Vertex3D vertex;
|
||||||
|
|
||||||
vertex.coord.x = ReadBinaryFloat(stream);
|
vertex.position.x = ReadBinaryFloat(stream);
|
||||||
vertex.coord.y = ReadBinaryFloat(stream);
|
vertex.position.y = ReadBinaryFloat(stream);
|
||||||
vertex.coord.z = ReadBinaryFloat(stream);
|
vertex.position.z = ReadBinaryFloat(stream);
|
||||||
|
|
||||||
vertex.normal.x = ReadBinaryFloat(stream);
|
vertex.normal.x = ReadBinaryFloat(stream);
|
||||||
vertex.normal.y = ReadBinaryFloat(stream);
|
vertex.normal.y = ReadBinaryFloat(stream);
|
||||||
vertex.normal.z = ReadBinaryFloat(stream);
|
vertex.normal.z = ReadBinaryFloat(stream);
|
||||||
|
|
||||||
vertex.texCoord.x = ReadBinaryFloat(stream);
|
vertex.uv.x = ReadBinaryFloat(stream);
|
||||||
vertex.texCoord.y = ReadBinaryFloat(stream);
|
vertex.uv.y = ReadBinaryFloat(stream);
|
||||||
|
|
||||||
vertex.texCoord2.x = ReadBinaryFloat(stream);
|
vertex.uv2.x = ReadBinaryFloat(stream);
|
||||||
vertex.texCoord2.y = ReadBinaryFloat(stream);
|
vertex.uv2.y = ReadBinaryFloat(stream);
|
||||||
|
|
||||||
return vertex;
|
return vertex;
|
||||||
}
|
}
|
||||||
|
@ -744,24 +744,24 @@ void ModelInput::ReadValuePrefix(std::istream& stream, const std::string& expect
|
||||||
throw CModelIOException(std::string("Unexpected prefix: '") + prefix + "', expected was: '" + expectedPrefix + "'");
|
throw CModelIOException(std::string("Unexpected prefix: '") + prefix + "', expected was: '" + expectedPrefix + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexTex2 ModelInput::ParseVertexTex2(const std::string& text)
|
Vertex3D ModelInput::ParseVertexTex2(const std::string& text)
|
||||||
{
|
{
|
||||||
VertexTex2 vertex;
|
Vertex3D vertex;
|
||||||
|
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream.str(text);
|
stream.str(text);
|
||||||
|
|
||||||
ReadValuePrefix(stream, "c");
|
ReadValuePrefix(stream, "c");
|
||||||
stream >> vertex.coord.x >> vertex.coord.y >> vertex.coord.z;
|
stream >> vertex.position.x >> vertex.position.y >> vertex.position.z;
|
||||||
|
|
||||||
ReadValuePrefix(stream, "n");
|
ReadValuePrefix(stream, "n");
|
||||||
stream >> vertex.normal.x >> vertex.normal.y >> vertex.normal.z;
|
stream >> vertex.normal.x >> vertex.normal.y >> vertex.normal.z;
|
||||||
|
|
||||||
ReadValuePrefix(stream, "t1");
|
ReadValuePrefix(stream, "t1");
|
||||||
stream >> vertex.texCoord.x >> vertex.texCoord.y;
|
stream >> vertex.uv.x >> vertex.uv.y;
|
||||||
|
|
||||||
ReadValuePrefix(stream, "t2");
|
ReadValuePrefix(stream, "t2");
|
||||||
stream >> vertex.texCoord2.x >> vertex.texCoord2.y;
|
stream >> vertex.uv2.x >> vertex.uv2.y;
|
||||||
|
|
||||||
return vertex;
|
return vertex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1018,46 +1018,6 @@ void CGL33Device::DrawPrimitive(PrimitiveType type, const Vertex *vertices, int
|
||||||
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
|
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGL33Device::DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount, Color color)
|
|
||||||
{
|
|
||||||
if (m_updateLights) UpdateLights();
|
|
||||||
|
|
||||||
unsigned int size = vertexCount * sizeof(VertexTex2);
|
|
||||||
|
|
||||||
DynamicBuffer& buffer = m_dynamicBuffer;
|
|
||||||
|
|
||||||
BindVAO(buffer.vao);
|
|
||||||
BindVBO(buffer.vbo);
|
|
||||||
|
|
||||||
unsigned int offset = UploadVertexData(buffer, vertices, size);
|
|
||||||
|
|
||||||
// Vertex coordinate
|
|
||||||
glEnableVertexAttribArray(0);
|
|
||||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(VertexTex2),
|
|
||||||
reinterpret_cast<void*>(offset + offsetof(VertexTex2, coord)));
|
|
||||||
|
|
||||||
// Normal
|
|
||||||
glEnableVertexAttribArray(1);
|
|
||||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(VertexTex2),
|
|
||||||
reinterpret_cast<void*>(offset + offsetof(VertexTex2, normal)));
|
|
||||||
|
|
||||||
// Color
|
|
||||||
glDisableVertexAttribArray(2);
|
|
||||||
glVertexAttrib4fv(2, color.Array());
|
|
||||||
|
|
||||||
// Texture coordinate 0
|
|
||||||
glEnableVertexAttribArray(3);
|
|
||||||
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(VertexTex2),
|
|
||||||
reinterpret_cast<void*>(offset + offsetof(VertexTex2, texCoord)));
|
|
||||||
|
|
||||||
// Texture coordinate 1
|
|
||||||
glEnableVertexAttribArray(4);
|
|
||||||
glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, sizeof(VertexTex2),
|
|
||||||
reinterpret_cast<void*>(offset + offsetof(VertexTex2, texCoord2)));
|
|
||||||
|
|
||||||
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CGL33Device::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int vertexCount)
|
void CGL33Device::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int vertexCount)
|
||||||
{
|
{
|
||||||
if (m_updateLights) UpdateLights();
|
if (m_updateLights) UpdateLights();
|
||||||
|
@ -1187,57 +1147,6 @@ void CGL33Device::DrawPrimitives(PrimitiveType type, const Vertex *vertices,
|
||||||
glMultiDrawArrays(TranslateGfxPrimitive(type), first, count, drawCount);
|
glMultiDrawArrays(TranslateGfxPrimitive(type), first, count, drawCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGL33Device::DrawPrimitives(PrimitiveType type, const VertexTex2 *vertices,
|
|
||||||
int first[], int count[], int drawCount, Color color)
|
|
||||||
{
|
|
||||||
if (m_updateLights) UpdateLights();
|
|
||||||
|
|
||||||
int vertexCount = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < drawCount; i++)
|
|
||||||
{
|
|
||||||
int currentCount = first[i] + count[i];
|
|
||||||
|
|
||||||
if (currentCount > vertexCount)
|
|
||||||
vertexCount = currentCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int size = vertexCount * sizeof(VertexTex2);
|
|
||||||
|
|
||||||
DynamicBuffer& buffer = m_dynamicBuffer;
|
|
||||||
|
|
||||||
BindVAO(buffer.vao);
|
|
||||||
BindVBO(buffer.vbo);
|
|
||||||
|
|
||||||
unsigned int offset = UploadVertexData(buffer, vertices, size);
|
|
||||||
|
|
||||||
// Vertex coordinate
|
|
||||||
glEnableVertexAttribArray(0);
|
|
||||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(VertexTex2),
|
|
||||||
reinterpret_cast<void*>(offset + offsetof(VertexTex2, coord)));
|
|
||||||
|
|
||||||
// Normal
|
|
||||||
glEnableVertexAttribArray(1);
|
|
||||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(VertexTex2),
|
|
||||||
reinterpret_cast<void*>(offset + offsetof(VertexTex2, normal)));
|
|
||||||
|
|
||||||
// Color
|
|
||||||
glDisableVertexAttribArray(2);
|
|
||||||
glVertexAttrib4fv(2, color.Array());
|
|
||||||
|
|
||||||
// Texture coordinate 0
|
|
||||||
glEnableVertexAttribArray(3);
|
|
||||||
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(VertexTex2),
|
|
||||||
reinterpret_cast<void*>(offset + offsetof(VertexTex2, texCoord)));
|
|
||||||
|
|
||||||
// Texture coordinate 1
|
|
||||||
glEnableVertexAttribArray(4);
|
|
||||||
glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, sizeof(VertexTex2),
|
|
||||||
reinterpret_cast<void*>(offset + offsetof(VertexTex2, texCoord2)));
|
|
||||||
|
|
||||||
glMultiDrawArrays(TranslateGfxPrimitive(type), first, count, drawCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CGL33Device::DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
void CGL33Device::DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
||||||
int first[], int count[], int drawCount)
|
int first[], int count[], int drawCount)
|
||||||
{
|
{
|
||||||
|
|
|
@ -148,8 +148,6 @@ public:
|
||||||
|
|
||||||
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount,
|
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount,
|
||||||
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
|
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
|
||||||
virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount,
|
|
||||||
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
|
|
||||||
virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount) override;
|
virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount) override;
|
||||||
|
|
||||||
virtual void DrawPrimitive(PrimitiveType type, const Vertex3D* vertices, int vertexCount) override;
|
virtual void DrawPrimitive(PrimitiveType type, const Vertex3D* vertices, int vertexCount) override;
|
||||||
|
@ -157,9 +155,6 @@ public:
|
||||||
virtual void DrawPrimitives(PrimitiveType type, const Vertex *vertices,
|
virtual void DrawPrimitives(PrimitiveType type, const Vertex *vertices,
|
||||||
int first[], int count[], int drawCount,
|
int first[], int count[], int drawCount,
|
||||||
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
|
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
|
||||||
virtual void DrawPrimitives(PrimitiveType type, const VertexTex2 *vertices,
|
|
||||||
int first[], int count[], int drawCount,
|
|
||||||
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
|
|
||||||
virtual void DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
virtual void DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
||||||
int first[], int count[], int drawCount) override;
|
int first[], int count[], int drawCount) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue