• Advertisement
Sign in to follow this  

Ribbon trail technique

This topic is 1588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys


Ive been researching the subject of the ribbon trail technique or the sword slash effect (picture below) and was wondering if anyone could provide any advice on how  this is implemented from one time frame of an animated model to the next.






Share this post

Link to post
Share on other sites

I came across a forum topic(link below)  in which the contributor jwatte  gave instructions on how to put together a ribbon trail

but the part where he writes "each frame, you shift the position of each pair of vertices "over" one -- vertex 0 becomes vertex 2, vertex 1 becomes vertex 3, etc." .Im not sure how I would go about implementing this part



ribbon trail link




trianglestrip code

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace TRISTRIP
    public class Game1 : Microsoft.Xna.Framework.Game
        GraphicsDeviceManager graphics;
        GraphicsDevice device;
        BasicEffect basicEffect;
        QuakeCamera fpsCam;
        CoordCross cCross;

        VertexPositionColor[] vertices;
        VertexDeclaration myVertexDeclaration;

        public Game1()
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

        protected override void Initialize()
            fpsCam = new QuakeCamera(GraphicsDevice.Viewport);            

        protected override void LoadContent()
            device = graphics.GraphicsDevice;
            basicEffect = new BasicEffect(device, null);
            cCross = new CoordCross(device);

        private void InitVertices()
            myVertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements);
            vertices = new VertexPositionColor[12];

            vertices[0] = new VertexPositionColor(new Vector3(-5, 1, 1), Color.Red);
            vertices[1] = new VertexPositionColor(new Vector3(-5, 5, 1), Color.Green);
            vertices[2] = new VertexPositionColor(new Vector3(-3, 1, 1), Color.Blue);

            vertices[3] = new VertexPositionColor(new Vector3(-3, 5, 1), Color.Gray);
            vertices[4] = new VertexPositionColor(new Vector3(-1, 1, 1), Color.Purple);
            vertices[5] = new VertexPositionColor(new Vector3(-1, 5, 1), Color.Orange);

            vertices[6] = new VertexPositionColor(new Vector3(1, 1, 1), Color.BurlyWood);
            vertices[7] = new VertexPositionColor(new Vector3(1, 5, 1), Color.Gray);
            vertices[8] = new VertexPositionColor(new Vector3(3, 1, 1), Color.Green);

            vertices[9] = new VertexPositionColor(new Vector3(3, 5, 1), Color.Yellow);
            vertices[10] = new VertexPositionColor(new Vector3(5, 1, 1), Color.Blue);
            vertices[11] = new VertexPositionColor(new Vector3(5, 5, 1), Color.Red);

        protected override void UnloadContent()

        protected override void Update(GameTime gameTime)
            GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);
            if (gamePadState.Buttons.Back == ButtonState.Pressed)

            MouseState mouseState = Mouse.GetState();
            KeyboardState keyState = Keyboard.GetState();
            if (keyState.IsKeyDown(Keys.Escape))
                this.Exit(); // Exit with ESC key

            fpsCam.Update(mouseState, keyState, gamePadState);


        protected override void Draw(GameTime gameTime)
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

            //draw triangles
            device.RenderState.CullMode = CullMode.None;
            basicEffect.World = Matrix.Identity;
            basicEffect.View = fpsCam.ViewMatrix;
            basicEffect.Projection = fpsCam.ProjectionMatrix;
            basicEffect.VertexColorEnabled = true;

            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
                device.VertexDeclaration = myVertexDeclaration;
                device.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, vertices, 0, 10);


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement