Getting the Vertices of the terrain:

Code: Select all

```
Ogre::Vector3 offset = mTerrainInfo->getOffset();
Ogre::Vector3 scale = mTerrainInfo->getScaling();
size_t tWidth = mTerrainInfo->getWidth();
size_t tHeight = mTerrainInfo->getHeight();
Ogre::ManualObject* tManualObject = new ManualObject("terrainMesh");
tManualObject->estimateVertexCount(tWidth * tHeight);
tManualObject->begin("BaseWhiteNoLighting", RenderOperation::OT_TRIANGLE_LIST);
// Create vertices
std::vector<Ogre::Vector3> vertices;
for(size_t h = 0; h < tHeight; h++)
{
for(size_t w = 0; w < tWidth; w++)
{
Ogre::Vector3 v3(
offset.x + w * scale.x,
offset.y + mTerrainInfo->at(w,h) * scale.y,
offset.z + h * scale.z
);
tManualObject->position(v3);
vertices.push_back(v3);
}
}
tManualObject->end();
mSceneManager->getRootSceneNode()->attachObject(tManualObject);
```

From this picture the vertices look correct. Its the indices that I give me a hard time.

I have searched for other threads and not found much on indices. Part of the problem is that I don't understand how they work!

Code: Select all

`Ogre::ManualObject::index(Ogre::uint16 idx)`

How can three idx (uint16) values be used to make a triangle? For example, what does index(0), index(5), and index(10) do for me? (Is this related to the list of Vertices, or the order at which I called "position" on the ManualObject? What is the relation?)

Should I use the "index" function, or the "triangle" or "quad" function? (pros/cons?)

This is my current code. Sorry for the noob code.

Code: Select all

```
for( size_t h = 0; h < tHeight - 1; h++)
{
for( size_t w = 0; w < tWidth - 1; w++)
{
/*
tManualObject->quad(
(h+1) + (w+1) * tWidth,
h + (w+1) * tWidth,
h + w * tWidth,
(h+1) + w * tWidth);
*/
tManualObject->quad(
(h * tWidth) + w,
((h+1) * tWidth) + w,
(h * tWidth) + (w+1),
((h+1) * tWidth) + (w+1));
/*
tManualObject->index((h+1) + (w+1) * tWidth);
tManualObject->index((h+1) + w * tWidth);
tManualObject->index(h + w * tWidth);
tManualObject->index((h+1)+(w+1) * tWidth);
tManualObject->index(h + w * tWidth);
tManualObject->index(h + (w+1) * tWidth);
/*
tManualObject->index((h * tHeight) + w);
tManualObject->index((h * tHeight) + (w + 1));
tManualObject->index((h + 1) * tHeight + w);
tManualObject->index((h + 1) * tHeight + w);
tManualObject->index((h * tHeight) + (w + 1));
tManualObject->index((h + 1) * tHeight + (w + 1));
*/
}
}
```

If anybody can provide any information on this please do, I'm trying to get ETM compatible with OgreOpcode, and integrate it into a demo for users.

Thanks for any help,

KungFooMasta