GetLinkPoint returning a different value than AddLinkPoint adds?
by Drethon · in Torque Game Builder · 12/19/2012 (1:54 pm) · 4 replies
I've got some mount code working good with hard coded values but when I try to use link points, the value being returned by getLinkPoint (I'm echoing all link points, not just the first one) is differing from addLinkPoint. I suspect I'm just missing something simple but haven't found anything on the website on this yet...
About the author
#2
12/19/2012 (6:43 pm)
I've done basically that, passing 50.999,50.999 to addLinkPoint (trying to create a somewhat unique value, I've tried others like 0.100,0.8625 which is my actual offsets). addLinkPoint returns an index of 3 in this case. Passing 3 to getLinkPoint and echoing it out produces 518.239258 1338.723755 which isn't anywhere near my input values.
#3
There is what is referrred to as world space (which is your world x,y coordinate system) and then there is local space (which is relative to the object in question).
So, to provide an answer to your problem (hopefully)..
Object space can be converted to world space with the t2dSceneObject::getWorldPoint() function.
World space can be converted to object space with the t2dSceneObject::getLocalPoint() function.
Just an FYI as to where I have found this information (all from TDN) here's the associated links:
LinkPoint:tdn.garagegames.com/wiki/TGB/Reference:_t2dSceneObject_Mounting_Methods
World/Object Space: tdn.garagegames.com/wiki/TGB/Reference:_Glossary#Object_Space
Hope that helps!
12/19/2012 (7:42 pm)
Ahhh.. A little more digging into this, I have found why you are most likely seeing what you are seeing as 'odd' numbers.There is what is referrred to as world space (which is your world x,y coordinate system) and then there is local space (which is relative to the object in question).
So, to provide an answer to your problem (hopefully)..
Object space can be converted to world space with the t2dSceneObject::getWorldPoint() function.
World space can be converted to object space with the t2dSceneObject::getLocalPoint() function.
Just an FYI as to where I have found this information (all from TDN) here's the associated links:
LinkPoint:tdn.garagegames.com/wiki/TGB/Reference:_t2dSceneObject_Mounting_Methods
World/Object Space: tdn.garagegames.com/wiki/TGB/Reference:_Glossary#Object_Space
Hope that helps!
#4
Thanks!
12/19/2012 (8:59 pm)
That answered it, plus me realizing that getLinkPoint ID appears to be 1 based instead of 0 based.Thanks!
Torque Owner Doc308
GetLinkPoint(%id) has to collect from the id of the object, whereas AddLinkPoint(%offset) assigns a link point to a vector coordinate.
Now, you can return the value of AddLinkPoint to get the id of the link point in order to access GetLinkPoint.
So in code, it would be something like:
function myObject.editLink(%this) { %id = %this.addLinkPoint(0,0); //returns the id %vec = %this.getLinkPoint(%id); //returns the vector }I've never tried it, but.. that's what the documentation says.