tBane Temat założony przez niniejszego użytkownika |
[Irrlicht] Renderowanie Tekstury » 2024-02-19 15:26:03 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. float outerRadius = 10.0f; float innerRadius = outerRadius * 0.866025404f;
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" ) ); Vertices[ 0 ] = video::S3DVertex( 0, 0, 0, 0, 0, 0, video::SColor( 255, 48, 48, 48 ), 0, 0 ); 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; } };
|
|
tBane Temat założony przez niniejszego użytkownika |
» 2024-02-19 16:18:00 Zmieniłem parametry centralnego punktu i faktycznie renderuje tylko jeden kolor. Jak to naprawić ? Vertices[ 0 ] = video::S3DVertex( 0, 0, 0, 0, 0, 0, video::SColor( 255, 255, 255, 255 ), 0, 0 ); |
|
DejaVu |
» 2024-02-19 16:20:01 Może nie załadowałeś tekstury w ogóle? |
|
tBane Temat założony przez niniejszego użytkownika |
» 2024-02-19 16:26:57 Załadowałem. W miejsca tu, tv (współrzędne tekstury) wstawiłem współrzędne wierzchołków oto jaki efekt otrzymałem. Vertices[ 0 ] = video::S3DVertex( 0, 0, 0, 0, 0, 0, video::SColor( 255, 255, 255, 255 ), 0, 0 ); Vertices[ 1 ] = video::S3DVertex( 0.0f, 0, outerRadius, 0, 0, 0, video::SColor( 255, 128, 48, 48 ), 0, outerRadius ); Vertices[ 2 ] = video::S3DVertex( innerRadius, 0, outerRadius * 0.5f, 0, 0, 0, video::SColor( 255, 128, 48, 48 ), innerRadius, outerRadius * 0.5f ); Vertices[ 3 ] = video::S3DVertex( innerRadius, 0, - outerRadius * 0.5f, 0, 0, 0, video::SColor( 255, 128, 48, 48 ), innerRadius, - outerRadius * 0.5f ); Vertices[ 4 ] = video::S3DVertex( 0.0f, 0, - outerRadius, 0, 0, 0, video::SColor( 255, 128, 48, 48 ), 0, - outerRadius ); Vertices[ 5 ] = video::S3DVertex( - innerRadius, 0, - outerRadius * 0.5f, 0, 0, 0, video::SColor( 255, 128, 48, 48 ), - innerRadius, - outerRadius * 0.5f ); Vertices[ 6 ] = video::S3DVertex( - innerRadius, 0, outerRadius * 0.5f, 0, 0, 0, video::SColor( 255, 128, 48, 48 ), - innerRadius, outerRadius * 0.5f ); Vertices[ 7 ] = video::S3DVertex( 0.0f, 0, outerRadius, 0, 0, 0, video::SColor( 255, 128, 48, 48 ), 0, outerRadius );
|
|
tBane Temat założony przez niniejszego użytkownika |
» 2024-02-19 16:26:57 W miejsca tu, tv (współrzędne tekstury) wstawiłem dane z zakresu [0.0f, 1.0f]. Problem rozwiązany!video::SColor color = video::SColor( 255, 255, 255, 255 );
Vertices[ 0 ] = video::S3DVertex( 0, 0, 0, 0, 0, 0, color, 0, 0 ); Vertices[ 1 ] = video::S3DVertex( 0.0f, 0, outerRadius, 0, 0, 0, color, 0, 1 ); Vertices[ 2 ] = video::S3DVertex( innerRadius, 0, outerRadius * 0.5f, 0, 0, 0, color, 1, 0.5f ); Vertices[ 3 ] = video::S3DVertex( innerRadius, 0, - outerRadius * 0.5f, 0, 0, 0, color, 1, - 0.5f ); Vertices[ 4 ] = video::S3DVertex( 0.0f, 0, - outerRadius, 0, 0, 0, color, 0, - 1 ); Vertices[ 5 ] = video::S3DVertex( - innerRadius, 0, - outerRadius * 0.5f, 0, 0, 0, color, - 1, - 0.5f ); Vertices[ 6 ] = video::S3DVertex( - innerRadius, 0, outerRadius * 0.5f, 0, 0, 0, color, - 1, 0.5f ); Vertices[ 7 ] = video::S3DVertex( 0.0f, 0, outerRadius, 0, 0, 0, color, 0, 1 );
|
|
« 1 » |