XNA Game Development Forums
2012/05/21 20:15:51 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Animation Problem..  (Read 3541 times)
DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« on: 2008/04/21 12:29:55 »

I recently tried the creators club skinning sample, and did a slight conversion for it to go into my engine. For some reason, nothing shows up. Ive tried it with my own custom models, as well as the examples dude.fbx. The Draw is being called, as well as update. Im thinking it has something to do with me trying to applay the objects own world transofrmation. i just tried this
Code:
Matrix world = Matrix.CreateScale(Scale) *
                            Matrix.CreateFromQuaternion(Rotation) *
                            Matrix.CreateTranslation(Position);
            player.Update(gametime.ElapsedGameTime, true, world);
although it still doesnt work when i use Matrix.Identity as an input as well. Im using the Shader system from this site, and not the Model.Effect way of doing it like in the sample
Logged
Chr0n1x
Global Moderator
Sr. Member
*****
Offline Offline

Posts: 307


View Profile WWW
« Reply #1 on: 2008/04/21 18:17:18 »

What is your graphics card?

Your world matrix looks correct so it could very well be something with the shader and this sample.
A fair number of people implemented this sample a while back, check the Engine Addtions forum and you might find your answer there.
Logged

DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« Reply #2 on: 2008/04/22 06:21:48 »

i use a integrated intel gma 950 chipset, which i am not very happy with. all other things that i add into my game appear just fine, normal static models appear fine, its just the animated ones
Logged
Chr0n1x
Global Moderator
Sr. Member
*****
Offline Offline

Posts: 307


View Profile WWW
« Reply #3 on: 2008/04/22 07:47:58 »

Have you checked to ensure that the animated models use the correct index type?

I think your chip requires a short rather than an int. If it is straight from CC with just some modifications then there is a good chance it is still the wrong type.
Logged

Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #4 on: 2008/04/22 13:02:53 »

I have a similar (if not the same) GCard, and it flew fine with me first time around. Have you included the pipeline stuff that loads up the bone data?? (If I remember the sample correctly)
Logged
DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« Reply #5 on: 2008/04/23 04:34:09 »

heres my animated model code
Code:
protected Model mymodel;
        string mydictname;

        CustomKeysValuesLoadManager myloader;
        AnimationPlayer player;
        public AnimatedModel(string dictname)            : base(dictname)
        {
            mydictname = dictname;
            CanDraw = true;
            CanLoad = true;
            CanUpdate = true;

        }
        public override void LoadContent(ContentManager content, GraphicsDevice device)
        {
            List<KeysValueClass> kvc = new List<KeysValueClass>();
            myloader = new CustomKeysValuesLoadManager(content);
            kvc = myloader.Load(mydictname);
            for (int i = 0; i < kvc.Count; i++)
            {

                if (kvc[i].ValueClass == WindowsGame2.Loading.ValueType.String)
                {
                    if (kvc[i].Name == "Texture Name")
                    {
                        StringKeysValueClass strkvc = kvc[i] as StringKeysValueClass;
                        Texture = content.Load<Texture2D>(strkvc.strValue);
                        TexPath = strkvc.strValue;
                    }
                    if (kvc[i].Name == "BumpTexture Name")
                    {
                        StringKeysValueClass strkvc = kvc[i] as StringKeysValueClass;
                        BumpTexture = content.Load<Texture2D>(strkvc.strValue);
                        BumpTexPath = strkvc.strValue;

                    }
                    if (kvc[i].Name == "HeightTexture Name")
                    {
                        StringKeysValueClass strkvc = kvc[i] as StringKeysValueClass;
                        HeightTexture = content.Load<Texture2D>(strkvc.strValue);
                        HeightTexPath = strkvc.strValue;

                    }
                    if (kvc[i].Name == "Effect Name")
                    {
                        StringKeysValueClass strkvc = kvc[i] as StringKeysValueClass;
                        Effect = content.Load<Effect>(strkvc.strValue);
                        EffectPath = strkvc.strValue;
                    }
                    if (kvc[i].Name == "Model Name")
                    {
                        StringKeysValueClass strkvc = kvc[i] as StringKeysValueClass;
                        mymodel = content.Load<Model>(strkvc.strValue);
                        ModelPath = strkvc.strValue;
                        player = new AnimationPlayer(mymodel.Tag as SkinningData);
                        SkinningData skinningData = mymodel.Tag as SkinningData;
                        AnimationClip clip = skinningData.AnimationClips["Take 001"];

                        player.StartClip(clip);
                    }
                }
            }
            base.LoadContent(content, device);
        }
        public override List<string> GetSaveData()
        {
            List<string> datalist = base.GetSaveData();
            datalist.Add("String");
            datalist.Add("Texture Name");
            datalist.Add(TexPath);
            datalist.Add("String");
            datalist.Add("Effect Name");
            datalist.Add(EffectPath);
            datalist.Add("String");
            datalist.Add("Model Name");
            datalist.Add(ModelPath);
            if (BumpTexture != null)
            {
                datalist.Add("String");
                datalist.Add("BumpTexture Name");
                datalist.Add(BumpTexPath);
            }
            if (HeightTexture != null)
            {
                datalist.Add("String");
                datalist.Add("HeightTexture Name");
                datalist.Add(HeightTexPath);
            }
            return datalist;

        }
        public override void Update(GameTime gametime)
        {
            Matrix world = Matrix.CreateScale(Scale) *
                            Matrix.CreateFromQuaternion(Rotation) *
                            Matrix.CreateTranslation(Position);
            player.Update(gametime.ElapsedGameTime, true, Matrix.Identity);
        }
        public override void Draw(GraphicsDeviceManager manager)
        {
            GraphicsDevice device = manager.GraphicsDevice;






            Matrix[] bones = player.GetSkinTransforms();

            Matrix world = Matrix.CreateScale(Scale) *
                            Matrix.CreateFromQuaternion(Rotation) *
                            Matrix.CreateTranslation(Position);
            if (Effect != null)
            {
                if (Effect.Parameters["World"] != null)
                {
                    Effect.Parameters["World"].SetValue(world);
                }
                if (Effect.Parameters["WVP"] != null)
                {
                    Effect.Parameters["WVP"].SetValue(world * CameraManager.ActiveCamera.View * CameraManager.ActiveCamera.Projection);

                    if (Effect.Parameters["Bones"] != null)
                    {
                        Effect.Parameters["Bones"].SetValue(bones);
                    }
                    if (Effect.Parameters["MyTexture"] != null)
                    {

                        Effect.Parameters["MyTexture"].SetValue(Texture);

                    }
                    if (Effect.Parameters["ColorMap"] != null)
                    {

                        Effect.Parameters["ColorMap"].SetValue(Texture);

                    }
                    if (Effect.Parameters["BumpMap"] != null)
                    {

                        Effect.Parameters["BumpMap"].SetValue(BumpTexture);

                    }
                    if (Effect.Parameters["HeightMap"] != null)
                    {

                        Effect.Parameters["HeightMap"].SetValue(HeightTexture);

                    }
                    if (Effect.Parameters["View"] != null)
                    {
                        Effect.Parameters["View"].SetValue(CameraManager.ActiveCamera.View);

                    }
                    if (Effect.Parameters["Color"] != null)
                    {
                        Effect.Parameters["Color"].SetValue(Color);

                    }
                    if (Effect.Parameters["AmbientLightColor"] != null)
                    {
                        Effect.Parameters["AmbientLightColor"].SetValue(new Vector4(0.25f, 0.25f, 0.25f, 1.0f));

                    }

                    if (Effect.Parameters["DiffuseColor"] != null)
                    {
                        Effect.Parameters["DiffuseColor"].SetValue(new Vector4(0.50f, 0.50f, 0.50f, 1.00f));

                    }
                    if (Effect.Parameters["SpecularPower"] != null)
                    {
                        Effect.Parameters["SpecularPower"].SetValue(1);

                    }
                    if (Effect.Parameters["EyePosition"] != null)
                    {
                        Effect.Parameters["EyePosition"].SetValue(CameraManager.ActiveCamera.Position);

                    }
                    if (Effect.Parameters["LightPosition"] != null)
                    {
                        Effect.Parameters["LightPosition"].SetValue(CameraManager.ActiveCamera.Position);

                    }
                    if (Effect.Parameters["LightDirection"] != null)
                    {
                        Vector3 dir = Position - CameraManager.ActiveCamera.Position;
                        dir.Normalize();
                        Effect.Parameters["LightDirection"].SetValue(new Vector3(1, -1, -1));

                    }
                    if (Effect.Parameters["LightDiffuseColor"] != null)
                    {
                        Effect.Parameters["LightDiffuseColor"].SetValue(new Vector4(0.25f, 0.25f, 1.0f, 1.0f));

                    }
                    if (Effect.Parameters["LightSpecularColor"] != null)
                    {
                        Effect.Parameters["LightSpecularColor"].SetValue(new Vector4(0.85f, 0.85f, 1.0f, 1.0f));

                    }
                    if (Effect.Parameters["Projection"] != null)
                    {
                        Effect.Parameters["Projection"].SetValue(CameraManager.ActiveCamera.Projection);

                    }
                }
                CullMode defaultcull = manager.GraphicsDevice.RenderState.CullMode;
                manager.GraphicsDevice.RenderState.CullMode = CullMode.None;
               

                foreach (ModelMesh mesh in mymodel.Meshes)
                {
                   


                    device.Indices = mesh.IndexBuffer;

                   
                    Effect.Begin();

                   
                    foreach (EffectPass pass in Effect.CurrentTechnique.Passes)
                    {
                        pass.Begin();

                       
                        foreach (ModelMeshPart part in mesh.MeshParts)
                        {
                           
                            device.VertexDeclaration = part.VertexDeclaration;
                            device.Vertices[0].SetSource(
                                mesh.VertexBuffer,
                                part.StreamOffset,
                                part.VertexStride
                            );

                           


                           
                            device.DrawIndexedPrimitives(
                                PrimitiveType.TriangleList,
                                part.BaseVertex, 0,
                                part.NumVertices,
                                part.StartIndex,
                                part.PrimitiveCount
                            );
                        }

                        pass.End();
                    }
                    Effect.End();
                   
                }
                manager.GraphicsDevice.RenderState.CullMode = defaultcull;


            }
        }
    }
« Last Edit: 2008/04/23 04:35:59 by DoomMarine » Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #6 on: 2008/04/24 02:17:52 »

That all looks OK, but are you adding the pipeline code too and also associating the model with it via the IDE (Forgive my scrappy replies, I currently have the flu)
Logged
DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« Reply #7 on: 2008/04/25 05:48:28 »

oh god... i think i got it lol... i might have messed up the brackets from the WVP parameter... ill check
Logged
DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« Reply #8 on: 2008/04/25 05:50:03 »

oh god this is umbarassing. srry for taking ur time guys. it looks like it was the brackets
Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #9 on: 2008/04/25 11:49:16 »

Cool! Glad you sorted it, we all make daft errors like that mate, don't worry about it.
Logged
DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« Reply #10 on: 2008/04/25 19:32:58 »

k new question, ive been trying to get these animations to stop after it reaches it final keyframe, but i noticed my simple animation, that in blender had only about 60 keyframes, now has over 200. This definitely is a problem with the code itself, and ill try to play around with it, any help would be appreciated
Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Got a problem with an .x file Hazy Mind XNA Engine bobbie_dache 8 2784 Last post 2007/01/16 12:26:30
by bobbie_dache
Mesh Animation Show Off Board Nemo Krad 2 2258 Last post 2007/07/30 01:24:29
by DaphydTheBard
Animations! But one problem... Hazy Mind XNA Engine EclipsE 2 1415 Last post 2007/04/12 02:42:27
by EclipsE
tutorial 4 problem Hazy Mind 3D Engine precious roy 3 2499 Last post 2007/08/03 12:24:26
by mikeschuld
usercontrols over gamewindow and keyboard problem General Discussion XNASorcerer 2 1465 Last post 2007/05/09 00:52:09
by Chr0n1x
Interface problem. Help!! General Discussion XNASorcerer 5 2112 Last post 2007/05/09 09:46:36
by CarlosFreitas
XNA Animation Component Library in XNA HMEngine Hazy Mind XNA Engine dotslash 0 2621 Last post 2007/05/31 13:53:12
by dotslash
ObjectManagers problem Hazy Mind XNA Engine Jonotron 1 1341 Last post 2007/08/03 12:29:19
by mikeschuld
Problem with the pick Hazy Mind 3D Engine Zandman26 0 1422 Last post 2007/08/06 15:04:06
by Zandman26
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.343 seconds with 19 queries.