Difference between revisions of "NiAVObjectSetLocalRotation"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>DragoonWraith
imported>DragoonWraith
Line 7: Line 7:
Sets the local rotation of the specified <tt>NiAVObject</tt>-derived block. Since <tt>blockID</tt> defaults to 0, the NIF's root <tt>NiNode</tt>, and <tt>NiNode</tt> is derived from <tt>NiAVObject</tt>, this function will change the local rotation of the NIF's root if called with no explicit <tt>blockID</tt>.
Sets the local rotation of the specified <tt>NiAVObject</tt>-derived block. Since <tt>blockID</tt> defaults to 0, the NIF's root <tt>NiNode</tt>, and <tt>NiNode</tt> is derived from <tt>NiAVObject</tt>, this function will change the local rotation of the NIF's root if called with no explicit <tt>blockID</tt>.


The passed <tt>array_var</tt> must be a 3&mult;3 [[GenerateRotationMatrix|rotation matrix]]
The passed <tt>array_var</tt> must be a 3×3 [[GenerateRotationMatrix|rotation matrix]]


== Example ==
== Example ==
Line 24: Line 24:
   
   
   let locRot := MatrixMultiply R locRot ; order matters
   let locRot := MatrixMultiply R locRot ; order matters
 
   NiAVObjectSetLocalRotation locRot nifID blockID
   NiAVObjectSetLocalRotation locRot nifID blockID
  loop
  loop

Revision as of 12:23, 21 January 2011

This is a command from NifSE.

Syntax

(bool:success) NiAVObjectSetLocalRotation array_var:rotation short:nifID short:blockID
(bool:success) NiAVObjSetLocRot array_var:rotation short:nifID short:blockID

Sets the local rotation of the specified NiAVObject-derived block. Since blockID defaults to 0, the NIF's root NiNode, and NiNode is derived from NiAVObject, this function will change the local rotation of the NIF's root if called with no explicit blockID.

The passed array_var must be a 3×3 rotation matrix

Example

This script will rotate each of the root's children, which are NiAVObject blocks, 180° about the X axis. This will effectively flip the NIF upside-down.

array_var R
array_var children
array_var child
short nifID
short blockID
...
let R := GenerateRotationMatrix X 180
let children := NiNodeGetChildren nifID
foreach child <- children
  let blockID := *child
  let locRot := NiAVObjectGetLocalRotation nifID blockID

  let locRot := MatrixMultiply R locRot ; order matters

  NiAVObjectSetLocalRotation locRot nifID blockID
loop

See Also


External Links