Description
The model primitive loads and renders
COLLADA (DAE) and AGI
MDL (MDL) models.
Public Methods
Public Properties
Articulations | Gets the model's articulations. Articulations identify geometry and contain transformations for manipulating that geometry. |
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. |
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. |
Scale | Gets or sets the linear scale used to increase or decrease the size of the rendered model. |
UriAsString | Gets the URI of the file used to load the file. |
Interfaces
CoClasses that Implement IAgStkGraphicsModelPrimitive
Example
Draw a model with moving articulations
[C#] |
---|
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
//
// Create the model
//
IAgStkGraphicsModelPrimitive model = manager.Initializers.ModelPrimitive.InitializeWithStringUri(
modelFile);
Array position = new object[3] { 36, -116.75, 25000.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#] |
---|
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
IAgStkGraphicsModelPrimitive model = manager.Initializers.ModelPrimitive.InitializeWithStringUri(
modelFile);
Array position = new object[] { 39.88, -75.25, 5000.0 };
model.SetPositionCartographic("Earth", ref position);
model.Scale = Math.Pow(10, 2);
manager.Primitives.Add((IAgStkGraphicsPrimitive)model);
|
|
Draw a glTF model with PBR materials
[C#] |
---|
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
IAgStkGraphicsModelPrimitive model = manager.Initializers.ModelPrimitive.InitializeWithStringUri(
modelFile);
Array position = new object[] { 39.88, -75.25, 500000.0 };
model.SetPositionCartographic("Earth", ref position);
model.Scale = Math.Pow(10, 2);
manager.Primitives.Add((IAgStkGraphicsPrimitive)model);
|
|
Draw a dynamically textured Collada model
[C#] |
---|
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
IAgStkGraphicsModelPrimitive model = manager.Initializers.ModelPrimitive.InitializeWithStringUri(
modelFile);
((IAgStkGraphicsPrimitive) model).AutomaticallyComputeBoundingSphere = false;
Array position = new object[] { 49.88, -77.25, 5000.0 };
model.SetPositionCartographic("Earth", ref position);
model.Scale = Math.Pow(10, 2);
IAgStkGraphicsBoundingSphere customBounds = manager.Initializers.BoundingSphere.Initialize(model.Position, 10.0 * model.Scale);
((IAgStkGraphicsPrimitive)model).BoundingSphere = customBounds;
manager.Primitives.Add((IAgStkGraphicsPrimitive)model);
// hellfireflame.anc
//
//
//
//
//
//
//
//
|
|
Orient a model
[C#] |
---|
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[] { 0, 0, 0 }; // Origin of reference frame
model.Position = zero;
model.Scale = Math.Pow(10, 1.5);
manager.Primitives.Add((IAgStkGraphicsPrimitive)model);
|
|
Draw a model with moving articulations
[Visual Basic .NET] |
---|
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] |
---|
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 dynamically textured Collada model
[Visual Basic .NET] |
---|
Dim manager As IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario, IAgScenario).SceneManager
Dim model As IAgStkGraphicsModelPrimitive = manager.Initializers.ModelPrimitive.InitializeWithStringUri( _
modelFile)
DirectCast(model, IAgStkGraphicsPrimitive).AutomaticallyComputeBoundingSphere = False
Dim position As Array = New Object() {49.88, -77.25, 5000.0}
model.SetPositionCartographic("Earth", position)
model.Scale = Math.Pow(10, 2)
Dim customBounds As IAgStkGraphicsBoundingSphere = manager.Initializers.BoundingSphere.Initialize(model.Position, 10.0 * model.Scale)
DirectCast(model, IAgStkGraphicsPrimitive).BoundingSphere = customBounds
manager.Primitives.Add(DirectCast(model, IAgStkGraphicsPrimitive))
' hellfireflame.anc
'
'
'
'
'
'
'
'
|
|
Draw a glTF model with PBR materials
[Visual Basic .NET] |
---|
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))
|
|
Orient a model
[Visual Basic .NET] |
---|
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] |
---|
% IAgScenario scenario: Scenario object
% Create a model primitive and sets properties
manager = scenario.SceneManager;
model = manager.Initializers.ModelPrimitive.InitializeWithStringUriAndUpAxis('C:\Program Files\AGI\STK 12\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] |
---|
% 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 12\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