[opensource-dev] Mesh rendering: What does indicesp provide?
Rob Nelson
nexisentertainment at gmail.com
Wed Jun 2 16:35:58 PDT 2010
I am almost to the point of going crazy. I was going to write a
notecard to a Linden, but I've been knocked out of SL for reasons
unknown, so I'll have to ask here.
In my infinite lack of wisdom, I decided to start working on a project
where I replace the heightmap terrain in Second Life with one based on
voxels. To get to the core of the reasoning behind this switch so I
don't spend too much time on it:
* Voxel-based land allows creation of overhangs/caves/floating chunks
of land (not possible with heightmaps)
* Also adds the ability to handle up to 255 terrain materials
(textures, eventually detail shaders) instead of 4, and the materials
are placed where desired instead of at fractional heights.
I am working on the rendering code in the SL viewer at the moment,
having completed the server-side code and some of the client-side
packet-handling classes. However, I have zero familiarity with OpenGL,
so bear with me.
My viewer needs to construct a terrain surface (a mesh) for display. I
have completed an LLViewerObject to this end, except for:
::getGeometry(LLStrider<LLVector3> &verticesp,
LLStrider<LLVector3> &normalsp,
LLStrider<LLColor4U> &colorsp,
LLStrider<LLVector2> &texCoords0p,
LLStrider<LLVector2> &texCoords1p,
LLStrider<U16> &indicesp)
What is confusing me is indicesp. I think it has something to do with
connecting vertices, but I'm not sure how. The example code I am
working with uses a mess of lookup tables in the following loop for each
voxel:
//Draw the triangles that were found. There can be up to five per cube
for(iTriangle = 0; iTriangle < 5; iTriangle++)
{
if(a2iTriangleConnectionTable[iFlagIndex][3*iTriangle] < 0)
break;
for(iCorner = 0; iCorner < 3; iCorner++)
{
iVertex =
a2iTriangleConnectionTable[iFlagIndex][3*iTriangle+iCorner];
vGetColor(sColor, asEdgeVertex[iVertex],
asEdgeNorm[iVertex]);
glColor4f(sColor.fX, sColor.fY, sColor.fZ, 0.6);
glNormal3f(asEdgeNorm[iVertex].fX,
asEdgeNorm[iVertex].fY, asEdgeNorm[iVertex].fZ);
glVertex3f(asEdgeVertex[iVertex].fX,
asEdgeVertex[iVertex].fY, asEdgeVertex[iVertex].fZ);
}
}
Can anyone give me any pointers on getting this converted?
Thanks.
Rob
More information about the opensource-dev
mailing list