/*
This example demonstrates how to retrieve the output arguments through the returned
ISIVTCollection, comparing using the Item vs. the Value property.
*/
NewScene( null, false );
// Create the Camera and Interest, and parent them to a newly created NULL object
var rtn = SIGetPrim( "CameraRoot", "MyCamera_Root", ActiveSceneRoot, true );
// Get the output arguments via the ISIVTCollection.Item property
var oPrim = rtn.Item(0); // equiv. to: var oPrim = rtn.Value("Primitive")
var o3DObj = rtn.Item(1); // equiv. to: var o3DObj = rtn.Value("Value")
// NB: This is a perfect example of why using the Value property is much
// safer than the Item property: you would expect the output arguments
// to use the same order in the ISIVTCollection, but in this case, they
// are opposite.
WhatAmI( o3DObj ); //INFO : MyCamera_Root is a CameraRig
WhatAmI( oPrim ); //INFO : MyCamera_Root.CameraRoot is a Primitive
SetValue( o3DObj + ".kine.global.posy", 2.0 );
SetValue( o3DObj + ".kine.global.posz", 20.0 );
// Get the output arguments via the ISIVTCollection.Value property
rtn = SIGetPrimCamera( "Camera", "MyCameraName", "MyCameraIntName" );
var o3DObjCamera = rtn.Value("3DObjCamera" );
var o3DObjCameraInterest = rtn.Value("3DObjCameraInterest" );
var oPrimObjCamera = rtn.Value( "PrimObjCamera" );
var oPrimObjCameraInterest = rtn.Value(" PrimObjCameraInterest" );
// For each object, find out its name and class, if possible
WhatAmI( o3DObjCamera ); //INFO : MyCameraName is a Camera
WhatAmI( o3DObjCameraInterest ); //INFO : MyCameraIntName is a Null
WhatAmI( oPrimObjCamera ); //INFO : MyCameraName.camera is a Primitive
WhatAmI( oPrimObjCameraInterest ); //INFO : input object is a undefined
// Convenience function
function WhatAmI( in_obj )
{
// To prevent crashes, use the try...catch statement, because using ClassName
// on a simple data type (string, number, etc.) will throw an error
try {
LogMessage( in_obj + " is a " + ClassName(in_obj) );
} catch (e) {
LogMessage( "input object is " + typeof(in_obj) );
}
}
|