we want to port camera code from cocos2d-x version 2 to version 3.3 with the goal to imitate the behaviour of a CCCamera in cocos2d-x version 2 exactly.
You can assume that values for "eye" and "up" are calculated correctly.
Old code operating on CCCamera:
camera->setEyeXYZ(eye.x, eye.y, 0); camera->setCenterXYZ(eye.x, eye.y, -1); camera->setUpXYZ(up.x, up.y, 0);New code operating on Camera:
camera->setPosition3D(Vec3(eye.x, eye.y, 0.0f)); camera->lookAt(Vec3(eye.x, eye.y, -1), Vec3(up.x, up.y, 0.0f));The setPosition3D part works fine and this is also a good indicator that I've set up the camera correctly in terms of setCameraFlag and Mask, correct layers, etc. but for some reason the tilting (modification of the up vector) doesn't work fine, it's kind of hard to describe, but it doesn't seem that the view matrix is calculated as intended.
The examples only contain code with fixed up vectors, e.g. Vec3(0, 1, 0), but I really need a dynamic one.
Thanks in advance, Chris
No comments:
Post a Comment