Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Translate 2D to 3D along an Axis

Author
Message
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 20th Oct 2013 13:46
So basically I'm dragging objects around. But I want to work out how to drag an object accurately at any angle (camera) along a desired axis (object) defined in a vector. Any clues guys would be very appreciated

"Get in the Van!" - Van B
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 24th Oct 2013 00:15
Hmm... this is harder than I thought also there's not very good sources on 3D manipulators/Gizmo's.

"Get in the Van!" - Van B
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 24th Oct 2013 11:27 Edited at: 24th Oct 2013 11:29
You could either use a mouse movement vector as a coefficient for the object's movement vector along the angle; or do as I do in my editor (and as they often do in Blender), use an invisible cursor which is used as a track for object manipulation.

For screen to world precision, interpolate the object's position to the nearest screen projected coordinate from the mouse cursor along that vector.

Le Verdier
13
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 24th Oct 2013 11:43
There is a plugin dedicated to 3D gizmos:

http://forum.thegamecreators.com/?m=forum_view&t=199163&b=5&msg=2380860#m2380860

For moving an object on a constrained axis, first project the mouse moves on a plane, and project on the axis

Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 25th Oct 2013 14:24 Edited at: 25th Oct 2013 14:29
Cheers Guy

Okay, got the core math done, just need to refine this further... but I'm thinking the blender-ish approach Chris is talking about might be better. I'll have to compare the two when this is finished to see which looks better considering I'm actually already using that method.

Here's where I'm at so far, as I said, needs refinement. Hold RMB to control camera, WASD and Mouse look:


I'll sort out the constraints better and handle special cases for errors with intersection.

Note: I never knew offset limb doesn't scale when the object scales, hence why they disappear when the offset limb points go outs the camera. I'll change all this anyway

"Get in the Van!" - Van B

Login to post a reply

Server time is: 2025-05-15 14:06:37
Your offset time is: 2025-05-15 14:06:37