GetAbsOrigin(): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
mNo edit summary
Line 1: Line 1:
'''<code>GetAbsOrigin()</code>''' returns the world co-ordinates of the [[origin]] of any [[point]] or [[model]] entity as a [[vector]]. This is ''normally'' either the centre of the object, but for NPCs (to choose a prominent example) will be a point exactly half way between the soles of their feet when in the [[reference posture]], or wherever else the modeller has placed it.
'''<code>GetAbsOrigin()</code>''' returns the world co-ordinates of the [[origin]] of any [[point]] or [[model]] entity as a [[vector]]. This is ''theoretically'' the centre of the object, but for NPCs (to choose a prominent example) will be a point exactly half way between the soles of their feet when in the [[reference posture]], or wherever else the modeller has placed it.


== Alternatives ==
== Alternatives ==
Line 8: Line 8:


;<code>WorldSpaceCenter()</code>
;<code>WorldSpaceCenter()</code>
:Calculates the centre of an [[object-aligned bounding box]] in all three dimensions.
:Calculates the centre of an entity's [[object-aligned bounding box]] in all three dimensions.
;<code>[[CollisionProp()]]->CalcNearestPoint( [[const]] Vector &vecWorldPt, Vector *pVecNearestWorldPt )</code>
;<code>[[CollisionProp()]]->CalcNearestPoint( [[const]] Vector &vecWorldPt, Vector *pVecNearestWorldPt )</code>
:Calculates the nearest point to <code>vecWorldPt</code> of an [[object-aligned bounding box]].  
:Calculates the nearest point to <code>vecWorldPt</code> of an entity's [[object-aligned bounding box]].  
:{{note|Instead of returning a value, this function will modify whatever variable is passed for <code>pVecNearestWorldPt</code>.}}
:{{note|Instead of returning a value, this function will modify whatever variable is passed for <code>pVecNearestWorldPt</code>.}}



Revision as of 14:25, 2 June 2008

GetAbsOrigin() returns the world co-ordinates of the origin of any point or model entity as a vector. This is theoretically the centre of the object, but for NPCs (to choose a prominent example) will be a point exactly half way between the soles of their feet when in the reference posture, or wherever else the modeller has placed it.

Alternatives

You may want to use a different method of finding an entity's location, particularly given the fact that GetAbsOrigin() will not work with brushes unless they are tied to an entity that creates one for them - which may well not mark the location of the object in any useful way!

Todo: How many of these OBB functions work with vphysics?
WorldSpaceCenter()
Calculates the centre of an entity's object-aligned bounding box in all three dimensions.
CollisionProp()->CalcNearestPoint( const Vector &vecWorldPt, Vector *pVecNearestWorldPt )
Calculates the nearest point to vecWorldPt of an entity's object-aligned bounding box.
Note.pngNote:Instead of returning a value, this function will modify whatever variable is passed for pVecNearestWorldPt.
Todo: More...