Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
rotate the "camera" by scripts?

Registered User
2022-12-22 15:39:44

Is possibile to rotate the "camera" by scripts on buttons?
I have 2 buttons, arrow right and arrow left.
I would like when a user click on right or left arrow, the "camera" rotate like happens with mouse or fingers on screen.

I dont know if that is possible...

Registered User
2022-12-22 16:10:30

Its possible.

You can rotate camera target around camera position.

There is action set camera target.. maybe its possible without script if you add node and childnode to it.. put camera at node position and set camera target to childnode you rotate node and its child rotates with it so the camera target ( havent done it with this way so no idea does it work )

Registered User
2022-12-23 01:02:31

here is easy way to make something like camera rotation
put camera inside pivot node and put this code inside "before first drawing do something"

var cam_pos = null; //camera pivot position need for camera target
var cam_dir = null; //camera direction (y axis) need for rotate and target
var cam_rot_spd = 2; //rotating speed

function camera_setup(pivot){
//this function is called every few milliseconds
//'pivot' the name of the scene node used as the camera pivot
this.camera_pivot = ccbGetSceneNodeFromName(pivot); //set camera pivot
cam_pos = ccbGetSceneNodeProperty(this.camera_pivot,"PositionAbs"); //get pivot position
cam_dir = ccbGetSceneNodeProperty(this.camera_pivot,"Rotation").y; //get pivot direction
//set camera target to 10 in pivot direction
//cam_pos.x+Math.sin(cam_dir/57.29)*10 && cam_pos.z+Math.cos(cam_dir/57.29)*10
function camera_rotation(left, right){
//call this function on key pressed, has two boolean 'left' and 'right'
if(left) cam_dir -= cam_rot_spd;
else if(right) cam_dir += cam_rot_spd;
//set pivot rotation

Create reply:

Posted by: (you are not logged in)

Enter the missing letter in: "Inter?ational" (you are not logged in)




Possible Codes

Feature Code
Link [url] [/url]
Bold [b]bold text[/b]
Image [img][/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]



Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact