public void WriteXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("Position/X", true, out subEle);
            subEle.Value = PositionX.ToString("G15");

            ele.TryPathTo("Position/Y", true, out subEle);
            subEle.Value = PositionY.ToString("G15");

            ele.TryPathTo("Position/Z", true, out subEle);
            subEle.Value = PositionZ.ToString("G15");

            ele.TryPathTo("Rotation/X", true, out subEle);
            subEle.Value = RotationX.ToString("G15");

            ele.TryPathTo("Rotation/Y", true, out subEle);
            subEle.Value = RotationY.ToString("G15");

            ele.TryPathTo("Rotation/Z", true, out subEle);
            subEle.Value = RotationZ.ToString("G15");

            ele.TryPathTo("Scale", true, out subEle);
            subEle.Value = Scale.ToString("G15");
        }
        protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("Door", true, out subEle);
            Door.WriteXML(subEle, master);

            ele.TryPathTo("Position/X", true, out subEle);
            subEle.Value = PositionX.ToString("G15");

            ele.TryPathTo("Position/Y", true, out subEle);
            subEle.Value = PositionY.ToString("G15");

            ele.TryPathTo("Position/Z", true, out subEle);
            subEle.Value = PositionZ.ToString("G15");

            ele.TryPathTo("Rotation/X", true, out subEle);
            subEle.Value = RotationX.ToString("G15");

            ele.TryPathTo("Rotation/Y", true, out subEle);
            subEle.Value = RotationY.ToString("G15");

            ele.TryPathTo("Rotation/Z", true, out subEle);
            subEle.Value = RotationZ.ToString("G15");

            ele.TryPathTo("Alarm", true, out subEle);
            subEle.Value = Alarm.ToString();
        }
Exemplo n.º 3
0
 internal void Write(EndianBinaryWriter writer)
 {
     AnchorZ.Write(writer);
     PositionZ.Write(writer);
     DirectionX.Write(writer);
     DirectionY.Write(writer);
     DirectionZ.Write(writer);
     RotationX.Write(writer);
     RotationY.Write(writer);
     ScaleZ.Write(writer);
 }
Exemplo n.º 4
0
 internal void Read(EndianBinaryReader reader)
 {
     AnchorZ.Read(reader);
     PositionZ.Read(reader);
     DirectionX.Read(reader);
     DirectionY.Read(reader);
     DirectionZ.Read(reader);
     RotationX.Read(reader);
     RotationY.Read(reader);
     ScaleZ.Read(reader);
 }
Exemplo n.º 5
0
        void FireBullet(float val)
        {
            Bullet bullet = BulletFactory.Self.CreateNew();

            bullet.Position = this.Position;
            int velocity = 180;

            if (!RotationY.Equals(0))
            {
                velocity *= -1;
            }
            bullet.VelocityY = velocity;
        }
Exemplo n.º 6
0
        public void Render()
        {
            Vector3 position       = new Vector3(PositionX, PositionY, PositionZ);
            Vector3 lookAt         = new Vector3(0, 0, 1.0f);
            float   pitch          = RotationX.ToRadians();
            float   yaw            = RotationY.ToRadians();
            float   roll           = RotationZ.ToRadians();
            Matrix  rotationMatrix = Matrix.RotationYawPitchRoll(yaw, pitch, roll);

            lookAt = Vector3.TransformCoordinate(lookAt, rotationMatrix);
            lookAt = position + lookAt;
            Vector3 up = Vector3.TransformCoordinate(Vector3.UnitY, rotationMatrix);

            ViewMatrix = Matrix.LookAtLH(position, lookAt, up);
        }
Exemplo n.º 7
0
 internal void Write(EndianBinaryWriter writer)
 {
     EyeX.Write(writer);
     EyeY.Write(writer);
     EyeZ.Write(writer);
     PositionX.Write(writer);
     PositionY.Write(writer);
     PositionZ.Write(writer);
     DirectionX.Write(writer);
     DirectionY.Write(writer);
     DirectionZ.Write(writer);
     RotationX.Write(writer);
     RotationY.Write(writer);
     RotationZ.Write(writer);
     Zoom.Write(writer);
 }
Exemplo n.º 8
0
 internal void Read(EndianBinaryReader reader)
 {
     EyeX.Read(reader);
     EyeY.Read(reader);
     EyeZ.Read(reader);
     PositionX.Read(reader);
     PositionY.Read(reader);
     PositionZ.Read(reader);
     DirectionX.Read(reader);
     DirectionY.Read(reader);
     DirectionZ.Read(reader);
     RotationX.Read(reader);
     RotationY.Read(reader);
     RotationZ.Read(reader);
     Zoom.Read(reader);
 }
Exemplo n.º 9
0
            /// <summary>
            /// JointName is only checked if in both objects JointName is not NULL. Everything else is checked regardless
            /// </summary>
            /// <param name="obj"></param>
            /// <returns></returns>
            public override bool Equals(object obj)
            {
                if (!(obj is BoneAnimation animation))
                {
                    return(false);
                }
                bool result = TranslationX.SequenceEqual(animation.TranslationX) &&
                              TranslationY.SequenceEqual(animation.TranslationY) &&
                              TranslationZ.SequenceEqual(animation.TranslationZ) &&
                              RotationX.SequenceEqual(animation.RotationX) &&
                              RotationY.SequenceEqual(animation.RotationY) &&
                              RotationZ.SequenceEqual(animation.RotationZ) &&
                              ScaleX.SequenceEqual(animation.ScaleX) &&
                              ScaleY.SequenceEqual(animation.ScaleY) &&
                              ScaleZ.SequenceEqual(animation.ScaleZ);

                return(result && ((JointName != null && animation.JointName != null) ? JointName.Equals(animation.JointName) : true));
            }
Exemplo n.º 10
0
        public int CompareTo(StaticPlacement other)
        {
            int result = 0;

            if (result == 0 && PositionZ != null && other.PositionZ != null)
            {
                result = PositionZ.CompareTo(other.PositionZ);
            }

            if (result == 0 && PositionX != null && other.PositionX != null)
            {
                result = PositionX.CompareTo(other.PositionX);
            }

            if (result == 0 && PositionY != null && other.PositionY != null)
            {
                result = PositionY.CompareTo(other.PositionY);
            }

            if (result == 0 && RotationX != null && other.RotationX != null)
            {
                result = RotationX.CompareTo(other.RotationX);
            }

            if (result == 0 && RotationY != null && other.RotationY != null)
            {
                result = RotationY.CompareTo(other.RotationY);
            }

            if (result == 0 && RotationZ != null && other.RotationZ != null)
            {
                result = RotationZ.CompareTo(other.RotationZ);
            }

            if (result == 0 && Scale != null && other.Scale != null)
            {
                result = Scale.CompareTo(other.Scale);
            }

            return(result);
        }
Exemplo n.º 11
0
        /// <summary>
        /// <para>Draws the shape at the desired coordinates. Coordinates are aligned to world coordinates.</para>
        /// <para>If you place this draw in a Tile draw such as SpecialDraw, post-draw, or another Tile draw, it will not draw at 60 fps.</para>
        /// <para>To draw your 3D model at 60 FPS, place it in the main Mod Draw function of your mod and set (ModifyInterfaceLayerFix = true).</para>
        /// </summary>
        /// <param name="spriteBatch">Spritebatch that will be used to draw this shape.</param>
        /// <param name="pos">The world coordinate to draw this shape.</param>
        public void Draw(Vector2 pos)
        {
            SpriteBatch spriteBatch = Main.spriteBatch;

            //if (_framesSkipped >= FrameskipCount)
            //{
            //	_framesSkipped = 0;
            //	return;
            //}
            //else
            //{
            //	_framesSkipped++;
            //}

            if (!Visible)
            {
                return;
            }

            _effect = new BasicEffect(spriteBatch.GraphicsDevice);

            // The effect world matrix will handle all visual tranformations to our model
            // This is easier than transforming all the vertices of our model one-by-one
            _effect.World =
                // Handles Rotation
                Matrix.CreateFromYawPitchRoll(
                    (float)RotationX.ToRadians(),
                    (float)RotationY.ToRadians(),
                    (float)RotationZ.ToRadians());

            if (ModifyInterfaceLayerFix)
            {
                // Handles Game Zoom set by the Zoom slider
                _effect.World *=
                    Matrix.CreateScale(
                        Main.GameViewMatrix.Zoom.X,
                        Main.GameViewMatrix.Zoom.X,
                        Main.GameViewMatrix.Zoom.Y);
            }

            var posWorldtoScreenCoords = Main.screenPosition - pos;

            // This is not respecting coordinates when put in Tile Draw
            // When this is ran through ModifyLayerInterface, it works appropriately
            // I have no clue what is going on. This is a major impedement.
            if (false)
            {
                float aspectRatio =
                    Main.graphics.GraphicsDevice.Viewport.Width / (float)Main.graphics.GraphicsDevice.Viewport.Height;
                float fieldOfView   = MathHelper.PiOver4;
                float nearClipPlane = 1;
                float farClipPlane  = 10000;

                _effect.View = Matrix.CreateLookAt(
                    new Vector3(0, 100, 0),           // Camera Position
                    Vector3.Zero,                     // Look-at Vector
                    Vector3.UnitZ);                   // Up Axis is Z

                var x       = (((float)Main.screenWidth / 2f)) + posWorldtoScreenCoords.X;
                var y       = (((float)Main.screenHeight / 2f)) + posWorldtoScreenCoords.Y;
                var yOffset = -862f;

                if (ModifyInterfaceLayerFix)
                {
                    x *= Main.GameZoomTarget;
                    y *= Main.GameZoomTarget;
                }
                else
                {
                    x += Main.GameZoomTarget;
                    y += Main.GameZoomTarget;
                }

                _effect.World = _effect.World
                                * Matrix.CreateTranslation(x, yOffset, y);

                _effect.Projection = Matrix.CreatePerspectiveFieldOfView(
                    fieldOfView, aspectRatio, nearClipPlane, farClipPlane);
            }
            else if (Projection == ProjectionType.Orthographic)
            {
                // We control the objects rotation by controlling the world
                // This way, we don't need to adjust every individual vertice

                _effect.View = Matrix.CreateLookAt(
                    new Vector3(0, 10000, 0),         // Camera Position
                    Vector3.Zero,                     // Look-at Vector
                    Vector3.UnitZ);                   // Up Axis is Z

                var x = ((float)Main.screenWidth / 2f + posWorldtoScreenCoords.X);
                var y = ((float)Main.screenHeight / 2f + posWorldtoScreenCoords.Y);

                if (ModifyInterfaceLayerFix)
                {
                    x *= Main.GameZoomTarget;
                    y *= Main.GameZoomTarget;
                }

                // Moves the object to the desired position
                // Multiplying the Matrices "adds" them together
                //
                // We translate the Y 3000 pixels towards us
                // so we can see 3D models up to 3000 pixels large
                // We don't see the Y axis in Orthographic mode
                // so it doesn't matter how large we make it!
                _effect.World = _effect.World
                                * Matrix.CreateTranslation(x, 3000, y);

                // Produces the "flat" style
                _effect.Projection =
                    Matrix.CreateOrthographic(
                        Main.graphics.GraphicsDevice.Viewport.Width,
                        Main.graphics.GraphicsDevice.Viewport.Height, -10000, 10000);
            }
            spriteBatch.End();

            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, _effect);
            {
                Main.graphics.GraphicsDevice.RasterizerState   = rasterizerState;
                Main.graphics.GraphicsDevice.DepthStencilState = depthStencilState;
                Main.graphics.GraphicsDevice.BlendState        = blendState;

                foreach (var face in Faces)
                {
                    _effect.TextureEnabled = true;
                    _effect.Texture        = face.Texture ?? DefaultTexture;

                    // Lighting
                    var     x     = (int)(pos.X) / 16;
                    var     y     = (int)(pos.Y) / 16;
                    Vector3 color = Lighting.GetColor(x, y).ToVector3();

                    _effect.LightingEnabled = true;
                    _effect.DirectionalLight0.DiffuseColor = color;
                    _effect.DirectionalLight1.DiffuseColor = color;
                    _effect.DirectionalLight2.DiffuseColor = color;
                    _effect.AmbientLightColor = color;
                    _effect.DiffuseColor      = color;
                    _effect.EmissiveColor     = color;

                    foreach (var pass in _effect.CurrentTechnique.Passes)
                    {
                        pass.Apply();

                        spriteBatch.GraphicsDevice.DrawUserPrimitives(
                            PrimitiveType.TriangleList,
                            face.Composition,
                            0,
                            face.PolygonCount);
                    }
                }

                spriteBatch.End();
            }

            Main.graphics.GraphicsDevice.RasterizerState   = previousRS;
            Main.graphics.GraphicsDevice.DepthStencilState = previousDS;
            Main.graphics.GraphicsDevice.BlendState        = previousBS;
            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
        }