I just started using Irrlicht a few weeks ago, and I'm impressed with it's simplistic power.
Anyways, my problem is creating a sky-dome and having access to vertex color data. I tried loading a 3DS file into irrlicht, but I couldn't figure out if I was able to change vertex color on those.
Next I tried making my own dome shape using a custom scene node. I'm not very experienced in creating objects from code. My dome wont even appear because I don't know how to calculate the indices?
Code: Select all
void ESphere::CreateSky(int nSubdivide, float fVertSweep, float fRadius, float fHeightScale, irr::core::vector3df &vPosition,
irr::video::SColor &cDayColor, irr::video::SColor &cNightColor)
{
// Find how many vertices are in the dome
m_nVerts = 1 + 4 * nSubdivide * nSubdivide;
// Assign the previoud number to the array of vertices
m_Verts = new irr::video::S3DVertex[ m_nVerts ];
// Adjust radius based on vertical sweep
float fRadAngle = (90 - fVertSweep) / 180 * PI;
fRadius /= cos (fRadAngle);
// Compute Z Adjustments
float fZAdj = fRadius * sin(fRadAngle);
// Create the very top vertex
m_Verts[0].Pos.X = 0;
m_Verts[0].Pos.Y = 0;
m_Verts[0].Pos.Z = ((fRadius - fZAdj) * fHeightScale);
m_Verts[0].Pos += vPosition;
// Calculate one angular section of the dome
float fHorzSweep = 90.0 / nSubdivide;
fVertSweep /= nSubdivide;
int nVertex = 1;
for (int i = 0; i < nSubdivide; i++)
{
//
// Compute the vertex that will be rotated around to make a ring
//
irr::core::vector3df vPoint(0, 0, fRadius);
irr::core::matrix4 m;
m.setTranslation(irr::core::vector3df(0, fVertSweep * (i + 1), 0));
//Multiply wtf?
//m. (vPoint, vPoint);
vPoint.Z = (vPoint.Z - fZAdj) * fHeightScale;
//
// Loop through the ring creating the points
//
for (int j = 0; j < nSubdivide * 4; j++)
{
//
// Map the point
//
m.setTranslation(irr::core::vector3df(fHorzSweep * j, 0, 0));
//m .PreMultiply (vPoint, m_pVertex [nVertex] .vVertex);
m_Verts[nVertex].Pos += vPosition;
nVertex++;
}
}
}
Thanks for your input/help in advance.