-1

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 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 😕/build-failed.blogspot.com/2012/05/create-3d-objects-inside-cocos2d-x.html

  • [2] http 😕/jameshui.tumblr.com/post/29459200037/rendering-simple-3d-objects-and- md2-models-with

  • [3] http 😕/www.cocos2d-x.org/news/67


All rights reserved

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí