Disscussion on a possible 2.5D architecture

Minggo has discussed about 3D model support before.

  • A possible architecture may be implemented as this,

CCLayerColor

/|
|
|

C3DLayer

C3DLayer inherits from CCLayerColor and has a member type C3DScene, which is used to manage the 3D scene

All the 3D elements(light, camera, 3D model) inherit from C3DNode, C3DNode implements the basic operation like addChild, setPosition and so on. It plays a role as CCNode in cocos2d-x

code example of building a 3D scene in the subclass of C3DLayer

//create a 3D model named girl 
C3DSprite* sprite = C3DSprite::create("girl");
//load it from file
sprite->loadFromFile("file name");
sprite->setMaterial("material file name");
sprite->setActiveMaterial(0);
sprite->setPosition(0, 0, -10);
//add the model to the scene, last parameter is the parent node
_scene->addNode(sprite, NULL);
sprite->playAnimationClip("animationName");

//add light to the scene, with name light1
C3DLight* light = C3DLight::createDirectional("light1", dir, color);
_scene->addNode(light, NULL);

//add a camera to the scene, with name maincamera
C3DCamera* camera = C3DCamera::createPerspective("maincamera", 45, 0.75f, 10, 1000);
camera->setPosition(0,0,10);
_scene->addNode(camera, NULL);
_scene->setActiveCamera(0); 

The C3DLayer collects 3D elements together, and we can patch render all the 3D objects in the C3DLayer’s draw function, therefore it is easier to optimize it.

  • According to this, we can divid it into several parts, The Model part, Skeleton Animation Part, Render Part and so on.
    In the Model part, we should support skin model and static model.
    In the Skeleton Animation part, we should implement the skeleton animation.
    In the Render part, we should render the static and skin model, maybe 3D particles in the future.
    I will discuss some detail of each part latter.

  • Is this enough for a 2.5D engine?
    Which feature do you expect?
    Any suggestions?
    both about the feature and design
    Feel free to discussion

Yep, i have created another thread discussing it here.

xiao yang andhouguohua are taking charge of adding this new feature for cocos2d-x.

Hi,
At present,We are discussing the technical framework.Welcome everyong to take part in the Discussing.

For model,
two types of model will be support, skinned model and static model,

For animation,
skeleton animation will be implemented

For render
there are two types of render, maybe add particle render in future.

General design as follow,

I haven’t looked at the design of the cocos3d extension for cocos2d-iphone, so I’m not sure if the current design has been taken from there already.
Maybe it makes sense to use an identical/similar API?

See
http://www.cocos2d-iphone.org/archives/1274

@Andre Rudlaff
Thanks for your reply.

I have read about the extension cocos3d, and run the sample, it is a powerful engine.

The design that a 3D Layer inherit from CCLayerColor is learnt from it.

We find that the design is very complex, for example CC3Node, and it is not convenient to animate actor, maybe I did not find the right function.
We hope the basic 3D node is as clean as CCNode in cocos2d, and easily used api about 3D model, animation, and so on.
Therefore we simplify the design. It may be not as powerful as cocos3d engine, but we will add enough 3D feature the 2.5D mobile engine needed. And make the design as clean as cocos2d-x at the same time.

Of course, we will try to use similar api as cocos2d. In fact, the extension cocos3d does very well.

Yep, easy to use, easy to understand is important.

支持你哈