Witam.
Piszę prostą mapę do gry i potrzebuję nałożyć teksturę na sześciokątną figurę (HexTile).
Nie wiem gdzie w moim kodzie jest błąd.
class HexTile : public scene::ISceneNode
{
core::aabbox3d<f32> Box;
video::S3DVertex Vertices[8];
video::SMaterial Material;
public:
HexTile(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id)
: scene::ISceneNode(parent, mgr, id)
{
Material.Wireframe = false;
Material.Lighting = false;
Material.setTexture(0,driver->getTexture("Media/grass.png"));
// verticves of hexagons
Vertices[0] = video::S3DVertex(0, 0, 0, 0, 0, 0, video::SColor(255, 48, 48, 48), 0, 0); // CENTER OF HEXTILE
Vertices[1] = video::S3DVertex(0.0f, 0, outerRadius, 0, 0, 0, video::SColor(255, 128, 48, 48), 0, 0);
Vertices[2] = video::S3DVertex(innerRadius, 0, outerRadius * 0.5f, 0, 0, 0, video::SColor(255, 128, 48, 48), 0, 0);
Vertices[3] = video::S3DVertex(innerRadius, 0, -outerRadius * 0.5f, 0, 0, 0, video::SColor(255, 128, 48, 48), 0, 0);
Vertices[4] = video::S3DVertex(0.0f, 0, -outerRadius, 0, 0, 0, video::SColor(255, 128, 128, 48), 0, 0);
Vertices[5] = video::S3DVertex(-innerRadius, 0, -outerRadius * 0.5f, 0, 0, 0, video::SColor(255, 128, 48, 48), 0, 0);
Vertices[6] = video::S3DVertex(-innerRadius, 0, outerRadius * 0.5f, 0, 0, 0, video::SColor(255, 128, 48, 48), 0, 0);
Vertices[7] = video::S3DVertex(0.0f, 0, outerRadius, 0, 0, 0, video::SColor(255, 128, 48, 48), 0, 0);
Box.reset(Vertices[0].Pos);
for (s32 i = 1; i < 7; ++i)
Box.addInternalPoint(Vertices[i].Pos);
}
virtual void OnRegisterSceneNode()
{
if (IsVisible)
SceneManager->registerNodeForRendering(this);
ISceneNode::OnRegisterSceneNode();
}
virtual void render()
{
u16 indices[] = { 0, 1, 2, /**/ 0, 2, 3, /**/ 0, 3, 4, /**/ 0, 4, 5, /**/ 0, 5, 6, /**/ 0, 6, 7 };
IVideoDriver* driver = SceneManager->getVideoDriver();
driver->setMaterial(Material);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->drawVertexPrimitiveList(&Vertices[0], 3, &indices[0], 6, 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;
}
};