winipcfg.exe:
this patch improves the API a little bit: https://github.com/cocos2d/cocos2d-x/pull/5049
History of Camera
:
Back in 2008, in order to have 3D effects I introduced the Camera
concept in Node
.
But it was kind of hack because:
* The Camera
was always looking at the center of the screen
* It was confusing because it was not the Scene camera. It was a per-node camera that was only useful for a couple of things
* The parent-child transform matrix didn’t include the Camera
So, what I tried to do in v3.0 beta was:
* Remove the concept of “each node has a Camera”
* Simplify the parent-child transform matrix
* Provide a way for users to keep doing the “camera” effect, but without the “Camera” object… (We will re-introduce the Camera concept in the near future, but it will be the Scene’s camera).
How ?
In v3.0-beta, both the “transform matrix” and the “additional transform matrix” were converted from 3x2 to 4x4.
That means that it is possible to transform each node in a real 3d space.
Why would you want that ? Well, that depends on your game, but 95% of the users won’t care about this new feature.
But this also means that it is possible to do any kind of 3d transformation on a node… including the old Camera effects without using a Camera.
As example, the Camera
object was setting a GL Lookup Matrix… so in v3.0 you can do it yourself by doing:
auto sprite2 = Sprite::create("hello.png");
kmVec3 eye, center, up;
kmVec3Fill(&eye, 150, 0, 200);
kmVec3Fill(¢er, 0, 0, 0);
kmVec3Fill(&up, 0, 1, 0);
kmMat4 lookupMatrix;
kmMat4LookAt(&lookupMatrix, &eye, ¢er, &up);
sprite2->setAdditionalTransform(lookupMatrix);
Benefits:
* cocos2d-x code is easier to understand, maintain an extend
* It is possible to add new 3D effects
Disadvantages:
* Users who were using the Camera
API directly, will need to do it manually.
What do you think about it?