No subject


Wed Apr 28 21:25:55 PDT 2010


at are offsets to vertexes in the vertex buffer. Read it as the vertexes no=
rmals and all this other stuff being in static arrays. It then runs through=
 the indice list and runs the associated glVertex3f commands or whatever on=
 the vertex at the specified index on the array. This is done for all data =
types.<br>

<br>vector&lt;LLVector3&gt; verts;<br>vector&lt;LLVector4&gt; colors;<br>ve=
ctor&lt;LLVector3&gt; normals;<br>U16 indices[3] =3D {0, 1, 2, 1};<br><br>f=
or(U16 i =3D 0; i &lt; 3; ++i)<br>{<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 U16 x =3D indices[i];<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =
glColor4f(colors[x].mV[0],colors[x].mV[1],colors[x].mV[2],colors[x].mV[3]);=
<br>

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 glNormal3f(normals[x].mV[0],norm=
als[x].mV[1],normals[x].mV[2]);<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 glVertex3f(verts[x].mV[0],verts[x].mV[1],verts[x].mV[2]);<br>}<br><br>I=
s the most simple example I can think of that would demonstrate how it work=
s internally.<br>

<br>In the code example you have, the vertexes are drawn one by one in imme=
diate mode, which is both slow, and undesired. You will have to do some res=
earch into using proper vertex buffers to properly convert the code.<br>

<br><div class=3D"gmail_quote">On Wed, Jun 2, 2010 at 19:35, Rob Nelson <sp=
an dir=3D"ltr">&lt;<a href=3D"mailto:nexisentertainment at gmail.com">nexisent=
ertainment at gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_qu=
ote" style=3D"margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 20=
4, 204); padding-left: 1ex;">

I am almost to the point of going crazy. =C2=A0I was going to write a<br>
notecard to a Linden, but I&#39;ve been knocked out of SL for reasons<br>
unknown, so I&#39;ll have to ask here.<br>
<br>
In my infinite lack of wisdom, I decided to start working on a project<br>
where I replace the heightmap terrain in Second Life with one based on<br>
voxels. =C2=A0To get to the core of the reasoning behind this switch so I<b=
r>
don&#39;t spend too much time on it:<br>
<br>
=C2=A0* Voxel-based land allows creation of overhangs/caves/floating chunks=
<br>
of land (not possible with heightmaps)<br>
=C2=A0* Also adds the ability to handle up to 255 terrain materials<br>
(textures, eventually detail shaders) instead of 4, and the materials<br>
are placed where desired instead of at fractional heights.<br>
<br>
I am working on the rendering code in the SL viewer at the moment,<br>
having completed the server-side code and some of the client-side<br>
packet-handling classes. =C2=A0However, I have zero familiarity with OpenGL=
,<br>
so bear with me.<br>
<br>
My viewer needs to construct a terrain surface (a mesh) for display. =C2=A0=
I<br>
have completed an LLViewerObject to this end, except for:<br>
<br>
::getGeometry(LLStrider&lt;LLVector3&gt; &amp;verticesp,<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0LLStrider&lt;LLVector3&gt; &amp;normalsp,<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0LLStrider&lt;LLColor4U&gt; &amp;colorsp,<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0LLStrider&lt;LLVector2&gt; &amp;texCoords0p,<br=
>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0LLStrider&lt;LLVector2&gt; &amp;texCoords1p,<br=
>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0LLStrider&lt;U16&gt; &amp;indicesp)<br>
<br>
What is confusing me is indicesp. =C2=A0I think it has something to do with=
<br>
connecting vertices, but I&#39;m not sure how. =C2=A0The example code I am<=
br>
working with uses a mess of lookup tables in the following loop for each<br=
>
voxel:<br>
<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0//Draw the triangles that were found. =C2=A0The=
re can be up to five per cube<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0for(iTriangle =3D 0; iTriangle &lt; 5; iTriangl=
e++)<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0{<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if(a2iTriangleConnectionTable[iFl=
agIndex][3*iTriangle] &lt; 0)<br>
break;<br>
<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0for(iCorner =3D 0; iCorner &lt; 3=
; iCorner++)<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0iVertex =3D<br>
a2iTriangleConnectionTable[iFlagIndex][3*iTriangle+iCorner];<br>
<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vGetColor(sColor, a=
sEdgeVertex[iVertex],<br>
asEdgeNorm[iVertex]);<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0glColor4f(sColor.fX=
, sColor.fY, sColor.fZ, 0.6);<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0glNormal3f(asEdgeNo=
rm[iVertex].fX,<br>
asEdgeNorm[iVertex].fY, =C2=A0 asEdgeNorm[iVertex].fZ);<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0glVertex3f(asEdgeVe=
rtex[iVertex].fX,<br>
asEdgeVertex[iVertex].fY, asEdgeVertex[iVertex].fZ);<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0}<br>
<br>
Can anyone give me any pointers on getting this converted?<br>
<br>
Thanks.<br>
<br>
Rob<br>
<br>
_______________________________________________<br>
Policies and (un)subscribe information available here:<br>
<a href=3D"http://wiki.secondlife.com/wiki/OpenSource-Dev" target=3D"_blank=
">http://wiki.secondlife.com/wiki/OpenSource-Dev</a><br>
Please read the policies before posting to keep unmoderated posting privile=
ges<br>
</blockquote></div><br>

--0016e6d7e06cb06f0104881edab7--


More information about the opensource-dev mailing list