//constructor public CelestialBodyViewModel(UniverseSimulatorController controller, HashSet <CelestialBody> gravitySources, IEnumerable <IMaterial> materials) { _controller = controller; _gravitySources = gravitySources; _materials = materials; }
//para crear desde xml public static CelestialBody CreateFromXml(XElement element, IResourceManager resourceManager, ShapeNode shape, IScene scene, IMaterial axisMaterial, IRenderer renderer, ShapeNode velShape, IMaterial velMaterial, UniverseSimulatorController controller) { //position Vector3 position = new Vector3(); var prop = element.Element("position"); position.X = float.Parse(prop.Element("x").Value, CultureInfo.InvariantCulture); position.Y = float.Parse(prop.Element("y").Value, CultureInfo.InvariantCulture); position.Z = float.Parse(prop.Element("z").Value, CultureInfo.InvariantCulture); //velocity Vector3 velocity = new Vector3(); prop = element.Element("velocity"); velocity.X = float.Parse(prop.Element("x").Value, CultureInfo.InvariantCulture); velocity.Y = float.Parse(prop.Element("y").Value, CultureInfo.InvariantCulture); velocity.Z = float.Parse(prop.Element("z").Value, CultureInfo.InvariantCulture); //velDir Vector3 velDir = new Vector3(); prop = element.Element("velDir"); velDir.X = float.Parse(prop.Element("x").Value, CultureInfo.InvariantCulture); velDir.Y = float.Parse(prop.Element("y").Value, CultureInfo.InvariantCulture); velDir.Z = float.Parse(prop.Element("z").Value, CultureInfo.InvariantCulture); //velLength prop = element.Element("velLength"); float velLength = float.Parse(prop.Value, CultureInfo.InvariantCulture); //rotAxis Vector3 rotAxis = new Vector3(); prop = element.Element("rotAxis"); rotAxis.X = float.Parse(prop.Element("x").Value, CultureInfo.InvariantCulture); rotAxis.Y = float.Parse(prop.Element("y").Value, CultureInfo.InvariantCulture); rotAxis.Z = float.Parse(prop.Element("z").Value, CultureInfo.InvariantCulture); //axisAlignmentRot Quaternion axisAlignmentRot = new Quaternion(); prop = element.Element("axisAlignmentRot"); axisAlignmentRot.X = float.Parse(prop.Element("x").Value, CultureInfo.InvariantCulture); axisAlignmentRot.Y = float.Parse(prop.Element("y").Value, CultureInfo.InvariantCulture); axisAlignmentRot.Z = float.Parse(prop.Element("z").Value, CultureInfo.InvariantCulture); axisAlignmentRot.W = float.Parse(prop.Element("w").Value, CultureInfo.InvariantCulture); //aroundAxisRot Quaternion aroundAxisRot = new Quaternion(); prop = element.Element("aroundAxisRot"); aroundAxisRot.X = float.Parse(prop.Element("x").Value, CultureInfo.InvariantCulture); aroundAxisRot.Y = float.Parse(prop.Element("y").Value, CultureInfo.InvariantCulture); aroundAxisRot.Z = float.Parse(prop.Element("z").Value, CultureInfo.InvariantCulture); aroundAxisRot.W = float.Parse(prop.Element("w").Value, CultureInfo.InvariantCulture); //angularVel prop = element.Element("angularVel"); float angularVel = float.Parse(prop.Value, CultureInfo.InvariantCulture); //angularRot prop = element.Element("angularRot"); float angularRot = float.Parse(prop.Value, CultureInfo.InvariantCulture); //mass prop = element.Element("mass"); float mass = float.Parse(prop.Value, CultureInfo.InvariantCulture); //radius prop = element.Element("radius"); float radius = float.Parse(prop.Value, CultureInfo.InvariantCulture); //hasGravity prop = element.Element("hasGravity"); bool hasGravity = bool.Parse(prop.Value); //isLightSource prop = element.Element("isLightSource"); bool isLightSource = bool.Parse(prop.Value); //name prop = element.Element("name"); string name = prop.Value; //material prop = element.Element("material"); string materialName = prop.Value; IMaterial material = resourceManager.GetMaterial(materialName); var cb = new CelestialBody(controller, position, shape, scene, axisMaterial, renderer, velShape, velMaterial); cb.Velocity = velocity; cb.VelocityLength = velLength; cb.VelocityDirection = velDir; cb.RotationAxis = rotAxis; cb.AxisAlignmentRotation = axisAlignmentRot; cb._aroundAxisRot = aroundAxisRot; cb.AngularVelocity = angularVel; cb._angularRot = angularRot; cb.Mass = mass; cb.Radius = radius; cb.HasGravity = hasGravity; cb.IsLightSource = isLightSource; cb.Name = name; cb.Material = material; return(cb); }
public LeftToolView(UniverseSimulatorController controller) { InitializeComponent(); _controller = controller; }
public CelestialBody(UniverseSimulatorController controller, Vector3 position, ShapeNode shape, IScene scene, IMaterial axisMaterial, IRenderer renderer, ShapeNode velShape, IMaterial velMaterial) { _controller = controller; _shape = shape; _defaultMaterial = shape.Shape.Material; _scene = scene; _renderer = renderer; _radius = 20; _mass = 100; _position = position; _velLength = 1; _velDir = Vector3.UnitX; _velocity = _velDir * _velLength; _rotAxis = Vector3.UnitZ; _angularRot = 0; _angularVel = 0; _hasGravity = false; _isLightSource = false; _isLightInScene = false; _name = "No name"; _nextPosition = _position; _nextVelocity = _velocity; _shapeToCelestialBodyMap.Add(_shape, this); _shape.Scale = new Vector3(_radius); _shape.Position = _position; _shape.Rotation = TextureCorrection; _lightUp = new PointLight(Color4.Yellow); _lightDown = new PointLight(Color4.Yellow); _lightLeft = new PointLight(Color4.Yellow); _lightRight = new PointLight(Color4.Yellow); _lightFront = new PointLight(Color4.Yellow); _lightBack = new PointLight(Color4.Yellow); //_lightCenter = new PointLight(Color4.Yellow); _axisLine = new Curve("axis" + _axisCounter++, 4); _axisLine.Material = axisMaterial; _axisBottom = new Vertex(_position - _rotAxis * _radius * 1.4f, DummyVector3, DummyVector3); _axisTop = new Vertex(_position + _rotAxis * _radius * 1.4f, DummyVector3, DummyVector3); _axisLine.AddPoint(_axisBottom); _axisLine.AddPoint(_axisTop); _axisLine.Configure(_renderer); _axisAlignmentRot = TextureCorrection; _aroundAxisRot = Quaternion.Identity; //velocity ball and line _velBall = velShape; _velOrigin = new Vertex(); _velTip = new Vertex(); _velLine = new Curve("velLine" + _velLineCounter++, 2); _velLine.Material = velMaterial; UpdateVelocityLineAndBall(); }
public TopToolView(UniverseSimulatorController controller) { InitializeComponent(); _controller = controller; this.Visibility = System.Windows.Visibility.Collapsed; }