• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
MohammadAhmed

Skinned Animation problem

19 posts in this topic

Hello every one , 

I am using Microsoft skinned model sample  , and my problem is Transformation problem ( Rotation).

 

Q : How to rotate the skinned model around when the camera move , and how to show the skinned model hand ?.( I just use camera.translation to translate the model and it's okay but it's not rotated ?? ).

Q2 : I assign a gun for  the model hand , now how to rotate the model hand + gun ?

0

Share this post


Link to post
Share on other sites

You want hands and gun to follow camera like in FPS games?

 

// offset matrix of gun/hand to reposition it where you like
matrix offMat;
offMat.rotate(...);
offMat.translate(...);
 
// take camera view matrix and invert it
matrix viewInvMat = camera->view;
viewInvMat.inverse();
 
// final transform
matrix finalMat = offMat * viewInvMat;
0

Share this post


Link to post
Share on other sites

You want hands and gun to follow camera like in FPS games?

 

 

// offset matrix of gun/hand to reposition it where you like
matrix offMat;
offMat.rotate(...);
offMat.translate(...);
 
// take camera view matrix and invert it
matrix viewInvMat = camera->view;
viewInvMat.inverse();
 
// final transform
matrix finalMat = offMat * viewInvMat;

This causes the model to behave oddly. The model lags behind where your camera is actually looking and the movement is jagged. Maybe a render target would work? I had a problem with my model's alpha a little while ago; it has since been fixed. The source I posted in this thread (http://www.gamedev.net/topic/639931-rendertargets-and-transparency) covers pretty much everything you need (both the code, and the shader).

0

Share this post


Link to post
Share on other sites

This causes the model to behave oddly. The model lags behind where your camera is actually looking and the movement is jagged

Thats for you maybe, for me it works fine.

 

I assume that model is centered at origin and "pointing" in positive Z axis. Camera view matrix must be updated before you extract view matrix and use it for gun/hand final matrix.

0

Share this post


Link to post
Share on other sites

Thanks for both of you  , vinn smile.png your code is great I will try it and post a reply okay smile.png , belfegor I try it before and did not work for me :/ sorry , by the way thank you .

Q1 : How to show just the model hand  and the gun ?
Q2 : How to make the town hands catch the gun (not just one !) , is that should be done in modeling software or I can make this as transformation matrices based on View    matrices ....etc ?

Edited by mrmohadnan
0

Share this post


Link to post
Share on other sites

This causes the model to behave oddly. The model lags behind where your camera is actually looking and the movement is jagged

Thats for you maybe, for me it works fine.

 

I assume that model is centered at origin and "pointing" in positive Z axis. Camera view matrix must be updated before you extract view matrix and use it for gun/hand final matrix.

Yeah, I see what you mean. It'll be easier to just draw the model in front of the camera.

 

 


 

 


Thanks for both of you  , vinn smile.png your code is great I will try it and post a reply okay smile.png , belfegor I try it before and did not work for me :/ sorry , by the way thank you .

Q1 : How to show just the model hand  and the gun ?
Q2 : How to make the town hands catch the gun (not just one !) , is that should be done in modeling software or I can make this as transformation matrices based on View    matrices ....etc ?

 

One: You normally make a model of just the hands and the gun, then draw it in front of the screen or on a render target.

 

Two: You want the same model to hold and use multiple weapons? It'll probably be easier to just model the hands onto the guns, and animate it from there. So you will have to use some modeling software. Blender is free, if you don't have anything to use.

 

I use two models, one is the third person model; I only use it in multiplayer or for shadows. The second is the first person view. Which is just the arms and weapons.

 

Here is a debug photo to help you visualize how the model looks and how to draw it.

7fiYdph.png

Edited by vinnyhalts
1

Share this post


Link to post
Share on other sites

woooooow vin :)  I am so happy for your code and the result , I will post comments ok If I face any problem :) so pls check my post while you are here if you have time .

0

Share this post


Link to post
Share on other sites

 

This causes the model to behave oddly. The model lags behind where your camera is actually looking and the movement is jagged

Thats for you maybe, for me it works fine.

 

I assume that model is centered at origin and "pointing" in positive Z axis. Camera view matrix must be updated before you extract view matrix and use it for gun/hand final matrix.

Yeah, I see what you mean. It'll be easier to just draw the model in front of the camera.

 

 


 

 


>>>>>Thanks for both of you  , vinn smile.png your code is great I will try it and post a reply okay smile.png , belfegor I try it before and did not work for me :/ sorry , by the way thank you .

Q1 : How to show just the model hand  and the gun ?
Q2 : How to make the town hands catch the gun (not just one !) , is that should be done in modeling software or I can make this as transformation matrices based on View    matrices ....etc ?

 

One: You normally make a model of just the hands and the gun, then draw it in front of the screen or on a render target.

 

Two: You want the same model to hold and use multiple weapons? It'll probably be easier to just model the hands onto the guns, and animate it from there. So you will have to use some modeling software. Blender is free, if you don't have anything to use.

 

I use two models, one is the third person model; I only use it in multiplayer or for shadows. The second is the first person view. Which is just the arms and weapons.

 

Here is a debug photo to help you visualize how the model looks and how to draw it.

7fiYdph.png

 


Yeah , I got it , but for  enemy models ? I can't do the same for them , so I can't just draw their hands ( Right vinn ?) . I see  you just make a trick by drawing the Model hands ! and used person model to simulate shadows , but you don't draw the person model . Instead , you used him to draw shadow  ? ( Right Vinn ?)

Q : OK but what about the ragDoll to simulate model when dies ?

Q2 : Second , Vinn in your post  "http://www.gamedev.net/topic/639931-rendertargets-and-transparency/  " why did you use render target ? why just not draw the model with it's transformation matrices to rotate the hands ? is that hard implementation or what ?
 

Q3 : Can you Vinn summarize the process of rotating Model hand and the gun ?( as I am now a little bit confusing as I did not even think to draw just model hands , I am using skinned model sample from Microsoft  and I do every thing for the model (sit , run , stop ...etc) and all I need is to rotate his hands and gun while his body just follow the camera by changing it's translation matrices )

Edited by mrmohadnan
0

Share this post


Link to post
Share on other sites

 

 

This causes the model to behave oddly. The model lags behind where your camera is actually looking and the movement is jagged

Thats for you maybe, for me it works fine.

 

I assume that model is centered at origin and "pointing" in positive Z axis. Camera view matrix must be updated before you extract view matrix and use it for gun/hand final matrix.

Yeah, I see what you mean. It'll be easier to just draw the model in front of the camera.

 

 


 

 


>>>>>Thanks for both of you  , vinn smile.png your code is great I will try it and post a reply okay smile.png , belfegor I try it before and did not work for me :/ sorry , by the way thank you .

Q1 : How to show just the model hand  and the gun ?
Q2 : How to make the town hands catch the gun (not just one !) , is that should be done in modeling software or I can make this as transformation matrices based on View    matrices ...

.etc ?

 

One: You normally make a model of just the hands and the gun, then draw it in front of the screen or on a render target.

 

Two: You want the same model to hold and use multiple weapons? It'll probably be easier to just model the hands onto the guns, and animate it from there. So you will have to use some modeling software. Blender is free, if you don't have anything to use.

 

I use two models, one is the third person model; I only use it in multiplayer or for shadows. The second is the first person view. Which is just the arms and weapons.

 

Here is a debug photo to help you visualize how the model looks and how to draw it.

7fiYdph.png


Yeah , I got it , but for  enemy models ? I can't do the same for them , so I can't just draw their hands ( Right vinn ?) . I see  you just make a trick by drawing the Model hands ! and used person model to simulate shadows , but you don't draw the person model . Instead , you used him to draw shadow  ? ( Right Vinn ?)

Q : OK but what about the ragDoll to simulate model when dies ?

Q2 : Second , Vinn in your post  "http://www.gamedev.net/topic/639931-rendertargets-and-transparency/  " why did you use render target ? why just not draw the model with it's transformation matrices to rotate the hands ? is that hard implementation or what ?
 

Q3 : Can you Vinn summarize the process of rotating Model hand and the gun ?( as I am now a little bit confusing as I did not even think to draw just model hands , I am using skinned model sample from Microsoft  and I do every thing for the model (sit , run , stop ...etc) and all I need is to rotate his hands and gun while his body just follow the camera by changing it's translation matrices )

 

 

Most of the time the ragdoll is tied in with the physics. BEPUPhysics is excellent and free. Take a look at their action figure and one armed man demos. They should solve your ragdoll problems.

 

As for the render target, I was going to use different rendering styles for the environment and weapons.

 

To move the hands, you would simply play the animation you want to use. So for example, when you press W to go forward (on the PC), you set the current playing animation to your walking animation. When you are idle, play the idle animation. It's less than ideal to draw an entire player's model, then put the camera behind the arms. The 3rd person model and the arms should be two different models.

 

So just to summarize:

1. Draw the arms on screen, in front of the camera.

2. Set the current animation based on player movement.

3. Play the animation.

 

Here is a pretty decent animation library: http://animationcomponents.codeplex.com/

1

Share this post


Link to post
Share on other sites

wooooow , thank you Vinn , I will never forget your help :) , I done using BEPU , now it's time to check out Animation library , so I will post questions later .

0

Share this post


Link to post
Share on other sites

still have some problems with rendering the hands in front of the camera ! ,

[URL=http://www.mediafire.com/view/?bmudn5ir9fjq75z]bmudn5ir9fjq75z4g.jpg[/URL]

            // Update Transformation Data of CharachterController
            CharachterControllerPosition = camera.Position;
            CharachterControllerRotaion = Matrix.CreateFromYawPitchRoll(cci.Camera.Yaw,cci.Camera.Pitch,0);
            CharachterControllerWorldTransform = cci.CharacterController.Body.WorldTransform;
            #endregion

            // Update Player
            Matrix translatePlayer = Matrix.CreateTranslation(camera.Position);
            Matrix scalePlayer = Matrix.CreateScale(0.08f);
            Matrix rotatePlayer = Matrix.CreateFromYawPitchRoll(cci.Camera.Yaw, cci.Camera.Pitch, 0) ;
            staticModel.Transform = scalePlayer * rotatePlayer * translatePlayer;
Edited by mrmohadnan
0

Share this post


Link to post
Share on other sites

the hands not front of the camera , it just move with the camera and rotate but not in front of the camera

0

Share this post


Link to post
Share on other sites

hello again ! , 

I am very happy to be with experienced game developers , so I hope some one try to see the problem in my code , as the hands associated with the gun did not positoned in front of camera !!! , I tried out  a lot of ways to figure it out but ??  here is the code ????????????????????? :/ I hate this code very much !

 

           
{..
..
...
..
.
            // Update player Weapon and hands
            weaponWorldMatrix = WeaponWorldMatrix(0.45f, -0.75f, 1.65f);
            staticModel.Transform = weaponWorldMatrix;
            /*
            Vector3 forward = cameraa.ViewMatrix.Forward * new Vector3(40);
            Matrix translatePlayer = Matrix.CreateTranslation(cameraa.ViewMatrix.Translation + forward);
            Matrix scalePlayer = Matrix.CreateScale(10f);
            Matrix rotatePlayer = Matrix.Invert(Matrix.CreateFromYawPitchRoll(cameraa.Yaw, cameraa.Pitch, 0));
            staticModel.Transform = (scalePlayer * rotatePlayer * translatePlayer );
            */
}

        /// <summary>
        /// Calculates the world transformation matrix for the weapon attached
        /// to the FirstPersonCamera. The weapon moves along with the camera.
        /// The offsets are to ensure the weapon is slightly in front of the
        /// camera and to one side.
        /// </summary>
        /// <param name="xOffset">How far to position the weapon left or right.</param>
        /// <param name="yOffset">How far to position the weapon up or down.</param>
        /// <param name="zOffset">How far to position the weapon in front or behind.</param>
        /// <returns>The weapon world transformation matrix.</returns>
        public Matrix WeaponWorldMatrix(float xOffset, float yOffset, float zOffset)
        {
            Vector3 weaponPos = cci.Camera.Position;

            weaponPos = cci.Camera.WorldMatrix.Translation + new Vector3(10, -10, 10);

            return Matrix.CreateRotationX(MathHelper.ToRadians(cci.Camera.Yaw))
                    * Matrix.CreateRotationY(MathHelper.ToRadians(cci.Camera.Pitch))
                    * Matrix.CreateTranslation(weaponPos);
        }
Edited by mrmohadnan
0

Share this post


Link to post
Share on other sites

I don't know if the problem was from my Camera implementation :

 

        public void Update(float dt, KeyboardState keyboardInput, MouseState mouseInput)
        {
            Yaw += (200 - mouseInput.X) * dt * .32f;
            Pitch += (200 - mouseInput.Y) * dt * .32f;


            WorldMatrix = Matrix.CreateFromAxisAngle(Vector3.Right, Pitch) * Matrix.CreateFromAxisAngle(Vector3.Up, Yaw);

            WorldMatrix = WorldMatrix * Matrix.CreateTranslation(Position);
            ViewMatrix = Matrix.Invert(WorldMatrix);
        }
0

Share this post


Link to post
Share on other sites

few pictures that show exactly what happened 

this is first pos : 
8x6lda07jcnf3na6g.jpg 


after rotating by 15 degree using mouse of course :

dhk5taecpo6k6mp6g.jpg 

furthor rotation  degree 

cl22ixerwedx9z26g.jpg 

then :
cl22ixerwedx9z26g.jpg

then :
fmiu6ck02c67fdv6g.jpg

then : 

384bp84n3a6g32h6g.jpg

0

Share this post


Link to post
Share on other sites

What it looks like if you put it like this:

public Matrix WeaponWorldMatrix(float xOffset, float yOffset, float zOffset)
{
    return Matrix.Invert(cci.Camera.ViewMatrix) * Matrix.CreateTranslation(new Vector3(10, -10, 10));
}

 

I don't know C#/XNA syntax so this might not compile.

0

Share this post


Link to post
Share on other sites

This is full code for my camera ( I think it's the problem !! ) 

Camera.cs
 


    /// <summary>
    /// Simple camera class for moving around the demos area.
    /// </summary>
    public class Camera : DrawableGameComponent
    {
        /// <summary>
        /// Gets or sets the position of the camera.
        /// </summary>
        public Vector3 Position { get; set; }

        public Matrix projection;

        private float yaw;
        private float pitch;
        
        /// <summary>
        /// Gets or sets the yaw rotation of the camera.
        /// </summary>
        public float Yaw
        {
            get { return yaw; }
            set { yaw = MathHelper.WrapAngle(value); }
        }

        /// <summary>
        /// Gets or sets the pitch rotation of the camera.
        /// </summary>
        public float Pitch
        {
            get { return pitch; }
            set
            {
                pitch = value;
                if (pitch > MathHelper.PiOver2 * .99f)
                    pitch = MathHelper.PiOver2 * .99f;
                else if (pitch < -MathHelper.PiOver2 * .99f)
                    pitch = -MathHelper.PiOver2 * .99f;
            }
        }

        /// <summary>
        /// Gets or sets the speed at which the camera moves.
        /// </summary>
        public float Speed { get; set; }

        /// <summary>
        /// Gets the view matrix of the camera.
        /// </summary>
        public Matrix ViewMatrix { get; private set; }

        /// <summary>
        /// Gets or sets the projection matrix of the camera.
        /// </summary>
        public Matrix ProjectionMatrix { get; set; }

        /// <summary>
        /// Gets the world transformation of the camera.
        /// </summary>
        public Matrix WorldMatrix { get; private set; }

        /// <summary>
        /// Whether or not to use the default free-flight camera controls.
        /// Set to false when using vehicles or character controllers.
        /// </summary>
        public bool UseMovementControls = true;

        /// <summary>
        /// Creates a camera.
        /// </summary>
        /// <param name="pos">Initial position of the camera.</param>
        /// <param name="s">Speed of the camera per second.</param>
        /// <param name="p">Initial pitch angle of the camera.</param>
        /// <param name="y">Initial yaw value of the camera.</param>
        public Camera(Game game, Vector3 pos, float s, float p, float y) : base (game)
        {

            float aspectRatio = (float)Game.Window.ClientBounds.Width /
                                (float)Game.Window.ClientBounds.Height;
            // 45 degrees
            float fieldOfView = MathHelper.PiOver4;

            projection = Matrix.CreatePerspectiveFieldOfView(fieldOfView, aspectRatio, 0.1f, 7000);

            Position = pos;
            Speed = s;
            Yaw = y;
            Pitch = p;
            ProjectionMatrix = projection;

            //rayCastFilter = RayCastFilter;
        }

        /// <summary>
        /// Moves the camera forward.
        /// </summary>
        /// <param name="distance">Distance to move.</param>
        public void MoveForward(float distance)
        {
            Position += WorldMatrix.Forward * distance;
        }

        /// <summary>
        /// Moves the camera to the right.
        /// </summary>
        /// <param name="distance">Distance to move.</param>
        public void MoveRight(float distance)
        {
            Position += WorldMatrix.Right * distance;
        }

        /// <summary>
        /// Moves the camera up.
        /// </summary>
        /// <param name="distance">Distanec to move.</param>
        public void MoveUp(float distance)
        {
            Position += new Vector3(0, distance, 0);
        }


        /// <summary>
        /// Updates the state of the camera.
        /// </summary>
        /// <param name="dt">Time since the last frame in seconds.</param>
        /// <param name="keyboardInput">Input for this frame from the keyboard.</param>
        /// <param name="oldMouseInput">Input from the previous frame from the mouse.</param>
        /// <param name="mouseInput">Input for this frame from the mouse.</param>

        public void Update(float dt, KeyboardState keyboardInput, MouseState mouseInput)
        {
            Yaw += (200 - mouseInput.X) * dt * .32f;
            Pitch += (200 - mouseInput.Y) * dt * .32f;


            WorldMatrix = Matrix.CreateFromAxisAngle(Vector3.Right, Pitch) * Matrix.CreateFromAxisAngle(Vector3.Up, Yaw);

            WorldMatrix = WorldMatrix * Matrix.CreateTranslation(Position);
            ViewMatrix = Matrix.Invert(WorldMatrix);
        }
    }

 

Here my modelManager.cs

 

// this methode updated , by calling it in the main Update methode inside my game :

class ModelManager{

.
.
.
.

        
public void Update(GameTime gameTime, KeyboardState KeyboardInputt, 
            KeyboardState PreviousKeyboardInputt, MouseState MouseInput)
        {

            // Update player Weapon and hands
            //weaponWorldMatrix = WeaponWorldMatrix(0.45f, -0.75f, 1.65f);
            //staticModel.Transform = weaponWorldMatrix;
            //staticModel.model.CopyAbsoluteBoneTransformsTo(weaponTransforms);

            
            Vector3 forward = cci.Camera.WorldMatrix.Forward + new Vector3(5, -5, 0);
            Matrix translatePlayer = Matrix.CreateTranslation(cci.Camera.Position + cci.Camera.WorldMatrix.Forward + forward);
            Matrix scalePlayer = Matrix.CreateScale(0.05f);
            Matrix rotatePlayer = Matrix.Invert(Matrix.CreateFromAxisAngle(cci.Camera.ViewMatrix.Right,
                cci.Camera.Pitch) * Matrix.CreateFromAxisAngle(cci.Camera.ViewMatrix.Up, cci.Camera.Yaw));
            staticModel.Transform = scalePlayer * rotatePlayer * translatePlayer ;
            
        }
.
.
.
.
}

 

This is the game.cs which is the main class ,

 

protected override void Initialize() {

            camera = new Camera(this, new Vector3(0, 50, 50), 1000, 0, 0);

            Components.Add(camera);

            modelManager = new ModelManager(this, camera, GraphicsDevice);

        }

        protected override void LoadContent() {
            
            spriteBatch = new SpriteBatch(GraphicsDevice);

            modelManager.LoadContent(Content);

            base.LoadContent();
        }



        protected override void Update(GameTime gameTime) {

            graphics.GraphicsDevice.RasterizerState = RasterizerState.CullNone;

            AMInput_PreviousKeyboardInput = AMInput_KeyboardInput;
            AMInput_KeyboardInput = Keyboard.GetState();

            AMInput_MouseInput = Mouse.GetState();

.
.
.
.
            else if (state == GameState.game){
.
.
.

                camera.Update((float)gameTime.ElapsedGameTime.TotalSeconds, AMInput_KeyboardInput, AMInput_MouseInput);

                // Updating Modesl data such as Transformations
                modelManager.Update(gameTime, AMInput_KeyboardInput, AMInput_PreviousKeyboardInput , AMInput_MouseInput);
.
.
.
.
.
.


            base.Update(gameTime);
        }
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0