Bonjour,
Je souhaite afficher un cube, pour cela j'utilise le code suivant qui devrait permettre de l'afficher via des triangles ou via des carrés
JE NE SOUHAITE PAS UTILISER LE CUBE NI LES TRIANGLES, je souhaite utiliser les carrés, je me fiche des problèmes de performances pour le moment, j'y arrivait aisément directement avec opengl, je mouline dans la bouillie via irrlicht!!
//called once per instance of XXXX
void XXXX::init ( void ) {
registerObservableEventType ( EV_CARD_SWAP );
registerObservableEventType ( EV_CARD_SUITE_OR_VALUE_CHANGED );
m_px = m_confManager.getFloat ( IRRCARD32_F_POSITIONX );
m_py = m_confManager.getFloat ( IRRCARD32_F_POSITIONY );
m_pz = m_confManager.getFloat ( IRRCARD32_F_POSITIONZ );
m_wx = m_confManager.getFloat ( IRRCARD32_F_WIDTHX );
m_wy = m_confManager.getFloat ( IRRCARD32_F_WIDTHY );
m_wz = m_confManager.getFloat ( IRRCARD32_F_WIDTHZ );
Material.Wireframe = false;
Material.Lighting = false;
Vertices[0] = irr::video::S3DVertex ( 0, 0, 0, -1, -1, -1,
video::SColor(255,0,255,255), 0, 1);
Vertices[1] = irr::video::S3DVertex ( 0, m_wy, 0, -1,1,-1,
video::SColor(255,0,255,255), 0, 1);
Vertices[2] = irr::video::S3DVertex ( m_wx, m_wy, 0, 1,1,-1,
video::SColor(255,0,255,255), 0, 1);
Vertices[3] = irr::video::S3DVertex ( m_wx, 0, 0, 1,-1,-1,
video::SColor(255,0,255,255), 0, 1);
Vertices[4] = irr::video::S3DVertex ( 0 , 0 , m_wz , -1,-1,1,
video::SColor(255,0,255,255), 0, 1);
Vertices[5] = irr::video::S3DVertex ( 0 , m_wy , m_wz , -1,1,1,
video::SColor(255,0,255,255), 0, 1);
Vertices[6] = irr::video::S3DVertex ( m_wx , m_wy , m_wz , 1,1,1,
video::SColor(255,0,255,255), 0, 1);
Vertices[7] = irr::video::S3DVertex ( m_wx , 0 , m_wz , 1,-1,1,
video::SColor(255,0,255,255), 0, 1);
Box.reset(Vertices[0].Pos);
Box.addInternalPoint(Vertices[1].Pos);
Box.addInternalPoint(Vertices[2].Pos);
Box.addInternalPoint(Vertices[3].Pos);
Box.addInternalPoint(Vertices[4].Pos);
Box.addInternalPoint(Vertices[5].Pos);
Box.addInternalPoint(Vertices[6].Pos);
Box.addInternalPoint(Vertices[7].Pos);
update ( );
}
void XXXX::render ( void ) {
u16 indices_quads[] = {
0,1,2,3,
3,2,6,7,
7,4,5,6,
4,0,1,5,
1,5,6,2,
0,3,7,4
};
u16 indices_triangles[] = {
0, 1, 3,
1, 2, 3,
3, 2, 7,
2, 6, 7,
7, 6, 5,
5, 4, 7,
5, 1, 0,
5, 0, 4,
5, 2, 1,
5, 6, 2,
0, 3, 4,
4, 3, 7
};
getEngine ( ).getDriver ( )->setMaterial ( Material );
//getEngine ( ).getDriver ( )->setTransform ( video::ETS_WORLD, AbsoluteTransformation );
//getEngine ( ).getDriver ( )->drawIndexedTriangleList ( &(Vertices[0]), 8, &(indices_triangles[0]), 12 );
//getEngine ( ).getDriver ( )->setMaterial ( Material );
getEngine ( ).getDriver ( )->drawVertexPrimitiveList ( &(Vertices[0]), 8, &(indices_quads[0]), 1, EVT_STANDARD, EPT_QUADS );
getEngine ( ).getDriver ( )->drawVertexPrimitiveList ( &(Vertices[0]), 8, &(indices_quads[4]), 1, EVT_STANDARD, EPT_QUADS );
getEngine ( ).getDriver ( )->drawVertexPrimitiveList ( &(Vertices[0]), 8, &(indices_quads[8]), 1, EVT_STANDARD, EPT_QUADS );
getEngine ( ).getDriver ( )->drawVertexPrimitiveList ( &(Vertices[0]), 8, &(indices_quads[12]), 1, EVT_STANDARD, EPT_QUADS );
getEngine ( ).getDriver ( )->drawVertexPrimitiveList ( &(Vertices[0]), 8, &(indices_quads[16]), 1, EVT_STANDARD, EPT_QUADS );
getEngine ( ).getDriver ( )->drawVertexPrimitiveList ( &(Vertices[0]), 8, &(indices_quads[20]), 1, EVT_STANDARD, EPT_QUADS );
}
Pas de bol, rien ne s'affiche si j'utilise la methode drawVertexPrimitiveList, en revanche pas de problème si je decommente la ligne getEngine ( ).getDriver ( )->drawIndexedTriangleList ( &(Vertices[0]), 8, &(indices_triangles[0]), 12 ); pour l'afficher sous forme de triangles.
Qu'ai-je omis ou mal fait?
Merci.