Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Drag n Drop (bug)

Robo
Guest
Quote
2019-09-06 04:35:20

If anyone can help me would be much appreciated:

I am trying to use the existing drag n drop extension but it causes the object to fall below the mouse position and jerk in mid air. I mostly cant click to drop the item also as the item is outside of the central mouse position.

Any solutions to this which is due to gravity (zero gravity stops this but still some problems) ????

Help please...or suggestions to try...


Existing extension code:

action_Drag3DObject = function(){};
currentlyDraggingAction = null;
dontRestartDraggingUntil = 0;

// called when the action is executed
action_Drag3DObject.prototype.execute = function(currentNode){
if (dontRestartDraggingUntil != 0){
var now = (new Date()).getTime();
if (dontRestartDraggingUntil > now)
return;
}
if (currentlyDraggingAction){
currentlyDraggingAction.stopDragging();
return;
}
currentlyDraggingAction = this;
var me = this;
this.registeredFunction = function() {
me.draggingFunc();
};
ccbRegisterOnFrameEvent(this.registeredFunction);
this.currentNode = currentNode;
var positionNode = ccbGetSceneNodeProperty(currentNode, "Position");
var positionCam = ccbGetSceneNodeProperty(ccbGetActiveCamera(), "Position");
this.distance = positionNode.substract(positionCam).getLength();
}

action_Drag3DObject.prototype.stopDragging = function(){
this.currentNode = null;
ccbUnregisterOnFrameEvent(this.registeredFunction);
currentlyDraggingAction = null;
dontRestartDraggingUntil = (new Date()).getTime() + 300;
}

action_Drag3DObject.prototype.draggingFunc = function(){
// update position
var mouseX = ccbGetMousePosX();
var mouseY = ccbGetMousePosY();
var pos3d = ccbGet3DPosFrom2DPos(mouseX, mouseY);
var positionCam = ccbGetSceneNodeProperty(ccbGetActiveCamera(), "Position");
var ray = pos3d.substract(positionCam);
ray.normalize();
ray.x *= this.distance;
ray.y *= this.distance;
ray.z *= this.distance;
ccbSetSceneNodeProperty(this.currentNode, "Position", ray.x + positionCam.x, ray.y + positionCam.y, ray.z + positionCam.z);
}


just_in_case
Moderator
Quote
2019-09-06 05:57:42

Don't know what you are talking about exactly but both of the drag and drop extensions are working good for me.

if your object has collide when moved behavior attached to it try disabling affected by gravity or remove that behavior...




Robo
Guest
Quote
2019-09-08 05:34:30

wrote:
Don't know what you are talking about exactly but both of the drag and drop extensions are working good for me.

if your object has collide when moved behavior attached to it try disabling affected by gravity or remove that behavior...



well, this is a video of what I was getting and how I fixed it..
https://youtu.be/QmCePeCeNro


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inte?national" (you are not logged in)


Text:

 

  

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