Description
The model primitive loads and renders
glTF 2.0 (.gltf, .glb),
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 glTF animations
[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("C-130").GetByName("Yaw").CurrentValue = 0.0;
model.Articulations.GetByName("C-130").GetByName("Pitch").CurrentValue = -50 * Math.PI / 180.0;
model.Articulations.GetByName("C-130").GetByName("Roll").CurrentValue = 35 * Math.PI / 180.0;
//
// Enable the "LandingGear" glTF animation for playback
//
model.Articulations.GetByName("LandingGear").GetByName("Enable").CurrentValue = 1.0;
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;
double Spin = (TimeEpSec * 0.1) % TwoPI;
((IAgStkGraphicsModelPrimitive)m_Model).Articulations.GetByName("Props").GetByName("Spin").CurrentValue = Spin;
double Gear = (TimeEpSec * 0.2) % 40.0;
if (Gear > 20.0)
{
// Ping-pong forwards and backwards.
Gear = 40.0 - Gear;
}
// Clamp within animation playback range.
Gear = Math.Max(0.0, Math.Min(16.0, Gear - 2.0));
((IAgStkGraphicsModelPrimitive)m_Model).Articulations.GetByName("LandingGear").GetByName("Seconds").CurrentValue = Gear;
}
}
|
|
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("C-130").GetByName("Yaw").CurrentValue = 19 * Math.PI / 180.0;
model.Articulations.GetByName("C-130").GetByName("Pitch").CurrentValue = -5 * Math.PI / 180.0;
model.Articulations.GetByName("C-130").GetByName("Roll").CurrentValue = 75 * Math.PI / 180.0;
//
// Put away the landing gear by jumping to the end of a glTF animation
//
model.Articulations.GetByName("LandingGear").GetByName("Enable").CurrentValue = 1.0;
model.Articulations.GetByName("LandingGear").GetByName("Seconds").CurrentValue = 16.0;
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;
double Spin = (TimeEpSec * 0.1) % TwoPI;
((IAgStkGraphicsModelPrimitive)m_Model).Articulations.GetByName("Props").GetByName("Spin").CurrentValue = Spin;
}
}
|
|
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);
|
|
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, 0.5);
manager.Primitives.Add((IAgStkGraphicsPrimitive)model);
|
|
Draw a model with glTF animations
[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("C-130").GetByName("Yaw").CurrentValue = 0.0
model.Articulations.GetByName("C-130").GetByName("Pitch").CurrentValue = -50 * Math.PI / 180.0
model.Articulations.GetByName("C-130").GetByName("Roll").CurrentValue = 35 * Math.PI / 180.0
'
' Enable the "LandingGear" glTF animation for playback
'
model.Articulations.GetByName("LandingGear").GetByName("Enable").CurrentValue = 1.0
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
Dim Spin As Double = (TimeEpSec * 0.1) Mod TwoPI
DirectCast(m_Model, IAgStkGraphicsModelPrimitive).Articulations.GetByName("Props").GetByName("Spin").CurrentValue = Spin
Dim Gear As Double = (TimeEpSec * 0.2) Mod 40.0
If Gear > 20.0 Then
' Ping-pong forwards and backwards.
Gear = 40.0 - Gear
End If
' Clamp within animation playback range.
Gear = Math.Max(0.0, Math.Min(16.0, Gear - 2.0))
DirectCast(m_Model, IAgStkGraphicsModelPrimitive).Articulations.GetByName("LandingGear").GetByName("Seconds").CurrentValue = Gear
End If
End Sub
|
|
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("C-130").GetByName("Yaw").CurrentValue = 19 * Math.PI / 180.0
model.Articulations.GetByName("C-130").GetByName("Pitch").CurrentValue = -5 * Math.PI / 180.0
model.Articulations.GetByName("C-130").GetByName("Roll").CurrentValue = 75 * Math.PI / 180.0
'
' Put away the landing gear by jumping to the end of a glTF animation
'
model.Articulations.GetByName("LandingGear").GetByName("Enable").CurrentValue = 1.0
model.Articulations.GetByName("LandingGear").GetByName("Seconds").CurrentValue = 16.0
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
Dim Spin As Double = (TimeEpSec * 0.1) Mod TwoPI
DirectCast(m_Model, IAgStkGraphicsModelPrimitive).Articulations.GetByName("Props").GetByName("Spin").CurrentValue = Spin
End If
End Sub
|
|
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, 0.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_ODTK 13\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_ODTK 13\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