( editing code works fine)
my thought was to create a node with 9 vertices to create 8 triangles, giving me 4 squares rendered.
vertex #4 would be the center of the node and I would use setPosition(pos) to set the node to the correct location.
(using a cube works fine, but I am wanting just a plane that always faces up, thinking I would edit the Y pos of each vertex based on the terrain height.)
since the plane always faces up, I thought to use vector3df(0,1,0) as the normal for all vertices.
// 0 1 2
// 3 4 5
// 6 7 8
Code: Select all
class FSTerrainEditorNode : public scene::ISceneNode
{
core::aabbox3d<f32> Box;
video::S3DVertex Vertices[9];
video::SMaterial Material;
public:
FSTerrainEditorNode(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id) : scene::ISceneNode(parent, mgr, id)
{
Material.Wireframe = true;
Material.Lighting = false;
// 0 1 2
// 3 4 5
// 6 7 8
vector3df always_up_vector(0, 1, 0);
Vertices[0] = video::S3DVertex(-10, 0, -10, always_up_vector.X,always_up_vector.Y,always_up_vector.Z, video::SColor(255, 0, 255, 255), 0, 0);
Vertices[1] = video::S3DVertex(0, 0, -10, always_up_vector.X,always_up_vector.Y,always_up_vector.Z, video::SColor(255, 255, 0, 255), 0.5, 0);
Vertices[2] = video::S3DVertex(10, 0, -10, always_up_vector.X,always_up_vector.Y,always_up_vector.Z, video::SColor(255, 255, 255, 0), 1, 0);
Vertices[3] = video::S3DVertex(-10, 0, 0, always_up_vector.X,always_up_vector.Y,always_up_vector.Z, video::SColor(255, 0, 255, 0), 0, 0.5);
Vertices[4] = video::S3DVertex(0, 0, 0, always_up_vector.X,always_up_vector.Y,always_up_vector.Z, video::SColor(255, 0, 255, 0), 0.5, 0.5);
Vertices[5] = video::S3DVertex(10, 0, 0, always_up_vector.X,always_up_vector.Y,always_up_vector.Z, video::SColor(255, 0, 255, 0), 1, 0.5);
Vertices[6] = video::S3DVertex(-10, 0, 10, always_up_vector.X,always_up_vector.Y,always_up_vector.Z, video::SColor(255, 0, 255, 0), 0, 1);
Vertices[7] = video::S3DVertex(0, 0, 10, always_up_vector.X,always_up_vector.Y,always_up_vector.Z, video::SColor(255, 0, 255, 0), 0.5, 1);
Vertices[8] = video::S3DVertex(10, 0, 10, always_up_vector.X,always_up_vector.Y,always_up_vector.Z, video::SColor(255, 0, 255, 0), 1, 1);
Box.reset(Vertices[0].Pos);
for (s32 i = 1; i < 8; ++i)
Box.addInternalPoint(Vertices[i].Pos);
}
virtual void OnRegisterSceneNode()
{
if (IsVisible)
SceneManager->registerNodeForRendering(this);
ISceneNode::OnRegisterSceneNode();
}
virtual void render()
{
// 0 1 2
// 3 4 5
// 6 7 8
u16 indices[] = { 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(&Vertices[0], 9, &indices[0], 8, video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT);
}
virtual const core::aabbox3d<f32>& getBoundingBox() const
{
return Box;
}
virtual u32 getMaterialCount() const
{
return 1;
}
virtual video::SMaterial& getMaterial(u32 i)
{
return Material;
}
void setVertexPosition(int index, vector3df pos)
{
//Vertices[index].Pos.Y = pos.Y;
}
};
this is not showing up when rendered. any help on getting this going would be appreciated.
Seven