Esempio n. 1
0
        public SceneObject(SavedSceneObject savedSceneObject)
        {
            Id = savedSceneObject.ObjectID;

            if (string.IsNullOrEmpty(savedSceneObject.ModelPath) == false)
            {
                model = new ModelLoader(SceneManager.currentRenderer.device).LoadRelative(savedSceneObject.ModelPath);
            }
            material  = savedSceneObject.Material;
            transform = new Transform(savedSceneObject.Transform);

            animationComponent = savedSceneObject.AnimationComponent;
            if (animationComponent != null)
            {
                AddComponent(animationComponent);
            }

            foreach (var component in savedSceneObject.Components)
            {
                AddComponent(component);
            }
        }
Esempio n. 2
0
        private static SceneObject CreatePlanet(float orbitRotationSpeed, float orbitDistance, float planetScale, SimpleMaterial baseMaterial, Vector4 planetColor, Model model, Transform parentTransform = null)
        {
            SceneObject planetRoot = new SceneObject();
            SimpleTransformAnimationComponent animationComponent = new SimpleTransformAnimationComponent()
            {
                RotationSpeed = new Vector3(orbitRotationSpeed, 0, 0),
            };

            planetRoot.AddComponent(animationComponent);
            planetRoot.animationComponent = animationComponent;
            planetRoot.transform.parent   = parentTransform;
            SceneObject planet = new SceneObject();

            planet.model = model;
            planet.transform.LocalPositionX = orbitDistance;
            planet.transform.LocalScale     = Vector3.One * planetScale;
            planet.transform.parent         = planetRoot.transform;
            SimpleMaterial planetMaterial = baseMaterial.CreateInstanceTyped();

            planetMaterial.pixelShaderData.DiffuseColor = planetColor;
            planet.material = planetMaterial;

            return(planet);
        }