ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Help with CopperCube
forum topic indicator Camera follows 2 object
person icon
Manomeno
Guest
Quote
2023-06-23 03:46:01

Hi , i have coppercube 6.6 , and I get this code

// get the position of the first object
var pos1 = coppercube.getSceneNodeFromName("Object1").getPosition();

// get the position of the second object
var pos2 = coppercube.getSceneNodeFromName("Object2").getPosition();

// calculate the midpoint between the two objects
var midpoint = new CL3D.Vect3d((pos1.X + pos2.X) / 2, (pos1.Y + pos2.Y) / 2, (pos1.Z + pos2.Z) / 2);


I just wanna know how to apply it on a camera object.

person icon
SamGrady
Guest
Quote
2023-06-24 22:06:34

don't know what kind of class you use but here same code

var pos1 = ccbGetSceneNodeProperty(ccbGetSceneNodeFromName("cubeMesh1"),"PositionAbs");
var pos2 = ccbGetSceneNodeProperty(ccbGetSceneNodeFromName("cubeMesh2"),"PositionAbs");
var midpoint = new vector3d((pos1.x + pos2.x) / 2, (pos1.y + pos2.y) / 2, (pos1.z + pos2.z) / 2);
//set camera target to middle point between two boxes
ccbSetSceneNodeProperty(ccbGetActiveCamera(),"Target",midpoint);


person icon
Manomeno
Guest
Quote
2023-06-25 03:37:34

Thanks but , what do you mean by "which class ?"

person icon
hadoken
Guest
Quote
2023-06-25 11:21:56

@Manomeno,

the code you presented is not CopperCube API commands conform thus will not be understood by CC JavaScript compiler/interpreter while @SamGrady's version looks like it does fullfil that requirement

CopperCube's JavaScript reference about valid syntax commands can be found at CC's documentation pages

Tried Ai?

person icon
Manomeno
Guest
Quote
2023-06-28 05:32:26

Ok ,Thanks a lot

person icon
Manomeno
Guest
Quote
2023-06-28 13:11:53

its telling me
script:5:ReferenceError: ccbGetActiveCamera is not defined

how can i fix that?

person icon
SamGrady
Guest
Quote
2023-06-28 18:03:33

strange thing cuz this code work even without camera node...

person icon
Manomeno
Guest
Quote
2023-06-29 05:43:00

So yo mean that I can remove the camera node?


Create reply:










 

  

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


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






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