Hi OpenSG Users !
I recently changed my code and get a "no source information available
error" since then. Very frustrating!
I'm working on a simple Terrain Editor and split the Terrain into
different subnodes, for to get view frustum culling and the like.
First I just duplicated the Vertices that are needed for two adjacent
Nodes. Then I thought it would be nice, if it was possible to share the
vertices between all nodes and just let them have a different index:
_points = GeoPositions3f::create();
beginEditCP(_points);
GeoPositions3f::StoredFieldType * p = _points->getFieldPtr();
// for all vertices:
p->push_back(Pnt3f(x, y, z);
...
endEditCP(_points);
// now all vertices are in _points
// that is: for every subnode
for (int nodesX = 0; nodesX < width/NODE_LENGTH; nodesX++)
{
for (int nodesY = 0; nodesY < width/NODE_LENGTH; nodesY++)
{
GeoIndicesUI32::StoredFieldType * i = index->getFieldPtr();
GeoPLengthsUI32::StoredFieldType * l = lens->getFieldPtr();
GeoPTypesUI8::StoredFieldType * t = types->getFieldPtr();
beginEditCP(index);
beginEditCP(lens);
beginEditCP(types);
t->push_back(GL_QUADS);
// #define NODE_LENGTH 8
int nodeLengthX = NODE_LENGTH;
int nodeLengthY = NODE_LENGTH;
if ( nodesX >= width/NODE_LENGTH-1)
{
nodeLengthX -= 1;
}
if ( nodesY >= width/NODE_LENGTH-1)
{
nodeLengthY -= 1;
}
int length = (nodeLengthX)*(nodeLengthY)*4;
l->push_back( length );
// now indexing into the vertices field _points.
for (int quadX = nodesX*nodeLengthX; quadX <
(nodesX+1)*nodeLengthX; quadX++)
{
for (int quadY = nodesY*nodeLengthY; quadY<
(nodesY+1)*nodeLengthY; quadY++)
{
// points to four vertices that will
// define a single quad
i->push_back(quadX*(width)+quadY);
i->push_back((quadX+1)*(width)+quadY);
i->push_back((quadX+1)*(width)+quadY+1);
i->push_back(quadX*(width)+quadY+1);
}
}
endEditCP(index);
endEditCP(lens);
endEditCP(types);
GeometryPtr geo = Geometry::create();
beginEditCP(geo);
geo->setColors(_colors);
geo->setMaterial(_terrainMaterial);
geo->setPositions(_points);
geo->setNormals(_normals);
geo->getIndexMapping().push_back(Geometry::MapPosition |
Geometry::MapNormal |
Geometry::MapTexCoords);
geo->setTexCoords(tex);
geo->setTexCoords1(tex1);
geo->setIndices(index);
geo->setTypes(types);
geo->setLengths(lens);
endEditCP(geo);
NodePtr terrainSubNode = Node::create();
beginEditCP (terrainSubNode);
terrainSubNode->setCore(geo);
endEditCP (terrainSubNode);
// this is a blitz++-Array, to give me later access to the subnodes.
_terrainSubNodes( nodesX, nodesY)= terrainSubNode;
beginEditCP(_terrainNode);
_terrainNode->addChild(_terrainSubNodes( nodesX, nodesY));
endEditCP(_terrainNode);
}
}
Well - it seems to work.
Now I would be grateful if anyone could verify this code and/or tell me
if this is a valid solution.
Many thanks in advance and greetings,
Tobias Kilian
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users