Ejemplo n.º 1
0
        public EntityLink LinkEntity(Entity linkedEntity, ModelComponent modelComponent, string boneName)
        {
            var modelEntityData = matchingEntities[modelComponent.Entity];
            var nodeIndex       = modelEntityData.ModelComponent.ModelViewHierarchy.Nodes.IndexOf(x => x.Name == boneName);

            var entityLink = new EntityLink {
                Entity = linkedEntity, ModelComponent = modelComponent, NodeIndex = nodeIndex
            };

            if (nodeIndex == -1)
            {
                return(entityLink);
            }

            linkedEntity.Transformation.isSpecialRoot = true;
            linkedEntity.Transformation.UseTRS        = false;

            if (modelEntityData.Links == null)
            {
                modelEntityData.Links = new List <EntityLink>();
            }

            modelEntityData.Links.Add(entityLink);

            return(entityLink);
        }
Ejemplo n.º 2
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            font = Asset.Load<SpriteFont>("Font");
            teapot = Asset.Load<Model>("Teapot");
            batch = new SpriteBatch(GraphicsDevice);

            BuildUI();

            spriteComponent = new SpriteComponent { SpriteProvider = new SpriteFromSheet { Sheet = Asset.Load<SpriteSheet>("SpriteSheet") } };
            modelComponent = new ModelComponent { Model = teapot };
            modelComponent2 = new ModelComponent { Model = teapot };
            modelComponent3 = new ModelComponent { Model = teapot };
            entity = new Entity { spriteComponent, modelComponent };
            entity2 = new Entity { modelComponent2 };
            entity3 = new Entity { modelComponent3 };
            SceneSystem.SceneInstance.Scene.Entities.Add(entity);
            SceneSystem.SceneInstance.Scene.Entities.Add(entity2);
            SceneSystem.SceneInstance.Scene.Entities.Add(entity3);

            if (Input.Accelerometer.IsSupported)
                Input.Accelerometer.IsEnabled = true;

            if (Input.Compass.IsSupported)
                Input.Compass.IsEnabled = true;

            if (Input.Gyroscope.IsSupported)
                Input.Gyroscope.IsEnabled = true;

            if (Input.UserAcceleration.IsSupported)
                Input.UserAcceleration.IsEnabled = true;

            if (Input.Gravity.IsSupported)
                Input.Gravity.IsEnabled = true;

            if (Input.Orientation.IsSupported)
                Input.Orientation.IsEnabled = true;

            ChangeScene(0);
        }
Ejemplo n.º 3
0
 public ModelNodeTransformLink(ModelComponent parentModelComponent, string nodeName, bool forceRecursive)
 {
     this.parentModelComponent = parentModelComponent;
     this.nodeName             = nodeName;
     this.forceRecursive       = forceRecursive;
 }
Ejemplo n.º 4
0
 public RenderModel(ModelComponent modelComponent)
 {
     RenderMeshesPerEffectSlot = new FastListStruct<FastListStruct<RenderMesh>>(4);
     ModelComponent = modelComponent;
 }
 public ModelViewHierarchyTransformOperation(ModelComponent modelComponent)
 {
     this.modelComponent = modelComponent;
 }
Ejemplo n.º 6
0
        public static async Task GenerateTestPrefabs(EngineContext engineContext)
        {
            var entityCube = new Entity("Cube");
            var meshComponent = new ModelComponent();
            meshComponent.SubMeshes.Add(new EffectMeshData { EffectData = new EffectData("SimpleCube"), MeshData = MeshDataHelper.CreateBox(100.0f, 100.0f, 100.0f, Color.Gray) });
            entityCube.Set(ModelComponent.Key, meshComponent);
            entityCube.Set(TransformationComponent.Key, new TransformationComponent());
            engineContext.AssetManager.Url.Set(entityCube, "/global_data/cube.hotei#/root");
            engineContext.AssetManager.Save(entityCube);

            var entitySphere = new Entity("Cube");
            meshComponent = new ModelComponent();
            meshComponent.SubMeshes.Add(new EffectMeshData { EffectData = new EffectData("SimpleCube"), MeshData = MeshDataHelper.CreateSphere(100.0f, 30, 30, Color.Gray) });
            entitySphere.Set(ModelComponent.Key, meshComponent);
            entitySphere.Set(TransformationComponent.Key, new TransformationComponent());
            engineContext.AssetManager.Url.Set(entitySphere, "/global_data/sphere.hotei#/root");
            engineContext.AssetManager.Save(entitySphere);
        }
Ejemplo n.º 7
0
 public ModelNodeTransformLink(ModelComponent parentModelComponent, string nodeName, bool forceRecursive)
 {
     this.parentModelComponent = parentModelComponent;
     this.nodeName = nodeName;
     this.forceRecursive = forceRecursive;
 }