ManualObject ->beginUpdate() ???

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
User avatar
mullencm
Gnoblar
Posts: 23
Joined: Sun Oct 30, 2005 8:38 pm

ManualObject ->beginUpdate() ???

Post by mullencm »

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
-chase
cdkeito
Orc
Posts: 468
Joined: Sat Jan 27, 2007 12:06 pm

Post by cdkeito »

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.
virtual 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
http://www.ogre3d.org/phpBB2/viewtopic. ... 6f4e2718c6

hope it help.
Image
User avatar
mullencm
Gnoblar
Posts: 23
Joined: Sun Oct 30, 2005 8:38 pm

Post by mullencm »

Thanks for the reply.

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
cdkeito
Orc
Posts: 468
Joined: Sat Jan 27, 2007 12:06 pm

Post by cdkeito »

From what i've here, you have to add index, a begin and a end in the 1st for and in the 2nd redeclare everything, you can see an example of it in the 1st link i posted above.

You can ever make a test... if you need it you can also do it via shader.
Image
User avatar
mullencm
Gnoblar
Posts: 23
Joined: Sun Oct 30, 2005 8:38 pm

Post by mullencm »

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
-chase