MSRS 安裝目錄 \samples\simulation 提供對應選單的教程專案,SimulationTutorial1 即為「基本模擬環境」的程式碼基礎。
protected override void Start()
{
base.Start();
SetupCamera(); // 設定攝影機視點
PopulateWorld(); // 填充實體物件
}

圖 6:插入地球儀
void AddTexturedSphere(Vector3 position)
{
SingleShapeEntity entity = new SingleShapeEntity(
new SphereShape(
new SphereShapeProperties(10, new Pose(), 1), // 10kg、預設半徑
position);
entity.State.Assets.Mesh = "earth.obj"; // .obj 格式網格
entity.SphereShape.SphereState.Material = new MaterialProperties("sphereMaterial", 0.5f, 0.4f, 0.5f);
entity.State.Name = "detailed sphere";
SimulationEngine.GlobalInstancePort.Insert(entity);
}
SingleShapeEntity 適合單一幾何形狀 (球體、盒體等) 的實體建立。SimulationEngine.GlobalInstancePort.Insert(entity) 將實體加入模擬。