I have surfed around for a while and could not get clarity on this.
I make a ManualObject with begin() and end() the first time.
Then I want to go back ( using beginUpdate() and end() ) and edit it, specifically I want to use the same vertex(s) but change the index(s).
Do I have to remake the vertex(s)???
This is in the context of a terrain manager, a big set of elevation data broke into tiles and then assigned different LODs that skip every other vertex or ever 4th or 8th....
thanks
ManualObject ->beginUpdate() ???
-
- Gnoblar
- Posts: 23
- Joined: Sun Oct 30, 2005 8:38 pm
-
- Orc
- Posts: 468
- Joined: Sat Jan 27, 2007 12:06 pm
You can also use beginUpdate() to alter the geometry later on if you wish. If you do this, you should call setDynamic(true) before your first call to begin(), and also consider using estimateVertexCount / estimateIndexCount if your geometry is going to be growing, to avoid buffer recreation during growth.
http://www.ogre3d.org/phpBB2/viewtopic. ... 6f4e2718c6virtual void Ogre::ManualObject::beginUpdate ( size_t sectionIndex ) [virtual]
Start the definition of an update to a part of the object.
Remarks:
Using this method, you can update an existing section of the object efficiently. You do not have the option of changing the operation type obviously, since it must match the one that was used before.
Note:
If your sections are changing size, particularly growing, use estimateVertexCount and estimateIndexCount to pre-size the buffers a little larger than the initial needs to avoid buffer reconstruction.
Parameters:
sectionIndex The index of the section you want to update. The first call to begin() would have created section 0, the second section 1, etc.
http://www.ogre3d.org/phpBB2/viewtopic. ... 6f4e2718c6
hope it help.
-
- Gnoblar
- Posts: 23
- Joined: Sun Oct 30, 2005 8:38 pm
Thanks for the reply.
I did read both of those though. I will try to be more specific.
Can I run makeMesh() and then run updateManObj() as they are?
or
Do I have to rebuild the vertex list in the updateManObj()?
I did read both of those though. I will try to be more specific.
Code: Select all
Ogre::ManualObject* floatGRID::makeMesh()
{
Ogre::ManualObject* manObj = new Ogre::ManualObject("Name");
manObj->setDynamic(true);
manObj->estimateVertexCount( someGuess);
manObj->estimateIndexCount( someGuess );
for(long r = 0; r < rows; r++)
{
for(long c = 0; c < cols; c++)
{
manObj->position( someVector3 );
manObj->normal( someOtherVector3 );
manObj->textureCoord( u,v );
}
}
return(manObj);
}
Ogre::ManualObject* floatGRID::updateManObj(Ogre::ManualObject* mo)
{
for(long r = 0; r < rows; r++)
{
for(long c = 0; c < cols; c++)
{
manObj->triangle( vertexID1, vertexID2, vertexID3 );
}
}
}
Can I run makeMesh() and then run updateManObj() as they are?
or
Do I have to rebuild the vertex list in the updateManObj()?
-chase
-
- Orc
- Posts: 468
- Joined: Sat Jan 27, 2007 12:06 pm
-
- Gnoblar
- Posts: 23
- Joined: Sun Oct 30, 2005 8:38 pm
thanks
I very much like the simplicity of the manualObject but I sure that but rebuilding the Vertex list for every is unnecessarily costly (considering that I don't really need to change them ever).
To implement an update scheme that only involves changing the index(s) I would have to dive in the the Vertex and Index Buffers in a simular way to
http://www.ogre3d.org/wiki/index.php/GeneratingAMesh
SUCK
I very much like the simplicity of the manualObject but I sure that but rebuilding the Vertex list for every is unnecessarily costly (considering that I don't really need to change them ever).
To implement an update scheme that only involves changing the index(s) I would have to dive in the the Vertex and Index Buffers in a simular way to
http://www.ogre3d.org/wiki/index.php/GeneratingAMesh
SUCK
-chase