//internal static MyActor CreateCullObject() //{ // var actor = Create(); // actor.AddComponent(MyComponentFactory<MyHierarchyComponent>.Create()); // return actor; //} internal static MyActor CreateGroup() { var actor = Create(); actor.AddComponent(MyComponentFactory <MyGroupRootComponent> .Create()); return(actor); }
internal static MyActor CreateSceneObject() { var actor = Create(); actor.AddComponent(MyComponentFactory <MyRenderableComponent> .Create()); return(actor); }
private void UpdateFoliage(bool refresh = false) { var foliageComponent = m_actor.GetFoliage(); bool removeComponent = m_lod > MyFoliageComponent.LodLimit || !m_actor.IsVisible; bool shouldInitializeFoliage = false; if (refresh && foliageComponent != null) { foliageComponent.RefreshStreams(); } if (foliageComponent == null && !removeComponent) { shouldInitializeFoliage = m_mesh.ShouldHaveFoliage(); } if (shouldInitializeFoliage) { m_actor.AddComponent <MyFoliageComponent>(MyComponentFactory <MyFoliageComponent> .Create()); } else if (foliageComponent != null && removeComponent) { foliageComponent.InvalidateStreams(); m_actor.RemoveComponent <MyFoliageComponent>(foliageComponent); } }
internal static MyActor CreateVoxelCell() { var actor = Create(); actor.AddComponent <MyRenderableComponent>(MyComponentFactory <MyVoxelRenderableComponent> .Create()); return(actor); }
internal static MyActor CreateSceneObject2() { var actor = Create(); actor.AddComponent <MyInstanceComponent>(MyComponentFactory <MyInstanceComponent> .Create()); return(actor); }
internal static MyActor CreateCharacter() { var actor = Create(); actor.AddComponent(MyComponentFactory <MyRenderableComponent> .Create()); actor.AddComponent(MyComponentFactory <MySkinningComponent> .Create()); return(actor); }
internal static MyActor GetInstanceActor(MyRenderableComponent original) { if (m_instanceActor == null) { m_instanceActor = MyActorFactory.Create(); m_instanceActor.AddComponent <MyInstanceLodComponent>(MyComponentFactory <MyInstanceLodComponent> .Create()); } return(m_instanceActor); }
internal MyClipmapCellProxy(MyCellCoord cellCoord, ref VRageMath.MatrixD worldMatrix, RenderFlags additionalFlags = 0) { m_worldMatrix = worldMatrix; m_actor = MyActorFactory.CreateSceneObject(); m_actor.SetMatrix(ref worldMatrix); m_actor.AddComponent(MyComponentFactory <MyFoliageComponent> .Create()); m_lod = cellCoord.Lod; Mesh = MyMeshes.CreateVoxelCell(cellCoord.CoordInLod, cellCoord.Lod); m_actor.GetRenderable().SetModel(Mesh); m_actor.GetRenderable().m_additionalFlags = MyProxiesFactory.GetRenderableProxyFlags(additionalFlags); }
internal MyClipmapCellProxy(MyCellCoord cellCoord, ref VRageMath.MatrixD worldMatrix) { m_worldMatrix = worldMatrix; m_actor = MyActorFactory.CreateSceneObject(); //m_mesh = new MyVoxelMesh(cellCoord.CoordInLod, cellCoord.Lod, ""); //m_actor.GetRenderable().SetModel(m_mesh); m_actor.SetMatrix(ref worldMatrix); m_actor.AddComponent(MyComponentFactory <MyFoliageComponent> .Create()); m_lod = cellCoord.Lod; Mesh = MyMeshes.CreateVoxelCell(cellCoord.CoordInLod, cellCoord.Lod); m_actor.GetRenderable().SetModel(Mesh); m_discardingOn = false; }
internal void Add(MyActor child) { child.AddComponent(MyComponentFactory <MyGroupLeafComponent> .Create()); child.GetGroupLeaf().m_parent = m_owner; m_children.Add(child); if (child.m_relativeTransform == null) { child.m_relativeTransform = (Matrix)(child.WorldMatrix * MatrixD.Invert(m_owner.WorldMatrix)); } if (!m_owner.m_localAabb.HasValue) { m_owner.m_localAabb = child.m_localAabb; } else { var localAabb = child.m_localAabb.Value; m_owner.m_localAabb = m_owner.m_localAabb.Value.Include(ref localAabb); } PropagateMatrixChange(child); if (child.GetRenderable() == null) { return; } //var mesh = child.GetRenderable().GetMesh(); var model = child.GetRenderable().GetModel(); var material = MyMeshes.GetMeshPart(model, 0, 0).Info.Material; bool fracture = model.Info.RuntimeGenerated || model.Info.Dynamic; if (MyMeshMaterials1.IsMergable(material) && MyBigMeshTable.Table.IsMergable(model) && !fracture) { child.GetGroupLeaf().m_mergable = true; MyBigMeshTable.Table.AddMesh(model); m_mergablesCounter++; if (!m_isMerged && m_mergablesCounter >= MERGE_THRESHOLD) { TurnIntoMergeInstancing(); } else if (m_isMerged) { Merge(child); } //var materialRk = MyMeshMaterials1.Table[material.Index].RepresentationKey; //var mergeGroupForMaterial = m_materialGroups.Get(materialRk); //if (mergeGroupForMaterial == null) //{ // var proxyIndex = m_materialGroups.Count; // mergeGroupForMaterial = new MyMaterialMergeGroup(MyBigMeshTable.Table, material, proxyIndex); // m_materialGroups[MyMeshMaterials1.Table[material.Index].RepresentationKey] = mergeGroupForMaterial; // m_dirtyProxy = true; //} //child.GetRenderable().SetStandaloneRendering(false); //child.GetGroupLeaf().m_mergeGroup = mergeGroupForMaterial; //mergeGroupForMaterial.AddEntity(child, model); //mergeGroupForMaterial.UpdateEntity(child); } else { //Debug.WriteLine(String.Format("Mesh {0}, material {1} is not mergable", mesh.Name, material)); } m_dirtyTree = true; }