Minggo has discussed about 3D model support before.
- A possible architecture may be implemented as this,
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?
both about the feature and design
Feel free to discussion