11/08/2018, 22:31

CREATE 3D OBJECTS INSIDE COCOS2D-X

3D objects are objects that occurs on a three-axis Cartesian coordinate system. Cocos2D-x is, as you might infer from its name, a 2d gaming library. But, as it uses OpenGL internally to draw its stuff, we might leverage it to create some 3D objects on the mix. Cocos2D-x use vector 2D but with ...

3D objects are objects that occurs on a three-axis Cartesian coordinate system. Cocos2D-x is, as you might infer from its name, a 2d gaming library. But, as it uses OpenGL internally to draw its stuff, we might leverage it to create some 3D objects on the mix. Cocos2D-x use vector 2D but with C++ we can define vector 3D.

Typedef struct {
    GLfloat x ;
    GLfloat y ;
    GLfloat z ;
} Vector3D ;

But it has some issues like :

  • Doesn’t allow you to draw sprites on top of the boxes.

  • The gluLookAt call shouldn’t be inside the Box class draw method.

  • The color shading is hardcoded.

  • And so on, so on…

Although I don’t recommend using Cocos2D-x for making a complete 3D game, adding some 3D objects might bring some interesting effects.

Example: https://github.com/bacph178/opengltests

References:

  • [1] http             </div>
            
            <div class=

0