AGI STK Graphics 11 Send comments on this topic.
IAgStkGraphicsModelPrimitive Interface





Description

The model primitive loads and renders COLLADA (DAE) and AGI MDL (MDL) models.

Object Model



Public Methods

Public Method LoadWithStringUri For convenience. Loads a COLLADA (DAE) or AGI MDL (MDL) model using a file path.
Public Method LoadWithStringUriAndUpAxis For convenience. Loads a COLLADA (DAE) or AGI MDL (MDL) model using a file path.
Public Method SetPositionCartographic For convenience. Sets the Cartographic position of the model. Longitude and latitude are in radians, and altitude is in meters. This also sets Position.

Public Properties

Public Property Articulations Gets the model's articulations. Articulations identify geometry and contain transformations for manipulating that geometry.
Public Property Orientation Gets or sets the model's orientation. The quaternion is a rotation from the model's local axes to the axes of the model's Reference Frame.
Public Property Position Gets or sets the position of the model. The position is defined in the model's Reference Frame. The array contains the components of the position in the order x, y, z.
Public Property Scale Gets or sets the linear scale used to increase or decrease the size of the rendered model.
Public Property UriAsString Gets the URI of the file used to load the file.

Example

Draw a model with moving articulations
[C#] Copy Code
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager; 
// 
// Create the model 
// 
IAgStkGraphicsModelPrimitive model = manager.Initializers.ModelPrimitive.InitializeWithStringUri( 
    modelFile); 
 
Array position = new object[3] { 36, -116.7525000.0 }; 
model.SetPositionCartographic("Earth"ref position); 
 
// 
// Rotate the model to be oriented correctly 
// 
model.Articulations.GetByName("Commuter").GetByName("Roll").CurrentValue = 4.084070562
model.Articulations.GetByName("Commuter").GetByName("Yaw").CurrentValue = -0.436332325
 
manager.Primitives.Add((IAgStkGraphicsPrimitive)model); 
 
 
internal void TimeChanged(double TimeEpSec) 

    // 
    // Rotate the propellors every time the animation updates 
    // 
    if (m_Model != null
    { 
        double TwoPI = 2 * Math.PI; 
        ((IAgStkGraphicsModelPrimitive)m_Model).Articulations.GetByName("props").GetByName("Spin").CurrentValue = TimeEpSec % TwoPI; 
    } 

 

Draw a Collada or MDL model
[C#] Copy Code
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager; 
IAgStkGraphicsModelPrimitive model = manager.Initializers.ModelPrimitive.InitializeWithStringUri( 
    modelFile); 
 
Array position = new object[] { 39.88, -75.255000.0 }; 
model.SetPositionCartographic("Earth"ref position); 
model.Scale = Math.Pow(102); 
 
manager.Primitives.Add((IAgStkGraphicsPrimitive)model); 
 

Draw a Collada model with user defined lighting
[C#] Copy Code
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager; 
IAgStkGraphicsModelPrimitive model = manager.Initializers.ModelPrimitive.InitializeWithStringUri( 
    modelFile); 
 
Array position = new object[] { 39.88, -75.25500000.0 }; 
model.SetPositionCartographic("Earth"ref position); 
model.Scale = Math.Pow(102); 
 
manager.Primitives.Add((IAgStkGraphicsPrimitive)model); 
 

Draw a dynamically textured Collada model
[C#] Copy Code
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager; 
IAgStkGraphicsModelPrimitive model = manager.Initializers.ModelPrimitive.InitializeWithStringUri( 
    modelFile); 
 
Array position = new object[] { 49.88, -77.255000.0 }; 
model.SetPositionCartographic("Earth"ref position); 
model.Scale = Math.Pow(102); 
 
manager.Primitives.Add((IAgStkGraphicsPrimitive)model); 
 
//  hellfireflame.anc 
// 
//  <?xml version = "1.0" standalone = "yes"?> 
//  <ancillary_model_data version = "1.0"> 
//       <video_textures> 
//           <video_texture image_id = "smoketex_tga" init_from = "smoke.avi" video_loop="true" video_framerate="60" /> 
//           <video_texture image_id = "flametex_tga" init_from = "flame.mov" video_loop="true" video_framerate="60" /> 
//      </video_textures> 
//  </ancillary_model_data> 
 

Orient a model
[C#] Copy Code
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager; 
 
IAgStkGraphicsModelPrimitive model = manager.Initializers.ModelPrimitive.InitializeWithStringUri( 
    modelFile); 
((IAgStkGraphicsPrimitive)model).ReferenceFrame = referenceFrame;  // Model is oriented using east-north-up axes.  Use model.Orientation for addition rotation. 
Array zero = new object[] { 000 }; // Origin of reference frame 
model.Position = zero; 
model.Scale = Math.Pow(101.5); 
 
manager.Primitives.Add((IAgStkGraphicsPrimitive)model); 
 

Draw a model with moving articulations
[Visual Basic .NET] Copy Code
Dim manager As IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario, IAgScenario).SceneManager
'
' Create the model
'
Dim model As IAgStkGraphicsModelPrimitive = manager.Initializers.ModelPrimitive.InitializeWithStringUri( _
    modelFile)

Dim position As Array = New Object() {36, -116.75, 25000.0}
model.SetPositionCartographic("Earth", position)

'
' Rotate the model to be oriented correctly
'
model.Articulations.GetByName("Commuter").GetByName("Roll").CurrentValue = 4.08407
model.Articulations.GetByName("Commuter").GetByName("Yaw").CurrentValue = -0.43633

manager.Primitives.Add(DirectCast(model, IAgStkGraphicsPrimitive))


Friend Sub TimeChanged(TimeEpSec As Double)
    '
    ' Rotate the propellors every time the animation updates
    '
    If m_Model IsNot Nothing Then
        Dim TwoPI As Double = 2 * Math.PI
        DirectCast(m_Model, IAgStkGraphicsModelPrimitive).Articulations.GetByName("props").GetByName("Spin").CurrentValue = TimeEpSec Mod TwoPI
    End If
End Sub

Draw a Collada or MDL model
[Visual Basic .NET] Copy Code
Dim manager As IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario, IAgScenario).SceneManager
Dim model As IAgStkGraphicsModelPrimitive = manager.Initializers.ModelPrimitive.InitializeWithStringUri( _
    modelFile)

Dim position As Array = New Object() {39.88, -75.25, 5000.0}
model.SetPositionCartographic("Earth", position)
model.Scale = Math.Pow(10, 2)

manager.Primitives.Add(DirectCast(model, IAgStkGraphicsPrimitive))

Draw a Collada model with user defined lighting
[Visual Basic .NET] Copy Code
Dim manager As IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario, IAgScenario).SceneManager
Dim model As IAgStkGraphicsModelPrimitive = manager.Initializers.ModelPrimitive.InitializeWithStringUri( _
    modelFile)

Dim position As Array = New Object() {39.88, -75.25, 500000.0}
model.SetPositionCartographic("Earth", position)
model.Scale = Math.Pow(10, 2)

manager.Primitives.Add(DirectCast(model, IAgStkGraphicsPrimitive))

Draw a dynamically textured Collada model
[Visual Basic .NET] Copy Code
Dim manager As IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario, IAgScenario).SceneManager
Dim model As IAgStkGraphicsModelPrimitive = manager.Initializers.ModelPrimitive.InitializeWithStringUri( _
    modelFile)

Dim position As Array = New Object() {49.88, -77.25, 5000.0}
model.SetPositionCartographic("Earth", position)
model.Scale = Math.Pow(10, 2)

manager.Primitives.Add(DirectCast(model, IAgStkGraphicsPrimitive))

' hellfireflame.anc
'
'
'
'
'
'
'
'

Orient a model
[Visual Basic .NET] Copy Code
Dim manager As IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario, IAgScenario).SceneManager

Dim model As IAgStkGraphicsModelPrimitive = manager.Initializers.ModelPrimitive.InitializeWithStringUri( _
    modelFile)
DirectCast(model, IAgStkGraphicsPrimitive).ReferenceFrame = referenceFrame
' Model is oriented using east-north-up axes. Use model.Orientation for addition rotation.
Dim zero As Array = New Object() {0, 0, 0}
' Origin of reference frame
model.Position = zero
model.Scale = Math.Pow(10, 1.5)

manager.Primitives.Add(DirectCast(model, IAgStkGraphicsPrimitive))

Draw a new Model Primitive
[MATLAB] Copy Code
% IAgScenario scenario: Scenario object 
% Create a model primitive and sets properties 
manager = scenario.SceneManager; 
model = manager.Initializers.ModelPrimitive.InitializeWithStringUriAndUpAxis('C:\Program Files\AGI\STK 11\STKData\VO\Models\Air\f-22a_raptor.mdl','eStkGraphicsModelUpAxisNegativeX'); 
model.SetPositionCartographic('Earth',{0;-3;15});    % Lat,Lon,Alt 
model.Scale = 10000; 
model.Translucency = 0; 
manager.Primitives.Add(model); 
manager.Render; 
 
 
Draw a new Model Primitive in a Reference Frame
[MATLAB] Copy Code
% IAgScenario scenario: Scenario object 
% IAgSatellite satellite: Satellite object 
% Create a model primitive and sets properties 
manager = scenario.SceneManager; 
modelRefFrame = manager.Initializers.ModelPrimitive.InitializeWithStringUriAndUpAxis('C:\Program Files\AGI\STK 11\STKData\VO\Models\Space\cubesat.mdl','eStkGraphicsModelUpAxisNegativeX'); 
modelRefFrame.Position = {0;.005;0}; 
modelRefFrame.ReferenceFrame = satellite.Vgt.Systems.Item('Body'); 
modelRefFrame.Scale = 1; 
manager.Primitives.Add(modelRefFrame); 
manager.Render; 
 
 

See Also

CoClasses that Implement IAgStkGraphicsModelPrimitive

© 2016 All Rights Reserved.

STK Programming Interface 11.0.1