PositionRelativeXYZ
Revision as of 06:52, 14 January 2010 by imported>QQuix (Clarifying the meaning of the arguments)
A User Function for use with Oblivion Script Extender
Syntax:
PositionRelative refAnchor DeltaX DeltaY DeltaZ DeltaAngZ
Positions an object relative to another object. E.g.: positioning a parrot on a pirate's shoulder .
DeltaX, DeltaY and DeltaZ are distances from the anchor objects when it is facing north (Angle Z = 0)
DeltaAngZ is used to rotate the positioned object relative to the anchor's Z angle.
Using the parrot on the shoulder example:
DeltaX = 15 - a little to the right of the player
DeltaY = 0 - not ahead, not behind
DeltaZ = 100 - distance from feet to shoulder
DeltaAngZ = 270 - the parrot faces the player's head
Notes:[edit | edit source]
- This function must be called on a reference (Ref.call <function>)
Example:[edit | edit source]
Positioning three objects lined up at eye level in front of the player:
if refObj1.getparentcell != player.getparentcell refObj1.moveto player ; avoid using moveto every frame refObj2.moveto player refObj3.moveto player endif refObj1.call zPositionRelativeXYZ player (-20) 50 120 0 refObj2.call zPositionRelativeXYZ player 0 50 120 0 refObj3.call zPositionRelativeXYZ player 20 50 120 0
Code[edit | edit source]
scn zPositionRelativeXYZ float posX float posY float posZ float angZ float dposX float dposY float dposZ float dangZ float angZanchor ref refAnchor begin Function { refAnchor dposX dposY dposZ dangZ} let angZanchor := refAnchor.getangle z let posX := refAnchor.getpos x + dposX * cos angZanchor + dposY * sin angZanchor let posY := refAnchor.getpos y - dposX * sin angZanchor + dposY * cos angZanchor let posZ := refAnchor.getpos z + dposZ let angZ := refAnchor.getangle z + dangZ setpos X posX setpos Y posY setpos Z posZ setangle Z angZ end
See Also[edit | edit source]