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 / A simple glue object method??

Author
Message
Alduce
22
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 15th Nov 2013 10:50
Hi guys I am in full programming mode but today I understand I can't remember how the hell I can glue an object into another one...

I have just:
1) a main cube as my main character
2) a sphere I need to put a bit on left of main cube

What I would is that moving and rotating the main cube so the sphere have to change his position and angle in according to the main cube!
Please help!
Derek Darkly
13
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 15th Nov 2013 13:38 Edited at: 15th Nov 2013 13:45
The command is GLUE OBJECT TO LIMB

You'll probably want to add a "dummy" or placeholder limb to your cube and position it with OFFSET LIMB, then either hide it (HIDE LIMB) or make its size zero (SCALE LIMB). Then you're ready to glue your object.

D.D.
chafari
Valued Member
19
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th Nov 2013 14:03
Hi there
We could position second object in same x,y,z offset a bit and rotate second object object angle y(1)...or set object orientation 2,1



I'm not a grumpy grandpa
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 15th Nov 2013 14:33
Scaling the cubes direction vectors is how offsetting works and how move objects commands work. For this you'd scale the right vector.

The trig:
Quote: "
amount = whatever

rightX = cos(objAngleZ) * cos(objAngleY)
rightY = sin(objAngleZ) * cos(objAngleY)
rightZ = -sin(objAngleY)

posX = objPosX + (rightX * amount)
posY = objPosY + (rightY * amount)
posZ = objPosZ + (rightZ * amount)
"


"Get in the Van!" - Van B
Derek Darkly
13
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 15th Nov 2013 15:25 Edited at: 17th Nov 2013 14:48
You could also position your object (every loop) to a particular vertex of your main object:



On second thought, this will probably not allow for the second object to rotate with the first.

D.D.
chafari
Valued Member
19
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 16th Nov 2013 13:37
Derek Darkly...if you decide to position second object on a vertex, then just force second object to poin to another vertex.

I'm not a grumpy grandpa
Alduce
22
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 17th Nov 2013 12:49
Ahh thank you very much guys!
Derek Darkly
13
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 17th Nov 2013 14:42
Quote: "Derek Darkly...if you decide to position second object on a vertex, then just force second object to poin to another vertex."


Excellent! Man I should have thought of that...duh!

D.D.
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 17th Nov 2013 15:45
I don't see how that would help with rotation because the other vertex doesn't take into account rotation. It would just point to the other vertex and remain static! Instead, get the vertex position and offset the limb of the main object by that position. And position object 2 to the resulting limb possible. Or you scale the direction vectors by the vertex position.

"Get in the Van!" - Van B
chafari
Valued Member
19
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Nov 2013 02:38 Edited at: 18th Nov 2013 02:57
Quote: "I don't see how that would help with rotation because the other vertex doesn't take into account rotation"


When an object rotate, its vertex rotate...right? so if we simple position second object on x,y,z of a vertex, it won't rotate unless we point the object to other vertex of the same object....here an example




Other example...this one takes into acount object position but sencond object works in the same way...position in one vertex and point to other vertex.



I'm not a grumpy grandpa
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 18th Nov 2013 05:38 Edited at: 18th Nov 2013 05:38
Quote: "make mesh from object 1,1
lock vertexdata for mesh 1"


Ooooh! I've never seen this! I never knew building a mesh would take account of rotation and store it in the mesh data, how interesting. Learn something new everyday although I can't imagine building a mesh every frame is quick.

Quicker would be to used offset limb:


Also note that point object won't take into account full rotation, so instead you can just rotate the second object to the first angle since they have the same rotation angle anyway!

"Get in the Van!" - Van B
chafari
Valued Member
19
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Nov 2013 10:39
Quote: "although I can't imagine building a mesh every frame is quick."


the fps drop is negligible, with this amount of vertex

I recognize, that your method goes better .If you see my first example, I pointed out for another method. I just was answering to Derek Darkly here :

Quote: "On second thought, this will probably not allow for the second object to rotate with the first."


Quote: "I never knew building a mesh would take account of rotation and store it in the mesh data"


It was something that I discovered by chance when I was creating my Lathe Tool program.

Cheers.

I'm not a grumpy grandpa
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 18th Nov 2013 16:33 Edited at: 18th Nov 2013 16:34
Quote: "I pointed out for another method. I just was answering to Derek Darkly here"


Aha I see

Quote: "It was something that I discovered by chance when I was creating my Lathe Tool program."


Y'know, what's even cooler about this is the fact that you can create a new axis to rotate around! By pre-rotating the object and creating a mesh from it. When you make an object out of the mesh it's still rotated but doesn't store the rotational and treats it as un-rotated. In a way, it's creating a new pivot angle! This is something that's incredibly handy when combining angles or create a new angle to rotate around. I wonder if you've noticed this...

Example:


Wow! I can think of so many uses for this!

"Get in the Van!" - Van B
chafari
Valued Member
19
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Nov 2013 17:43
Quote: "I wonder if you've noticed this"


Yeah, we can make as many meshes as we need, and change the mesh when needed .

Cheers.

I'm not a grumpy grandpa

Login to post a reply

Server time is: 2025-05-16 07:24:04
Your offset time is: 2025-05-16 07:24:04