Beispiel #1
0
 /// <summary>
 /// Updates every limbs position
 /// </summary>
 public void UpdateLimbPositions()
 {
     for (int i = 0; i < limbs.Count; i++)
     {
         RigLimb currentLimb = limbCollection[limbs[i]];
         limbCollection[limbs[i]].SetPosition(Vector3.Zero);
         UpdateLimbPositions(currentLimb.name);
     }
 }
Beispiel #2
0
        public void Draw(bool drawLines, Vector2 offset, RigLimb rigLimb, DrawBatch drawBatch, float depth, float orientation)
        {
            Vector4 line       = rigLimb.Get2DLine(orientation);
            Vector3 scaleAngle = Texture.GetScaleAndAngle(line);
            int     index      = Texture.GetIndex(GetAngleToDisplay(rigLimb.rotation, orientation));

            Color color = Color.White;

            //if (rigLimb.name == Game1.selectedLimb)
            //{
            //    color = Color.Green;
            //}
            //else
            //    color = Color.White;

            //spriteBatch.Draw(Texture.Texture, new Vector2(line.X + offset.X, line.Y + offset.Y), Texture.GetSourceRectangle(index), color, scaleAngle.Z, new Vector2(8, 8), new Vector2(scaleAngle.X, scaleAngle.Y), SpriteEffects.None, depth);
            if (Game1.rigDrawTextures && rigLimb.drawTexture)
            {
                Rectangle rectangleToDraw = new Rectangle(new Vector2(line.X + offset.X, line.Y + offset.Y).ToPoint(), new Vector2(Texture.Width * scaleAngle.X + Texture.Origin.X * 2, Texture.Height * scaleAngle.Y).ToPoint());

                //float fuckScale = (((rectangleToDraw.Width * 2 - Texture.Origin.X * 2))) / (Texture.Width * 2 + Texture.Origin.X * 2);
                //float fuckOrigin = (Texture.Width / 2) * (1-fuckScale) + ((fuckScale) * Texture.Origin.X);

                float fuckOrigin;
                if (scaleAngle.X < .5f)
                {
                    fuckOrigin = ((Texture.Width / 2f) - (Texture.Width / 4f) * scaleAngle.X) * (1 - scaleAngle.X);// + 8 * (scaleAngle.X);
                }
                else
                {
                    fuckOrigin = Texture.Origin.X + (Texture.Origin.X / 2) * ((1 - scaleAngle.X) * 2);
                }

                if (scaleAngle.X > 1)
                {
                    drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, Texture.Texture, rectangleToDraw, Texture.GetSourceRectangle(index), scaleAngle.Z, new Vector2(Texture.Origin.X / scaleAngle.X, Texture.Origin.Y), color, depth, SpriteEffects.None);
                }
                else
                {
                    drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, Texture.Texture, rectangleToDraw, Texture.GetSourceRectangle(index), scaleAngle.Z, new Vector2(fuckOrigin, Texture.Origin.Y), color, depth, SpriteEffects.None);
                }
            }
            //Game1.DrawLine(spriteBatch, new Vector2(line.X + offset.X, line.Y + offset.Y), new Vector2(line.X + offset.X, line.Y + offset.Y) + Extensions.GetVector2(Texture.Texture.Width * scaleAngle.X, scaleAngle.Z), 2, Color.Lerp(Color.Blue, Color.Transparent, .5f), 0f);

            if (drawLines)
            {
                if (rigLimb.name == Game1.selectedLimb)
                {
                    Game1.DrawLine(drawBatch, new Vector2(line.X + offset.X, line.Y + offset.Y), new Vector2(line.Z + offset.X, line.W + offset.Y), 2, Color.Lerp(Color.Red, Color.Transparent, 0f), depth);
                }
                else
                {
                    Game1.DrawLine(drawBatch, new Vector2(line.X + offset.X, line.Y + offset.Y), new Vector2(line.Z + offset.X, line.W + offset.Y), 2, Color.Lerp(Color.Black, Color.Transparent, 0f), depth);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Adds a limb to the collection and a reference in the parent
        /// </summary>
        /// <param name="limb"></param>
        public void AddLimb(RigLimb limb)
        {
            limbCollection.Add(limb.name, limb);
            limbDrawerCollection.Add(limb.name, new RigLimbDrawer("TestSheet"));

            if (limb.parent == "Rig")
            {
                limbs.Add(limb.name);
            }
            else
            {
                limbCollection[limb.parent].AddLimb(limb.name);
            }
        }