Description
The model primitive loads and renders
COLLADA (DAE) and AGI
MDL (MDL) models.
Object Model
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. |
Example
Draw a model with moving articulations
[C#] | Copy Code |
---|
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
IAgStkGraphicsModelPrimitive model = manager.Initializers.ModelPrimitive.InitializeWithStringUri(
modelFile);
Array position = new object[3] { 36, -116.75, 25000.0 };
model.SetPositionCartographic("Earth", ref position);
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)
{
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.25, 5000.0 };
model.SetPositionCartographic("Earth", ref position);
model.Scale = Math.Pow(10, 2);
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.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#] | Copy Code |
---|
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);
|
|
Orient a model
[C#] | Copy Code |
---|
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
IAgStkGraphicsModelPrimitive model = manager.Initializers.ModelPrimitive.InitializeWithStringUri(
modelFile);
((IAgStkGraphicsPrimitive)model).ReferenceFrame = referenceFrame;
Array zero = new object[] { 0, 0, 0 };
model.Position = zero;
model.Scale = Math.Pow(10, 1.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
Dim model As IAgStkGraphicsModelPrimitive = manager.Initializers.ModelPrimitive.InitializeWithStringUri( _ modelFile)
Dim position As Array = New Object() {36, -116.75, 25000.0} model.SetPositionCartographic("Earth", position)
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) 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 primitive = DirectCast(model, IAgStkGraphicsPrimitive) primitive.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) primitive.BoundingSphere = customBounds
manager.Primitives.Add(primitive)
|
|
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
Dim zero As Array = New Object() {0, 0, 0}
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