I am using cocos2d-x 3.4final
I have a scene that have two models in it,one of the road and another is a car.
When i wrote code like this the car was covered by the road:
mCamera = Camera::createPerspective(60, vs.width/vs.height, 0.01, 2600);
mCamera->setCameraFlag(CameraFlag::USER1);
mCamera->setPosition3D(Vec3(vs.width/2, 0, 1100));
mCamera->lookAt(Vec3(vs.width/2,vs.height*3/5,0));
addChild(mCamera);
Sprite3D* test = Sprite3D::create("road.c3b");
test->setPosition3D(Vec3(vs.width/2, vs.height/2, 0));
test->setCameraMask((unsigned int)CameraFlag::USER1);
addChild(test);
Sprite3D* car1 = Sprite3D::create("car1.c3b");
car1->setPosition3D(Vec3(vs.width/2, vs.height/2,42.1));
car1->setCameraMask((unsigned int)CameraFlag::USER1);
addChild(car1);
This is the screen shot:
When i wrote code like this the car was displayed on the road :
mCamera = Camera::createPerspective(60, vs.width/vs.height, 0.01, 2600);
mCamera->setCameraFlag(CameraFlag::USER1);
mCamera->setPosition3D(Vec3(vs.width/2, vs.height/2, 1100));
mCamera->lookAt(Vec3(vs.width/2,vs.height/2,0));
addChild(mCamera);
//Other codes as same as the first codes
This is the screen shot:
All differences just two row.
the car was covered by the road:
mCamera->setPosition3D(Vec3(vs.width/2, 0, 1100));
mCamera->lookAt(Vec3(vs.width/2,vs.height*3/5,0));
The car was displayed on the road:
mCamera->setPosition3D(Vec3(vs.width/2, vs.height/2, 1100));
mCamera->lookAt(Vec3(vs.width/2,vs.height/2,0));
Is this a 3D Camera bug? or i worte the wrong code?