≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
rotate the "camera" by scripts?
Posted by:
(you are not logged in)
Enter the missing letter in: "In?ernational"
(you are not logged in)
Text:
[quote][b][/b] wrote: 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" [code] 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 ccbSetSceneNodeProperty(ccbGetCurrentNode(),"Target",cam_pos.x+Math.sin(cam_dir/57.29)*10,cam_pos.y,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 ccbSetSceneNodeProperty(this.camera_pivot,"Rotation",0,cam_dir,0); } [/code][/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact