Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
adjust Z pos after setting ccbGet3DPosFrom2DPos

2022-11-23 15:16:21

I'm trying to adjust the Z position and orientation of a node when combined with "ccbGet3DPosFrom2DPos".

Basic setup is a Camera with a "shoot" behavior.
It does shoot the node "bullet" from the object "followMouse".
BUT the 3d position of the "followMouse" object is linked to the FarPlane of the Camera.

Is it possible to adjust the z position of the followMouse without changing the cameras farplane?

Any clue on this would be great - thanks all.

function onFrameDrawing()

var mouseX = ccbGetMousePosX();
var mouseY = ccbGetMousePosY();
var anode = ccbGetSceneNodeFromName("followMouse");

//ccbSetSceneNodePositionWithoutCollision(anode, mouseX, mouseY, -50);
//ccbSetSceneNodePositionWithoutCollision(anode, mouseX, mouseY, -50);

var pos3d = ccbGet3DPosFrom2DPos(mouseX, mouseY);

ccbSetSceneNodeProperty(anode, "Position", pos3d);



2022-11-24 03:05:20

you can use
ccbSetSceneNodeProperty(anode, "Position", pos3d.x, pos3d.y,pos3d.z);
now you can feed your own desired value to any of the axis.
you can use the .x and .y coming from your mouse position and can feed a different value for the .z position.

hope that helps.

2022-11-24 13:15:36

@just_in_case thanks - this did some of a trick.
I tried your solution. It's kinda working; but now the mouse.Pos in relation to the follower is completely off axes when not dead center at 0,0,0. The further away from center point, the more distorted/offset it gets.

Any clue how to compensate the offaxes shift?

Many thanks, this is driving me nuts :)

2022-11-25 09:44:13

It's hard to say, what you are trying to acheive and what probelm you are facing with the code, maybe you can explain in a bit detail what you want to do with the mouse and camera far plane.

Create reply:

Posted by: (you are not logged in)

Enter the missing letter in: "Internation?l" (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