To make it more visual, I am trying to 'paint' a rectangle around the editing target area.
rendering the square to show the selected area i am using this theory
based on the target vertice (index), select the vertices around it
012
345
678
with 4 being the actual target but modifying the points around it also. (this all works for editing)
to create the poly i do this
terrain pointer, selected index (4) and width of terrain heightmap
Code: Select all
void setup(ITerrainSceneNode* terrain, int index, int width)
{
scene::IMesh* pMesh = terrain->getMesh();
scene::IMeshBuffer* pMeshBuffer = pMesh->getMeshBuffer(0);
if (pMeshBuffer->getVertexType() != video::EVT_2TCOORDS) return;
video::S3DVertex2TCoords* pVertices = (video::S3DVertex2TCoords*)pMeshBuffer->getVertices();
smallVertices[0].Pos = pVertices[index - 1 + width].Pos;
smallVertices[1].Pos = pVertices[index + width ].Pos;
smallVertices[2].Pos = pVertices[index + 1 + width].Pos;
smallVertices[3].Pos = pVertices[index - 1].Pos;
smallVertices[4].Pos = pVertices[index].Pos;
smallVertices[5].Pos = pVertices[index + 1].Pos;
smallVertices[6].Pos = pVertices[index - 1 - width].Pos;
smallVertices[7].Pos = pVertices[index - width ].Pos;
smallVertices[8].Pos = pVertices[index + 1 - width].Pos;
for (int c = 0; c < 9; c++)
{
smallVertices[c].Pos.Y += 10;
smallVertices[c].Normal = vector3df(0, 1, 0);
}
}
i then try to render like this
Code: Select all
virtual void render()
{
u16 smallindices[27] =
{ 0,1,3,
3,1,4,
1,2,4,
4,2,5,
3,4,6,
6,4,7,
4,5,7,
7,5,8};
video::IVideoDriver* driver = SceneManager->getVideoDriver();
driver->setMaterial(Material);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->drawVertexPrimitiveList(&smallVertices[0], 9, &smallindices[0], 8, video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT);
}
any help is appreciated.