running whitespaces.py update 1
This commit is contained in:
parent
badf97dc77
commit
7cc83e1475
@ -67,7 +67,7 @@ public:
|
||||
float m_parachute_ubound_fraction; /**<Upper bound fraction of speed when
|
||||
lost will detach parachute. */
|
||||
float m_parachute_lbound_fraction; /**<Lower bound fraction of speed when
|
||||
lost will detach parachute. */
|
||||
lost will detach parachute. */
|
||||
float m_parachute_max_speed; /**<Max speed to rate current speed */
|
||||
float m_parachute_time; /**<Time a parachute is active. */
|
||||
float m_parachute_time_other; /**<Time a parachute attached to other
|
||||
|
@ -14,232 +14,232 @@ CBatchingMesh::CBatchingMesh()
|
||||
|
||||
CBatchingMesh::~CBatchingMesh()
|
||||
{
|
||||
u32 i;
|
||||
for (i=0; i < DestBuffers.size(); ++i)
|
||||
DestBuffers[i].Buffer->drop();
|
||||
u32 i;
|
||||
for (i=0; i < DestBuffers.size(); ++i)
|
||||
DestBuffers[i].Buffer->drop();
|
||||
|
||||
for (i=0; i < SourceBuffers.size(); ++i)
|
||||
SourceBuffers[i]->drop();
|
||||
for (i=0; i < SourceBuffers.size(); ++i)
|
||||
SourceBuffers[i]->drop();
|
||||
}
|
||||
|
||||
bool CBatchingMesh::isDirty(s32 id)
|
||||
{
|
||||
if ((u32)id > DestBuffers.size())
|
||||
return IsDirty;
|
||||
else
|
||||
return DestBuffers[id].IsDirty;
|
||||
if ((u32)id > DestBuffers.size())
|
||||
return IsDirty;
|
||||
else
|
||||
return DestBuffers[id].IsDirty;
|
||||
}
|
||||
|
||||
//! refreshes the internal buffers from source
|
||||
void CBatchingMesh::update()
|
||||
{
|
||||
// allocate the index and vertex arrays
|
||||
u32 i;
|
||||
for (i=0; i<DestBuffers.size(); ++i)
|
||||
{
|
||||
if (DestBuffers[i].IndexCount != DestBuffers[i].Buffer->getIndexCount() ||
|
||||
DestBuffers[i].VertexCount != DestBuffers[i].Buffer->getVertexCount())
|
||||
{
|
||||
DestBuffers[i].IsDirty = true;
|
||||
// allocate the index and vertex arrays
|
||||
u32 i;
|
||||
for (i=0; i<DestBuffers.size(); ++i)
|
||||
{
|
||||
if (DestBuffers[i].IndexCount != DestBuffers[i].Buffer->getIndexCount() ||
|
||||
DestBuffers[i].VertexCount != DestBuffers[i].Buffer->getVertexCount())
|
||||
{
|
||||
DestBuffers[i].IsDirty = true;
|
||||
|
||||
switch (DestBuffers[i].VertexType)
|
||||
{
|
||||
case video::EVT_STANDARD:
|
||||
{
|
||||
SMeshBuffer* mb = (SMeshBuffer*)DestBuffers[i].Buffer;
|
||||
mb->Vertices.set_used(DestBuffers[i].VertexCount);
|
||||
mb->Indices.set_used(DestBuffers[i].IndexCount);
|
||||
break;
|
||||
}
|
||||
case video::EVT_2TCOORDS:
|
||||
{
|
||||
SMeshBufferLightMap* mb = (SMeshBufferLightMap*)DestBuffers[i].Buffer;
|
||||
mb->Vertices.set_used(DestBuffers[i].VertexCount);
|
||||
mb->Indices.set_used(DestBuffers[i].IndexCount);
|
||||
break;
|
||||
}
|
||||
case video::EVT_TANGENTS:
|
||||
{
|
||||
SMeshBufferTangents* mb = (SMeshBufferTangents*)DestBuffers[i].Buffer;
|
||||
mb->Vertices.set_used(DestBuffers[i].VertexCount);
|
||||
mb->Indices.set_used(DestBuffers[i].IndexCount);
|
||||
break;
|
||||
}
|
||||
default: // shouldn't ever happen
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (DestBuffers[i].VertexType)
|
||||
{
|
||||
case video::EVT_STANDARD:
|
||||
{
|
||||
SMeshBuffer* mb = (SMeshBuffer*)DestBuffers[i].Buffer;
|
||||
mb->Vertices.set_used(DestBuffers[i].VertexCount);
|
||||
mb->Indices.set_used(DestBuffers[i].IndexCount);
|
||||
break;
|
||||
}
|
||||
case video::EVT_2TCOORDS:
|
||||
{
|
||||
SMeshBufferLightMap* mb = (SMeshBufferLightMap*)DestBuffers[i].Buffer;
|
||||
mb->Vertices.set_used(DestBuffers[i].VertexCount);
|
||||
mb->Indices.set_used(DestBuffers[i].IndexCount);
|
||||
break;
|
||||
}
|
||||
case video::EVT_TANGENTS:
|
||||
{
|
||||
SMeshBufferTangents* mb = (SMeshBufferTangents*)DestBuffers[i].Buffer;
|
||||
mb->Vertices.set_used(DestBuffers[i].VertexCount);
|
||||
mb->Indices.set_used(DestBuffers[i].IndexCount);
|
||||
break;
|
||||
}
|
||||
default: // shouldn't ever happen
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// refresh dirty buffers from source
|
||||
for (i=0; i<BufferReferences.size(); ++i)
|
||||
{
|
||||
if (DestBuffers[BufferReferences[i].DestReference].IsDirty)
|
||||
{
|
||||
updateDestFromSourceBuffer(i);
|
||||
}
|
||||
}
|
||||
// refresh dirty buffers from source
|
||||
for (i=0; i<BufferReferences.size(); ++i)
|
||||
{
|
||||
if (DestBuffers[BufferReferences[i].DestReference].IsDirty)
|
||||
{
|
||||
updateDestFromSourceBuffer(i);
|
||||
}
|
||||
}
|
||||
|
||||
// calculate bounding boxes
|
||||
for (i=0; i< DestBuffers.size(); ++i)
|
||||
{
|
||||
if (DestBuffers[i].IsDirty)
|
||||
{
|
||||
recalculateDestBufferBoundingBox(i);
|
||||
// reset dirty state too
|
||||
DestBuffers[i].IsDirty = false;
|
||||
}
|
||||
}
|
||||
// calculate bounding boxes
|
||||
for (i=0; i< DestBuffers.size(); ++i)
|
||||
{
|
||||
if (DestBuffers[i].IsDirty)
|
||||
{
|
||||
recalculateDestBufferBoundingBox(i);
|
||||
// reset dirty state too
|
||||
DestBuffers[i].IsDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
IsDirty = false;
|
||||
recalculateBoundingBox();
|
||||
IsDirty = false;
|
||||
recalculateBoundingBox();
|
||||
}
|
||||
|
||||
//! adds a mesh to the buffers with the given offset
|
||||
/** \Returns Returns an array of ID numbers */
|
||||
core::array<s32> CBatchingMesh::addMesh(IMesh* mesh, core::vector3df pos, core::vector3df rot, core::vector3df scale)
|
||||
{
|
||||
core::matrix4 m;
|
||||
m.setRotationDegrees(rot);
|
||||
m.setTranslation(pos);
|
||||
core::matrix4 m;
|
||||
m.setRotationDegrees(rot);
|
||||
m.setTranslation(pos);
|
||||
|
||||
core::matrix4 scalem;
|
||||
scalem.setScale(scale);
|
||||
m *= scalem;
|
||||
core::matrix4 scalem;
|
||||
scalem.setScale(scale);
|
||||
m *= scalem;
|
||||
|
||||
return addMesh(mesh, m);
|
||||
return addMesh(mesh, m);
|
||||
}
|
||||
|
||||
//! adds a mesh with the given transformation
|
||||
core::array<s32> CBatchingMesh::addMesh(IMesh* mesh, const core::matrix4 &transform)
|
||||
{
|
||||
core::array<s32> bufferNos;
|
||||
core::array<s32> bufferNos;
|
||||
|
||||
if (!mesh)
|
||||
return bufferNos;
|
||||
if (!mesh)
|
||||
return bufferNos;
|
||||
|
||||
u32 i;
|
||||
for (i=0; i<mesh->getMeshBufferCount(); ++i)
|
||||
bufferNos.push_back(addMeshBuffer(mesh->getMeshBuffer(i), transform));
|
||||
u32 i;
|
||||
for (i=0; i<mesh->getMeshBufferCount(); ++i)
|
||||
bufferNos.push_back(addMeshBuffer(mesh->getMeshBuffer(i), transform));
|
||||
|
||||
return bufferNos;
|
||||
return bufferNos;
|
||||
}
|
||||
|
||||
//! adds a mesh buffer with the given transformation
|
||||
/** \Return Returns the ID of this mesh buffer */
|
||||
s32 CBatchingMesh::addMeshBuffer(IMeshBuffer* buffer, core::vector3df pos, core::vector3df rot, core::vector3df scale)
|
||||
{
|
||||
core::matrix4 m;
|
||||
m.setRotationDegrees(rot);
|
||||
m.setTranslation(pos);
|
||||
core::matrix4 m;
|
||||
m.setRotationDegrees(rot);
|
||||
m.setTranslation(pos);
|
||||
|
||||
core::matrix4 scalem;
|
||||
scalem.setScale(scale);
|
||||
m *= scalem;
|
||||
core::matrix4 scalem;
|
||||
scalem.setScale(scale);
|
||||
m *= scalem;
|
||||
|
||||
return addMeshBuffer(buffer, m);
|
||||
return addMeshBuffer(buffer, m);
|
||||
}
|
||||
|
||||
//! adds a mesh with the given transformation
|
||||
/** \Return Returns the ID of this mesh buffer */
|
||||
s32 CBatchingMesh::addMeshBuffer(IMeshBuffer* buffer, const core::matrix4 &transform)
|
||||
{
|
||||
if (!buffer || IsFinal)
|
||||
return -1;
|
||||
if (!buffer || IsFinal)
|
||||
return -1;
|
||||
|
||||
u32 i;
|
||||
video::SMaterial m = buffer->getMaterial();
|
||||
u32 i;
|
||||
video::SMaterial m = buffer->getMaterial();
|
||||
|
||||
// find material
|
||||
bool found=false;
|
||||
video::E_VERTEX_TYPE vt = buffer->getVertexType();
|
||||
for (i=0; i<MaterialReferences.size(); ++i)
|
||||
{
|
||||
if (MaterialReferences[i].VertexType == vt &&
|
||||
MaterialReferences[i].Material == m)
|
||||
{
|
||||
// will there be too many vertices in the buffer?
|
||||
u32 newTotalI = buffer->getIndexCount() + DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount;
|
||||
u32 newTotalV = buffer->getVertexCount() + DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount;
|
||||
// find material
|
||||
bool found=false;
|
||||
video::E_VERTEX_TYPE vt = buffer->getVertexType();
|
||||
for (i=0; i<MaterialReferences.size(); ++i)
|
||||
{
|
||||
if (MaterialReferences[i].VertexType == vt &&
|
||||
MaterialReferences[i].Material == m)
|
||||
{
|
||||
// will there be too many vertices in the buffer?
|
||||
u32 newTotalI = buffer->getIndexCount() + DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount;
|
||||
u32 newTotalV = buffer->getVertexCount() + DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount;
|
||||
|
||||
if ( newTotalI < 65536*3 && newTotalV < 65536)
|
||||
{
|
||||
found = true;
|
||||
DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount = newTotalI;
|
||||
DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount = newTotalV;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( newTotalI < 65536*3 && newTotalV < 65536)
|
||||
{
|
||||
found = true;
|
||||
DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount = newTotalI;
|
||||
DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount = newTotalV;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
// we need a new destination buffer and material reference
|
||||
IMeshBuffer *mb=0;
|
||||
if (!found)
|
||||
{
|
||||
// we need a new destination buffer and material reference
|
||||
IMeshBuffer *mb=0;
|
||||
|
||||
SMaterialReference r;
|
||||
r.Material = m;
|
||||
r.VertexType = vt;
|
||||
r.BufferIndex = DestBuffers.size();
|
||||
switch (vt)
|
||||
{
|
||||
case video::EVT_STANDARD:
|
||||
mb = (IMeshBuffer*)new SMeshBuffer();
|
||||
mb->getMaterial() = m;
|
||||
break;
|
||||
case video::EVT_2TCOORDS:
|
||||
mb = (IMeshBuffer*)new SMeshBufferLightMap();
|
||||
mb->getMaterial() = m;
|
||||
break;
|
||||
case video::EVT_TANGENTS:
|
||||
mb = (IMeshBuffer*)new SMeshBufferTangents();
|
||||
mb->getMaterial() = m;
|
||||
break;
|
||||
default: // unknown vertex type
|
||||
return -1;
|
||||
}
|
||||
i = MaterialReferences.size();
|
||||
MaterialReferences.push_back(r);
|
||||
SMaterialReference r;
|
||||
r.Material = m;
|
||||
r.VertexType = vt;
|
||||
r.BufferIndex = DestBuffers.size();
|
||||
switch (vt)
|
||||
{
|
||||
case video::EVT_STANDARD:
|
||||
mb = (IMeshBuffer*)new SMeshBuffer();
|
||||
mb->getMaterial() = m;
|
||||
break;
|
||||
case video::EVT_2TCOORDS:
|
||||
mb = (IMeshBuffer*)new SMeshBufferLightMap();
|
||||
mb->getMaterial() = m;
|
||||
break;
|
||||
case video::EVT_TANGENTS:
|
||||
mb = (IMeshBuffer*)new SMeshBufferTangents();
|
||||
mb->getMaterial() = m;
|
||||
break;
|
||||
default: // unknown vertex type
|
||||
return -1;
|
||||
}
|
||||
i = MaterialReferences.size();
|
||||
MaterialReferences.push_back(r);
|
||||
|
||||
SDestBufferReference db;
|
||||
db.Buffer = mb;
|
||||
db.IndexCount = buffer->getIndexCount();
|
||||
db.VertexCount = buffer->getVertexCount();
|
||||
db.IsDirty = true;
|
||||
db.VertexType = vt;
|
||||
SDestBufferReference db;
|
||||
db.Buffer = mb;
|
||||
db.IndexCount = buffer->getIndexCount();
|
||||
db.VertexCount = buffer->getVertexCount();
|
||||
db.IsDirty = true;
|
||||
db.VertexType = vt;
|
||||
|
||||
DestBuffers.push_back(db);
|
||||
}
|
||||
// now we add the mesh reference
|
||||
SBufferReference r;
|
||||
r.DestReference = i;
|
||||
r.SourceBuffer = buffer;
|
||||
r.Transform = transform;
|
||||
r.IndexCount = buffer->getIndexCount();
|
||||
r.VertexCount = buffer->getVertexCount();
|
||||
r.FirstIndex = DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount - r.IndexCount;
|
||||
r.FirstVertex = DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount - r.VertexCount;
|
||||
r.Initialized = false;
|
||||
BufferReferences.push_back(r);
|
||||
addSourceBuffer(buffer);
|
||||
DestBuffers.push_back(db);
|
||||
}
|
||||
// now we add the mesh reference
|
||||
SBufferReference r;
|
||||
r.DestReference = i;
|
||||
r.SourceBuffer = buffer;
|
||||
r.Transform = transform;
|
||||
r.IndexCount = buffer->getIndexCount();
|
||||
r.VertexCount = buffer->getVertexCount();
|
||||
r.FirstIndex = DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount - r.IndexCount;
|
||||
r.FirstVertex = DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount - r.VertexCount;
|
||||
r.Initialized = false;
|
||||
BufferReferences.push_back(r);
|
||||
addSourceBuffer(buffer);
|
||||
|
||||
IsDirty = true;
|
||||
return BufferReferences.size()-1;
|
||||
IsDirty = true;
|
||||
return BufferReferences.size()-1;
|
||||
}
|
||||
|
||||
//! updates bouding box from internal buffers
|
||||
void CBatchingMesh::recalculateBoundingBox()
|
||||
{
|
||||
if (DestBuffers.size() == 0)
|
||||
Box.reset(0,0,0);
|
||||
else
|
||||
{
|
||||
Box.reset(DestBuffers[0].Buffer->getBoundingBox().MinEdge);
|
||||
if (DestBuffers.size() == 0)
|
||||
Box.reset(0,0,0);
|
||||
else
|
||||
{
|
||||
Box.reset(DestBuffers[0].Buffer->getBoundingBox().MinEdge);
|
||||
|
||||
u32 i;
|
||||
for (i=0; i < DestBuffers.size(); ++i)
|
||||
Box.addInternalBox(DestBuffers[i].Buffer->getBoundingBox());
|
||||
}
|
||||
u32 i;
|
||||
for (i=0; i < DestBuffers.size(); ++i)
|
||||
Box.addInternalBox(DestBuffers[i].Buffer->getBoundingBox());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -249,7 +249,7 @@ void CBatchingMesh::recalculateBoundingBox()
|
||||
/** \return Returns the amount of mesh buffers (IMeshBuffer) in this mesh. */
|
||||
u32 CBatchingMesh::getMeshBufferCount() const
|
||||
{
|
||||
return DestBuffers.size();
|
||||
return DestBuffers.size();
|
||||
}
|
||||
|
||||
//! Returns pointer to a mesh buffer.
|
||||
@ -259,29 +259,29 @@ getMeshBufferCount() - 1;
|
||||
NULL if there is no such mesh buffer. */
|
||||
IMeshBuffer* CBatchingMesh::getMeshBuffer(u32 nr) const
|
||||
{
|
||||
if (nr < DestBuffers.size())
|
||||
return DestBuffers[nr].Buffer;
|
||||
else
|
||||
return 0;
|
||||
if (nr < DestBuffers.size())
|
||||
return DestBuffers[nr].Buffer;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! Returns pointer to a mesh buffer which fits a material
|
||||
IMeshBuffer* CBatchingMesh::getMeshBuffer( const video::SMaterial &material) const
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! Returns an axis aligned bounding box of the mesh.
|
||||
/** \return A bounding box of this mesh is returned. */
|
||||
const core::aabbox3d<f32>& CBatchingMesh::getBoundingBox() const
|
||||
{
|
||||
return Box;
|
||||
return Box;
|
||||
}
|
||||
|
||||
//! set user axis aligned bounding box
|
||||
void CBatchingMesh::setBoundingBox( const core::aabbox3df& box)
|
||||
{
|
||||
Box = box;
|
||||
Box = box;
|
||||
}
|
||||
|
||||
//! Sets a flag of all contained materials to a new value.
|
||||
@ -289,218 +289,218 @@ void CBatchingMesh::setBoundingBox( const core::aabbox3df& box)
|
||||
\param newvalue: New value to set in all materials. */
|
||||
void CBatchingMesh::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
|
||||
{
|
||||
for (u32 i=0; i<DestBuffers.size(); ++i)
|
||||
DestBuffers[i].Buffer->getMaterial().setFlag(flag, newvalue);
|
||||
for (u32 i=0; i<DestBuffers.size(); ++i)
|
||||
DestBuffers[i].Buffer->getMaterial().setFlag(flag, newvalue);
|
||||
}
|
||||
|
||||
//! drops all buffers and clears internal states
|
||||
void CBatchingMesh::clear()
|
||||
{
|
||||
u32 i;
|
||||
for (i=0; i < DestBuffers.size(); ++i)
|
||||
DestBuffers[i].Buffer->drop();
|
||||
u32 i;
|
||||
for (i=0; i < DestBuffers.size(); ++i)
|
||||
DestBuffers[i].Buffer->drop();
|
||||
|
||||
for (i=0; i < SourceBuffers.size(); ++i)
|
||||
SourceBuffers[i]->drop();
|
||||
for (i=0; i < SourceBuffers.size(); ++i)
|
||||
SourceBuffers[i]->drop();
|
||||
|
||||
BufferReferences.clear();
|
||||
MaterialReferences.clear();
|
||||
DestBuffers.clear();
|
||||
SourceBuffers.clear();
|
||||
BufferReferences.clear();
|
||||
MaterialReferences.clear();
|
||||
DestBuffers.clear();
|
||||
SourceBuffers.clear();
|
||||
|
||||
IsDirty = false;
|
||||
IsFinal = false;
|
||||
IsDirty = false;
|
||||
IsFinal = false;
|
||||
}
|
||||
|
||||
//! first updates the mesh, then drops all source buffers.
|
||||
/** once this mesh has been finalized, it cannot be changed again! */
|
||||
void CBatchingMesh::finalize()
|
||||
{
|
||||
update();
|
||||
update();
|
||||
|
||||
for (u32 i=0; i < SourceBuffers.size(); ++i)
|
||||
SourceBuffers[i]->drop();
|
||||
for (u32 i=0; i < SourceBuffers.size(); ++i)
|
||||
SourceBuffers[i]->drop();
|
||||
|
||||
SourceBuffers.clear();
|
||||
SourceBuffers.clear();
|
||||
|
||||
IsFinal = true;
|
||||
IsFinal = true;
|
||||
}
|
||||
|
||||
//! Moves a mesh
|
||||
core::array<bool> CBatchingMesh::moveMesh(const core::array<s32>& bufferIDs, const core::matrix4 &newMatrix)
|
||||
{
|
||||
core::array<bool> result;
|
||||
result.reallocate(bufferIDs.size());
|
||||
for (u32 i=0; i<bufferIDs.size(); ++i)
|
||||
result.push_back(moveMeshBuffer(bufferIDs[i], newMatrix));
|
||||
core::array<bool> result;
|
||||
result.reallocate(bufferIDs.size());
|
||||
for (u32 i=0; i<bufferIDs.size(); ++i)
|
||||
result.push_back(moveMeshBuffer(bufferIDs[i], newMatrix));
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//! Moves a mesh buffer
|
||||
bool CBatchingMesh::moveMeshBuffer(const s32 id, const core::matrix4 &newMatrix)
|
||||
{
|
||||
if ((u32)id > BufferReferences.size() || IsFinal )
|
||||
return false;
|
||||
if ((u32)id > BufferReferences.size() || IsFinal )
|
||||
return false;
|
||||
|
||||
BufferReferences[id].Transform = newMatrix;
|
||||
BufferReferences[id].Transform = newMatrix;
|
||||
|
||||
// is the source buffer dirty?
|
||||
if (!DestBuffers[BufferReferences[id].DestReference].IsDirty)
|
||||
{
|
||||
// transform each vertex and normal
|
||||
updateDestFromSourceBuffer(id);
|
||||
recalculateDestBufferBoundingBox(BufferReferences[id].DestReference);
|
||||
}
|
||||
return true;
|
||||
// is the source buffer dirty?
|
||||
if (!DestBuffers[BufferReferences[id].DestReference].IsDirty)
|
||||
{
|
||||
// transform each vertex and normal
|
||||
updateDestFromSourceBuffer(id);
|
||||
recalculateDestBufferBoundingBox(BufferReferences[id].DestReference);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! returns the source buffer, if available
|
||||
IMeshBuffer* CBatchingMesh::getSourceBuffer(s32 id)
|
||||
{
|
||||
if ((u32)id > BufferReferences.size() || IsFinal)
|
||||
return 0;
|
||||
else
|
||||
return BufferReferences[id].SourceBuffer;
|
||||
if ((u32)id > BufferReferences.size() || IsFinal)
|
||||
return 0;
|
||||
else
|
||||
return BufferReferences[id].SourceBuffer;
|
||||
}
|
||||
|
||||
//! returns the matrix of the source buffer
|
||||
core::matrix4 CBatchingMesh::getSourceBufferMatrix(s32 id)
|
||||
{
|
||||
core::matrix4 ret;
|
||||
if ((u32)id > BufferReferences.size() || IsFinal)
|
||||
ret.makeIdentity();
|
||||
else
|
||||
ret = BufferReferences[id].Transform;
|
||||
core::matrix4 ret;
|
||||
if ((u32)id > BufferReferences.size() || IsFinal)
|
||||
ret.makeIdentity();
|
||||
else
|
||||
ret = BufferReferences[id].Transform;
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//! returns the number of source buffers
|
||||
u32 CBatchingMesh::getSourceBufferCount() const
|
||||
{
|
||||
return BufferReferences.size();
|
||||
return BufferReferences.size();
|
||||
}
|
||||
|
||||
// private functions
|
||||
|
||||
void CBatchingMesh::recalculateDestBufferBoundingBox(u32 i)
|
||||
{
|
||||
switch (DestBuffers[i].VertexType)
|
||||
{
|
||||
case video::EVT_STANDARD:
|
||||
((SMeshBuffer*)DestBuffers[i].Buffer)->recalculateBoundingBox();
|
||||
break;
|
||||
case video::EVT_2TCOORDS:
|
||||
((SMeshBufferLightMap*)DestBuffers[i].Buffer)->recalculateBoundingBox();
|
||||
break;
|
||||
case video::EVT_TANGENTS:
|
||||
((SMeshBufferTangents*)DestBuffers[i].Buffer)->recalculateBoundingBox();
|
||||
break;
|
||||
}
|
||||
switch (DestBuffers[i].VertexType)
|
||||
{
|
||||
case video::EVT_STANDARD:
|
||||
((SMeshBuffer*)DestBuffers[i].Buffer)->recalculateBoundingBox();
|
||||
break;
|
||||
case video::EVT_2TCOORDS:
|
||||
((SMeshBufferLightMap*)DestBuffers[i].Buffer)->recalculateBoundingBox();
|
||||
break;
|
||||
case video::EVT_TANGENTS:
|
||||
((SMeshBufferTangents*)DestBuffers[i].Buffer)->recalculateBoundingBox();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CBatchingMesh::updateDestFromSourceBuffer(u32 i)
|
||||
{
|
||||
u16* ind = BufferReferences[i].SourceBuffer->getIndices();
|
||||
void*ver = BufferReferences[i].SourceBuffer->getVertices();
|
||||
core::matrix4 m = BufferReferences[i].Transform;
|
||||
u32 fi = BufferReferences[i].FirstIndex;
|
||||
u32 fv = BufferReferences[i].FirstVertex;
|
||||
u32 ic = BufferReferences[i].IndexCount;
|
||||
u32 vc = BufferReferences[i].VertexCount;
|
||||
u32 x;
|
||||
video::E_VERTEX_TYPE vt = DestBuffers[BufferReferences[i].DestReference].VertexType;
|
||||
switch (vt)
|
||||
{
|
||||
case video::EVT_STANDARD:
|
||||
{
|
||||
SMeshBuffer* dest = (SMeshBuffer*) DestBuffers[BufferReferences[i].DestReference].Buffer;
|
||||
u16* ind = BufferReferences[i].SourceBuffer->getIndices();
|
||||
void*ver = BufferReferences[i].SourceBuffer->getVertices();
|
||||
core::matrix4 m = BufferReferences[i].Transform;
|
||||
u32 fi = BufferReferences[i].FirstIndex;
|
||||
u32 fv = BufferReferences[i].FirstVertex;
|
||||
u32 ic = BufferReferences[i].IndexCount;
|
||||
u32 vc = BufferReferences[i].VertexCount;
|
||||
u32 x;
|
||||
video::E_VERTEX_TYPE vt = DestBuffers[BufferReferences[i].DestReference].VertexType;
|
||||
switch (vt)
|
||||
{
|
||||
case video::EVT_STANDARD:
|
||||
{
|
||||
SMeshBuffer* dest = (SMeshBuffer*) DestBuffers[BufferReferences[i].DestReference].Buffer;
|
||||
|
||||
for (x=fi; x < fi+ic; ++x)
|
||||
dest->Indices[x] = ind[x-fi]+fv;
|
||||
for (x=fi; x < fi+ic; ++x)
|
||||
dest->Indices[x] = ind[x-fi]+fv;
|
||||
|
||||
video::S3DVertex* vertices= (video::S3DVertex*) ver;
|
||||
video::S3DVertex* vertices= (video::S3DVertex*) ver;
|
||||
|
||||
for (x=fv; x < fv+vc; ++x)
|
||||
{
|
||||
dest->Vertices[x] = vertices[x-fv];
|
||||
m.transformVect(dest->Vertices[x].Pos);
|
||||
m.rotateVect(dest->Vertices[x].Normal);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case video::EVT_2TCOORDS:
|
||||
{
|
||||
SMeshBufferLightMap* dest = (SMeshBufferLightMap*) DestBuffers[BufferReferences[i].DestReference].Buffer;
|
||||
for (x=fv; x < fv+vc; ++x)
|
||||
{
|
||||
dest->Vertices[x] = vertices[x-fv];
|
||||
m.transformVect(dest->Vertices[x].Pos);
|
||||
m.rotateVect(dest->Vertices[x].Normal);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case video::EVT_2TCOORDS:
|
||||
{
|
||||
SMeshBufferLightMap* dest = (SMeshBufferLightMap*) DestBuffers[BufferReferences[i].DestReference].Buffer;
|
||||
|
||||
for (x=fi; x < fi+ic; ++x)
|
||||
dest->Indices[x] = ind[x-fi]+fv;
|
||||
for (x=fi; x < fi+ic; ++x)
|
||||
dest->Indices[x] = ind[x-fi]+fv;
|
||||
|
||||
video::S3DVertex2TCoords* vertices= (video::S3DVertex2TCoords*) ver;
|
||||
video::S3DVertex2TCoords* vertices= (video::S3DVertex2TCoords*) ver;
|
||||
|
||||
for (x=fv; x < fv+vc; ++x)
|
||||
{
|
||||
dest->Vertices[x] = vertices[x-fv];
|
||||
m.transformVect(dest->Vertices[x].Pos);
|
||||
m.rotateVect(dest->Vertices[x].Normal);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case video::EVT_TANGENTS:
|
||||
{
|
||||
SMeshBufferTangents* dest = (SMeshBufferTangents*) DestBuffers[BufferReferences[i].DestReference].Buffer;
|
||||
for (x=fv; x < fv+vc; ++x)
|
||||
{
|
||||
dest->Vertices[x] = vertices[x-fv];
|
||||
m.transformVect(dest->Vertices[x].Pos);
|
||||
m.rotateVect(dest->Vertices[x].Normal);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case video::EVT_TANGENTS:
|
||||
{
|
||||
SMeshBufferTangents* dest = (SMeshBufferTangents*) DestBuffers[BufferReferences[i].DestReference].Buffer;
|
||||
|
||||
for (x=fi; x < fi+ic; ++x)
|
||||
dest->Indices[x] = ind[x-fi]+fv;
|
||||
for (x=fi; x < fi+ic; ++x)
|
||||
dest->Indices[x] = ind[x-fi]+fv;
|
||||
|
||||
video::S3DVertexTangents* vertices= (video::S3DVertexTangents*) ver;
|
||||
video::S3DVertexTangents* vertices= (video::S3DVertexTangents*) ver;
|
||||
|
||||
for (x=fv; x < fv+vc; ++x)
|
||||
{
|
||||
dest->Vertices[x] = vertices[x-fv];
|
||||
m.transformVect(dest->Vertices[x].Pos);
|
||||
m.rotateVect(dest->Vertices[x].Normal); // are tangents/binormals in face space?
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
for (x=fv; x < fv+vc; ++x)
|
||||
{
|
||||
dest->Vertices[x] = vertices[x-fv];
|
||||
m.transformVect(dest->Vertices[x].Pos);
|
||||
m.rotateVect(dest->Vertices[x].Normal); // are tangents/binormals in face space?
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CBatchingMesh::addSourceBuffer(IMeshBuffer *source)
|
||||
{
|
||||
bool found = false;
|
||||
for (u32 i=0; i<SourceBuffers.size(); ++i)
|
||||
{
|
||||
if (SourceBuffers[i] == source)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
source->grab();
|
||||
SourceBuffers.push_back(source);
|
||||
}
|
||||
bool found = false;
|
||||
for (u32 i=0; i<SourceBuffers.size(); ++i)
|
||||
{
|
||||
if (SourceBuffers[i] == source)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
source->grab();
|
||||
SourceBuffers.push_back(source);
|
||||
}
|
||||
}
|
||||
|
||||
void CBatchingMesh::setHardwareMappingHint(E_HARDWARE_MAPPING mapping, E_BUFFER_TYPE type)
|
||||
{
|
||||
for (u32 i=0; i < DestBuffers.size(); ++i)
|
||||
DestBuffers[i].Buffer->setHardwareMappingHint(mapping, type);
|
||||
for (u32 i=0; i < DestBuffers.size(); ++i)
|
||||
DestBuffers[i].Buffer->setHardwareMappingHint(mapping, type);
|
||||
}
|
||||
|
||||
|
||||
void CBatchingMesh::setDirty(E_BUFFER_TYPE type)
|
||||
{
|
||||
for (u32 i=0; i < DestBuffers.size(); ++i)
|
||||
DestBuffers[i].Buffer->setDirty(type);
|
||||
for (u32 i=0; i < DestBuffers.size(); ++i)
|
||||
DestBuffers[i].Buffer->setDirty(type);
|
||||
}
|
||||
|
||||
} // namespace scene
|
||||
|
@ -15,157 +15,157 @@ namespace scene
|
||||
class CBatchingMesh : public IMesh
|
||||
{
|
||||
public:
|
||||
CBatchingMesh();
|
||||
CBatchingMesh();
|
||||
|
||||
virtual ~CBatchingMesh();
|
||||
virtual ~CBatchingMesh();
|
||||
|
||||
//! returns true if new buffers have been added without updating the internal buffers
|
||||
bool isDirty(s32 id=-1);
|
||||
//! returns true if new buffers have been added without updating the internal buffers
|
||||
bool isDirty(s32 id=-1);
|
||||
|
||||
//! refreshes the internal buffers from source
|
||||
void update();
|
||||
//! refreshes the internal buffers from source
|
||||
void update();
|
||||
|
||||
//! drops all buffers and clears internal states
|
||||
void clear();
|
||||
//! drops all buffers and clears internal states
|
||||
void clear();
|
||||
|
||||
//! first updates the mesh, then drops all source buffers.
|
||||
/** once this mesh has been finalized, it cannot be changed again! */
|
||||
void finalize();
|
||||
//! first updates the mesh, then drops all source buffers.
|
||||
/** once this mesh has been finalized, it cannot be changed again! */
|
||||
void finalize();
|
||||
|
||||
//! adds a mesh to the buffers with the given offset
|
||||
/** \Return: Returns an array of ID numbers */
|
||||
core::array<s32> addMesh(IMesh* mesh,
|
||||
core::vector3df pos = core::vector3df(0,0,0),
|
||||
core::vector3df rot = core::vector3df(0,0,0),
|
||||
core::vector3df scale = core::vector3df(1,1,1));
|
||||
//! adds a mesh to the buffers with the given offset
|
||||
/** \Return: Returns an array of ID numbers */
|
||||
core::array<s32> addMesh(IMesh* mesh,
|
||||
core::vector3df pos = core::vector3df(0,0,0),
|
||||
core::vector3df rot = core::vector3df(0,0,0),
|
||||
core::vector3df scale = core::vector3df(1,1,1));
|
||||
|
||||
//! adds a mesh with the given transformation
|
||||
/** \Return: Returns an array of ID numbers */
|
||||
core::array<s32> addMesh(IMesh* mesh, const core::matrix4 &transform);
|
||||
//! adds a mesh with the given transformation
|
||||
/** \Return: Returns an array of ID numbers */
|
||||
core::array<s32> addMesh(IMesh* mesh, const core::matrix4 &transform);
|
||||
|
||||
//! adds a mesh buffer with the given transformation
|
||||
/** \Return: Returns the ID of this mesh buffer */
|
||||
s32 addMeshBuffer(IMeshBuffer* buffer,
|
||||
core::vector3df pos = core::vector3df(0,0,0),
|
||||
core::vector3df rot = core::vector3df(0,0,0),
|
||||
core::vector3df scale = core::vector3df(1,1,1));
|
||||
//! adds a mesh buffer with the given transformation
|
||||
/** \Return: Returns the ID of this mesh buffer */
|
||||
s32 addMeshBuffer(IMeshBuffer* buffer,
|
||||
core::vector3df pos = core::vector3df(0,0,0),
|
||||
core::vector3df rot = core::vector3df(0,0,0),
|
||||
core::vector3df scale = core::vector3df(1,1,1));
|
||||
|
||||
//! adds a mesh with the given transformation
|
||||
/** \Return Returns the ID of this mesh buffer */
|
||||
s32 addMeshBuffer(IMeshBuffer* buffer, const core::matrix4 &transform);
|
||||
//! adds a mesh with the given transformation
|
||||
/** \Return Returns the ID of this mesh buffer */
|
||||
s32 addMeshBuffer(IMeshBuffer* buffer, const core::matrix4 &transform);
|
||||
|
||||
//! updates bouding box from internal buffers
|
||||
void recalculateBoundingBox();
|
||||
//! updates bouding box from internal buffers
|
||||
void recalculateBoundingBox();
|
||||
|
||||
//! Moves a mesh,
|
||||
/** mesh buffers in clean destination buffers will be moved immediately,
|
||||
ones in dirty buffers will be left until the next update */
|
||||
core::array<bool> moveMesh(const core::array<s32>& bufferIDs, const core::matrix4 &newMatrix);
|
||||
//! Moves a mesh,
|
||||
/** mesh buffers in clean destination buffers will be moved immediately,
|
||||
ones in dirty buffers will be left until the next update */
|
||||
core::array<bool> moveMesh(const core::array<s32>& bufferIDs, const core::matrix4 &newMatrix);
|
||||
|
||||
//! Moves a mesh buffer
|
||||
/** if the destination buffer is clean it will be moved immediately,
|
||||
if a member of a dirty buffer, it will be left until the next update */
|
||||
bool moveMeshBuffer(const s32 id, const core::matrix4 &newMatrix);
|
||||
//! Moves a mesh buffer
|
||||
/** if the destination buffer is clean it will be moved immediately,
|
||||
if a member of a dirty buffer, it will be left until the next update */
|
||||
bool moveMeshBuffer(const s32 id, const core::matrix4 &newMatrix);
|
||||
|
||||
//! returns the source buffer, if available
|
||||
IMeshBuffer* getSourceBuffer(s32 id);
|
||||
//! returns the source buffer, if available
|
||||
IMeshBuffer* getSourceBuffer(s32 id);
|
||||
|
||||
//! returns the matrix of the source buffer
|
||||
core::matrix4 getSourceBufferMatrix(s32 id);
|
||||
//! returns the matrix of the source buffer
|
||||
core::matrix4 getSourceBufferMatrix(s32 id);
|
||||
|
||||
//! returns the number of source buffers
|
||||
u32 getSourceBufferCount() const;
|
||||
//! returns the number of source buffers
|
||||
u32 getSourceBufferCount() const;
|
||||
|
||||
/* Standard IMesh functions */
|
||||
/* Standard IMesh functions */
|
||||
|
||||
//! Returns the amount of mesh buffers.
|
||||
/** \return Returns the amount of mesh buffers (IMeshBuffer) in this mesh. */
|
||||
virtual u32 getMeshBufferCount() const;
|
||||
//! Returns the amount of mesh buffers.
|
||||
/** \return Returns the amount of mesh buffers (IMeshBuffer) in this mesh. */
|
||||
virtual u32 getMeshBufferCount() const;
|
||||
|
||||
//! Returns pointer to a mesh buffer.
|
||||
/** \param nr: Zero based index of the mesh buffer. The maximum value is
|
||||
getMeshBufferCount() - 1;
|
||||
\return Returns the pointer to the mesh buffer or
|
||||
NULL if there is no such mesh buffer. */
|
||||
virtual IMeshBuffer* getMeshBuffer(u32 nr) const;
|
||||
//! Returns pointer to a mesh buffer.
|
||||
/** \param nr: Zero based index of the mesh buffer. The maximum value is
|
||||
getMeshBufferCount() - 1;
|
||||
\return Returns the pointer to the mesh buffer or
|
||||
NULL if there is no such mesh buffer. */
|
||||
virtual IMeshBuffer* getMeshBuffer(u32 nr) const;
|
||||
|
||||
//! Returns pointer to a mesh buffer which fits a material
|
||||
/** \param material: material to search for
|
||||
\return Returns the pointer to the mesh buffer or
|
||||
NULL if there is no such mesh buffer. */
|
||||
virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const;
|
||||
//! Returns pointer to a mesh buffer which fits a material
|
||||
/** \param material: material to search for
|
||||
\return Returns the pointer to the mesh buffer or
|
||||
NULL if there is no such mesh buffer. */
|
||||
virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const;
|
||||
|
||||
//! Returns an axis aligned bounding box of the mesh.
|
||||
/** \return A bounding box of this mesh is returned. */
|
||||
virtual const core::aabbox3d<f32>& getBoundingBox() const;
|
||||
//! Returns an axis aligned bounding box of the mesh.
|
||||
/** \return A bounding box of this mesh is returned. */
|
||||
virtual const core::aabbox3d<f32>& getBoundingBox() const;
|
||||
|
||||
//! set user axis aligned bounding box
|
||||
virtual void setBoundingBox( const core::aabbox3df& box);
|
||||
//! set user axis aligned bounding box
|
||||
virtual void setBoundingBox( const core::aabbox3df& box);
|
||||
|
||||
//! Sets a flag of all contained materials to a new value.
|
||||
/** \param flag: Flag to set in all materials.
|
||||
\param newvalue: New value to set in all materials. */
|
||||
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue);
|
||||
//! Sets a flag of all contained materials to a new value.
|
||||
/** \param flag: Flag to set in all materials.
|
||||
\param newvalue: New value to set in all materials. */
|
||||
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue);
|
||||
|
||||
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING mapping, E_BUFFER_TYPE type);
|
||||
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING mapping, E_BUFFER_TYPE type);
|
||||
|
||||
virtual void setDirty(E_BUFFER_TYPE type);
|
||||
virtual void setDirty(E_BUFFER_TYPE type);
|
||||
|
||||
private:
|
||||
|
||||
// add a buffer to the source buffers array if it doesn't already exist
|
||||
void addSourceBuffer(IMeshBuffer* source);
|
||||
// add a buffer to the source buffers array if it doesn't already exist
|
||||
void addSourceBuffer(IMeshBuffer* source);
|
||||
|
||||
// updates the vertices in dest buffer from the source one
|
||||
void updateDestFromSourceBuffer(u32 id);
|
||||
// updates the vertices in dest buffer from the source one
|
||||
void updateDestFromSourceBuffer(u32 id);
|
||||
|
||||
// recalculates the bounding box for the given dest buffer
|
||||
void recalculateDestBufferBoundingBox(u32 i);
|
||||
// recalculates the bounding box for the given dest buffer
|
||||
void recalculateDestBufferBoundingBox(u32 i);
|
||||
|
||||
struct SBufferReference
|
||||
{
|
||||
SBufferReference()
|
||||
: SourceBuffer(0), DestReference(0), FirstVertex(0), VertexCount(0),
|
||||
FirstIndex(0), IndexCount(0), Initialized(false) { }
|
||||
struct SBufferReference
|
||||
{
|
||||
SBufferReference()
|
||||
: SourceBuffer(0), DestReference(0), FirstVertex(0), VertexCount(0),
|
||||
FirstIndex(0), IndexCount(0), Initialized(false) { }
|
||||
|
||||
IMeshBuffer* SourceBuffer;
|
||||
u32 DestReference;
|
||||
u32 FirstVertex, VertexCount, FirstIndex, IndexCount;
|
||||
core::matrix4 Transform;
|
||||
bool Initialized;
|
||||
};
|
||||
IMeshBuffer* SourceBuffer;
|
||||
u32 DestReference;
|
||||
u32 FirstVertex, VertexCount, FirstIndex, IndexCount;
|
||||
core::matrix4 Transform;
|
||||
bool Initialized;
|
||||
};
|
||||
|
||||
struct SMaterialReference
|
||||
{
|
||||
video::SMaterial Material;
|
||||
video::E_VERTEX_TYPE VertexType;
|
||||
u32 BufferIndex;
|
||||
};
|
||||
struct SMaterialReference
|
||||
{
|
||||
video::SMaterial Material;
|
||||
video::E_VERTEX_TYPE VertexType;
|
||||
u32 BufferIndex;
|
||||
};
|
||||
|
||||
struct SDestBufferReference
|
||||
{
|
||||
IMeshBuffer* Buffer;
|
||||
video::E_VERTEX_TYPE VertexType;
|
||||
u32 VertexCount;
|
||||
u32 IndexCount;
|
||||
bool IsDirty;
|
||||
};
|
||||
struct SDestBufferReference
|
||||
{
|
||||
IMeshBuffer* Buffer;
|
||||
video::E_VERTEX_TYPE VertexType;
|
||||
u32 VertexCount;
|
||||
u32 IndexCount;
|
||||
bool IsDirty;
|
||||
};
|
||||
|
||||
//! Source mesh buffers, these are locked
|
||||
core::array<IMeshBuffer*> SourceBuffers;
|
||||
//! Source mesh buffers, these are locked
|
||||
core::array<IMeshBuffer*> SourceBuffers;
|
||||
|
||||
core::array<SBufferReference> BufferReferences;
|
||||
core::array<SMaterialReference> MaterialReferences;
|
||||
core::array<SDestBufferReference> DestBuffers;
|
||||
core::array<SBufferReference> BufferReferences;
|
||||
core::array<SMaterialReference> MaterialReferences;
|
||||
core::array<SDestBufferReference> DestBuffers;
|
||||
|
||||
//! bounding containing all destination buffers
|
||||
core::aabbox3d<f32> Box;
|
||||
//! bounding containing all destination buffers
|
||||
core::aabbox3d<f32> Box;
|
||||
|
||||
//! does it require an update?
|
||||
bool IsDirty;
|
||||
//! does it require an update?
|
||||
bool IsDirty;
|
||||
|
||||
//! can it be changed?
|
||||
bool IsFinal;
|
||||
//! can it be changed?
|
||||
bool IsFinal;
|
||||
};
|
||||
|
||||
} // namespace scene
|
||||
|
@ -558,21 +558,21 @@ void DisplaceProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
|
||||
void DisplaceProvider::update()
|
||||
{
|
||||
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
||||
const float speed = World::getWorld()->getTrack()->getDisplacementSpeed();
|
||||
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
||||
const float speed = World::getWorld()->getTrack()->getDisplacementSpeed();
|
||||
|
||||
float strength = time;
|
||||
strength = fabsf(noise2d(strength / 10.0f)) * 0.006f + 0.002f;
|
||||
float strength = time;
|
||||
strength = fabsf(noise2d(strength / 10.0f)) * 0.006f + 0.002f;
|
||||
|
||||
vector3df wind = irr_driver->getWind() * strength * speed;
|
||||
m_dir[0] += wind.X;
|
||||
m_dir[1] += wind.Z;
|
||||
vector3df wind = irr_driver->getWind() * strength * speed;
|
||||
m_dir[0] += wind.X;
|
||||
m_dir[1] += wind.Z;
|
||||
|
||||
strength = time * 0.56f + sinf(time);
|
||||
strength = fabsf(noise2d(0.0, strength / 6.0f)) * 0.0095f + 0.0025f;
|
||||
strength = time * 0.56f + sinf(time);
|
||||
strength = fabsf(noise2d(0.0, strength / 6.0f)) * 0.0095f + 0.0025f;
|
||||
|
||||
wind = irr_driver->getWind() * strength * speed;
|
||||
wind.rotateXZBy(cosf(time));
|
||||
m_dir2[0] += wind.X;
|
||||
m_dir2[1] += wind.Z;
|
||||
wind = irr_driver->getWind() * strength * speed;
|
||||
wind.rotateXZBy(cosf(time));
|
||||
m_dir2[0] += wind.X;
|
||||
m_dir2[1] += wind.Z;
|
||||
}
|
@ -121,15 +121,15 @@ public:
|
||||
m_amplitude = amp;
|
||||
}
|
||||
|
||||
float getSpeed() const
|
||||
{
|
||||
return m_speed;
|
||||
}
|
||||
float getSpeed() const
|
||||
{
|
||||
return m_speed;
|
||||
}
|
||||
|
||||
float getAmplitude() const
|
||||
{
|
||||
return m_amplitude;
|
||||
}
|
||||
float getAmplitude() const
|
||||
{
|
||||
return m_amplitude;
|
||||
}
|
||||
|
||||
private:
|
||||
float m_amplitude, m_speed;
|
||||
@ -327,20 +327,20 @@ public:
|
||||
m_color[2] = b;
|
||||
}
|
||||
|
||||
float getRed() const
|
||||
{
|
||||
return m_color[0];
|
||||
}
|
||||
float getRed() const
|
||||
{
|
||||
return m_color[0];
|
||||
}
|
||||
|
||||
float getGreen() const
|
||||
{
|
||||
return m_color[1];
|
||||
}
|
||||
float getGreen() const
|
||||
{
|
||||
return m_color[1];
|
||||
}
|
||||
|
||||
float getBlue() const
|
||||
{
|
||||
return m_color[2];
|
||||
}
|
||||
float getBlue() const
|
||||
{
|
||||
return m_color[2];
|
||||
}
|
||||
|
||||
private:
|
||||
float m_color[3];
|
||||
@ -555,27 +555,27 @@ public:
|
||||
m_dir[0] = m_dir[1] = m_dir2[0] = m_dir2[1] = 0;
|
||||
}
|
||||
|
||||
void update();
|
||||
void update();
|
||||
|
||||
float getDirX() const
|
||||
{
|
||||
return m_dir[0];
|
||||
}
|
||||
float getDirX() const
|
||||
{
|
||||
return m_dir[0];
|
||||
}
|
||||
|
||||
float getDirY() const
|
||||
{
|
||||
return m_dir[1];
|
||||
}
|
||||
float getDirY() const
|
||||
{
|
||||
return m_dir[1];
|
||||
}
|
||||
|
||||
float getDir2X() const
|
||||
{
|
||||
return m_dir2[0];
|
||||
}
|
||||
float getDir2X() const
|
||||
{
|
||||
return m_dir2[0];
|
||||
}
|
||||
|
||||
float getDir2Y() const
|
||||
{
|
||||
return m_dir2[1];
|
||||
}
|
||||
float getDir2Y() const
|
||||
{
|
||||
return m_dir2[1];
|
||||
}
|
||||
|
||||
private:
|
||||
float m_screen[2];
|
||||
|
@ -141,64 +141,64 @@ debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei le
|
||||
|
||||
void initGL()
|
||||
{
|
||||
if (is_gl_init)
|
||||
return;
|
||||
is_gl_init = true;
|
||||
if (is_gl_init)
|
||||
return;
|
||||
is_gl_init = true;
|
||||
#ifdef _IRR_WINDOWS_API_
|
||||
glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC)IRR_OGL_LOAD_EXTENSION("glGenTransformFeedbacks");
|
||||
glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glBindTransformFeedback");
|
||||
glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glDrawTransformFeedback");
|
||||
glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glBeginTransformFeedback");
|
||||
glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glEndTransformFeedback");
|
||||
glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)IRR_OGL_LOAD_EXTENSION("glBindBufferBase");
|
||||
glGenBuffers = (PFNGLGENBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glGenBuffers");
|
||||
glBindBuffer = (PFNGLBINDBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBindBuffer");
|
||||
glBufferData = (PFNGLBUFFERDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferData");
|
||||
glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribPointer");
|
||||
glCreateShader = (PFNGLCREATESHADERPROC)IRR_OGL_LOAD_EXTENSION("glCreateShader");
|
||||
glCompileShader = (PFNGLCOMPILESHADERPROC)IRR_OGL_LOAD_EXTENSION("glCompileShader");
|
||||
glShaderSource = (PFNGLSHADERSOURCEPROC)IRR_OGL_LOAD_EXTENSION("glShaderSource");
|
||||
glCreateProgram = (PFNGLCREATEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glCreateProgram");
|
||||
glAttachShader = (PFNGLATTACHSHADERPROC)IRR_OGL_LOAD_EXTENSION("glAttachShader");
|
||||
glLinkProgram = (PFNGLLINKPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glLinkProgram");
|
||||
glUseProgram = (PFNGLUSEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glUseProgram");
|
||||
glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)IRR_OGL_LOAD_EXTENSION("glEnableVertexAttribArray");
|
||||
glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetUniformLocation");
|
||||
glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix4fv");
|
||||
glUniform1f = (PFNGLUNIFORM1FPROC)IRR_OGL_LOAD_EXTENSION("glUniform1f");
|
||||
glUniform3f = (PFNGLUNIFORM3FPROC)IRR_OGL_LOAD_EXTENSION("glUniform3f");
|
||||
glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)IRR_OGL_LOAD_EXTENSION("glDisableVertexAttribArray");
|
||||
glDeleteShader = (PFNGLDELETESHADERPROC)IRR_OGL_LOAD_EXTENSION("glDeleteShader");
|
||||
glGetShaderiv = (PFNGLGETSHADERIVPROC)IRR_OGL_LOAD_EXTENSION("glGetShaderiv");
|
||||
glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetShaderInfoLog");
|
||||
glActiveTexture = (PFNGLACTIVETEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glActiveTexture");
|
||||
glUniform2f = (PFNGLUNIFORM2FPROC)IRR_OGL_LOAD_EXTENSION("glUniform2f");
|
||||
glUniform4i = (PFNGLUNIFORM4IPROC)IRR_OGL_LOAD_EXTENSION("glUniform4i");
|
||||
glUniform3i = (PFNGLUNIFORM3IPROC)IRR_OGL_LOAD_EXTENSION("glUniform3i");
|
||||
glUniform1i = (PFNGLUNIFORM1IPROC)IRR_OGL_LOAD_EXTENSION("glUniform1i");
|
||||
glGetProgramiv = (PFNGLGETPROGRAMIVPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramiv");
|
||||
glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramInfoLog");
|
||||
glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)IRR_OGL_LOAD_EXTENSION("glTransformFeedbackVaryings");
|
||||
glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetAttribLocation");
|
||||
glBlendEquation = (PFNGLBLENDEQUATIONPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquation");
|
||||
glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribDivisor");
|
||||
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)IRR_OGL_LOAD_EXTENSION("glDrawArraysInstanced");
|
||||
glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteBuffers");
|
||||
glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)IRR_OGL_LOAD_EXTENSION("glGenVertexArrays");
|
||||
glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)IRR_OGL_LOAD_EXTENSION("glBindVertexArray");
|
||||
glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteVertexArrays");
|
||||
glTexBuffer = (PFNGLTEXBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glTexBuffer");
|
||||
glUniform1fv = (PFNGLUNIFORM1FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform1fv");
|
||||
glUniform4fv = (PFNGLUNIFORM4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform4fv");
|
||||
glBufferSubData = (PFNGLBUFFERSUBDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferSubData");
|
||||
glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribIPointer");
|
||||
glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC)IRR_OGL_LOAD_EXTENSION("glGenTransformFeedbacks");
|
||||
glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glBindTransformFeedback");
|
||||
glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glDrawTransformFeedback");
|
||||
glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glBeginTransformFeedback");
|
||||
glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glEndTransformFeedback");
|
||||
glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)IRR_OGL_LOAD_EXTENSION("glBindBufferBase");
|
||||
glGenBuffers = (PFNGLGENBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glGenBuffers");
|
||||
glBindBuffer = (PFNGLBINDBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBindBuffer");
|
||||
glBufferData = (PFNGLBUFFERDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferData");
|
||||
glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribPointer");
|
||||
glCreateShader = (PFNGLCREATESHADERPROC)IRR_OGL_LOAD_EXTENSION("glCreateShader");
|
||||
glCompileShader = (PFNGLCOMPILESHADERPROC)IRR_OGL_LOAD_EXTENSION("glCompileShader");
|
||||
glShaderSource = (PFNGLSHADERSOURCEPROC)IRR_OGL_LOAD_EXTENSION("glShaderSource");
|
||||
glCreateProgram = (PFNGLCREATEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glCreateProgram");
|
||||
glAttachShader = (PFNGLATTACHSHADERPROC)IRR_OGL_LOAD_EXTENSION("glAttachShader");
|
||||
glLinkProgram = (PFNGLLINKPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glLinkProgram");
|
||||
glUseProgram = (PFNGLUSEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glUseProgram");
|
||||
glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)IRR_OGL_LOAD_EXTENSION("glEnableVertexAttribArray");
|
||||
glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetUniformLocation");
|
||||
glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix4fv");
|
||||
glUniform1f = (PFNGLUNIFORM1FPROC)IRR_OGL_LOAD_EXTENSION("glUniform1f");
|
||||
glUniform3f = (PFNGLUNIFORM3FPROC)IRR_OGL_LOAD_EXTENSION("glUniform3f");
|
||||
glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)IRR_OGL_LOAD_EXTENSION("glDisableVertexAttribArray");
|
||||
glDeleteShader = (PFNGLDELETESHADERPROC)IRR_OGL_LOAD_EXTENSION("glDeleteShader");
|
||||
glGetShaderiv = (PFNGLGETSHADERIVPROC)IRR_OGL_LOAD_EXTENSION("glGetShaderiv");
|
||||
glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetShaderInfoLog");
|
||||
glActiveTexture = (PFNGLACTIVETEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glActiveTexture");
|
||||
glUniform2f = (PFNGLUNIFORM2FPROC)IRR_OGL_LOAD_EXTENSION("glUniform2f");
|
||||
glUniform4i = (PFNGLUNIFORM4IPROC)IRR_OGL_LOAD_EXTENSION("glUniform4i");
|
||||
glUniform3i = (PFNGLUNIFORM3IPROC)IRR_OGL_LOAD_EXTENSION("glUniform3i");
|
||||
glUniform1i = (PFNGLUNIFORM1IPROC)IRR_OGL_LOAD_EXTENSION("glUniform1i");
|
||||
glGetProgramiv = (PFNGLGETPROGRAMIVPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramiv");
|
||||
glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramInfoLog");
|
||||
glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)IRR_OGL_LOAD_EXTENSION("glTransformFeedbackVaryings");
|
||||
glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetAttribLocation");
|
||||
glBlendEquation = (PFNGLBLENDEQUATIONPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquation");
|
||||
glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribDivisor");
|
||||
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)IRR_OGL_LOAD_EXTENSION("glDrawArraysInstanced");
|
||||
glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteBuffers");
|
||||
glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)IRR_OGL_LOAD_EXTENSION("glGenVertexArrays");
|
||||
glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)IRR_OGL_LOAD_EXTENSION("glBindVertexArray");
|
||||
glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteVertexArrays");
|
||||
glTexBuffer = (PFNGLTEXBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glTexBuffer");
|
||||
glUniform1fv = (PFNGLUNIFORM1FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform1fv");
|
||||
glUniform4fv = (PFNGLUNIFORM4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform4fv");
|
||||
glBufferSubData = (PFNGLBUFFERSUBDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferSubData");
|
||||
glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribIPointer");
|
||||
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glGenFramebuffers");
|
||||
glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBindFramebuffer");
|
||||
glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glFramebufferTexture");
|
||||
glTexImage3D = (PFNGLTEXIMAGE3DPROC)IRR_OGL_LOAD_EXTENSION("glTexImage3D");
|
||||
glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)IRR_OGL_LOAD_EXTENSION("glCheckFramebufferStatus");
|
||||
#ifdef DEBUG
|
||||
glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)IRR_OGL_LOAD_EXTENSION("glDebugMessageCallbackARB");
|
||||
glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)IRR_OGL_LOAD_EXTENSION("glDebugMessageCallbackARB");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ARB_DEBUG_OUTPUT
|
||||
@ -210,36 +210,36 @@ void initGL()
|
||||
// Mostly from shader tutorial
|
||||
GLuint LoadShader(const char * file, unsigned type)
|
||||
{
|
||||
GLuint Id = glCreateShader(type);
|
||||
GLuint Id = glCreateShader(type);
|
||||
char versionString[20];
|
||||
sprintf(versionString, "#version %d\n", irr_driver->getGLSLVersion());
|
||||
std::string Code = versionString;
|
||||
std::ifstream Stream(file, std::ios::in);
|
||||
if (Stream.is_open())
|
||||
{
|
||||
std::string Line = "";
|
||||
while (getline(Stream, Line))
|
||||
Code += "\n" + Line;
|
||||
Stream.close();
|
||||
}
|
||||
GLint Result = GL_FALSE;
|
||||
int InfoLogLength;
|
||||
Log::info("GLWrap", "Compiling shader : %s", file);
|
||||
char const * SourcePointer = Code.c_str();
|
||||
int length = strlen(SourcePointer);
|
||||
glShaderSource(Id, 1, &SourcePointer, &length);
|
||||
glCompileShader(Id);
|
||||
std::ifstream Stream(file, std::ios::in);
|
||||
if (Stream.is_open())
|
||||
{
|
||||
std::string Line = "";
|
||||
while (getline(Stream, Line))
|
||||
Code += "\n" + Line;
|
||||
Stream.close();
|
||||
}
|
||||
GLint Result = GL_FALSE;
|
||||
int InfoLogLength;
|
||||
Log::info("GLWrap", "Compiling shader : %s", file);
|
||||
char const * SourcePointer = Code.c_str();
|
||||
int length = strlen(SourcePointer);
|
||||
glShaderSource(Id, 1, &SourcePointer, &length);
|
||||
glCompileShader(Id);
|
||||
|
||||
glGetShaderiv(Id, GL_COMPILE_STATUS, &Result);
|
||||
if (Result == GL_FALSE)
|
||||
glGetShaderiv(Id, GL_COMPILE_STATUS, &Result);
|
||||
if (Result == GL_FALSE)
|
||||
{
|
||||
Log::error("GLWrap", "Error in shader %s", file);
|
||||
glGetShaderiv(Id, GL_INFO_LOG_LENGTH, &InfoLogLength);
|
||||
char *ErrorMessage = new char[InfoLogLength];
|
||||
glGetShaderInfoLog(Id, InfoLogLength, NULL, ErrorMessage);
|
||||
glGetShaderiv(Id, GL_INFO_LOG_LENGTH, &InfoLogLength);
|
||||
char *ErrorMessage = new char[InfoLogLength];
|
||||
glGetShaderInfoLog(Id, InfoLogLength, NULL, ErrorMessage);
|
||||
Log::error("GLWrap", ErrorMessage);
|
||||
delete[] ErrorMessage;
|
||||
}
|
||||
delete[] ErrorMessage;
|
||||
}
|
||||
|
||||
GLenum glErr = glGetError();
|
||||
if (glErr != GL_NO_ERROR)
|
||||
@ -247,27 +247,27 @@ GLuint LoadShader(const char * file, unsigned type)
|
||||
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
|
||||
}
|
||||
|
||||
return Id;
|
||||
return Id;
|
||||
}
|
||||
|
||||
GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount)
|
||||
{
|
||||
GLuint Program = glCreateProgram();
|
||||
GLuint Program = glCreateProgram();
|
||||
loadAndAttach(Program, GL_VERTEX_SHADER, vertex_file_path);
|
||||
glTransformFeedbackVaryings(Program, varyingscount, varyings, GL_INTERLEAVED_ATTRIBS);
|
||||
glLinkProgram(Program);
|
||||
glTransformFeedbackVaryings(Program, varyingscount, varyings, GL_INTERLEAVED_ATTRIBS);
|
||||
glLinkProgram(Program);
|
||||
|
||||
GLint Result = GL_FALSE;
|
||||
int InfoLogLength;
|
||||
glGetProgramiv(Program, GL_LINK_STATUS, &Result);
|
||||
if (Result == GL_FALSE)
|
||||
GLint Result = GL_FALSE;
|
||||
int InfoLogLength;
|
||||
glGetProgramiv(Program, GL_LINK_STATUS, &Result);
|
||||
if (Result == GL_FALSE)
|
||||
{
|
||||
glGetProgramiv(Program, GL_INFO_LOG_LENGTH, &InfoLogLength);
|
||||
char *ErrorMessage = new char[InfoLogLength];
|
||||
glGetProgramInfoLog(Program, InfoLogLength, NULL, ErrorMessage);
|
||||
printf(ErrorMessage);
|
||||
delete[] ErrorMessage;
|
||||
}
|
||||
glGetProgramiv(Program, GL_INFO_LOG_LENGTH, &InfoLogLength);
|
||||
char *ErrorMessage = new char[InfoLogLength];
|
||||
glGetProgramInfoLog(Program, InfoLogLength, NULL, ErrorMessage);
|
||||
printf(ErrorMessage);
|
||||
delete[] ErrorMessage;
|
||||
}
|
||||
|
||||
GLenum glErr = glGetError();
|
||||
if (glErr != GL_NO_ERROR)
|
||||
@ -275,7 +275,7 @@ GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsi
|
||||
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
|
||||
}
|
||||
|
||||
return Program;
|
||||
return Program;
|
||||
}
|
||||
|
||||
GLuint getTextureGLuint(irr::video::ITexture *tex)
|
||||
@ -291,12 +291,12 @@ GLuint getDepthTexture(irr::video::ITexture *tex)
|
||||
|
||||
void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + TextureUnit);
|
||||
glBindTexture(GL_TEXTURE_2D, TextureId);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, MagFilter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MinFilter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glActiveTexture(GL_TEXTURE0 + TextureUnit);
|
||||
glBindTexture(GL_TEXTURE_2D, TextureId);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, MagFilter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MinFilter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
int aniso = UserConfigParams::m_anisotropic;
|
||||
if (aniso == 0) aniso = 1;
|
||||
@ -470,14 +470,14 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
|
||||
}
|
||||
|
||||
void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
|
||||
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
|
||||
const video::SColor* const colors, bool useAlphaChannelOfTexture)
|
||||
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
|
||||
const video::SColor* const colors, bool useAlphaChannelOfTexture)
|
||||
{
|
||||
if (!irr_driver->isGLSL())
|
||||
{
|
||||
irr_driver->getVideoDriver()->draw2DImage(texture, destRect, sourceRect, clipRect, colors, useAlphaChannelOfTexture);
|
||||
return;
|
||||
}
|
||||
if (!irr_driver->isGLSL())
|
||||
{
|
||||
irr_driver->getVideoDriver()->draw2DImage(texture, destRect, sourceRect, clipRect, colors, useAlphaChannelOfTexture);
|
||||
return;
|
||||
}
|
||||
|
||||
float width, height,
|
||||
center_pos_x, center_pos_y,
|
||||
@ -487,15 +487,15 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
|
||||
getSize(texture, destRect, sourceRect, width, height, center_pos_x, center_pos_y,
|
||||
tex_width, tex_height, tex_center_pos_x, tex_center_pos_y);
|
||||
|
||||
if (useAlphaChannelOfTexture)
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
if (useAlphaChannelOfTexture)
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
if (clipRect)
|
||||
{
|
||||
if (!clipRect->isValid())
|
||||
@ -506,15 +506,15 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
|
||||
glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y,
|
||||
clipRect->getWidth(), clipRect->getHeight());
|
||||
}
|
||||
if (colors)
|
||||
drawTexColoredQuad(texture, colors, width, height, center_pos_x, center_pos_y,
|
||||
tex_center_pos_x, tex_center_pos_y, tex_width, tex_height);
|
||||
else
|
||||
drawTexQuad(texture, width, height, center_pos_x, center_pos_y,
|
||||
tex_center_pos_x, tex_center_pos_y, tex_width, tex_height);
|
||||
if (colors)
|
||||
drawTexColoredQuad(texture, colors, width, height, center_pos_x, center_pos_y,
|
||||
tex_center_pos_x, tex_center_pos_y, tex_width, tex_height);
|
||||
else
|
||||
drawTexQuad(texture, width, height, center_pos_x, center_pos_y,
|
||||
tex_center_pos_x, tex_center_pos_y, tex_width, tex_height);
|
||||
if (clipRect)
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glUseProgram(0);
|
||||
glUseProgram(0);
|
||||
|
||||
GLenum glErr = glGetError();
|
||||
if (glErr != GL_NO_ERROR)
|
||||
@ -524,39 +524,39 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
|
||||
}
|
||||
|
||||
void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
|
||||
const core::rect<s32>* clip)
|
||||
const core::rect<s32>* clip)
|
||||
{
|
||||
|
||||
if (!irr_driver->isGLSL())
|
||||
{
|
||||
irr_driver->getVideoDriver()->draw2DRectangle(color, position, clip);
|
||||
return;
|
||||
}
|
||||
if (!irr_driver->isGLSL())
|
||||
{
|
||||
irr_driver->getVideoDriver()->draw2DRectangle(color, position, clip);
|
||||
return;
|
||||
}
|
||||
|
||||
core::dimension2d<u32> frame_size =
|
||||
irr_driver->getVideoDriver()->getCurrentRenderTargetSize();
|
||||
const int screen_w = frame_size.Width;
|
||||
const int screen_h = frame_size.Height;
|
||||
float center_pos_x = position.UpperLeftCorner.X + position.LowerRightCorner.X;
|
||||
center_pos_x /= screen_w;
|
||||
center_pos_x -= 1;
|
||||
float center_pos_y = position.UpperLeftCorner.Y + position.LowerRightCorner.Y;
|
||||
center_pos_y /= screen_h;
|
||||
center_pos_y = 1 - center_pos_y;
|
||||
float width = position.LowerRightCorner.X - position.UpperLeftCorner.X;
|
||||
width /= screen_w;
|
||||
float height = position.LowerRightCorner.Y - position.UpperLeftCorner.Y;
|
||||
height /= screen_h;
|
||||
core::dimension2d<u32> frame_size =
|
||||
irr_driver->getVideoDriver()->getCurrentRenderTargetSize();
|
||||
const int screen_w = frame_size.Width;
|
||||
const int screen_h = frame_size.Height;
|
||||
float center_pos_x = position.UpperLeftCorner.X + position.LowerRightCorner.X;
|
||||
center_pos_x /= screen_w;
|
||||
center_pos_x -= 1;
|
||||
float center_pos_y = position.UpperLeftCorner.Y + position.LowerRightCorner.Y;
|
||||
center_pos_y /= screen_h;
|
||||
center_pos_y = 1 - center_pos_y;
|
||||
float width = position.LowerRightCorner.X - position.UpperLeftCorner.X;
|
||||
width /= screen_w;
|
||||
float height = position.LowerRightCorner.Y - position.UpperLeftCorner.Y;
|
||||
height /= screen_h;
|
||||
|
||||
if (color.getAlpha() < 255)
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
if (color.getAlpha() < 255)
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
if (clip)
|
||||
{
|
||||
@ -569,16 +569,16 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
|
||||
clip->getWidth(), clip->getHeight());
|
||||
}
|
||||
|
||||
glUseProgram(UIShader::ColoredRectShader::Program);
|
||||
glBindVertexArray(UIShader::ColoredRectShader::vao);
|
||||
UIShader::ColoredRectShader::setUniforms(center_pos_x, center_pos_y, width, height, color);
|
||||
glUseProgram(UIShader::ColoredRectShader::Program);
|
||||
glBindVertexArray(UIShader::ColoredRectShader::vao);
|
||||
UIShader::ColoredRectShader::setUniforms(center_pos_x, center_pos_y, width, height, color);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
if (clip)
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glUseProgram(0);
|
||||
glUseProgram(0);
|
||||
|
||||
GLenum glErr = glGetError();
|
||||
if (glErr != GL_NO_ERROR)
|
||||
|
@ -156,9 +156,9 @@ void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect<s32>
|
||||
const irr::video::SColor &color, bool useAlphaChannelOfTexture);
|
||||
|
||||
void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect<s32>& destRect,
|
||||
const irr::core::rect<s32>& sourceRect, const irr::core::rect<s32>* clipRect,
|
||||
const irr::video::SColor* const colors, bool useAlphaChannelOfTexture);
|
||||
const irr::core::rect<s32>& sourceRect, const irr::core::rect<s32>* clipRect,
|
||||
const irr::video::SColor* const colors, bool useAlphaChannelOfTexture);
|
||||
|
||||
void GL32_draw2DRectangle(irr::video::SColor color, const irr::core::rect<s32>& position,
|
||||
const irr::core::rect<s32>* clip = 0);
|
||||
const irr::core::rect<s32>* clip = 0);
|
||||
#endif
|
||||
|
@ -155,7 +155,7 @@ STKRenderingPass IrrDriver::getPhase() const
|
||||
|
||||
void IrrDriver::IncreaseObjectCount()
|
||||
{
|
||||
object_count[m_phase]++;
|
||||
object_count[m_phase]++;
|
||||
}
|
||||
|
||||
core::array<video::IRenderTarget> &IrrDriver::getMainSetup()
|
||||
@ -424,10 +424,10 @@ void IrrDriver::initDevice()
|
||||
|
||||
GLMajorVersion = 2;
|
||||
GLMinorVersion = 1;
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &GLMajorVersion);
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &GLMajorVersion);
|
||||
glGetIntegerv(GL_MINOR_VERSION, &GLMinorVersion);
|
||||
Log::info("IrrDriver", "OPENGL VERSION IS %d.%d", GLMajorVersion, GLMinorVersion);
|
||||
m_glsl = (GLMajorVersion > 3 || (GLMajorVersion == 3 && GLMinorVersion >= 1)) && UserConfigParams::m_pixel_shaders;
|
||||
m_glsl = (GLMajorVersion > 3 || (GLMajorVersion == 3 && GLMinorVersion >= 1)) && UserConfigParams::m_pixel_shaders;
|
||||
|
||||
// This remaps the window, so it has to be done before the clear to avoid flicker
|
||||
m_device->setResizable(false);
|
||||
@ -458,7 +458,7 @@ void IrrDriver::initDevice()
|
||||
m_mrt.push_back(m_rtts->getRTT(RTT_COLOR));
|
||||
m_mrt.push_back(m_rtts->getRTT(RTT_NORMAL_AND_DEPTH));
|
||||
|
||||
irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver();
|
||||
irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver();
|
||||
gl_driver->extGlGenQueries(1, &m_lensflare_query);
|
||||
m_query_issued = false;
|
||||
|
||||
@ -964,17 +964,17 @@ scene::ISceneNode *IrrDriver::addBillboard(const core::dimension2d< f32 > size,
|
||||
video::ITexture *texture,
|
||||
scene::ISceneNode* parent, bool alphaTesting)
|
||||
{
|
||||
scene::IBillboardSceneNode* node;
|
||||
if (isGLSL())
|
||||
{
|
||||
if (!parent)
|
||||
parent = m_scene_manager->getRootSceneNode();
|
||||
scene::IBillboardSceneNode* node;
|
||||
if (isGLSL())
|
||||
{
|
||||
if (!parent)
|
||||
parent = m_scene_manager->getRootSceneNode();
|
||||
|
||||
node = new STKBillboard(parent, m_scene_manager, -1, vector3df(0., 0., 0.), size);
|
||||
node->drop();
|
||||
}
|
||||
else
|
||||
node = m_scene_manager->addBillboardSceneNode(parent, size);
|
||||
node = new STKBillboard(parent, m_scene_manager, -1, vector3df(0., 0., 0.), size);
|
||||
node->drop();
|
||||
}
|
||||
else
|
||||
node = m_scene_manager->addBillboardSceneNode(parent, size);
|
||||
assert(node->getMaterialCount() > 0);
|
||||
node->setMaterialTexture(0, texture);
|
||||
if(alphaTesting)
|
||||
@ -1150,7 +1150,7 @@ scene::ISceneNode *IrrDriver::addSkyDome(video::ITexture *texture,
|
||||
float texture_percent,
|
||||
float sphere_percent)
|
||||
{
|
||||
Log::error("skybox", "Using deprecated SkyDome");
|
||||
Log::error("skybox", "Using deprecated SkyDome");
|
||||
return m_scene_manager->addSkyDomeSceneNode(texture, hori_res, vert_res,
|
||||
texture_percent,
|
||||
sphere_percent);
|
||||
@ -1171,7 +1171,7 @@ scene::ISceneNode *IrrDriver::addSkyBox(const std::vector<video::ITexture*>
|
||||
&texture)
|
||||
{
|
||||
assert(texture.size() == 6);
|
||||
SkyboxTextures = texture;
|
||||
SkyboxTextures = texture;
|
||||
SkyboxCubeMap = 0;
|
||||
ConvolutedSkyboxCubeMap = 0;
|
||||
return m_scene_manager->addSkyBoxSceneNode(texture[0], texture[1],
|
||||
@ -1181,7 +1181,7 @@ scene::ISceneNode *IrrDriver::addSkyBox(const std::vector<video::ITexture*>
|
||||
|
||||
void IrrDriver::suppressSkyBox()
|
||||
{
|
||||
SkyboxTextures.clear();
|
||||
SkyboxTextures.clear();
|
||||
glDeleteTextures(1, &SkyboxCubeMap);
|
||||
glDeleteTextures(1, &ConvolutedSkyboxCubeMap);
|
||||
SkyboxCubeMap = 0;
|
||||
@ -1518,9 +1518,9 @@ void IrrDriver::displayFPS()
|
||||
{
|
||||
sprintf(buffer, "FPS: %i/%i/%i - Objects (P1:%d P2:%d T:%d) KTris - LightDst : ~%d",
|
||||
min, fps, max, object_count[SOLID_NORMAL_AND_DEPTH_PASS], object_count[SOLID_NORMAL_AND_DEPTH_PASS], object_count[TRANSPARENT_PASS], m_last_light_bucket_distance);
|
||||
object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0;
|
||||
object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0;
|
||||
object_count[TRANSPARENT_PASS] = 0;
|
||||
object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0;
|
||||
object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0;
|
||||
object_count[TRANSPARENT_PASS] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2216,7 +2216,7 @@ scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos, float energy,
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_scene_manager->addLightSceneNode(m_scene_manager->getRootSceneNode(),
|
||||
return m_scene_manager->addLightSceneNode(m_scene_manager->getRootSceneNode(),
|
||||
pos, video::SColorf(1.0f, r, g, b));
|
||||
}
|
||||
}
|
||||
|
@ -65,13 +65,13 @@ class ShadowImportance;
|
||||
|
||||
enum STKRenderingPass
|
||||
{
|
||||
SOLID_NORMAL_AND_DEPTH_PASS,
|
||||
SOLID_LIT_PASS,
|
||||
TRANSPARENT_PASS,
|
||||
GLOW_PASS,
|
||||
DISPLACEMENT_PASS,
|
||||
SHADOW_PASS,
|
||||
PASS_COUNT,
|
||||
SOLID_NORMAL_AND_DEPTH_PASS,
|
||||
SOLID_LIT_PASS,
|
||||
TRANSPARENT_PASS,
|
||||
GLOW_PASS,
|
||||
DISPLACEMENT_PASS,
|
||||
SHADOW_PASS,
|
||||
PASS_COUNT,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -115,7 +115,7 @@ private:
|
||||
/** Matrixes used in several places stored here to avoid recomputation. */
|
||||
core::matrix4 m_ViewMatrix, m_InvViewMatrix, m_ProjMatrix, m_InvProjMatrix, m_ProjViewMatrix, m_InvProjViewMatrix;
|
||||
|
||||
std::vector<video::ITexture *> SkyboxTextures;
|
||||
std::vector<video::ITexture *> SkyboxTextures;
|
||||
|
||||
float blueSHCoeff[9];
|
||||
float greenSHCoeff[9];
|
||||
@ -183,9 +183,9 @@ private:
|
||||
bool m_shadowviz;
|
||||
bool m_lightviz;
|
||||
bool m_distortviz;
|
||||
/** Performance stats */
|
||||
/** Performance stats */
|
||||
unsigned m_last_light_bucket_distance;
|
||||
unsigned object_count[PASS_COUNT];
|
||||
unsigned object_count[PASS_COUNT];
|
||||
u32 m_renderpass;
|
||||
u32 m_lensflare_query;
|
||||
bool m_query_issued;
|
||||
@ -208,7 +208,7 @@ private:
|
||||
|
||||
std::vector<scene::ISceneNode *> m_background;
|
||||
|
||||
STKRenderingPass m_phase;
|
||||
STKRenderingPass m_phase;
|
||||
|
||||
#ifdef DEBUG
|
||||
/** Used to visualise skeletons. */
|
||||
@ -244,13 +244,13 @@ public:
|
||||
void reset();
|
||||
void generateSkyboxCubemap();
|
||||
void renderSkybox();
|
||||
void setPhase(STKRenderingPass);
|
||||
STKRenderingPass getPhase() const;
|
||||
void setPhase(STKRenderingPass);
|
||||
STKRenderingPass getPhase() const;
|
||||
const std::vector<core::matrix4> &getShadowViewProj() const
|
||||
{
|
||||
return sun_ortho_matrix;
|
||||
}
|
||||
void IncreaseObjectCount();
|
||||
void IncreaseObjectCount();
|
||||
core::array<video::IRenderTarget> &getMainSetup();
|
||||
void updateConfigIfRelevant();
|
||||
void setAllMaterialFlags(scene::IMesh *mesh) const;
|
||||
@ -297,7 +297,7 @@ public:
|
||||
int vert_res, float texture_percent,
|
||||
float sphere_percent);
|
||||
scene::ISceneNode *addSkyBox(const std::vector<video::ITexture*> &texture_names);
|
||||
void suppressSkyBox();
|
||||
void suppressSkyBox();
|
||||
void removeNode(scene::ISceneNode *node);
|
||||
void removeMeshFromCache(scene::IMesh *mesh);
|
||||
void removeTexture(video::ITexture *t);
|
||||
|
@ -13,43 +13,43 @@ namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
//! A SMeshBuffer with 32-bit indices
|
||||
class LargeMeshBuffer : public SMeshBuffer
|
||||
{
|
||||
public:
|
||||
//! Get type of index data which is stored in this meshbuffer.
|
||||
/** \return Index type of this buffer. */
|
||||
virtual video::E_INDEX_TYPE getIndexType() const
|
||||
{
|
||||
return video::EIT_32BIT;
|
||||
}
|
||||
//! A SMeshBuffer with 32-bit indices
|
||||
class LargeMeshBuffer : public SMeshBuffer
|
||||
{
|
||||
public:
|
||||
//! Get type of index data which is stored in this meshbuffer.
|
||||
/** \return Index type of this buffer. */
|
||||
virtual video::E_INDEX_TYPE getIndexType() const
|
||||
{
|
||||
return video::EIT_32BIT;
|
||||
}
|
||||
|
||||
//! Get pointer to indices
|
||||
/** \return Pointer to indices. */
|
||||
virtual const u16* getIndices() const
|
||||
{
|
||||
return (u16 *) Indices.const_pointer();
|
||||
}
|
||||
//! Get pointer to indices
|
||||
/** \return Pointer to indices. */
|
||||
virtual const u16* getIndices() const
|
||||
{
|
||||
return (u16 *) Indices.const_pointer();
|
||||
}
|
||||
|
||||
|
||||
//! Get pointer to indices
|
||||
/** \return Pointer to indices. */
|
||||
virtual u16* getIndices()
|
||||
{
|
||||
return (u16 *) Indices.pointer();
|
||||
}
|
||||
//! Get pointer to indices
|
||||
/** \return Pointer to indices. */
|
||||
virtual u16* getIndices()
|
||||
{
|
||||
return (u16 *) Indices.pointer();
|
||||
}
|
||||
|
||||
|
||||
//! Get number of indices
|
||||
/** \return Number of indices. */
|
||||
virtual u32 getIndexCount() const
|
||||
{
|
||||
return Indices.size();
|
||||
}
|
||||
//! Get number of indices
|
||||
/** \return Number of indices. */
|
||||
virtual u32 getIndexCount() const
|
||||
{
|
||||
return Indices.size();
|
||||
}
|
||||
|
||||
//! Indices into the vertices of this buffer.
|
||||
core::array<u32> Indices;
|
||||
};
|
||||
//! Indices into the vertices of this buffer.
|
||||
core::array<u32> Indices;
|
||||
};
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -661,11 +661,11 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
|
||||
|
||||
int modes = 0;
|
||||
|
||||
if (!m_lighting && irr_driver->isGLSL() && !m_alpha_blending && !m_add)
|
||||
{
|
||||
m->MaterialType = irr_driver->getShader(ES_OBJECT_UNLIT);
|
||||
modes++;
|
||||
}
|
||||
if (!m_lighting && irr_driver->isGLSL() && !m_alpha_blending && !m_add)
|
||||
{
|
||||
m->MaterialType = irr_driver->getShader(ES_OBJECT_UNLIT);
|
||||
modes++;
|
||||
}
|
||||
|
||||
if (m_alpha_testing)
|
||||
{
|
||||
@ -765,8 +765,8 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
|
||||
if (irr_driver->isGLSL())
|
||||
{
|
||||
|
||||
if (mb->getVertexType() != video::EVT_TANGENTS)
|
||||
Log::error("material", "Requiring normal map without tangent enabled mesh");
|
||||
if (mb->getVertexType() != video::EVT_TANGENTS)
|
||||
Log::error("material", "Requiring normal map without tangent enabled mesh");
|
||||
ITexture* tex = irr_driver->getTexture(m_normal_map_tex);
|
||||
if (m_is_heightmap)
|
||||
{
|
||||
|
@ -346,9 +346,9 @@ public:
|
||||
void onMadeVisible(scene::IMeshBuffer* who);
|
||||
void onHidden(scene::IMeshBuffer* who);
|
||||
void isInitiallyHidden(scene::IMeshBuffer* who);
|
||||
/** For particle system : specify if the particle should be additively blended
|
||||
*/
|
||||
bool isAlphaAdditive() const { return !m_alpha_blending; }
|
||||
/** For particle system : specify if the particle should be additively blended
|
||||
*/
|
||||
bool isAlphaAdditive() const { return !m_alpha_blending; }
|
||||
} ;
|
||||
|
||||
|
||||
|
@ -390,21 +390,21 @@ void ParticleEmitter::setCreationRateAbsolute(float f)
|
||||
|
||||
if (f <= 0.0f && m_node->getEmitter())
|
||||
{
|
||||
m_node->clearParticles();
|
||||
m_node->clearParticles();
|
||||
}
|
||||
else if (m_node->getEmitter() == NULL)
|
||||
{
|
||||
m_node->setEmitter(m_emitter);
|
||||
}
|
||||
#endif
|
||||
/* if (f <= 0.0f)
|
||||
{
|
||||
m_node->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_node->setVisible(true);
|
||||
}*/
|
||||
/* if (f <= 0.0f)
|
||||
{
|
||||
m_node->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_node->setVisible(true);
|
||||
}*/
|
||||
} // setCreationRateAbsolute
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -520,7 +520,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
|
||||
case EMITTER_POINT:
|
||||
{
|
||||
m_emitter = m_node->createPointEmitter(velocity,
|
||||
type->getMinRate(), type->getMaxRate(),
|
||||
type->getMinRate(), type->getMaxRate(),
|
||||
type->getMinColor(), type->getMinColor(),
|
||||
lifeTimeMin, lifeTimeMax,
|
||||
m_particle_type->getAngleSpread() /* angle */
|
||||
@ -680,7 +680,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
|
||||
if (flips)
|
||||
{
|
||||
if (m_is_glsl)
|
||||
static_cast<ParticleSystemProxy *>(m_node)->setFlip();
|
||||
static_cast<ParticleSystemProxy *>(m_node)->setFlip();
|
||||
}
|
||||
}
|
||||
} // setParticleType
|
||||
|
@ -58,11 +58,11 @@ PostProcessing::PostProcessing(IVideoDriver* video_driver)
|
||||
io::IReadFile *areamap = irr_driver->getDevice()->getFileSystem()->
|
||||
createMemoryReadFile((void *) AreaMap33, sizeof(AreaMap33),
|
||||
"AreaMap33", false);
|
||||
if (!areamap)
|
||||
{
|
||||
Log::fatal("postprocessing", "Failed to load the areamap");
|
||||
return;
|
||||
}
|
||||
if (!areamap)
|
||||
{
|
||||
Log::fatal("postprocessing", "Failed to load the areamap");
|
||||
return;
|
||||
}
|
||||
m_areamap = irr_driver->getVideoDriver()->getTexture(areamap);
|
||||
areamap->drop();
|
||||
|
||||
@ -207,77 +207,77 @@ void PostProcessing::update(float dt)
|
||||
static
|
||||
void renderBloom(ITexture *in)
|
||||
{
|
||||
const float threshold = World::getWorld()->getTrack()->getBloomThreshold();
|
||||
glUseProgram(FullScreenShader::BloomShader::Program);
|
||||
glBindVertexArray(FullScreenShader::BloomShader::vao);
|
||||
glUniform1f(FullScreenShader::BloomShader::uniform_low, threshold);
|
||||
const float threshold = World::getWorld()->getTrack()->getBloomThreshold();
|
||||
glUseProgram(FullScreenShader::BloomShader::Program);
|
||||
glBindVertexArray(FullScreenShader::BloomShader::vao);
|
||||
glUniform1f(FullScreenShader::BloomShader::uniform_low, threshold);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glUniform1i(FullScreenShader::BloomShader::uniform_texture, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glUniform1i(FullScreenShader::BloomShader::uniform_texture, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
static
|
||||
void renderBloomBlend(ITexture *in)
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glUseProgram(FullScreenShader::BloomBlendShader::Program);
|
||||
glBindVertexArray(FullScreenShader::BloomBlendShader::vao);
|
||||
glUseProgram(FullScreenShader::BloomBlendShader::Program);
|
||||
glBindVertexArray(FullScreenShader::BloomBlendShader::vao);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::BloomBlendShader::uniform_texture, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::BloomBlendShader::uniform_texture, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
static
|
||||
void renderColorLevel(ITexture *in)
|
||||
{
|
||||
core::vector3df m_inlevel = World::getWorld()->getTrack()->getColorLevelIn();
|
||||
core::vector2df m_outlevel = World::getWorld()->getTrack()->getColorLevelOut();
|
||||
core::vector3df m_inlevel = World::getWorld()->getTrack()->getColorLevelIn();
|
||||
core::vector2df m_outlevel = World::getWorld()->getTrack()->getColorLevelOut();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glUseProgram(FullScreenShader::ColorLevelShader::Program);
|
||||
glBindVertexArray(FullScreenShader::ColorLevelShader::vao);
|
||||
glUniform3f(FullScreenShader::ColorLevelShader::uniform_inlevel, m_inlevel.X, m_inlevel.Y, m_inlevel.Z);
|
||||
glUniform2f(FullScreenShader::ColorLevelShader::uniform_outlevel, m_outlevel.X, m_outlevel.Y);
|
||||
glUseProgram(FullScreenShader::ColorLevelShader::Program);
|
||||
glBindVertexArray(FullScreenShader::ColorLevelShader::vao);
|
||||
glUniform3f(FullScreenShader::ColorLevelShader::uniform_inlevel, m_inlevel.X, m_inlevel.Y, m_inlevel.Z);
|
||||
glUniform2f(FullScreenShader::ColorLevelShader::uniform_outlevel, m_outlevel.X, m_outlevel.Y);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glUniform1i(FullScreenShader::ColorLevelShader::uniform_tex, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glUniform1i(FullScreenShader::ColorLevelShader::uniform_tex, 0);
|
||||
glUniform1i(FullScreenShader::ColorLevelShader::uniform_dtex, 1);
|
||||
glUniformMatrix4fv(FullScreenShader::ColorLevelShader::uniform_invprojm, 1, GL_FALSE, irr_driver->getInvProjMatrix().pointer());
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff)
|
||||
@ -349,103 +349,103 @@ void PostProcessing::renderShadowedSunlight(const std::vector<core::matrix4> &su
|
||||
|
||||
void PostProcessing::renderGaussian3Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height)
|
||||
{
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(temprtt, false, false);
|
||||
glUseProgram(FullScreenShader::Gaussian3VBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian3VBlurShader::vao);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(temprtt, false, false);
|
||||
glUseProgram(FullScreenShader::Gaussian3VBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian3VBlurShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian3VBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
glUniform2f(FullScreenShader::Gaussian3VBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::Gaussian3VBlurShader::uniform_tex, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::Gaussian3VBlurShader::uniform_tex, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(in, false, false);
|
||||
glUseProgram(FullScreenShader::Gaussian3HBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian3HBlurShader::vao);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(in, false, false);
|
||||
glUseProgram(FullScreenShader::Gaussian3HBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian3HBlurShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian3HBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
glUniform2f(FullScreenShader::Gaussian3HBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(temprtt));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::Gaussian3HBlurShader::uniform_tex, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::Gaussian3HBlurShader::uniform_tex, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void PostProcessing::renderGaussian6Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height)
|
||||
{
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(temprtt, false, false);
|
||||
glUseProgram(FullScreenShader::Gaussian6VBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian6VBlurShader::vao);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(temprtt, false, false);
|
||||
glUseProgram(FullScreenShader::Gaussian6VBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian6VBlurShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian6VBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
glUniform2f(FullScreenShader::Gaussian6VBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::Gaussian6VBlurShader::uniform_tex, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::Gaussian6VBlurShader::uniform_tex, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(in, false, false);
|
||||
glUseProgram(FullScreenShader::Gaussian6HBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian6HBlurShader::vao);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(in, false, false);
|
||||
glUseProgram(FullScreenShader::Gaussian6HBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian6HBlurShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian6HBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
glUniform2f(FullScreenShader::Gaussian6HBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(temprtt));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::Gaussian6HBlurShader::uniform_tex, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::Gaussian6HBlurShader::uniform_tex, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void PostProcessing::renderPassThrough(ITexture *tex)
|
||||
{
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glUseProgram(FullScreenShader::PassThroughShader::Program);
|
||||
glBindVertexArray(FullScreenShader::PassThroughShader::vao);
|
||||
glUseProgram(FullScreenShader::PassThroughShader::Program);
|
||||
glBindVertexArray(FullScreenShader::PassThroughShader::vao);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(tex));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::PassThroughShader::uniform_texture, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::PassThroughShader::uniform_texture, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void PostProcessing::renderPassThrough(GLuint tex)
|
||||
@ -471,85 +471,85 @@ void PostProcessing::renderPassThrough(GLuint tex)
|
||||
|
||||
void PostProcessing::renderGlow(ITexture *tex)
|
||||
{
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glUseProgram(FullScreenShader::GlowShader::Program);
|
||||
glBindVertexArray(FullScreenShader::GlowShader::vao);
|
||||
glUseProgram(FullScreenShader::GlowShader::Program);
|
||||
glBindVertexArray(FullScreenShader::GlowShader::vao);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(tex));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::GlowShader::uniform_tex, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::GlowShader::uniform_tex, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
ITexture *noise_tex = 0;
|
||||
|
||||
void PostProcessing::renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm)
|
||||
{
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
|
||||
if (!noise_tex)
|
||||
noise_tex = irr_driver->getTexture(file_manager->getAsset("textures/noise.png").c_str());
|
||||
if (!noise_tex)
|
||||
noise_tex = irr_driver->getTexture(file_manager->getAsset("textures/noise.png").c_str());
|
||||
|
||||
glUseProgram(FullScreenShader::SSAOShader::Program);
|
||||
glBindVertexArray(FullScreenShader::SSAOShader::vao);
|
||||
glUseProgram(FullScreenShader::SSAOShader::Program);
|
||||
glBindVertexArray(FullScreenShader::SSAOShader::vao);
|
||||
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(1, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_LINEAR, GL_LINEAR);
|
||||
setTexture(2, getTextureGLuint(noise_tex), GL_NEAREST, GL_NEAREST);
|
||||
|
||||
FullScreenShader::SSAOShader::setUniforms(projm, invprojm, 0, 1, 2);
|
||||
FullScreenShader::SSAOShader::setUniforms(projm, invprojm, 0, 1, 2);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void PostProcessing::renderFog(const core::matrix4 &ipvmat)
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
||||
const Track * const track = World::getWorld()->getTrack();
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
||||
const Track * const track = World::getWorld()->getTrack();
|
||||
|
||||
// This function is only called once per frame - thus no need for setters.
|
||||
const float fogmax = track->getFogMax();
|
||||
const float startH = track->getFogStartHeight();
|
||||
const float endH = track->getFogEndHeight();
|
||||
const float start = track->getFogStart();
|
||||
const float end = track->getFogEnd();
|
||||
const SColor tmpcol = track->getFogColor();
|
||||
// This function is only called once per frame - thus no need for setters.
|
||||
const float fogmax = track->getFogMax();
|
||||
const float startH = track->getFogStartHeight();
|
||||
const float endH = track->getFogEndHeight();
|
||||
const float start = track->getFogStart();
|
||||
const float end = track->getFogEnd();
|
||||
const SColor tmpcol = track->getFogColor();
|
||||
|
||||
core::vector3df col( tmpcol.getRed() / 255.0f,
|
||||
tmpcol.getGreen() / 255.0f,
|
||||
tmpcol.getBlue() / 255.0f );
|
||||
core::vector3df col( tmpcol.getRed() / 255.0f,
|
||||
tmpcol.getGreen() / 255.0f,
|
||||
tmpcol.getBlue() / 255.0f );
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glUseProgram(FullScreenShader::FogShader::Program);
|
||||
glBindVertexArray(FullScreenShader::FogShader::vao);
|
||||
glUseProgram(FullScreenShader::FogShader::Program);
|
||||
glBindVertexArray(FullScreenShader::FogShader::vao);
|
||||
|
||||
setTexture(0, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::FogShader::setUniforms(ipvmat, fogmax, startH, endH, start, end, col, 0);
|
||||
FullScreenShader::FogShader::setUniforms(ipvmat, fogmax, startH, endH, start, end, col, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void PostProcessing::renderMotionBlur(unsigned cam, ITexture *in, ITexture *out)
|
||||
@ -647,24 +647,24 @@ void PostProcessing::render()
|
||||
mocb->setCurrentCamera(cam);
|
||||
ITexture *in = irr_driver->getRTT(RTT_COLOR);
|
||||
ITexture *out = irr_driver->getRTT(RTT_TMP1);
|
||||
// Each effect uses these as named, and sets them up for the next effect.
|
||||
// This allows chaining effects where some may be disabled.
|
||||
// Each effect uses these as named, and sets them up for the next effect.
|
||||
// This allows chaining effects where some may be disabled.
|
||||
|
||||
// As the original color shouldn't be touched, the first effect can't be disabled.
|
||||
// As the original color shouldn't be touched, the first effect can't be disabled.
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Bloom", 0xFF, 0x00, 0x00);
|
||||
if (1) // bloom
|
||||
{
|
||||
// Blit the base to tmp1
|
||||
drv->setRenderTarget(out, true, false);
|
||||
renderPassThrough(in);
|
||||
// Blit the base to tmp1
|
||||
drv->setRenderTarget(out, true, false);
|
||||
renderPassThrough(in);
|
||||
|
||||
const bool globalbloom = World::getWorld()->getTrack()->getBloom();
|
||||
|
||||
if (globalbloom)
|
||||
{
|
||||
drv->setRenderTarget(irr_driver->getRTT(RTT_TMP3), true, false);
|
||||
renderBloom(in);
|
||||
drv->setRenderTarget(irr_driver->getRTT(RTT_TMP3), true, false);
|
||||
renderBloom(in);
|
||||
}
|
||||
|
||||
|
||||
@ -681,23 +681,23 @@ void PostProcessing::render()
|
||||
|
||||
// To half
|
||||
drv->setRenderTarget(irr_driver->getRTT(RTT_HALF1), true, false);
|
||||
renderPassThrough(irr_driver->getRTT(RTT_TMP3));
|
||||
renderPassThrough(irr_driver->getRTT(RTT_TMP3));
|
||||
|
||||
|
||||
// To quarter
|
||||
drv->setRenderTarget(irr_driver->getRTT(RTT_QUARTER1), true, false);
|
||||
renderPassThrough(irr_driver->getRTT(RTT_HALF1));
|
||||
drv->setRenderTarget(irr_driver->getRTT(RTT_QUARTER1), true, false);
|
||||
renderPassThrough(irr_driver->getRTT(RTT_HALF1));
|
||||
|
||||
// To eighth
|
||||
drv->setRenderTarget(irr_driver->getRTT(RTT_EIGHTH1), true, false);
|
||||
renderPassThrough(irr_driver->getRTT(RTT_QUARTER1));
|
||||
drv->setRenderTarget(irr_driver->getRTT(RTT_EIGHTH1), true, false);
|
||||
renderPassThrough(irr_driver->getRTT(RTT_QUARTER1));
|
||||
|
||||
// Blur it for distribution.
|
||||
renderGaussian6Blur(irr_driver->getRTT(RTT_EIGHTH1), irr_driver->getRTT(RTT_EIGHTH2), 8.f / UserConfigParams::m_width, 8.f / UserConfigParams::m_height);
|
||||
renderGaussian6Blur(irr_driver->getRTT(RTT_EIGHTH1), irr_driver->getRTT(RTT_EIGHTH2), 8.f / UserConfigParams::m_width, 8.f / UserConfigParams::m_height);
|
||||
|
||||
// Additively blend on top of tmp1
|
||||
drv->setRenderTarget(out, false, false);
|
||||
renderBloomBlend(irr_driver->getRTT(RTT_EIGHTH1));
|
||||
drv->setRenderTarget(out, false, false);
|
||||
renderBloomBlend(irr_driver->getRTT(RTT_EIGHTH1));
|
||||
} // end if bloom
|
||||
|
||||
in = irr_driver->getRTT(RTT_TMP1);
|
||||
@ -735,7 +735,7 @@ void PostProcessing::render()
|
||||
|
||||
|
||||
// Blur
|
||||
renderGaussian3Blur(irr_driver->getRTT(RTT_QUARTER1),
|
||||
renderGaussian3Blur(irr_driver->getRTT(RTT_QUARTER1),
|
||||
irr_driver->getRTT(RTT_QUARTER2),
|
||||
4.f / UserConfigParams::m_width,
|
||||
4.f / UserConfigParams::m_height);
|
||||
@ -853,14 +853,14 @@ void PostProcessing::render()
|
||||
}
|
||||
|
||||
// Final blit
|
||||
// TODO : Use glBlitFramebuffer
|
||||
drv->setRenderTarget(ERT_FRAME_BUFFER, false, false);
|
||||
// TODO : Use glBlitFramebuffer
|
||||
drv->setRenderTarget(ERT_FRAME_BUFFER, false, false);
|
||||
if (irr_driver->getNormals())
|
||||
renderPassThrough(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH));
|
||||
renderPassThrough(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH));
|
||||
else if (irr_driver->getSSAOViz())
|
||||
renderPassThrough(irr_driver->getRTT(RTT_SSAO));
|
||||
renderPassThrough(irr_driver->getRTT(RTT_SSAO));
|
||||
else
|
||||
renderColorLevel(in);
|
||||
renderColorLevel(in);
|
||||
}
|
||||
} // render
|
||||
|
||||
|
@ -72,24 +72,24 @@ public:
|
||||
void begin();
|
||||
void update(float dt);
|
||||
|
||||
/** Generate diffuse and specular map */
|
||||
void renderSunlight();
|
||||
/** Generate diffuse and specular map */
|
||||
void renderSunlight();
|
||||
void renderShadowedSunlight(const std::vector<core::matrix4> &sun_ortho_matrix, unsigned depthtex);
|
||||
|
||||
void renderFog(const core::matrix4 &ipvmat);
|
||||
void renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm);
|
||||
void renderFog(const core::matrix4 &ipvmat);
|
||||
void renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm);
|
||||
void renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff);
|
||||
|
||||
/** Blur the in texture */
|
||||
void renderGaussian3Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height);
|
||||
void renderGaussian6Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height);
|
||||
/** Blur the in texture */
|
||||
void renderGaussian3Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height);
|
||||
void renderGaussian6Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height);
|
||||
|
||||
/** Render tex. Used for blit/texture resize */
|
||||
void renderPassThrough(video::ITexture *tex);
|
||||
/** Render tex. Used for blit/texture resize */
|
||||
void renderPassThrough(video::ITexture *tex);
|
||||
void renderPassThrough(unsigned tex);
|
||||
|
||||
void renderMotionBlur(unsigned cam, video::ITexture *in, video::ITexture *out);
|
||||
void renderGlow(video::ITexture *tex);
|
||||
void renderGlow(video::ITexture *tex);
|
||||
|
||||
/** Render the post-processed scene */
|
||||
void render();
|
||||
|
@ -189,14 +189,14 @@ void IrrDriver::renderGLSL(float dt)
|
||||
}*/
|
||||
|
||||
// Fire up the MRT
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
|
||||
PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00);
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
|
||||
PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDisable(GL_BLEND);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_CULL_FACE);
|
||||
irr_driver->setPhase(SOLID_NORMAL_AND_DEPTH_PASS);
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
@ -204,7 +204,7 @@ void IrrDriver::renderGLSL(float dt)
|
||||
irr_driver->setViewMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW));
|
||||
irr_driver->genProjViewMatrix();
|
||||
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
// Todo : reenable glow and shadows
|
||||
//ShadowImportanceProvider * const sicb = (ShadowImportanceProvider *)
|
||||
@ -227,14 +227,14 @@ void IrrDriver::renderGLSL(float dt)
|
||||
|
||||
// Lights
|
||||
renderLights(cambox, camnode, overridemat, cam, dt);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Solid Pass 2", 0x00, 0x00, 0xFF);
|
||||
PROFILER_PUSH_CPU_MARKER("- Solid Pass 2", 0x00, 0x00, 0xFF);
|
||||
irr_driver->setPhase(SOLID_LIT_PASS);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
|
||||
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(1, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST);
|
||||
@ -248,27 +248,27 @@ void IrrDriver::renderGLSL(float dt)
|
||||
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
if (World::getWorld()->getTrack()->isFogEnabled())
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("- Fog", 0xFF, 0x00, 0x00);
|
||||
m_post_processing->renderFog(irr_driver->getInvProjMatrix());
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
if (World::getWorld()->getTrack()->isFogEnabled())
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("- Fog", 0xFF, 0x00, 0x00);
|
||||
m_post_processing->renderFog(irr_driver->getInvProjMatrix());
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Glow", 0xFF, 0xFF, 0x00);
|
||||
|
||||
// Render anything glowing.
|
||||
if (!m_mipviz && !m_wireframe)
|
||||
{
|
||||
irr_driver->setPhase(GLOW_PASS);
|
||||
renderGlow(overridemat, glows, cambox, cam);
|
||||
} // end glow
|
||||
// Render anything glowing.
|
||||
if (!m_mipviz && !m_wireframe)
|
||||
{
|
||||
irr_driver->setPhase(GLOW_PASS);
|
||||
renderGlow(overridemat, glows, cambox, cam);
|
||||
} // end glow
|
||||
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Skybox", 0xFF, 0x00, 0xFF);
|
||||
renderSkybox();
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
PROFILER_PUSH_CPU_MARKER("- Skybox", 0xFF, 0x00, 0xFF);
|
||||
renderSkybox();
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Lensflare/godray", 0x00, 0xFF, 0xFF);
|
||||
// Is the lens flare enabled & visible? Check last frame's query.
|
||||
@ -276,7 +276,7 @@ void IrrDriver::renderGLSL(float dt)
|
||||
const bool hasgodrays = World::getWorld()->getTrack()->hasGodRays();
|
||||
if (true)//hasflare || hasgodrays)
|
||||
{
|
||||
irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver();
|
||||
irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver();
|
||||
|
||||
GLuint res = 0;
|
||||
if (m_query_issued)
|
||||
@ -305,26 +305,26 @@ void IrrDriver::renderGLSL(float dt)
|
||||
|
||||
// We need to re-render camera due to the per-cam-node hack.
|
||||
PROFILER_PUSH_CPU_MARKER("- Transparent Pass", 0xFF, 0x00, 0x00);
|
||||
irr_driver->setPhase(TRANSPARENT_PASS);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT;
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_CULL_FACE);
|
||||
irr_driver->setPhase(TRANSPARENT_PASS);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT;
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_CULL_FACE);
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Particles", 0xFF, 0xFF, 0x00);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT_EFFECT;
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
PROFILER_PUSH_CPU_MARKER("- Particles", 0xFF, 0xFF, 0x00);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT_EFFECT;
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Displacement", 0x00, 0x00, 0xFF);
|
||||
// Handle displacing nodes, if any
|
||||
@ -689,10 +689,10 @@ void IrrDriver::renderGlow(video::SOverrideMaterial &overridemat,
|
||||
glStencilFunc(GL_ALWAYS, 1, ~0);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
for (u32 i = 0; i < glowcount; i++)
|
||||
{
|
||||
@ -723,22 +723,22 @@ void IrrDriver::renderGlow(video::SOverrideMaterial &overridemat,
|
||||
|
||||
// To half
|
||||
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_HALF1), false, false);
|
||||
m_post_processing->renderPassThrough(m_rtts->getRTT(RTT_TMP1));
|
||||
m_post_processing->renderPassThrough(m_rtts->getRTT(RTT_TMP1));
|
||||
|
||||
// To quarter
|
||||
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_QUARTER1), false, false);
|
||||
m_post_processing->renderPassThrough(m_rtts->getRTT(RTT_HALF1));
|
||||
m_post_processing->renderPassThrough(m_rtts->getRTT(RTT_HALF1));
|
||||
|
||||
// Blur it
|
||||
m_post_processing->renderGaussian6Blur(m_rtts->getRTT(RTT_QUARTER1), m_rtts->getRTT(RTT_QUARTER2), 4.f / UserConfigParams::m_width, 4.f / UserConfigParams::m_height);
|
||||
m_post_processing->renderGaussian6Blur(m_rtts->getRTT(RTT_QUARTER1), m_rtts->getRTT(RTT_QUARTER2), 4.f / UserConfigParams::m_width, 4.f / UserConfigParams::m_height);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glStencilFunc(GL_EQUAL, 0, ~0);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glStencilFunc(GL_EQUAL, 0, ~0);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_COLOR), false, false);
|
||||
m_post_processing->renderGlow(m_rtts->getRTT(RTT_QUARTER1));
|
||||
m_post_processing->renderGlow(m_rtts->getRTT(RTT_QUARTER1));
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
}
|
||||
|
||||
@ -863,9 +863,9 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
|
||||
|
||||
// Blur it to reduce noise.
|
||||
if(UserConfigParams::m_ssao == 1)
|
||||
m_post_processing->renderGaussian3Blur(irr_driver->getRTT(RTT_SSAO), irr_driver->getRTT(RTT_QUARTER4), 4.f / UserConfigParams::m_width, 4.f / UserConfigParams::m_height);
|
||||
m_post_processing->renderGaussian3Blur(irr_driver->getRTT(RTT_SSAO), irr_driver->getRTT(RTT_QUARTER4), 4.f / UserConfigParams::m_width, 4.f / UserConfigParams::m_height);
|
||||
else if (UserConfigParams::m_ssao == 2)
|
||||
m_post_processing->renderGaussian6Blur(irr_driver->getRTT(RTT_SSAO), irr_driver->getRTT(RTT_TMP4), 1.f / UserConfigParams::m_width, 1.f / UserConfigParams::m_height);
|
||||
m_post_processing->renderGaussian6Blur(irr_driver->getRTT(RTT_SSAO), irr_driver->getRTT(RTT_TMP4), 1.f / UserConfigParams::m_width, 1.f / UserConfigParams::m_height);
|
||||
|
||||
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_COLOR), false, false);
|
||||
}
|
||||
@ -1265,17 +1265,17 @@ void IrrDriver::renderSkybox()
|
||||
if (!SkyboxCubeMap)
|
||||
generateSkyboxCubemap();
|
||||
glBindVertexArray(MeshShader::SkyboxShader::cubevao);
|
||||
glDisable(GL_CULL_FACE);
|
||||
assert(SkyboxTextures.size() == 6);
|
||||
core::matrix4 transform = irr_driver->getProjViewMatrix();
|
||||
core::matrix4 translate;
|
||||
translate.setTranslation(camera->getAbsolutePosition());
|
||||
glDisable(GL_CULL_FACE);
|
||||
assert(SkyboxTextures.size() == 6);
|
||||
core::matrix4 transform = irr_driver->getProjViewMatrix();
|
||||
core::matrix4 translate;
|
||||
translate.setTranslation(camera->getAbsolutePosition());
|
||||
|
||||
// Draw the sky box between the near and far clip plane
|
||||
const f32 viewDistance = (camera->getNearValue() + camera->getFarValue()) * 0.5f;
|
||||
core::matrix4 scale;
|
||||
scale.setScale(core::vector3df(viewDistance, viewDistance, viewDistance));
|
||||
transform *= translate * scale;
|
||||
// Draw the sky box between the near and far clip plane
|
||||
const f32 viewDistance = (camera->getNearValue() + camera->getFarValue()) * 0.5f;
|
||||
core::matrix4 scale;
|
||||
scale.setScale(core::vector3df(viewDistance, viewDistance, viewDistance));
|
||||
transform *= translate * scale;
|
||||
core::matrix4 invtransform;
|
||||
transform.getInverse(invtransform);
|
||||
|
||||
@ -1297,15 +1297,15 @@ void IrrDriver::renderDisplacement(video::SOverrideMaterial &overridemat,
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_TMP4), true, false);
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_DISPLACE), true, false);
|
||||
|
||||
DisplaceProvider * const cb = (DisplaceProvider *)irr_driver->getCallback(ES_DISPLACE);
|
||||
cb->update();
|
||||
DisplaceProvider * const cb = (DisplaceProvider *)irr_driver->getCallback(ES_DISPLACE);
|
||||
cb->update();
|
||||
|
||||
const int displacingcount = m_displacing.size();
|
||||
irr_driver->setPhase(DISPLACEMENT_PASS);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
irr_driver->setPhase(DISPLACEMENT_PASS);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glStencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||
|
@ -70,7 +70,7 @@ RTT::RTT()
|
||||
rtts[RTT_TMP2] = drv->addRenderTargetTexture(res, "rtt.tmp2", ECF_A8R8G8B8, stencil);
|
||||
rtts[RTT_TMP3] = drv->addRenderTargetTexture(res, "rtt.tmp3", ECF_A8R8G8B8, stencil);
|
||||
rtts[RTT_TMP4] = drv->addRenderTargetTexture(res, "rtt.tmp4", ECF_R8, stencil);
|
||||
rtts[RTT_NORMAL_AND_DEPTH] = drv->addRenderTargetTexture(res, "rtt.normal_and_depth", ECF_G16R16F, stencil);
|
||||
rtts[RTT_NORMAL_AND_DEPTH] = drv->addRenderTargetTexture(res, "rtt.normal_and_depth", ECF_G16R16F, stencil);
|
||||
rtts[RTT_COLOR] = drv->addRenderTargetTexture(res, "rtt.color", ECF_A16B16G16R16F, stencil);
|
||||
|
||||
rtts[RTT_HALF1] = drv->addRenderTargetTexture(half, "rtt.half1", ECF_A8R8G8B8, stencil);
|
||||
|
@ -23,8 +23,8 @@ const u16 ScreenQuad::indices[4] = {0, 1, 2, 3};
|
||||
static const SColor white(255, 255, 255, 255);
|
||||
|
||||
const S3DVertex ScreenQuad::vertices[4] = {
|
||||
S3DVertex(-1, 1, 0, 0, 1, 0, white, 0, 1),
|
||||
S3DVertex(1, 1, 0, 0, 1, 0, white, 1, 1),
|
||||
S3DVertex(-1, -1, 0, 0, 1, 0, white, 0, 0),
|
||||
S3DVertex(1, -1, 0, 0, 1, 0, white, 1, 0),
|
||||
};
|
||||
S3DVertex(-1, 1, 0, 0, 1, 0, white, 0, 1),
|
||||
S3DVertex(1, 1, 0, 0, 1, 0, white, 1, 1),
|
||||
S3DVertex(-1, -1, 0, 0, 1, 0, white, 0, 0),
|
||||
S3DVertex(1, -1, 0, 0, 1, 0, white, 1, 0),
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <vector>
|
||||
|
||||
typedef unsigned int GLuint;
|
||||
typedef unsigned int GLuint;
|
||||
using namespace irr;
|
||||
class ParticleSystemProxy;
|
||||
|
||||
@ -36,22 +36,22 @@ namespace MeshShader
|
||||
class ObjectPass1Shader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal;
|
||||
static GLuint uniform_MVP, uniform_TIMV;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal;
|
||||
static GLuint uniform_MVP, uniform_TIMV;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView);
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView);
|
||||
};
|
||||
|
||||
class ObjectRefPass1Shader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TM, uniform_TIMV, uniform_tex;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TM, uniform_TIMV, uniform_tex;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix, unsigned TU_texture);
|
||||
};
|
||||
|
||||
@ -80,108 +80,108 @@ public:
|
||||
class ObjectPass2Shader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint TU_Albedo;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
||||
};
|
||||
|
||||
class DetailledObjectPass2Shader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
||||
static GLuint TU_Albedo, TU_detail;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||
};
|
||||
|
||||
class ObjectRimLimitShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TIMV, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TIMV, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint TU_Albedo;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix);
|
||||
};
|
||||
|
||||
class UntexturedObjectShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_color;
|
||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_color;
|
||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||
};
|
||||
|
||||
class ObjectUnlitShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_MVP;
|
||||
static GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||
};
|
||||
|
||||
class ObjectRefPass2Shader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint TU_Albedo;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
||||
};
|
||||
|
||||
class GrassPass2Shader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient, uniform_windDir;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient, uniform_windDir;
|
||||
static GLuint TU_Albedo;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection);
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection);
|
||||
};
|
||||
|
||||
class SphereMapShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal;
|
||||
static GLuint uniform_MVP, uniform_TIMV, uniform_TVM, uniform_invproj, uniform_screen;
|
||||
static GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeViewMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &InvProj, const core::vector2df& screen);
|
||||
};
|
||||
|
||||
class SplattingShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
||||
static GLuint TU_tex_layout, TU_tex_detail0, TU_tex_detail1, TU_tex_detail2, TU_tex_detail3;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||
};
|
||||
|
||||
class CausticsShader
|
||||
@ -199,22 +199,22 @@ public:
|
||||
class BubbleShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_tex, uniform_time, uniform_transparency;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex, float time, float transparency);
|
||||
};
|
||||
|
||||
class TransparentShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
||||
static GLuint uniform_MVP, uniform_TM, uniform_tex;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
||||
static GLuint uniform_MVP, uniform_TM, uniform_tex;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex);
|
||||
};
|
||||
|
||||
@ -232,24 +232,24 @@ public:
|
||||
class BillboardShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_corner, attrib_texcoord;
|
||||
static GLuint uniform_MV, uniform_P, uniform_tex, uniform_Position, uniform_Size;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_corner, attrib_texcoord;
|
||||
static GLuint uniform_MV, uniform_P, uniform_tex, uniform_Position, uniform_Size;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewMatrix, const core::matrix4 &ProjectionMatrix, const core::vector3df &Position, const core::dimension2d<float> &size, unsigned TU_tex);
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewMatrix, const core::matrix4 &ProjectionMatrix, const core::vector3df &Position, const core::dimension2d<float> &size, unsigned TU_tex);
|
||||
};
|
||||
|
||||
|
||||
class ColorizeShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position;
|
||||
static GLuint uniform_MVP, uniform_col;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position;
|
||||
static GLuint uniform_MVP, uniform_col;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, float r, float g, float b);
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, float r, float g, float b);
|
||||
};
|
||||
|
||||
class ShadowShader
|
||||
@ -299,11 +299,11 @@ public:
|
||||
class DisplaceShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||
static GLuint uniform_MVP, uniform_MV, uniform_displacement_tex, uniform_mask_tex, uniform_color_tex, uniform_screen, uniform_dir, uniform_dir2;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ModelViewMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex);
|
||||
};
|
||||
|
||||
@ -359,11 +359,11 @@ namespace ParticleShader
|
||||
class SimpleSimulationShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size;
|
||||
static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size;
|
||||
static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
};
|
||||
|
||||
|
||||
@ -371,23 +371,23 @@ public:
|
||||
class HeightmapSimulationShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size;
|
||||
static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor;
|
||||
static GLuint uniform_track_x, uniform_track_z, uniform_track_x_len, uniform_track_z_len, uniform_heightmap;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size;
|
||||
static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor;
|
||||
static GLuint uniform_track_x, uniform_track_z, uniform_track_x_len, uniform_track_z_len, uniform_heightmap;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
};
|
||||
|
||||
class SimpleParticleRender
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz;
|
||||
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj, uniform_color_from, uniform_color_to;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz;
|
||||
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj, uniform_color_from, uniform_color_to;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix,
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix,
|
||||
const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex,
|
||||
unsigned TU_normal_and_depth, const ParticleSystemProxy* particle_system);
|
||||
};
|
||||
@ -395,12 +395,12 @@ public:
|
||||
class FlipParticleRender
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz, attrib_rotationvec, attrib_anglespeed;
|
||||
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz, attrib_rotationvec, attrib_anglespeed;
|
||||
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth);
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth);
|
||||
};
|
||||
}
|
||||
|
||||
@ -410,42 +410,42 @@ namespace FullScreenShader
|
||||
class BloomShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_texture, uniform_low;
|
||||
static GLuint vao;
|
||||
static GLuint Program;
|
||||
static GLuint uniform_texture, uniform_low;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
};
|
||||
|
||||
class BloomBlendShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_texture, uniform_low;
|
||||
static GLuint vao;
|
||||
static GLuint Program;
|
||||
static GLuint uniform_texture, uniform_low;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
};
|
||||
|
||||
class ColorLevelShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_invprojm, uniform_dtex, uniform_inlevel, uniform_outlevel;
|
||||
static GLuint vao;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
};
|
||||
|
||||
class SunLightShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_direction, uniform_col, uniform_invproj;
|
||||
static GLuint vao;
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_direction, uniform_col, uniform_invproj;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex);
|
||||
static void init();
|
||||
static void setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex);
|
||||
};
|
||||
|
||||
class DiffuseEnvMapShader
|
||||
@ -473,41 +473,41 @@ public:
|
||||
class Gaussian6HBlurShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_pixel;
|
||||
static GLuint vao;
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_pixel;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
};
|
||||
|
||||
class Gaussian3HBlurShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_pixel;
|
||||
static GLuint vao;
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_pixel;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
};
|
||||
|
||||
class Gaussian6VBlurShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_pixel;
|
||||
static GLuint vao;
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_pixel;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
};
|
||||
|
||||
class Gaussian3VBlurShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_pixel;
|
||||
static GLuint vao;
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_pixel;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
};
|
||||
|
||||
class PenumbraHShader
|
||||
@ -546,44 +546,44 @@ public:
|
||||
class PassThroughShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_texture;
|
||||
static GLuint vao;
|
||||
static GLuint Program;
|
||||
static GLuint uniform_texture;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
};
|
||||
|
||||
class GlowShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex;
|
||||
static GLuint vao;
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void init();
|
||||
};
|
||||
|
||||
class SSAOShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_noise_texture, uniform_invprojm, uniform_projm, uniform_samplePoints;
|
||||
static GLuint vao;
|
||||
static float SSAOSamples[64];
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_noise_texture, uniform_invprojm, uniform_projm, uniform_samplePoints;
|
||||
static GLuint vao;
|
||||
static float SSAOSamples[64];
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4& projm, const core::matrix4 &invprojm, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_noise);
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4& projm, const core::matrix4 &invprojm, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_noise);
|
||||
};
|
||||
|
||||
class FogShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col, uniform_ipvmat;
|
||||
static GLuint vao;
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col, uniform_ipvmat;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, unsigned TU_ntex);
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, unsigned TU_ntex);
|
||||
};
|
||||
|
||||
class MotionBlurShader
|
||||
@ -626,13 +626,13 @@ namespace UIShader
|
||||
class TextureRectShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize;
|
||||
static GLuint vao;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex);
|
||||
static void init();
|
||||
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex);
|
||||
};
|
||||
|
||||
class UniformColoredTextureRectShader
|
||||
@ -650,26 +650,26 @@ public:
|
||||
class ColoredTextureRectShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
||||
static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize;
|
||||
static GLuint colorvbo;
|
||||
static GLuint vao;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
||||
static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize;
|
||||
static GLuint colorvbo;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex);
|
||||
static void init();
|
||||
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex);
|
||||
};
|
||||
|
||||
class ColoredRectShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position;
|
||||
static GLuint uniform_center, uniform_size, uniform_color;
|
||||
static GLuint vao;
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position;
|
||||
static GLuint uniform_center, uniform_size, uniform_color;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, const video::SColor &color);
|
||||
static void init();
|
||||
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, const video::SColor &color);
|
||||
};
|
||||
}
|
||||
|
||||
@ -690,7 +690,7 @@ public:
|
||||
ACT(ES_GAUSSIAN3V) \
|
||||
ACT(ES_MIPVIZ) \
|
||||
ACT(ES_COLORIZE) \
|
||||
ACT(ES_OBJECT_UNLIT) \
|
||||
ACT(ES_OBJECT_UNLIT) \
|
||||
ACT(ES_OBJECTPASS) \
|
||||
ACT(ES_OBJECTPASS_REF) \
|
||||
ACT(ES_SUNLIGHT) \
|
||||
|
@ -16,7 +16,7 @@ const core::vector3df& rotation,
|
||||
const core::vector3df& scale) :
|
||||
CAnimatedMeshSceneNode(mesh, parent, mgr, id, position, rotation, scale)
|
||||
{
|
||||
firstTime = true;
|
||||
firstTime = true;
|
||||
}
|
||||
|
||||
void STKAnimatedMesh::cleanGLMeshes()
|
||||
@ -45,13 +45,13 @@ void STKAnimatedMesh::cleanGLMeshes()
|
||||
|
||||
void STKAnimatedMesh::setMesh(scene::IAnimatedMesh* mesh)
|
||||
{
|
||||
firstTime = true;
|
||||
GLmeshes.clear();
|
||||
firstTime = true;
|
||||
GLmeshes.clear();
|
||||
for (unsigned i = 0; i < FPSM_COUNT; i++)
|
||||
GeometricMesh[i].clear();
|
||||
for (unsigned i = 0; i < SM_COUNT; i++)
|
||||
ShadedMesh[i].clear();
|
||||
CAnimatedMeshSceneNode::setMesh(mesh);
|
||||
CAnimatedMeshSceneNode::setMesh(mesh);
|
||||
}
|
||||
|
||||
void STKAnimatedMesh::drawSolidPass1(const GLMesh &mesh, GeometricMaterial type)
|
||||
@ -97,26 +97,26 @@ void STKAnimatedMesh::drawSolidPass2(const GLMesh &mesh, ShadedMaterial type)
|
||||
|
||||
void STKAnimatedMesh::render()
|
||||
{
|
||||
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
||||
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
||||
|
||||
bool isTransparentPass =
|
||||
SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT;
|
||||
bool isTransparentPass =
|
||||
SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT;
|
||||
|
||||
++PassCount;
|
||||
++PassCount;
|
||||
|
||||
scene::IMesh* m = getMeshForCurrentFrame();
|
||||
scene::IMesh* m = getMeshForCurrentFrame();
|
||||
|
||||
if (m)
|
||||
{
|
||||
Box = m->getBoundingBox();
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::error("animated mesh", "Animated Mesh returned no mesh to render.");
|
||||
return;
|
||||
}
|
||||
if (m)
|
||||
{
|
||||
Box = m->getBoundingBox();
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::error("animated mesh", "Animated Mesh returned no mesh to render.");
|
||||
return;
|
||||
}
|
||||
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
|
||||
if (firstTime)
|
||||
{
|
||||
@ -157,7 +157,7 @@ void STKAnimatedMesh::render()
|
||||
}
|
||||
}
|
||||
}
|
||||
firstTime = false;
|
||||
firstTime = false;
|
||||
|
||||
for (u32 i = 0; i<m->getMeshBufferCount(); ++i)
|
||||
{
|
||||
|
@ -10,11 +10,11 @@
|
||||
class STKAnimatedMesh : public irr::scene::CAnimatedMeshSceneNode
|
||||
{
|
||||
protected:
|
||||
bool firstTime;
|
||||
bool firstTime;
|
||||
std::vector<GLMesh *> GeometricMesh[FPSM_COUNT];
|
||||
std::vector<GLMesh *> ShadedMesh[SM_COUNT];
|
||||
std::vector<GLMesh *> TransparentMesh[TM_COUNT];
|
||||
std::vector<GLMesh> GLmeshes;
|
||||
std::vector<GLMesh> GLmeshes;
|
||||
core::matrix4 ModelViewProjectionMatrix, TransposeInverseModelView;
|
||||
void drawSolidPass1(const GLMesh &mesh, GeometricMaterial type);
|
||||
void drawSolidPass2(const GLMesh &mesh, ShadedMaterial type);
|
||||
|
@ -9,36 +9,36 @@ static GLuint billboardvao = 0;
|
||||
|
||||
static void createbillboardvao()
|
||||
{
|
||||
glGenVertexArrays(1, &billboardvao);
|
||||
glBindVertexArray(billboardvao);
|
||||
glGenVertexArrays(1, &billboardvao);
|
||||
glBindVertexArray(billboardvao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, SharedObject::billboardvbo);
|
||||
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_corner);
|
||||
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_texcoord);
|
||||
glVertexAttribPointer(MeshShader::BillboardShader::attrib_corner, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||
glVertexAttribPointer(MeshShader::BillboardShader::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*) (2 * sizeof(float)));
|
||||
glBindVertexArray(0);
|
||||
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_corner);
|
||||
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_texcoord);
|
||||
glVertexAttribPointer(MeshShader::BillboardShader::attrib_corner, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||
glVertexAttribPointer(MeshShader::BillboardShader::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*) (2 * sizeof(float)));
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
STKBillboard::STKBillboard(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||
const irr::core::vector3df& position, const irr::core::dimension2d<irr::f32>& size,
|
||||
irr::video::SColor colorTop, irr::video::SColor colorBottom) :
|
||||
CBillboardSceneNode(parent, mgr, id, position, size, colorTop, colorBottom), IBillboardSceneNode(parent, mgr, id, position)
|
||||
const irr::core::vector3df& position, const irr::core::dimension2d<irr::f32>& size,
|
||||
irr::video::SColor colorTop, irr::video::SColor colorBottom) :
|
||||
CBillboardSceneNode(parent, mgr, id, position, size, colorTop, colorBottom), IBillboardSceneNode(parent, mgr, id, position)
|
||||
{
|
||||
if (!billboardvao)
|
||||
createbillboardvao();
|
||||
if (!billboardvao)
|
||||
createbillboardvao();
|
||||
}
|
||||
|
||||
void STKBillboard::render()
|
||||
{
|
||||
if (irr_driver->getPhase() != TRANSPARENT_PASS)
|
||||
return;
|
||||
core::vector3df pos = getAbsolutePosition();
|
||||
glBindVertexArray(billboardvao);
|
||||
core::vector3df pos = getAbsolutePosition();
|
||||
glBindVertexArray(billboardvao);
|
||||
GLuint texid = getTextureGLuint(Material.getTexture(0));
|
||||
setTexture(0, texid, GL_LINEAR, GL_LINEAR);
|
||||
glUseProgram(MeshShader::BillboardShader::Program);
|
||||
MeshShader::BillboardShader::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), pos, Size, 0);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
return;
|
||||
setTexture(0, texid, GL_LINEAR, GL_LINEAR);
|
||||
glUseProgram(MeshShader::BillboardShader::Program);
|
||||
MeshShader::BillboardShader::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), pos, Size, 0);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
return;
|
||||
}
|
||||
|
@ -8,12 +8,12 @@
|
||||
class STKBillboard : public irr::scene::CBillboardSceneNode
|
||||
{
|
||||
public:
|
||||
STKBillboard(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||
const irr::core::vector3df& position, const irr::core::dimension2d<irr::f32>& size,
|
||||
irr::video::SColor colorTop = irr::video::SColor(0xFFFFFFFF),
|
||||
irr::video::SColor colorBottom = irr::video::SColor(0xFFFFFFFF));
|
||||
STKBillboard(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||
const irr::core::vector3df& position, const irr::core::dimension2d<irr::f32>& size,
|
||||
irr::video::SColor colorTop = irr::video::SColor(0xFFFFFFFF),
|
||||
irr::video::SColor colorBottom = irr::video::SColor(0xFFFFFFFF));
|
||||
|
||||
virtual void render();
|
||||
virtual void render();
|
||||
};
|
||||
|
||||
#endif
|
@ -57,153 +57,153 @@ GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_t
|
||||
{
|
||||
if (attrib_position == -1)
|
||||
return 0;
|
||||
GLuint vao;
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
glEnableVertexAttribArray(attrib_position);
|
||||
if ((GLint)attrib_texcoord != -1)
|
||||
glEnableVertexAttribArray(attrib_texcoord);
|
||||
if ((GLint)attrib_second_texcoord != -1)
|
||||
glEnableVertexAttribArray(attrib_second_texcoord);
|
||||
if ((GLint)attrib_normal != -1)
|
||||
glEnableVertexAttribArray(attrib_normal);
|
||||
if ((GLint)attrib_tangent != -1)
|
||||
glEnableVertexAttribArray(attrib_tangent);
|
||||
if ((GLint)attrib_bitangent != -1)
|
||||
glEnableVertexAttribArray(attrib_bitangent);
|
||||
if ((GLint)attrib_color != -1)
|
||||
glEnableVertexAttribArray(attrib_color);
|
||||
glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, stride, 0);
|
||||
if ((GLint)attrib_texcoord != -1)
|
||||
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 28);
|
||||
if ((GLint)attrib_second_texcoord != -1)
|
||||
{
|
||||
if (stride < 44)
|
||||
Log::error("material", "Second texcoords not present in VBO");
|
||||
glVertexAttribPointer(attrib_second_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 36);
|
||||
}
|
||||
if ((GLint)attrib_normal != -1)
|
||||
glVertexAttribPointer(attrib_normal, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 12);
|
||||
if ((GLint)attrib_tangent != -1)
|
||||
{
|
||||
if (stride < 48)
|
||||
Log::error("material", "Tangents not present in VBO");
|
||||
glVertexAttribPointer(attrib_tangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)36);
|
||||
}
|
||||
GLuint vao;
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
glEnableVertexAttribArray(attrib_position);
|
||||
if ((GLint)attrib_texcoord != -1)
|
||||
glEnableVertexAttribArray(attrib_texcoord);
|
||||
if ((GLint)attrib_second_texcoord != -1)
|
||||
glEnableVertexAttribArray(attrib_second_texcoord);
|
||||
if ((GLint)attrib_normal != -1)
|
||||
glEnableVertexAttribArray(attrib_normal);
|
||||
if ((GLint)attrib_tangent != -1)
|
||||
glEnableVertexAttribArray(attrib_tangent);
|
||||
if ((GLint)attrib_bitangent != -1)
|
||||
glEnableVertexAttribArray(attrib_bitangent);
|
||||
if ((GLint)attrib_color != -1)
|
||||
glEnableVertexAttribArray(attrib_color);
|
||||
glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, stride, 0);
|
||||
if ((GLint)attrib_texcoord != -1)
|
||||
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 28);
|
||||
if ((GLint)attrib_second_texcoord != -1)
|
||||
{
|
||||
if (stride < 44)
|
||||
Log::error("material", "Second texcoords not present in VBO");
|
||||
glVertexAttribPointer(attrib_second_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 36);
|
||||
}
|
||||
if ((GLint)attrib_normal != -1)
|
||||
glVertexAttribPointer(attrib_normal, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 12);
|
||||
if ((GLint)attrib_tangent != -1)
|
||||
{
|
||||
if (stride < 48)
|
||||
Log::error("material", "Tangents not present in VBO");
|
||||
glVertexAttribPointer(attrib_tangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)36);
|
||||
}
|
||||
|
||||
if ((GLint)attrib_bitangent != -1)
|
||||
{
|
||||
if (stride < 60)
|
||||
Log::error("material", "Bitangents not present in VBO");
|
||||
glVertexAttribPointer(attrib_bitangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)48);
|
||||
}
|
||||
if ((GLint)attrib_color != -1)
|
||||
glVertexAttribPointer(attrib_color, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, (GLvoid*)24);
|
||||
if ((GLint)attrib_bitangent != -1)
|
||||
{
|
||||
if (stride < 60)
|
||||
Log::error("material", "Bitangents not present in VBO");
|
||||
glVertexAttribPointer(attrib_bitangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)48);
|
||||
}
|
||||
if ((GLint)attrib_color != -1)
|
||||
glVertexAttribPointer(attrib_color, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, (GLvoid*)24);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, idx);
|
||||
glBindVertexArray(0);
|
||||
return vao;
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, idx);
|
||||
glBindVertexArray(0);
|
||||
return vao;
|
||||
}
|
||||
|
||||
GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb)
|
||||
{
|
||||
GLMesh result = {};
|
||||
if (!mb)
|
||||
return result;
|
||||
glBindVertexArray(0);
|
||||
glGenBuffers(1, &(result.vertex_buffer));
|
||||
glGenBuffers(1, &(result.index_buffer));
|
||||
GLMesh result = {};
|
||||
if (!mb)
|
||||
return result;
|
||||
glBindVertexArray(0);
|
||||
glGenBuffers(1, &(result.vertex_buffer));
|
||||
glGenBuffers(1, &(result.index_buffer));
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, result.vertex_buffer);
|
||||
const void* vertices = mb->getVertices();
|
||||
const u32 vertexCount = mb->getVertexCount();
|
||||
const irr::video::E_VERTEX_TYPE vType = mb->getVertexType();
|
||||
result.Stride = getVertexPitchFromType(vType);
|
||||
const c8* vbuf = static_cast<const c8*>(vertices);
|
||||
glBufferData(GL_ARRAY_BUFFER, vertexCount * result.Stride, vbuf, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, result.vertex_buffer);
|
||||
const void* vertices = mb->getVertices();
|
||||
const u32 vertexCount = mb->getVertexCount();
|
||||
const irr::video::E_VERTEX_TYPE vType = mb->getVertexType();
|
||||
result.Stride = getVertexPitchFromType(vType);
|
||||
const c8* vbuf = static_cast<const c8*>(vertices);
|
||||
glBufferData(GL_ARRAY_BUFFER, vertexCount * result.Stride, vbuf, GL_STATIC_DRAW);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, result.index_buffer);
|
||||
const void* indices = mb->getIndices();
|
||||
u32 indexCount = mb->getIndexCount();
|
||||
GLenum indexSize;
|
||||
switch (mb->getIndexType())
|
||||
{
|
||||
case irr::video::EIT_16BIT:
|
||||
{
|
||||
indexSize = sizeof(u16);
|
||||
result.IndexType = GL_UNSIGNED_SHORT;
|
||||
break;
|
||||
}
|
||||
case irr::video::EIT_32BIT:
|
||||
{
|
||||
indexSize = sizeof(u32);
|
||||
result.IndexType = GL_UNSIGNED_INT;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
assert(0 && "Wrong index size");
|
||||
}
|
||||
}
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, result.index_buffer);
|
||||
const void* indices = mb->getIndices();
|
||||
u32 indexCount = mb->getIndexCount();
|
||||
GLenum indexSize;
|
||||
switch (mb->getIndexType())
|
||||
{
|
||||
case irr::video::EIT_16BIT:
|
||||
{
|
||||
indexSize = sizeof(u16);
|
||||
result.IndexType = GL_UNSIGNED_SHORT;
|
||||
break;
|
||||
}
|
||||
case irr::video::EIT_32BIT:
|
||||
{
|
||||
indexSize = sizeof(u32);
|
||||
result.IndexType = GL_UNSIGNED_INT;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
assert(0 && "Wrong index size");
|
||||
}
|
||||
}
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_STATIC_DRAW);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
|
||||
result.IndexCount = mb->getIndexCount();
|
||||
switch (mb->getPrimitiveType())
|
||||
{
|
||||
case scene::EPT_POINTS:
|
||||
result.PrimitiveType = GL_POINTS;
|
||||
break;
|
||||
case scene::EPT_TRIANGLE_STRIP:
|
||||
result.PrimitiveType = GL_TRIANGLE_STRIP;
|
||||
break;
|
||||
case scene::EPT_TRIANGLE_FAN:
|
||||
result.PrimitiveType = GL_TRIANGLE_FAN;
|
||||
break;
|
||||
case scene::EPT_LINES:
|
||||
result.PrimitiveType = GL_LINES;
|
||||
result.IndexCount = mb->getIndexCount();
|
||||
switch (mb->getPrimitiveType())
|
||||
{
|
||||
case scene::EPT_POINTS:
|
||||
result.PrimitiveType = GL_POINTS;
|
||||
break;
|
||||
case scene::EPT_TRIANGLES:
|
||||
result.PrimitiveType = GL_TRIANGLES;
|
||||
break;
|
||||
case scene::EPT_POINT_SPRITES:
|
||||
case scene::EPT_LINE_LOOP:
|
||||
case scene::EPT_POLYGON:
|
||||
case scene::EPT_LINE_STRIP:
|
||||
case scene::EPT_QUAD_STRIP:
|
||||
case scene::EPT_QUADS:
|
||||
assert(0 && "Unsupported primitive type");
|
||||
}
|
||||
ITexture *tex;
|
||||
for (unsigned i = 0; i < 6; i++)
|
||||
{
|
||||
tex = mb->getMaterial().getTexture(i);
|
||||
if (tex)
|
||||
result.textures[i] = getTextureGLuint(tex);
|
||||
else
|
||||
result.textures[i] = 0;
|
||||
}
|
||||
case scene::EPT_TRIANGLE_STRIP:
|
||||
result.PrimitiveType = GL_TRIANGLE_STRIP;
|
||||
break;
|
||||
case scene::EPT_TRIANGLE_FAN:
|
||||
result.PrimitiveType = GL_TRIANGLE_FAN;
|
||||
break;
|
||||
case scene::EPT_LINES:
|
||||
result.PrimitiveType = GL_LINES;
|
||||
break;
|
||||
case scene::EPT_TRIANGLES:
|
||||
result.PrimitiveType = GL_TRIANGLES;
|
||||
break;
|
||||
case scene::EPT_POINT_SPRITES:
|
||||
case scene::EPT_LINE_LOOP:
|
||||
case scene::EPT_POLYGON:
|
||||
case scene::EPT_LINE_STRIP:
|
||||
case scene::EPT_QUAD_STRIP:
|
||||
case scene::EPT_QUADS:
|
||||
assert(0 && "Unsupported primitive type");
|
||||
}
|
||||
ITexture *tex;
|
||||
for (unsigned i = 0; i < 6; i++)
|
||||
{
|
||||
tex = mb->getMaterial().getTexture(i);
|
||||
if (tex)
|
||||
result.textures[i] = getTextureGLuint(tex);
|
||||
else
|
||||
result.textures[i] = 0;
|
||||
}
|
||||
result.TextureMatrix = 0;
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void computeMVP(core::matrix4 &ModelViewProjectionMatrix)
|
||||
{
|
||||
ModelViewProjectionMatrix = irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION);
|
||||
ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
|
||||
ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
|
||||
ModelViewProjectionMatrix = irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION);
|
||||
ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
|
||||
ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
|
||||
}
|
||||
|
||||
void computeTIMV(core::matrix4 &TransposeInverseModelView)
|
||||
{
|
||||
TransposeInverseModelView = irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
|
||||
TransposeInverseModelView *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
|
||||
TransposeInverseModelView.makeInverse();
|
||||
TransposeInverseModelView = TransposeInverseModelView.getTransposed();
|
||||
TransposeInverseModelView = irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
|
||||
TransposeInverseModelView *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
|
||||
TransposeInverseModelView.makeInverse();
|
||||
TransposeInverseModelView = TransposeInverseModelView.getTransposed();
|
||||
}
|
||||
|
||||
void drawObjectPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
||||
@ -240,34 +240,34 @@ void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProje
|
||||
void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, core::vector3df windDir)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
|
||||
MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, windDir, 0);
|
||||
MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, windDir, 0);
|
||||
|
||||
assert(mesh.vao_first_pass);
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
assert(mesh.textures[1]);
|
||||
setTexture(0, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
assert(mesh.textures[1]);
|
||||
setTexture(0, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
|
||||
MeshShader::NormalMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0);
|
||||
MeshShader::NormalMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0);
|
||||
|
||||
assert(mesh.vao_first_pass);
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
||||
@ -437,27 +437,27 @@ void drawCaustics(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionM
|
||||
void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, core::vector3df windDir)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
setTexture(MeshShader::GrassPass2Shader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
if (irr_driver->getLightViz())
|
||||
{
|
||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLint swizzleMask[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA};
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
if (irr_driver->getLightViz())
|
||||
{
|
||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLint swizzleMask[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA};
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
|
||||
MeshShader::GrassPass2Shader::setUniforms(ModelViewProjectionMatrix, windDir);
|
||||
|
||||
assert(mesh.vao_second_pass);
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
||||
@ -477,53 +477,53 @@ void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProj
|
||||
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
setTexture(MeshShader::ObjectRimLimitShader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
if (irr_driver->getLightViz())
|
||||
{
|
||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
if (irr_driver->getLightViz())
|
||||
{
|
||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
|
||||
MeshShader::ObjectRimLimitShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
|
||||
|
||||
assert(mesh.vao_second_pass);
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
setTexture(MeshShader::ObjectUnlitShader::TU_tex, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
if (irr_driver->getLightViz())
|
||||
{
|
||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
if (irr_driver->getLightViz())
|
||||
{
|
||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
|
||||
MeshShader::ObjectUnlitShader::setUniforms(ModelViewProjectionMatrix);
|
||||
|
||||
assert(mesh.vao_second_pass);
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
||||
@ -557,43 +557,43 @@ void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelView
|
||||
void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
setTexture(MeshShader::ObjectPass2Shader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
if (irr_driver->getLightViz())
|
||||
{
|
||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
if (irr_driver->getLightViz())
|
||||
{
|
||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
}
|
||||
|
||||
MeshShader::ObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, TextureMatrix);
|
||||
|
||||
assert(mesh.vao_second_pass);
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
|
||||
MeshShader::TransparentShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, 0);
|
||||
|
||||
assert(mesh.vao_first_pass);
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
||||
@ -630,20 +630,20 @@ void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelView
|
||||
void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
||||
float transparency = 1.;
|
||||
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
||||
float transparency = 1.;
|
||||
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
|
||||
MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency);
|
||||
MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency);
|
||||
|
||||
assert(mesh.vao_first_pass);
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void drawShadowRef(const GLMesh &mesh)
|
||||
@ -692,41 +692,41 @@ void drawShadow(const GLMesh &mesh)
|
||||
|
||||
bool isObject(video::E_MATERIAL_TYPE type)
|
||||
{
|
||||
if (type == irr_driver->getShader(ES_OBJECTPASS))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_NORMAL_MAP))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_SPHERE_MAP))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_SPLATTING))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_GRASS))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_GRASS_REF))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_BUBBLES))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_OBJECTPASS))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_NORMAL_MAP))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_SPHERE_MAP))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_SPLATTING))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_GRASS))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_GRASS_REF))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_BUBBLES))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_CAUSTICS))
|
||||
return true;
|
||||
if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL)
|
||||
return true;
|
||||
if (type == video::EMT_ONETEXTURE_BLEND)
|
||||
return true;
|
||||
if (type == video::EMT_TRANSPARENT_ADD_COLOR)
|
||||
return true;
|
||||
if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL)
|
||||
return true;
|
||||
if (type == video::EMT_ONETEXTURE_BLEND)
|
||||
return true;
|
||||
if (type == video::EMT_TRANSPARENT_ADD_COLOR)
|
||||
return true;
|
||||
if (type == video::EMT_SOLID)
|
||||
return true;
|
||||
if (type == video::EMT_LIGHTMAP_LIGHTING)
|
||||
return true;
|
||||
if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
|
||||
return true;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void initvaostate(GLMesh &mesh, GeometricMaterial GeoMat, ShadedMaterial ShadedMat)
|
||||
|
@ -40,19 +40,19 @@ enum TransparentMaterial
|
||||
};
|
||||
|
||||
struct GLMesh {
|
||||
GLuint vao_first_pass;
|
||||
GLuint vao_second_pass;
|
||||
GLuint vao_glow_pass;
|
||||
GLuint vao_displace_pass;
|
||||
GLuint vao_first_pass;
|
||||
GLuint vao_second_pass;
|
||||
GLuint vao_glow_pass;
|
||||
GLuint vao_displace_pass;
|
||||
GLuint vao_displace_mask_pass;
|
||||
GLuint vao_shadow_pass;
|
||||
GLuint vertex_buffer;
|
||||
GLuint index_buffer;
|
||||
GLuint textures[6];
|
||||
GLenum PrimitiveType;
|
||||
GLenum IndexType;
|
||||
size_t IndexCount;
|
||||
size_t Stride;
|
||||
GLuint vertex_buffer;
|
||||
GLuint index_buffer;
|
||||
GLuint textures[6];
|
||||
GLenum PrimitiveType;
|
||||
GLenum IndexType;
|
||||
size_t IndexCount;
|
||||
size_t Stride;
|
||||
core::matrix4 TextureMatrix;
|
||||
};
|
||||
|
||||
|
@ -24,14 +24,14 @@ using core::vector3df;
|
||||
class Wind
|
||||
{
|
||||
public:
|
||||
Wind();
|
||||
Wind();
|
||||
|
||||
vector3df getWind() const;
|
||||
void update();
|
||||
vector3df getWind() const;
|
||||
void update();
|
||||
|
||||
private:
|
||||
vector3df m_wind;
|
||||
float m_seed;
|
||||
vector3df m_wind;
|
||||
float m_seed;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -2097,7 +2097,7 @@ void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor,
|
||||
core::recti innerArea = borderArea;
|
||||
innerArea.UpperLeftCorner += position2d< s32 >( 3, 3 );
|
||||
innerArea.LowerRightCorner -= position2d< s32 >( 3, 3 );
|
||||
GL32_draw2DRectangle(focused ? bg_color_focused : bg_color, innerArea);
|
||||
GL32_draw2DRectangle(focused ? bg_color_focused : bg_color, innerArea);
|
||||
return;
|
||||
}
|
||||
else if (type == WTYPE_LIST)
|
||||
@ -2161,7 +2161,7 @@ void Skin::drawBGFadeColor()
|
||||
SColor color = SkinConfig::m_colors["dialog_background::neutral"];
|
||||
if (m_dialog_size < 1.0f)
|
||||
color.setAlpha( (unsigned int)(color.getAlpha()*m_dialog_size ));
|
||||
GL32_draw2DRectangle(color,
|
||||
GL32_draw2DRectangle(color,
|
||||
core::recti(position2d< s32 >(0,0),
|
||||
GUIEngine::getDriver()->getCurrentRenderTargetSize()) );
|
||||
} // drawBGFadeColor
|
||||
@ -2211,7 +2211,7 @@ void Skin::draw3DMenuPane (IGUIElement *element, const core::recti &rect,
|
||||
const core::recti *clip)
|
||||
{
|
||||
SColor color = SColor(150, 96, 74, 196);
|
||||
GL32_draw2DRectangle(color, rect);
|
||||
GL32_draw2DRectangle(color, rect);
|
||||
} // draw3DMenuPane
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -16,155 +16,155 @@
|
||||
using namespace irr;
|
||||
using namespace gui;
|
||||
|
||||
class CGUIEditBox : public IGUIEditBox
|
||||
{
|
||||
public:
|
||||
class CGUIEditBox : public IGUIEditBox
|
||||
{
|
||||
public:
|
||||
|
||||
LEAK_CHECK()
|
||||
|
||||
//! constructor
|
||||
CGUIEditBox(const wchar_t* text, bool border, IGUIEnvironment* environment,
|
||||
IGUIElement* parent, s32 id, const core::rect<s32>& rectangle, bool is_rtl);
|
||||
//! constructor
|
||||
CGUIEditBox(const wchar_t* text, bool border, IGUIEnvironment* environment,
|
||||
IGUIElement* parent, s32 id, const core::rect<s32>& rectangle, bool is_rtl);
|
||||
|
||||
//! destructor
|
||||
virtual ~CGUIEditBox();
|
||||
//! destructor
|
||||
virtual ~CGUIEditBox();
|
||||
|
||||
//! Sets another skin independent font.
|
||||
virtual void setOverrideFont(IGUIFont* font=0);
|
||||
//! Sets another skin independent font.
|
||||
virtual void setOverrideFont(IGUIFont* font=0);
|
||||
|
||||
//! Sets another color for the text.
|
||||
virtual void setOverrideColor(video::SColor color);
|
||||
//! Sets another color for the text.
|
||||
virtual void setOverrideColor(video::SColor color);
|
||||
|
||||
//! Gets the override color
|
||||
virtual video::SColor getOverrideColor() const;
|
||||
//! Gets the override color
|
||||
virtual video::SColor getOverrideColor() const;
|
||||
|
||||
//! Sets if the text should use the overide color or the
|
||||
//! color in the gui skin.
|
||||
virtual void enableOverrideColor(bool enable);
|
||||
//! Sets if the text should use the overide color or the
|
||||
//! color in the gui skin.
|
||||
virtual void enableOverrideColor(bool enable);
|
||||
|
||||
//! Checks if an override color is enabled
|
||||
/** \return true if the override color is enabled, false otherwise */
|
||||
virtual bool isOverrideColorEnabled(void) const;
|
||||
//! Checks if an override color is enabled
|
||||
/** \return true if the override color is enabled, false otherwise */
|
||||
virtual bool isOverrideColorEnabled(void) const;
|
||||
|
||||
//! Turns the border on or off
|
||||
virtual void setDrawBorder(bool border);
|
||||
//! Turns the border on or off
|
||||
virtual void setDrawBorder(bool border);
|
||||
|
||||
//! Enables or disables word wrap for using the edit box as multiline text editor.
|
||||
virtual void setWordWrap(bool enable);
|
||||
//! Enables or disables word wrap for using the edit box as multiline text editor.
|
||||
virtual void setWordWrap(bool enable);
|
||||
|
||||
//! Checks if word wrap is enabled
|
||||
//! \return true if word wrap is enabled, false otherwise
|
||||
virtual bool isWordWrapEnabled() const;
|
||||
//! Checks if word wrap is enabled
|
||||
//! \return true if word wrap is enabled, false otherwise
|
||||
virtual bool isWordWrapEnabled() const;
|
||||
|
||||
//! Enables or disables newlines.
|
||||
/** \param enable: If set to true, the EGET_EDITBOX_ENTER event will not be fired,
|
||||
instead a newline character will be inserted. */
|
||||
virtual void setMultiLine(bool enable);
|
||||
//! Enables or disables newlines.
|
||||
/** \param enable: If set to true, the EGET_EDITBOX_ENTER event will not be fired,
|
||||
instead a newline character will be inserted. */
|
||||
virtual void setMultiLine(bool enable);
|
||||
|
||||
//! Checks if multi line editing is enabled
|
||||
//! \return true if mult-line is enabled, false otherwise
|
||||
virtual bool isMultiLineEnabled() const;
|
||||
//! Checks if multi line editing is enabled
|
||||
//! \return true if mult-line is enabled, false otherwise
|
||||
virtual bool isMultiLineEnabled() const;
|
||||
|
||||
//! Enables or disables automatic scrolling with cursor position
|
||||
//! \param enable: If set to true, the text will move around with the cursor position
|
||||
virtual void setAutoScroll(bool enable);
|
||||
//! Enables or disables automatic scrolling with cursor position
|
||||
//! \param enable: If set to true, the text will move around with the cursor position
|
||||
virtual void setAutoScroll(bool enable);
|
||||
|
||||
//! Checks to see if automatic scrolling is enabled
|
||||
//! \return true if automatic scrolling is enabled, false if not
|
||||
virtual bool isAutoScrollEnabled() const;
|
||||
//! Checks to see if automatic scrolling is enabled
|
||||
//! \return true if automatic scrolling is enabled, false if not
|
||||
virtual bool isAutoScrollEnabled() const;
|
||||
|
||||
//! Gets the size area of the text in the edit box
|
||||
//! \return Returns the size in pixels of the text
|
||||
virtual core::dimension2du getTextDimension();
|
||||
//! Gets the size area of the text in the edit box
|
||||
//! \return Returns the size in pixels of the text
|
||||
virtual core::dimension2du getTextDimension();
|
||||
|
||||
//! Sets text justification
|
||||
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical);
|
||||
//! Sets text justification
|
||||
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical);
|
||||
|
||||
//! called if an event happened.
|
||||
virtual bool OnEvent(const SEvent& event);
|
||||
//! called if an event happened.
|
||||
virtual bool OnEvent(const SEvent& event);
|
||||
|
||||
//! draws the element and its children
|
||||
virtual void draw();
|
||||
//! draws the element and its children
|
||||
virtual void draw();
|
||||
|
||||
//! Sets the new caption of this element.
|
||||
virtual void setText(const wchar_t* text);
|
||||
//! Sets the new caption of this element.
|
||||
virtual void setText(const wchar_t* text);
|
||||
|
||||
//! Sets the maximum amount of characters which may be entered in the box.
|
||||
//! \param max: Maximum amount of characters. If 0, the character amount is
|
||||
//! infinity.
|
||||
virtual void setMax(u32 max);
|
||||
//! Sets the maximum amount of characters which may be entered in the box.
|
||||
//! \param max: Maximum amount of characters. If 0, the character amount is
|
||||
//! infinity.
|
||||
virtual void setMax(u32 max);
|
||||
|
||||
//! Returns maximum amount of characters, previously set by setMax();
|
||||
virtual u32 getMax() const;
|
||||
//! Returns maximum amount of characters, previously set by setMax();
|
||||
virtual u32 getMax() const;
|
||||
|
||||
//! Sets whether the edit box is a password box. Setting this to true will
|
||||
/** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x
|
||||
\param passwordBox: true to enable password, false to disable
|
||||
\param passwordChar: the character that is displayed instead of letters */
|
||||
virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*');
|
||||
//! Sets whether the edit box is a password box. Setting this to true will
|
||||
/** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x
|
||||
\param passwordBox: true to enable password, false to disable
|
||||
\param passwordChar: the character that is displayed instead of letters */
|
||||
virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*');
|
||||
|
||||
//! Returns true if the edit box is currently a password box.
|
||||
virtual bool isPasswordBox() const;
|
||||
//! Returns true if the edit box is currently a password box.
|
||||
virtual bool isPasswordBox() const;
|
||||
|
||||
//! Updates the absolute position, splits text if required
|
||||
virtual void updateAbsolutePosition();
|
||||
//! Updates the absolute position, splits text if required
|
||||
virtual void updateAbsolutePosition();
|
||||
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
|
||||
//! Writes attributes of the element.
|
||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
|
||||
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
|
||||
//! Reads attributes of the element
|
||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
|
||||
|
||||
virtual irr::gui::IGUIFont* getOverrideFont() const { return NULL; }
|
||||
virtual irr::gui::IGUIFont* getActiveFont() const { return NULL; }
|
||||
virtual void setDrawBackground(bool) { }
|
||||
|
||||
protected:
|
||||
//! Breaks the single text line.
|
||||
void breakText();
|
||||
//! sets the area of the given line
|
||||
void setTextRect(s32 line);
|
||||
//! returns the line number that the cursor is on
|
||||
s32 getLineFromPos(s32 pos);
|
||||
//! adds a letter to the edit box
|
||||
void inputChar(wchar_t c);
|
||||
//! calculates the current scroll position
|
||||
void calculateScrollPos();
|
||||
//! send some gui event to parent
|
||||
void sendGuiEvent(EGUI_EVENT_TYPE type);
|
||||
//! set text markers
|
||||
void setTextMarkers(s32 begin, s32 end);
|
||||
protected:
|
||||
//! Breaks the single text line.
|
||||
void breakText();
|
||||
//! sets the area of the given line
|
||||
void setTextRect(s32 line);
|
||||
//! returns the line number that the cursor is on
|
||||
s32 getLineFromPos(s32 pos);
|
||||
//! adds a letter to the edit box
|
||||
void inputChar(wchar_t c);
|
||||
//! calculates the current scroll position
|
||||
void calculateScrollPos();
|
||||
//! send some gui event to parent
|
||||
void sendGuiEvent(EGUI_EVENT_TYPE type);
|
||||
//! set text markers
|
||||
void setTextMarkers(s32 begin, s32 end);
|
||||
|
||||
bool processKey(const SEvent& event);
|
||||
bool processMouse(const SEvent& event);
|
||||
s32 getCursorPos(s32 x, s32 y);
|
||||
bool processKey(const SEvent& event);
|
||||
bool processMouse(const SEvent& event);
|
||||
s32 getCursorPos(s32 x, s32 y);
|
||||
|
||||
bool MouseMarking;
|
||||
bool Border;
|
||||
bool OverrideColorEnabled;
|
||||
s32 MarkBegin;
|
||||
s32 MarkEnd;
|
||||
bool MouseMarking;
|
||||
bool Border;
|
||||
bool OverrideColorEnabled;
|
||||
s32 MarkBegin;
|
||||
s32 MarkEnd;
|
||||
|
||||
video::SColor OverrideColor;
|
||||
gui::IGUIFont *OverrideFont, *LastBreakFont;
|
||||
IOSOperator* Operator;
|
||||
video::SColor OverrideColor;
|
||||
gui::IGUIFont *OverrideFont, *LastBreakFont;
|
||||
IOSOperator* Operator;
|
||||
|
||||
StkTime::TimeType BlinkStartTime;
|
||||
s32 CursorPos;
|
||||
s32 HScrollPos, VScrollPos; // scroll position in characters
|
||||
u32 Max;
|
||||
s32 CursorPos;
|
||||
s32 HScrollPos, VScrollPos; // scroll position in characters
|
||||
u32 Max;
|
||||
|
||||
bool m_rtl;
|
||||
|
||||
bool WordWrap, MultiLine, AutoScroll, PasswordBox;
|
||||
wchar_t PasswordChar;
|
||||
EGUI_ALIGNMENT HAlign, VAlign;
|
||||
bool WordWrap, MultiLine, AutoScroll, PasswordBox;
|
||||
wchar_t PasswordChar;
|
||||
EGUI_ALIGNMENT HAlign, VAlign;
|
||||
|
||||
core::array< core::stringw > BrokenText;
|
||||
core::array< s32 > BrokenTextPositions;
|
||||
core::array< core::stringw > BrokenText;
|
||||
core::array< s32 > BrokenTextPositions;
|
||||
|
||||
core::rect<s32> CurrentTextRect, FrameRect; // temporary values
|
||||
};
|
||||
core::rect<s32> CurrentTextRect, FrameRect; // temporary values
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@ -21,59 +21,59 @@ namespace gui
|
||||
|
||||
//! constructor
|
||||
CGUISTKListBox::CGUISTKListBox(IGUIEnvironment* environment, IGUIElement* parent,
|
||||
s32 id, core::rect<s32> rectangle, bool clip,
|
||||
bool drawBack, bool moveOverSelect)
|
||||
s32 id, core::rect<s32> rectangle, bool clip,
|
||||
bool drawBack, bool moveOverSelect)
|
||||
: IGUIElement(EGUIET_LIST_BOX, environment, parent, id, rectangle), Selected(-1),
|
||||
ItemHeight(0),ItemHeightOverride(0),
|
||||
TotalItemHeight(0), ItemsIconWidth(0), Font(0), IconBank(0),
|
||||
ScrollBar(0), selectTime(0), LastKeyTime(0), Selecting(false), DrawBack(drawBack),
|
||||
MoveOverSelect(moveOverSelect), AutoScroll(true), HighlightWhenNotFocused(true)
|
||||
ItemHeight(0),ItemHeightOverride(0),
|
||||
TotalItemHeight(0), ItemsIconWidth(0), Font(0), IconBank(0),
|
||||
ScrollBar(0), selectTime(0), LastKeyTime(0), Selecting(false), DrawBack(drawBack),
|
||||
MoveOverSelect(moveOverSelect), AutoScroll(true), HighlightWhenNotFocused(true)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CGUISTKListBox");
|
||||
#endif
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CGUISTKListBox");
|
||||
#endif
|
||||
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
const s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE);
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
const s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE);
|
||||
|
||||
ScrollBar = Environment->addScrollBar(false,
|
||||
core::rect<s32>(RelativeRect.getWidth() - s, 0,
|
||||
RelativeRect.getWidth(), RelativeRect.getHeight()), this, -1);
|
||||
ScrollBar->grab();
|
||||
ScrollBar->setSubElement(true);
|
||||
ScrollBar->setTabStop(false);
|
||||
ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
|
||||
ScrollBar->setVisible(false);
|
||||
ScrollBar->setPos(0);
|
||||
ScrollBar->setSubElement(true);
|
||||
ScrollBar->setTabStop(false);
|
||||
ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
|
||||
ScrollBar->setVisible(false);
|
||||
ScrollBar->setPos(0);
|
||||
|
||||
setNotClipped(!clip);
|
||||
setNotClipped(!clip);
|
||||
|
||||
// this element can be tabbed to
|
||||
setTabStop(true);
|
||||
setTabOrder(-1);
|
||||
// this element can be tabbed to
|
||||
setTabStop(true);
|
||||
setTabOrder(-1);
|
||||
|
||||
updateAbsolutePosition();
|
||||
updateAbsolutePosition();
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
CGUISTKListBox::~CGUISTKListBox()
|
||||
{
|
||||
if (ScrollBar)
|
||||
ScrollBar->drop();
|
||||
if (ScrollBar)
|
||||
ScrollBar->drop();
|
||||
|
||||
if (Font)
|
||||
Font->drop();
|
||||
if (Font)
|
||||
Font->drop();
|
||||
|
||||
if (IconBank)
|
||||
IconBank->drop();
|
||||
if (IconBank)
|
||||
IconBank->drop();
|
||||
}
|
||||
|
||||
|
||||
//! returns amount of list items
|
||||
u32 CGUISTKListBox::getItemCount() const
|
||||
{
|
||||
return Items.size();
|
||||
return Items.size();
|
||||
}
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ const wchar_t* CGUISTKListBox::getCellText(u32 row_num, u32 col_num) const
|
||||
return 0;
|
||||
if ( col_num >= Items[row_num].m_contents.size() )
|
||||
return 0;
|
||||
return Items[row_num].m_contents[col_num].m_text.c_str();
|
||||
return Items[row_num].m_contents[col_num].m_text.c_str();
|
||||
}
|
||||
|
||||
CGUISTKListBox::ListItem CGUISTKListBox::getItem(u32 id) const
|
||||
@ -105,109 +105,109 @@ s32 CGUISTKListBox::getIcon(u32 row_num, u32 col_num) const
|
||||
|
||||
void CGUISTKListBox::removeItem(u32 id)
|
||||
{
|
||||
if (id >= Items.size())
|
||||
return;
|
||||
if (id >= Items.size())
|
||||
return;
|
||||
|
||||
if ((u32)Selected==id)
|
||||
{
|
||||
Selected = -1;
|
||||
}
|
||||
else if ((u32)Selected > id)
|
||||
{
|
||||
Selected -= 1;
|
||||
selectTime = (u32)StkTime::getTimeSinceEpoch();
|
||||
}
|
||||
if ((u32)Selected==id)
|
||||
{
|
||||
Selected = -1;
|
||||
}
|
||||
else if ((u32)Selected > id)
|
||||
{
|
||||
Selected -= 1;
|
||||
selectTime = (u32)StkTime::getTimeSinceEpoch();
|
||||
}
|
||||
|
||||
Items.erase(id);
|
||||
Items.erase(id);
|
||||
|
||||
recalculateItemHeight();
|
||||
recalculateItemHeight();
|
||||
}
|
||||
|
||||
|
||||
s32 CGUISTKListBox::getItemAt(s32 xpos, s32 ypos) const
|
||||
{
|
||||
if ( xpos < AbsoluteRect.UpperLeftCorner.X || xpos >= AbsoluteRect.LowerRightCorner.X
|
||||
|| ypos < AbsoluteRect.UpperLeftCorner.Y || ypos >= AbsoluteRect.LowerRightCorner.Y
|
||||
)
|
||||
return -1;
|
||||
if ( xpos < AbsoluteRect.UpperLeftCorner.X || xpos >= AbsoluteRect.LowerRightCorner.X
|
||||
|| ypos < AbsoluteRect.UpperLeftCorner.Y || ypos >= AbsoluteRect.LowerRightCorner.Y
|
||||
)
|
||||
return -1;
|
||||
|
||||
if ( ItemHeight == 0 )
|
||||
return -1;
|
||||
if ( ItemHeight == 0 )
|
||||
return -1;
|
||||
|
||||
s32 item = ((ypos - AbsoluteRect.UpperLeftCorner.Y - 1) + ScrollBar->getPos()) / ItemHeight;
|
||||
if ( item < 0 || item >= (s32)Items.size())
|
||||
return -1;
|
||||
s32 item = ((ypos - AbsoluteRect.UpperLeftCorner.Y - 1) + ScrollBar->getPos()) / ItemHeight;
|
||||
if ( item < 0 || item >= (s32)Items.size())
|
||||
return -1;
|
||||
|
||||
return item;
|
||||
return item;
|
||||
}
|
||||
|
||||
//! clears the list
|
||||
void CGUISTKListBox::clear()
|
||||
{
|
||||
Items.clear();
|
||||
ItemsIconWidth = 0;
|
||||
Selected = -1;
|
||||
Items.clear();
|
||||
ItemsIconWidth = 0;
|
||||
Selected = -1;
|
||||
|
||||
if (ScrollBar)
|
||||
ScrollBar->setPos(0);
|
||||
if (ScrollBar)
|
||||
ScrollBar->setPos(0);
|
||||
|
||||
recalculateItemHeight();
|
||||
recalculateItemHeight();
|
||||
}
|
||||
|
||||
|
||||
void CGUISTKListBox::recalculateItemHeight()
|
||||
{
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
|
||||
if (Font != skin->getFont())
|
||||
{
|
||||
if (Font)
|
||||
Font->drop();
|
||||
if (Font != skin->getFont())
|
||||
{
|
||||
if (Font)
|
||||
Font->drop();
|
||||
|
||||
Font = skin->getFont();
|
||||
if ( 0 == ItemHeightOverride )
|
||||
ItemHeight = 0;
|
||||
Font = skin->getFont();
|
||||
if ( 0 == ItemHeightOverride )
|
||||
ItemHeight = 0;
|
||||
|
||||
if (Font)
|
||||
{
|
||||
if ( 0 == ItemHeightOverride )
|
||||
ItemHeight = Font->getDimension(L"A").Height + 4;
|
||||
if (Font)
|
||||
{
|
||||
if ( 0 == ItemHeightOverride )
|
||||
ItemHeight = Font->getDimension(L"A").Height + 4;
|
||||
|
||||
Font->grab();
|
||||
}
|
||||
}
|
||||
Font->grab();
|
||||
}
|
||||
}
|
||||
|
||||
TotalItemHeight = ItemHeight * Items.size();
|
||||
ScrollBar->setMax( core::max_(0, TotalItemHeight - AbsoluteRect.getHeight()) );
|
||||
s32 minItemHeight = ItemHeight > 0 ? ItemHeight : 1;
|
||||
ScrollBar->setSmallStep ( minItemHeight );
|
||||
ScrollBar->setLargeStep ( 2*minItemHeight );
|
||||
TotalItemHeight = ItemHeight * Items.size();
|
||||
ScrollBar->setMax( core::max_(0, TotalItemHeight - AbsoluteRect.getHeight()) );
|
||||
s32 minItemHeight = ItemHeight > 0 ? ItemHeight : 1;
|
||||
ScrollBar->setSmallStep ( minItemHeight );
|
||||
ScrollBar->setLargeStep ( 2*minItemHeight );
|
||||
|
||||
if ( TotalItemHeight <= AbsoluteRect.getHeight() )
|
||||
ScrollBar->setVisible(false);
|
||||
else
|
||||
ScrollBar->setVisible(true);
|
||||
if ( TotalItemHeight <= AbsoluteRect.getHeight() )
|
||||
ScrollBar->setVisible(false);
|
||||
else
|
||||
ScrollBar->setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
//! returns id of selected item. returns -1 if no item is selected.
|
||||
s32 CGUISTKListBox::getSelected() const
|
||||
{
|
||||
return Selected;
|
||||
return Selected;
|
||||
}
|
||||
|
||||
|
||||
//! sets the selected item. Set this to -1 if no item should be selected
|
||||
void CGUISTKListBox::setSelected(s32 id)
|
||||
{
|
||||
if ((u32)id>=Items.size())
|
||||
Selected = -1;
|
||||
else
|
||||
Selected = id;
|
||||
if ((u32)id>=Items.size())
|
||||
Selected = -1;
|
||||
else
|
||||
Selected = id;
|
||||
|
||||
selectTime = (u32)StkTime::getTimeSinceEpoch();
|
||||
selectTime = (u32)StkTime::getTimeSinceEpoch();
|
||||
|
||||
recalculateScrollPos();
|
||||
recalculateScrollPos();
|
||||
}
|
||||
|
||||
s32 CGUISTKListBox::getRowByCellText(const wchar_t * text)
|
||||
@ -249,184 +249,184 @@ s32 CGUISTKListBox::getRowByInternalName(const std::string & text) const
|
||||
//! called if an event happened.
|
||||
bool CGUISTKListBox::OnEvent(const SEvent& event)
|
||||
{
|
||||
if (isEnabled())
|
||||
{
|
||||
switch(event.EventType)
|
||||
{
|
||||
case EET_KEY_INPUT_EVENT:
|
||||
if (event.KeyInput.PressedDown &&
|
||||
(event.KeyInput.Key == KEY_DOWN ||
|
||||
event.KeyInput.Key == KEY_UP ||
|
||||
event.KeyInput.Key == KEY_HOME ||
|
||||
event.KeyInput.Key == KEY_END ||
|
||||
event.KeyInput.Key == KEY_NEXT ||
|
||||
event.KeyInput.Key == KEY_PRIOR ) )
|
||||
{
|
||||
s32 oldSelected = Selected;
|
||||
switch (event.KeyInput.Key)
|
||||
{
|
||||
case KEY_DOWN:
|
||||
Selected += 1;
|
||||
break;
|
||||
case KEY_UP:
|
||||
Selected -= 1;
|
||||
break;
|
||||
case KEY_HOME:
|
||||
Selected = 0;
|
||||
break;
|
||||
case KEY_END:
|
||||
Selected = (s32)Items.size()-1;
|
||||
break;
|
||||
case KEY_NEXT:
|
||||
Selected += AbsoluteRect.getHeight() / ItemHeight;
|
||||
break;
|
||||
case KEY_PRIOR:
|
||||
Selected -= AbsoluteRect.getHeight() / ItemHeight;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (Selected >= (s32)Items.size())
|
||||
Selected = Items.size() - 1;
|
||||
else
|
||||
if (Selected<0)
|
||||
Selected = 0;
|
||||
if (isEnabled())
|
||||
{
|
||||
switch(event.EventType)
|
||||
{
|
||||
case EET_KEY_INPUT_EVENT:
|
||||
if (event.KeyInput.PressedDown &&
|
||||
(event.KeyInput.Key == KEY_DOWN ||
|
||||
event.KeyInput.Key == KEY_UP ||
|
||||
event.KeyInput.Key == KEY_HOME ||
|
||||
event.KeyInput.Key == KEY_END ||
|
||||
event.KeyInput.Key == KEY_NEXT ||
|
||||
event.KeyInput.Key == KEY_PRIOR ) )
|
||||
{
|
||||
s32 oldSelected = Selected;
|
||||
switch (event.KeyInput.Key)
|
||||
{
|
||||
case KEY_DOWN:
|
||||
Selected += 1;
|
||||
break;
|
||||
case KEY_UP:
|
||||
Selected -= 1;
|
||||
break;
|
||||
case KEY_HOME:
|
||||
Selected = 0;
|
||||
break;
|
||||
case KEY_END:
|
||||
Selected = (s32)Items.size()-1;
|
||||
break;
|
||||
case KEY_NEXT:
|
||||
Selected += AbsoluteRect.getHeight() / ItemHeight;
|
||||
break;
|
||||
case KEY_PRIOR:
|
||||
Selected -= AbsoluteRect.getHeight() / ItemHeight;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (Selected >= (s32)Items.size())
|
||||
Selected = Items.size() - 1;
|
||||
else
|
||||
if (Selected<0)
|
||||
Selected = 0;
|
||||
|
||||
recalculateScrollPos();
|
||||
recalculateScrollPos();
|
||||
|
||||
// post the news
|
||||
// post the news
|
||||
|
||||
if (oldSelected != Selected && Parent && !Selecting && !MoveOverSelect)
|
||||
{
|
||||
SEvent e;
|
||||
e.EventType = EET_GUI_EVENT;
|
||||
e.GUIEvent.Caller = this;
|
||||
e.GUIEvent.Element = 0;
|
||||
e.GUIEvent.EventType = EGET_LISTBOX_CHANGED;
|
||||
Parent->OnEvent(e);
|
||||
}
|
||||
if (oldSelected != Selected && Parent && !Selecting && !MoveOverSelect)
|
||||
{
|
||||
SEvent e;
|
||||
e.EventType = EET_GUI_EVENT;
|
||||
e.GUIEvent.Caller = this;
|
||||
e.GUIEvent.Element = 0;
|
||||
e.GUIEvent.EventType = EGET_LISTBOX_CHANGED;
|
||||
Parent->OnEvent(e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (!event.KeyInput.PressedDown && ( event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE ) )
|
||||
{
|
||||
if (Parent)
|
||||
{
|
||||
SEvent e;
|
||||
e.EventType = EET_GUI_EVENT;
|
||||
e.GUIEvent.Caller = this;
|
||||
e.GUIEvent.Element = 0;
|
||||
e.GUIEvent.EventType = EGET_LISTBOX_SELECTED_AGAIN;
|
||||
Parent->OnEvent(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (!event.KeyInput.PressedDown && ( event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE ) )
|
||||
{
|
||||
if (Parent)
|
||||
{
|
||||
SEvent e;
|
||||
e.EventType = EET_GUI_EVENT;
|
||||
e.GUIEvent.Caller = this;
|
||||
e.GUIEvent.Element = 0;
|
||||
e.GUIEvent.EventType = EGET_LISTBOX_SELECTED_AGAIN;
|
||||
Parent->OnEvent(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case EET_GUI_EVENT:
|
||||
switch(event.GUIEvent.EventType)
|
||||
{
|
||||
case gui::EGET_SCROLL_BAR_CHANGED:
|
||||
if (event.GUIEvent.Caller == ScrollBar)
|
||||
return true;
|
||||
break;
|
||||
case gui::EGET_ELEMENT_FOCUS_LOST:
|
||||
{
|
||||
if (event.GUIEvent.Caller == this)
|
||||
Selecting = false;
|
||||
break;
|
||||
}
|
||||
case EET_GUI_EVENT:
|
||||
switch(event.GUIEvent.EventType)
|
||||
{
|
||||
case gui::EGET_SCROLL_BAR_CHANGED:
|
||||
if (event.GUIEvent.Caller == ScrollBar)
|
||||
return true;
|
||||
break;
|
||||
case gui::EGET_ELEMENT_FOCUS_LOST:
|
||||
{
|
||||
if (event.GUIEvent.Caller == this)
|
||||
Selecting = false;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case EET_MOUSE_INPUT_EVENT:
|
||||
{
|
||||
core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y);
|
||||
case EET_MOUSE_INPUT_EVENT:
|
||||
{
|
||||
core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y);
|
||||
|
||||
switch(event.MouseInput.Event)
|
||||
{
|
||||
case EMIE_MOUSE_WHEEL:
|
||||
ScrollBar->setPos(ScrollBar->getPos() + (event.MouseInput.Wheel < 0 ? -1 : 1)*-ItemHeight/2);
|
||||
return true;
|
||||
switch(event.MouseInput.Event)
|
||||
{
|
||||
case EMIE_MOUSE_WHEEL:
|
||||
ScrollBar->setPos(ScrollBar->getPos() + (event.MouseInput.Wheel < 0 ? -1 : 1)*-ItemHeight/2);
|
||||
return true;
|
||||
|
||||
case EMIE_LMOUSE_PRESSED_DOWN:
|
||||
{
|
||||
Selecting = true;
|
||||
return true;
|
||||
}
|
||||
case EMIE_LMOUSE_PRESSED_DOWN:
|
||||
{
|
||||
Selecting = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
case EMIE_LMOUSE_LEFT_UP:
|
||||
{
|
||||
Selecting = false;
|
||||
case EMIE_LMOUSE_LEFT_UP:
|
||||
{
|
||||
Selecting = false;
|
||||
|
||||
if (isPointInside(p))
|
||||
selectNew(event.MouseInput.Y);
|
||||
if (isPointInside(p))
|
||||
selectNew(event.MouseInput.Y);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
case EMIE_MOUSE_MOVED:
|
||||
if (Selecting || MoveOverSelect)
|
||||
{
|
||||
if (isPointInside(p))
|
||||
{
|
||||
selectNew(event.MouseInput.Y, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EET_LOG_TEXT_EVENT:
|
||||
case EET_USER_EVENT:
|
||||
case EET_JOYSTICK_INPUT_EVENT:
|
||||
case EGUIET_FORCE_32_BIT:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case EMIE_MOUSE_MOVED:
|
||||
if (Selecting || MoveOverSelect)
|
||||
{
|
||||
if (isPointInside(p))
|
||||
{
|
||||
selectNew(event.MouseInput.Y, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EET_LOG_TEXT_EVENT:
|
||||
case EET_USER_EVENT:
|
||||
case EET_JOYSTICK_INPUT_EVENT:
|
||||
case EGUIET_FORCE_32_BIT:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return IGUIElement::OnEvent(event);
|
||||
return IGUIElement::OnEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void CGUISTKListBox::selectNew(s32 ypos, bool onlyHover)
|
||||
{
|
||||
u32 now = (u32)StkTime::getTimeSinceEpoch();
|
||||
s32 oldSelected = Selected;
|
||||
u32 now = (u32)StkTime::getTimeSinceEpoch();
|
||||
s32 oldSelected = Selected;
|
||||
|
||||
Selected = getItemAt(AbsoluteRect.UpperLeftCorner.X, ypos);
|
||||
if (Selected<0 && !Items.empty())
|
||||
Selected = 0;
|
||||
Selected = getItemAt(AbsoluteRect.UpperLeftCorner.X, ypos);
|
||||
if (Selected<0 && !Items.empty())
|
||||
Selected = 0;
|
||||
|
||||
recalculateScrollPos();
|
||||
recalculateScrollPos();
|
||||
|
||||
gui::EGUI_EVENT_TYPE eventType = (Selected == oldSelected && now < selectTime + 500) ? EGET_LISTBOX_SELECTED_AGAIN : EGET_LISTBOX_CHANGED;
|
||||
selectTime = now;
|
||||
// post the news
|
||||
if (Parent && !onlyHover)
|
||||
{
|
||||
SEvent event;
|
||||
event.EventType = EET_GUI_EVENT;
|
||||
event.GUIEvent.Caller = this;
|
||||
event.GUIEvent.Element = 0;
|
||||
event.GUIEvent.EventType = eventType;
|
||||
Parent->OnEvent(event);
|
||||
}
|
||||
gui::EGUI_EVENT_TYPE eventType = (Selected == oldSelected && now < selectTime + 500) ? EGET_LISTBOX_SELECTED_AGAIN : EGET_LISTBOX_CHANGED;
|
||||
selectTime = now;
|
||||
// post the news
|
||||
if (Parent && !onlyHover)
|
||||
{
|
||||
SEvent event;
|
||||
event.EventType = EET_GUI_EVENT;
|
||||
event.GUIEvent.Caller = this;
|
||||
event.GUIEvent.Element = 0;
|
||||
event.GUIEvent.EventType = eventType;
|
||||
Parent->OnEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Update the position and size of the listbox, and update the scrollbar
|
||||
void CGUISTKListBox::updateAbsolutePosition()
|
||||
{
|
||||
IGUIElement::updateAbsolutePosition();
|
||||
IGUIElement::updateAbsolutePosition();
|
||||
|
||||
recalculateItemHeight();
|
||||
recalculateItemHeight();
|
||||
}
|
||||
|
||||
|
||||
@ -563,10 +563,10 @@ void CGUISTKListBox::draw()
|
||||
//! adds an list item with an icon
|
||||
u32 CGUISTKListBox::addItem(const ListItem & item)
|
||||
{
|
||||
Items.push_back(item);
|
||||
recalculateItemHeight();
|
||||
recalculateIconWidth();
|
||||
return Items.size() - 1;
|
||||
Items.push_back(item);
|
||||
recalculateItemHeight();
|
||||
recalculateIconWidth();
|
||||
return Items.size() - 1;
|
||||
}
|
||||
|
||||
|
||||
@ -574,44 +574,44 @@ void CGUISTKListBox::setSpriteBank(IGUISpriteBank* bank)
|
||||
{
|
||||
if ( bank == IconBank )
|
||||
return;
|
||||
if (IconBank)
|
||||
IconBank->drop();
|
||||
if (IconBank)
|
||||
IconBank->drop();
|
||||
|
||||
IconBank = bank;
|
||||
if (IconBank)
|
||||
IconBank->grab();
|
||||
IconBank = bank;
|
||||
if (IconBank)
|
||||
IconBank->grab();
|
||||
}
|
||||
|
||||
|
||||
void CGUISTKListBox::recalculateScrollPos()
|
||||
{
|
||||
if (!AutoScroll)
|
||||
return;
|
||||
if (!AutoScroll)
|
||||
return;
|
||||
|
||||
const s32 selPos = (Selected == -1 ? TotalItemHeight : Selected * ItemHeight) - ScrollBar->getPos();
|
||||
const s32 selPos = (Selected == -1 ? TotalItemHeight : Selected * ItemHeight) - ScrollBar->getPos();
|
||||
|
||||
if (selPos < 0)
|
||||
{
|
||||
ScrollBar->setPos(ScrollBar->getPos() + selPos);
|
||||
}
|
||||
else
|
||||
if (selPos > AbsoluteRect.getHeight() - ItemHeight)
|
||||
{
|
||||
ScrollBar->setPos(ScrollBar->getPos() + selPos - AbsoluteRect.getHeight() + ItemHeight);
|
||||
}
|
||||
if (selPos < 0)
|
||||
{
|
||||
ScrollBar->setPos(ScrollBar->getPos() + selPos);
|
||||
}
|
||||
else
|
||||
if (selPos > AbsoluteRect.getHeight() - ItemHeight)
|
||||
{
|
||||
ScrollBar->setPos(ScrollBar->getPos() + selPos - AbsoluteRect.getHeight() + ItemHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CGUISTKListBox::setAutoScrollEnabled(bool scroll)
|
||||
{
|
||||
AutoScroll = scroll;
|
||||
AutoScroll = scroll;
|
||||
}
|
||||
|
||||
|
||||
bool CGUISTKListBox::isAutoScrollEnabled() const
|
||||
{
|
||||
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
|
||||
return AutoScroll;
|
||||
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
|
||||
return AutoScroll;
|
||||
}
|
||||
|
||||
void CGUISTKListBox::recalculateIconWidth()
|
||||
@ -619,128 +619,128 @@ void CGUISTKListBox::recalculateIconWidth()
|
||||
for(int x = 0; x < (int)Items.getLast().m_contents.size(); ++x)
|
||||
{
|
||||
s32 icon = Items.getLast().m_contents[x].m_icon;
|
||||
if (IconBank && icon > -1 &&
|
||||
IconBank->getSprites().size() > (u32)icon &&
|
||||
IconBank->getSprites()[(u32)icon].Frames.size())
|
||||
{
|
||||
u32 rno = IconBank->getSprites()[(u32)icon].Frames[0].rectNumber;
|
||||
if (IconBank->getPositions().size() > rno)
|
||||
{
|
||||
const s32 w = IconBank->getPositions()[rno].getWidth();
|
||||
if (w > ItemsIconWidth)
|
||||
ItemsIconWidth = w;
|
||||
}
|
||||
}
|
||||
if (IconBank && icon > -1 &&
|
||||
IconBank->getSprites().size() > (u32)icon &&
|
||||
IconBank->getSprites()[(u32)icon].Frames.size())
|
||||
{
|
||||
u32 rno = IconBank->getSprites()[(u32)icon].Frames[0].rectNumber;
|
||||
if (IconBank->getPositions().size() > rno)
|
||||
{
|
||||
const s32 w = IconBank->getPositions()[rno].getWidth();
|
||||
if (w > ItemsIconWidth)
|
||||
ItemsIconWidth = w;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CGUISTKListBox::setCell(u32 row_num, u32 col_num, const wchar_t* text, s32 icon)
|
||||
{
|
||||
if ( row_num >= Items.size() )
|
||||
return;
|
||||
if ( row_num >= Items.size() )
|
||||
return;
|
||||
if ( col_num >= Items[row_num].m_contents.size() )
|
||||
return;
|
||||
Items[row_num].m_contents[col_num].m_text = text;
|
||||
Items[row_num].m_contents[col_num].m_icon = icon;
|
||||
|
||||
recalculateItemHeight();
|
||||
recalculateIconWidth();
|
||||
recalculateItemHeight();
|
||||
recalculateIconWidth();
|
||||
}
|
||||
|
||||
void CGUISTKListBox::swapItems(u32 index1, u32 index2)
|
||||
{
|
||||
if ( index1 >= Items.size() || index2 >= Items.size() )
|
||||
return;
|
||||
if ( index1 >= Items.size() || index2 >= Items.size() )
|
||||
return;
|
||||
|
||||
ListItem dummmy = Items[index1];
|
||||
Items[index1] = Items[index2];
|
||||
Items[index2] = dummmy;
|
||||
ListItem dummmy = Items[index1];
|
||||
Items[index1] = Items[index2];
|
||||
Items[index2] = dummmy;
|
||||
}
|
||||
|
||||
|
||||
void CGUISTKListBox::setItemOverrideColor(u32 index, video::SColor color)
|
||||
{
|
||||
for ( u32 c=0; c < EGUI_LBC_COUNT; ++c )
|
||||
{
|
||||
Items[index].OverrideColors[c].Use = true;
|
||||
Items[index].OverrideColors[c].Color = color;
|
||||
}
|
||||
for ( u32 c=0; c < EGUI_LBC_COUNT; ++c )
|
||||
{
|
||||
Items[index].OverrideColors[c].Use = true;
|
||||
Items[index].OverrideColors[c].Color = color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CGUISTKListBox::setItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType, video::SColor color)
|
||||
{
|
||||
if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
||||
return;
|
||||
if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
||||
return;
|
||||
|
||||
Items[index].OverrideColors[colorType].Use = true;
|
||||
Items[index].OverrideColors[colorType].Color = color;
|
||||
Items[index].OverrideColors[colorType].Use = true;
|
||||
Items[index].OverrideColors[colorType].Color = color;
|
||||
}
|
||||
|
||||
|
||||
void CGUISTKListBox::clearItemOverrideColor(u32 index)
|
||||
{
|
||||
for (u32 c=0; c < (u32)EGUI_LBC_COUNT; ++c )
|
||||
{
|
||||
Items[index].OverrideColors[c].Use = false;
|
||||
}
|
||||
for (u32 c=0; c < (u32)EGUI_LBC_COUNT; ++c )
|
||||
{
|
||||
Items[index].OverrideColors[c].Use = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CGUISTKListBox::clearItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType)
|
||||
{
|
||||
if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
||||
return;
|
||||
if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
||||
return;
|
||||
|
||||
Items[index].OverrideColors[colorType].Use = false;
|
||||
Items[index].OverrideColors[colorType].Use = false;
|
||||
}
|
||||
|
||||
|
||||
bool CGUISTKListBox::hasItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const
|
||||
{
|
||||
if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
||||
return false;
|
||||
if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
||||
return false;
|
||||
|
||||
return Items[index].OverrideColors[colorType].Use;
|
||||
return Items[index].OverrideColors[colorType].Use;
|
||||
}
|
||||
|
||||
|
||||
video::SColor CGUISTKListBox::getItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const
|
||||
{
|
||||
if ( (u32)index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
||||
return video::SColor();
|
||||
if ( (u32)index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
||||
return video::SColor();
|
||||
|
||||
return Items[index].OverrideColors[colorType].Color;
|
||||
return Items[index].OverrideColors[colorType].Color;
|
||||
}
|
||||
|
||||
|
||||
video::SColor CGUISTKListBox::getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const
|
||||
{
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
if ( !skin )
|
||||
return video::SColor();
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
if ( !skin )
|
||||
return video::SColor();
|
||||
|
||||
switch ( colorType )
|
||||
{
|
||||
case EGUI_LBC_TEXT:
|
||||
return skin->getColor(EGDC_BUTTON_TEXT);
|
||||
case EGUI_LBC_TEXT_HIGHLIGHT:
|
||||
return skin->getColor(EGDC_HIGH_LIGHT_TEXT);
|
||||
case EGUI_LBC_ICON:
|
||||
return skin->getColor(EGDC_ICON);
|
||||
case EGUI_LBC_ICON_HIGHLIGHT:
|
||||
return skin->getColor(EGDC_ICON_HIGH_LIGHT);
|
||||
default:
|
||||
return video::SColor();
|
||||
}
|
||||
switch ( colorType )
|
||||
{
|
||||
case EGUI_LBC_TEXT:
|
||||
return skin->getColor(EGDC_BUTTON_TEXT);
|
||||
case EGUI_LBC_TEXT_HIGHLIGHT:
|
||||
return skin->getColor(EGDC_HIGH_LIGHT_TEXT);
|
||||
case EGUI_LBC_ICON:
|
||||
return skin->getColor(EGDC_ICON);
|
||||
case EGUI_LBC_ICON_HIGHLIGHT:
|
||||
return skin->getColor(EGDC_ICON_HIGH_LIGHT);
|
||||
default:
|
||||
return video::SColor();
|
||||
}
|
||||
}
|
||||
|
||||
//! set global itemHeight
|
||||
void CGUISTKListBox::setItemHeight( s32 height )
|
||||
{
|
||||
ItemHeight = height;
|
||||
ItemHeightOverride = 1;
|
||||
ItemHeight = height;
|
||||
ItemHeightOverride = 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,12 +17,12 @@ namespace irr
|
||||
{
|
||||
namespace gui
|
||||
{
|
||||
class IGUIFont;
|
||||
class IGUIScrollBar;
|
||||
class IGUIFont;
|
||||
class IGUIScrollBar;
|
||||
|
||||
class CGUISTKListBox : public IGUIElement
|
||||
{
|
||||
public:
|
||||
class CGUISTKListBox : public IGUIElement
|
||||
{
|
||||
public:
|
||||
|
||||
struct ListItem
|
||||
{
|
||||
@ -163,7 +163,7 @@ namespace irr
|
||||
//! Sets whether to draw the background
|
||||
virtual void setDrawBackground(bool draw);
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
void recalculateItemHeight();
|
||||
void selectNew(s32 ypos, bool onlyHover=false);
|
||||
@ -189,7 +189,7 @@ namespace irr
|
||||
bool MoveOverSelect;
|
||||
bool AutoScroll;
|
||||
bool HighlightWhenNotFocused;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
|
@ -62,17 +62,17 @@ void SpinnerWidget::add()
|
||||
|
||||
if (min_s.size() > 0)
|
||||
{
|
||||
if (!StringUtils::parseString<int>(min_s, &m_min))
|
||||
if (!StringUtils::parseString<int>(min_s, &m_min))
|
||||
{
|
||||
Log::warn("invalid value for spinner widget minimum value : %s", min_s.c_str());
|
||||
Log::warn("invalid value for spinner widget minimum value : %s", min_s.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (max_s.size() > 0)
|
||||
{
|
||||
if (!StringUtils::parseString<int>(max_s, &m_max))
|
||||
{
|
||||
Log::warn("invalid value for spinner widget maximum value : %s", max_s.c_str());
|
||||
if (!StringUtils::parseString<int>(max_s, &m_max))
|
||||
{
|
||||
Log::warn("invalid value for spinner widget maximum value : %s", max_s.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ namespace GUIEngine
|
||||
void addLabel(irr::core::stringw label);
|
||||
void clearLabels();
|
||||
|
||||
// next four functions are for background colour behind playername in multikart screen selection
|
||||
// next four functions are for background colour behind playername in multikart screen selection
|
||||
void setUseBackgroundColor() {m_use_background_color=true; }
|
||||
bool getUseBackgroundColor() {return m_use_background_color; }
|
||||
void setSpinnerWidgetPlayerID(int playerID) {m_spinner_widget_player_id=playerID;}
|
||||
|
@ -481,13 +481,13 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
|
||||
m_mode == INPUT_SENSE_GAMEPAD)
|
||||
{
|
||||
// Do not pick disabled gamepads for input sensing
|
||||
if (type == Input::IT_STICKBUTTON || type == Input::IT_STICKMOTION)
|
||||
if (type == Input::IT_STICKBUTTON || type == Input::IT_STICKMOTION)
|
||||
{
|
||||
GamePadDevice *gPad = m_device_manager->getGamePadFromIrrID(deviceID);
|
||||
DeviceConfig *conf = gPad->getConfiguration();
|
||||
if (!conf->isEnabled())
|
||||
return;
|
||||
}
|
||||
GamePadDevice *gPad = m_device_manager->getGamePadFromIrrID(deviceID);
|
||||
DeviceConfig *conf = gPad->getConfiguration();
|
||||
if (!conf->isEnabled())
|
||||
return;
|
||||
}
|
||||
|
||||
inputSensing(type, deviceID, button, axisDirection, value);
|
||||
return;
|
||||
|
@ -2595,7 +2595,7 @@ void Kart::setOnScreenText(const wchar_t *text)
|
||||
// FIXME: Titlefont is the only font guaranteed to be loaded if STK
|
||||
// is started without splash screen (since "Loading" is shown even in this
|
||||
// case). A smaller font would be better
|
||||
// TODO: Add support in the engine for BillboardText or find a replacement
|
||||
// TODO: Add support in the engine for BillboardText or find a replacement
|
||||
/*scene::ISceneManager* sm = irr_driver->getSceneManager();
|
||||
sm->addBillboardTextSceneNode(GUIEngine::getFont() ? GUIEngine::getFont()
|
||||
: GUIEngine::getTitleFont(),
|
||||
|
@ -483,7 +483,7 @@ void World::terminateRace()
|
||||
mode_name, 1);
|
||||
}
|
||||
}
|
||||
} // for i < kart_amount
|
||||
} // for i < kart_amount
|
||||
} // if (achiev)
|
||||
|
||||
Achievement *win = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::ACHIEVE_UNSTOPPABLE);
|
||||
|
@ -121,10 +121,10 @@ void STKHost::setupServer(uint32_t address, uint16_t port, int peer_count,
|
||||
addr->port = port;
|
||||
|
||||
#ifdef WIN32/*
|
||||
addr->host = 0;
|
||||
addr->host += ((unsigned int)(192)<<0); // 192.168.0.11
|
||||
addr->host += ((unsigned int)(168)<<8); // 192.168.0.11
|
||||
addr->host += ((unsigned int)(11)<<24); // 192.168.0.11*/
|
||||
addr->host = 0;
|
||||
addr->host += ((unsigned int)(192)<<0); // 192.168.0.11
|
||||
addr->host += ((unsigned int)(168)<<8); // 192.168.0.11
|
||||
addr->host += ((unsigned int)(11)<<24); // 192.168.0.11*/
|
||||
#endif
|
||||
|
||||
m_host = enet_host_create(addr, peer_count, channel_limit,
|
||||
@ -235,10 +235,10 @@ uint8_t* STKHost::receiveRawPacket(TransportAddress* sender)
|
||||
len = recvfrom(m_host->socket, (char*)buffer, 2048, 0, (struct sockaddr*)(&addr), &from_len);
|
||||
StkTime::sleep(1); // wait 1 millisecond between two checks
|
||||
}
|
||||
if (len == SOCKET_ERROR)
|
||||
{
|
||||
Log::error("STKHost", "Problem with the socket. Please contact the dev team.");
|
||||
}
|
||||
if (len == SOCKET_ERROR)
|
||||
{
|
||||
Log::error("STKHost", "Problem with the socket. Please contact the dev team.");
|
||||
}
|
||||
// we received the data
|
||||
sender->ip = ntohl((uint32_t)(addr.sin_addr.s_addr));
|
||||
sender->port = ntohs(addr.sin_port);
|
||||
@ -272,8 +272,8 @@ uint8_t* STKHost::receiveRawPacket(TransportAddress sender, int max_tries)
|
||||
while(len < 0 || addr.sin_addr.s_addr == sender.ip)
|
||||
{
|
||||
i++;
|
||||
if (len>=0)
|
||||
{
|
||||
if (len>=0)
|
||||
{
|
||||
Log::info("STKHost", "Message received but the ip address didn't match the expected one.");
|
||||
}
|
||||
len = recvfrom(m_host->socket, (char*)buffer, 2048, 0, (struct sockaddr*)(&addr), &from_len);
|
||||
@ -281,10 +281,10 @@ uint8_t* STKHost::receiveRawPacket(TransportAddress sender, int max_tries)
|
||||
if (i >= max_tries && max_tries != -1)
|
||||
{
|
||||
Log::verbose("STKHost", "No answer from the server on %u.%u.%u.%u:%u", (m_host->address.host&0xff),
|
||||
(m_host->address.host>>8&0xff),
|
||||
(m_host->address.host>>16&0xff),
|
||||
(m_host->address.host>>24&0xff),
|
||||
(m_host->address.port));
|
||||
(m_host->address.host>>8&0xff),
|
||||
(m_host->address.host>>16&0xff),
|
||||
(m_host->address.host>>24&0xff),
|
||||
(m_host->address.port));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ bool Track::loadMainTrack(const XMLNode &root)
|
||||
|
||||
assert(GUIEngine::getHighresDigitFont() != NULL);
|
||||
|
||||
// TODO: Add support in the engine for BillboardText or find a replacement
|
||||
// TODO: Add support in the engine for BillboardText or find a replacement
|
||||
/* scene::ISceneManager* sm = irr_driver->getSceneManager();
|
||||
scene::ISceneNode* sn =
|
||||
sm->addBillboardTextSceneNode(GUIEngine::getHighresDigitFont(),
|
||||
@ -1581,7 +1581,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
|
||||
|
||||
// Sky dome and boxes support
|
||||
// --------------------------
|
||||
irr_driver->suppressSkyBox();
|
||||
irr_driver->suppressSkyBox();
|
||||
if(m_sky_type==SKY_DOME && m_sky_textures.size() > 0)
|
||||
{
|
||||
scene::ISceneNode *node = irr_driver->addSkyDome(m_sky_textures[0],
|
||||
|
@ -188,9 +188,9 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(const XMLNode& xml_node
|
||||
|
||||
bool animated = skeletal_animation && (UserConfigParams::m_graphical_effects ||
|
||||
World::getWorld()->getIdent() == IDENT_CUTSCENE);
|
||||
bool displacing = false;
|
||||
xml_node.get("displacing", &displacing);
|
||||
animated &= !displacing;
|
||||
bool displacing = false;
|
||||
xml_node.get("displacing", &displacing);
|
||||
animated &= !displacing;
|
||||
|
||||
if (animated)
|
||||
{
|
||||
@ -256,10 +256,10 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node, scene::ISceneNod
|
||||
|
||||
bool animated = skeletal_animation && (UserConfigParams::m_graphical_effects ||
|
||||
World::getWorld()->getIdent() == IDENT_CUTSCENE);
|
||||
bool displacing = false;
|
||||
if(xml_node)
|
||||
bool displacing = false;
|
||||
if(xml_node)
|
||||
xml_node->get("displacing", &displacing);
|
||||
animated &= !displacing;
|
||||
animated &= !displacing;
|
||||
|
||||
m_mesh->grab();
|
||||
irr_driver->grabAllTextures(m_mesh);
|
||||
|
@ -96,31 +96,31 @@ void addPowerup(PowerupManager::PowerupType powerup)
|
||||
|
||||
void addAttachment(Attachment::AttachmentType type)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (world == NULL) return;
|
||||
for(unsigned int i = 0; i < world->getNumKarts(); i++)
|
||||
{
|
||||
AbstractKart *kart = world->getKart(i);
|
||||
if (kart->getController()->isPlayerController()) {
|
||||
if (type == Attachment::ATTACH_ANVIL)
|
||||
{
|
||||
kart->getAttachment()
|
||||
->set(type, stk_config->m_anvil_time);
|
||||
kart->adjustSpeed(stk_config->m_anvil_speed_factor);
|
||||
kart->updateWeight();
|
||||
}
|
||||
else if (type == Attachment::ATTACH_PARACHUTE)
|
||||
{
|
||||
kart->getAttachment()
|
||||
->set(type, stk_config->m_parachute_time);
|
||||
}
|
||||
else if (type == Attachment::ATTACH_BOMB)
|
||||
{
|
||||
kart->getAttachment()
|
||||
->set(type, stk_config->m_bomb_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
World* world = World::getWorld();
|
||||
if (world == NULL) return;
|
||||
for(unsigned int i = 0; i < world->getNumKarts(); i++)
|
||||
{
|
||||
AbstractKart *kart = world->getKart(i);
|
||||
if (kart->getController()->isPlayerController()) {
|
||||
if (type == Attachment::ATTACH_ANVIL)
|
||||
{
|
||||
kart->getAttachment()
|
||||
->set(type, stk_config->m_anvil_time);
|
||||
kart->adjustSpeed(stk_config->m_anvil_speed_factor);
|
||||
kart->updateWeight();
|
||||
}
|
||||
else if (type == Attachment::ATTACH_PARACHUTE)
|
||||
{
|
||||
kart->getAttachment()
|
||||
->set(type, stk_config->m_parachute_time);
|
||||
}
|
||||
else if (type == Attachment::ATTACH_BOMB)
|
||||
{
|
||||
kart->getAttachment()
|
||||
->set(type, stk_config->m_bomb_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -369,15 +369,15 @@ bool onEvent(const SEvent &event)
|
||||
}
|
||||
else if (cmdID == DEBUG_ATTACHMENT_ANVIL)
|
||||
{
|
||||
addAttachment(Attachment::ATTACH_ANVIL);
|
||||
addAttachment(Attachment::ATTACH_ANVIL);
|
||||
}
|
||||
else if (cmdID == DEBUG_ATTACHMENT_BOMB)
|
||||
{
|
||||
addAttachment(Attachment::ATTACH_BOMB);
|
||||
addAttachment(Attachment::ATTACH_BOMB);
|
||||
}
|
||||
else if (cmdID == DEBUG_ATTACHMENT_PARACHUTE)
|
||||
{
|
||||
addAttachment(Attachment::ATTACH_PARACHUTE);
|
||||
addAttachment(Attachment::ATTACH_PARACHUTE);
|
||||
}
|
||||
else if (cmdID == DEBUG_TOGGLE_GUI)
|
||||
{
|
||||
|
@ -76,99 +76,99 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
static inline float mod289(float x) {
|
||||
// return x - floorf(x * (1.0 / 289.0)) * 289.0;
|
||||
return fmodf(x, 289);
|
||||
// return x - floorf(x * (1.0 / 289.0)) * 289.0;
|
||||
return fmodf(x, 289);
|
||||
}
|
||||
|
||||
static inline float permute(float x) {
|
||||
return mod289(((x*34.0f)+1.0f)*x);
|
||||
return mod289(((x*34.0f)+1.0f)*x);
|
||||
}
|
||||
|
||||
// Vectorized 2d simplex noise.
|
||||
float noise2d(float v1, float v2) {
|
||||
|
||||
const float C[] = {
|
||||
0.211324865405187f,
|
||||
0.366025403784439f,
|
||||
-0.577350269189626f,
|
||||
0.024390243902439f };
|
||||
const float C[] = {
|
||||
0.211324865405187f,
|
||||
0.366025403784439f,
|
||||
-0.577350269189626f,
|
||||
0.024390243902439f };
|
||||
|
||||
// First corner
|
||||
float i[2];
|
||||
i[0] = floorf(v1 + v1*C[1] + v2*C[1]);
|
||||
i[1] = floorf(v2 + v1*C[1] + v2*C[1]);
|
||||
// First corner
|
||||
float i[2];
|
||||
i[0] = floorf(v1 + v1*C[1] + v2*C[1]);
|
||||
i[1] = floorf(v2 + v1*C[1] + v2*C[1]);
|
||||
|
||||
float x0[2];
|
||||
x0[0] = v1 - i[0] + i[0]*C[0] + i[1]*C[0];
|
||||
x0[1] = v2 - i[1] + i[0]*C[0] + i[1]*C[0];
|
||||
float x0[2];
|
||||
x0[0] = v1 - i[0] + i[0]*C[0] + i[1]*C[0];
|
||||
x0[1] = v2 - i[1] + i[0]*C[0] + i[1]*C[0];
|
||||
|
||||
// Other corners
|
||||
float i1[2];
|
||||
if (x0[0] > x0[1]) {
|
||||
i1[0] = 1;
|
||||
i1[1] = 0;
|
||||
} else {
|
||||
i1[0] = 0;
|
||||
i1[1] = 1;
|
||||
}
|
||||
// Other corners
|
||||
float i1[2];
|
||||
if (x0[0] > x0[1]) {
|
||||
i1[0] = 1;
|
||||
i1[1] = 0;
|
||||
} else {
|
||||
i1[0] = 0;
|
||||
i1[1] = 1;
|
||||
}
|
||||
|
||||
float x12[4];
|
||||
x12[0] = x0[0] + C[0] - i1[0];
|
||||
x12[1] = x0[1] + C[0] - i1[1];
|
||||
x12[2] = x0[0] + C[2];
|
||||
x12[3] = x0[1] + C[2];
|
||||
float x12[4];
|
||||
x12[0] = x0[0] + C[0] - i1[0];
|
||||
x12[1] = x0[1] + C[0] - i1[1];
|
||||
x12[2] = x0[0] + C[2];
|
||||
x12[3] = x0[1] + C[2];
|
||||
|
||||
// Permutations
|
||||
i[0] = mod289(i[0]);
|
||||
i[1] = mod289(i[1]);
|
||||
// Permutations
|
||||
i[0] = mod289(i[0]);
|
||||
i[1] = mod289(i[1]);
|
||||
|
||||
float p[3];
|
||||
p[0] = permute(permute(i[1]) + i[0]);
|
||||
p[1] = permute(permute(i[1] + i1[1]) + i[0] + i1[0]);
|
||||
p[2] = permute(permute(i[1] + 1) + i[0] + 1);
|
||||
float p[3];
|
||||
p[0] = permute(permute(i[1]) + i[0]);
|
||||
p[1] = permute(permute(i[1] + i1[1]) + i[0] + i1[0]);
|
||||
p[2] = permute(permute(i[1] + 1) + i[0] + 1);
|
||||
|
||||
float m[3];
|
||||
m[0] = std::max<float>(0.5f - x0[0]*x0[0] - x0[1]*x0[1], 0);
|
||||
m[1] = std::max<float>(0.5f - x12[0]*x12[0] - x12[1]*x12[1], 0);
|
||||
m[2] = std::max<float>(0.5f - x12[2]*x12[2] - x12[3]*x12[3], 0);
|
||||
float m[3];
|
||||
m[0] = std::max<float>(0.5f - x0[0]*x0[0] - x0[1]*x0[1], 0);
|
||||
m[1] = std::max<float>(0.5f - x12[0]*x12[0] - x12[1]*x12[1], 0);
|
||||
m[2] = std::max<float>(0.5f - x12[2]*x12[2] - x12[3]*x12[3], 0);
|
||||
|
||||
m[0] = m[0] * m[0] * m[0] * m[0];
|
||||
m[1] = m[1] * m[1] * m[1] * m[1];
|
||||
m[2] = m[2] * m[2] * m[2] * m[2];
|
||||
m[0] = m[0] * m[0] * m[0] * m[0];
|
||||
m[1] = m[1] * m[1] * m[1] * m[1];
|
||||
m[2] = m[2] * m[2] * m[2] * m[2];
|
||||
|
||||
// Gradients
|
||||
float tmp;
|
||||
// Gradients
|
||||
float tmp;
|
||||
|
||||
float x[3];
|
||||
x[0] = 2 * modff(p[0] * C[3], &tmp) - 1;
|
||||
x[1] = 2 * modff(p[1] * C[3], &tmp) - 1;
|
||||
x[2] = 2 * modff(p[2] * C[3], &tmp) - 1;
|
||||
float x[3];
|
||||
x[0] = 2 * modff(p[0] * C[3], &tmp) - 1;
|
||||
x[1] = 2 * modff(p[1] * C[3], &tmp) - 1;
|
||||
x[2] = 2 * modff(p[2] * C[3], &tmp) - 1;
|
||||
|
||||
float h[3];
|
||||
h[0] = fabsf(x[0]) - 0.5f;
|
||||
h[1] = fabsf(x[1]) - 0.5f;
|
||||
h[2] = fabsf(x[2]) - 0.5f;
|
||||
float h[3];
|
||||
h[0] = fabsf(x[0]) - 0.5f;
|
||||
h[1] = fabsf(x[1]) - 0.5f;
|
||||
h[2] = fabsf(x[2]) - 0.5f;
|
||||
|
||||
float ox[3];
|
||||
ox[0] = floorf(x[0] + 0.5f);
|
||||
ox[1] = floorf(x[1] + 0.5f);
|
||||
ox[2] = floorf(x[2] + 0.5f);
|
||||
float ox[3];
|
||||
ox[0] = floorf(x[0] + 0.5f);
|
||||
ox[1] = floorf(x[1] + 0.5f);
|
||||
ox[2] = floorf(x[2] + 0.5f);
|
||||
|
||||
float a0[3];
|
||||
a0[0] = x[0] - ox[0];
|
||||
a0[1] = x[1] - ox[1];
|
||||
a0[2] = x[2] - ox[2];
|
||||
float a0[3];
|
||||
a0[0] = x[0] - ox[0];
|
||||
a0[1] = x[1] - ox[1];
|
||||
a0[2] = x[2] - ox[2];
|
||||
|
||||
// Normalize
|
||||
m[0] *= 1.79284291400159f - 0.85373472095314f * (a0[0]*a0[0] + h[0]*h[0]);
|
||||
m[1] *= 1.79284291400159f - 0.85373472095314f * (a0[1]*a0[1] + h[1]*h[1]);
|
||||
m[2] *= 1.79284291400159f - 0.85373472095314f * (a0[2]*a0[2] + h[2]*h[2]);
|
||||
// Normalize
|
||||
m[0] *= 1.79284291400159f - 0.85373472095314f * (a0[0]*a0[0] + h[0]*h[0]);
|
||||
m[1] *= 1.79284291400159f - 0.85373472095314f * (a0[1]*a0[1] + h[1]*h[1]);
|
||||
m[2] *= 1.79284291400159f - 0.85373472095314f * (a0[2]*a0[2] + h[2]*h[2]);
|
||||
|
||||
// Compute final value
|
||||
float g[3];
|
||||
g[0] = a0[0] * x0[0] + h[0] * x0[1];
|
||||
g[1] = a0[1] * x12[0] + h[1] * x12[1];
|
||||
g[2] = a0[2] * x12[2] + h[2] * x12[3];
|
||||
// Compute final value
|
||||
float g[3];
|
||||
g[0] = a0[0] * x0[0] + h[0] * x0[1];
|
||||
g[1] = a0[1] * x12[0] + h[1] * x12[1];
|
||||
g[2] = a0[2] * x12[2] + h[2] * x12[3];
|
||||
|
||||
return 130 * (m[0] * g[0] + m[1] * g[1] + m[2] * g[2]);
|
||||
return 130 * (m[0] * g[0] + m[1] * g[1] + m[2] * g[2]);
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ namespace internal
|
||||
);
|
||||
}
|
||||
|
||||
//Deprecated in release 2.3
|
||||
//Deprecated in release 2.3
|
||||
template <typename octet_iterator>
|
||||
inline bool is_bom (octet_iterator it)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user