Code: Select all
class CFloorSceneNode : public scene::ISceneNode
{
core::aabbox3d<f32> Box;
video::S3DVertex Vertices[4];
video::SMaterial Material;
public:
CFloorSceneNode(irr_wrapper & parent, s32 id, char * tex, float size)
: scene::ISceneNode(parent.getSmgr()->getRootSceneNode(), parent.getSmgr(), id)
{
Material.Wireframe = false;
Material.Lighting = false;
setMaterialTexture(0, parent.getDriver()->getTexture(tex));
float half_size = size / 2.f;
Vertices[0] = video::S3DVertex(half_size,half_size,0, 0,0,1, video::SColor(255,255,255,255), 1, 0);
Vertices[1] = video::S3DVertex(half_size,-half_size,0, 0,0,1, video::SColor(255,255,255,255), 1, 1);
Vertices[2] = video::S3DVertex(-half_size,-half_size,0, 0,0,1, video::SColor(255,255,255,255), 0, 1);
Vertices[3] = video::S3DVertex(-half_size,half_size,0, 0,0,1, video::SColor(255,255,255,255), 0, 0);
Box.reset(Vertices[0].Pos);
for (s32 i=1; i<4; ++i)
Box.addInternalPoint(Vertices[i].Pos);
}
virtual void OnRegisterSceneNode()
{
if (IsVisible)
SceneManager->registerNodeForRendering(this);
ISceneNode::OnRegisterSceneNode();
}
virtual void render()
{
u16 indices[] = { 0,2,1, 2,0,3 };
video::IVideoDriver* driver = SceneManager->getVideoDriver();
driver->setMaterial(Material);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->drawIndexedTriangleList(&Vertices[0], 4, &indices[0], 2);
}
virtual const aabbox3d<f32>& getBoundingBox() const { return Box; }
virtual u32 getMaterialCount() { return 1; }
virtual SMaterial& getMaterial(u32 i) { return Material; }
};