• 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
markypooch

Tweening Questions

7 posts in this topic

Hello all!

 

I started to look into tweening since it looked like a fun and sort of quick way to get some basic animations going on my meshes.

 

Well, due to the sake of simplicity I decided to implement it on the CPU side first with dynamic buffers. While performance is pitifull, thats to be expected when pushing data back and forth from the CPU to the GPU.

 

However, I've run into a issue that makes me ask

 

The OBJ format. I've heard that the blender exporter (correct me if im wrong) will rearrange the vertices from export to export. thus negating any tweening attempts. Since I most comfortable with the OBJ format is there a way around it (I see in the mesh export options in blender, keep vertex order) or is this just wishful thinking. If you think OBJ is a no go. What format do you recommend?

 

Also, my implementation is based on Advanced Animation with DirectX, i just stuffed all the values into XNA types.

I'm including my tweening implementation just in case I missed something silly that someone could hint to. (And also as a validation that this isn't completely off XD) And also because my meshes when tweening wig out and start rendering crazy polygonal shapes and colors! Also as if I'm referencing out-of bounds garbage memory and passing it to D3D

float time = 0.0f;
float length = 5.0f;
 
if (isMoving)
 {
        Time += 5.0f * dt;
        if (Time > 5.0f) Time = 0.0f;
 }
//Note: vertices[x].at(x) represents a vector of pointers which hold all the info of each subset of the overall mesh

scalar = Time / length;

D3D11_MAPPED_SUBRESOURCE ms;
                for (int i = 0; i < mCount; i++) //mCount = subsetMeshCount
                {
                    verticesResult.resize(verticeCount[i]);
                    for (int j = 0; j < verticeCount[i]; j++)
                    {
                        //Interpolate Positions
                        /////////////////////////////////////////////
                        XMVECTOR vecSource = XMLoadFloat3(&vertices[i].at(j).pos);
                        float value = (1.0f - scalar);
                        vecSource *= value;

                        XMVECTOR vecTarget = XMLoadFloat3(&vertices2[i].at(j).pos);
                        vecTarget *= scalar;

                        XMStoreFloat3(&verticesResult.at(j).pos, (vecSource + vecTarget));

                        //Iterpolate Normals
                        //////////////////////////////////////////////
                        XMVECTOR vecSourceNorm = XMLoadFloat3(&vertices[i].at(j).norm);
                        value = (1.0f - scalar);
                        vecSourceNorm *= value;

                        XMVECTOR vecTargetNorm = XMLoadFloat3(&vertices2[i].at(j).norm);
                        vecTargetNorm *= scalar;
                        XMStoreFloat3(&verticesResult.at(j).norm, (vecSourceNorm + vecTargetNorm));

                        verticesResult.at(j).norm               = vertices[i].at(j).norm;

                        //Pass along Materials
                        ///////////////////////////////////////////////
                        verticesResult.at(j).color                = vertices[i].at(j).color;
                    }

                    //Lock the dynamic buffer (block the GPU)
                    ///////////////////////////////////////////////////
                    bro->devcon->Map(vertexBuffer[i], NULL, D3D11_MAP_WRITE_DISCARD, NULL, &ms);

                    //Grab a pointer to the data, pass along update vertice info, and remap the buffer
                    ////////////////////////////////////////////////////////////////////////////////////
                    VertexM *v = reinterpret_cast<VertexM*>(ms.pData);
                    *v          = verticesResult[0];
                    bro->devcon->Unmap(vertexBuffer[i], NULL);
                }

Any replies are appreciated smile.png

 

-Marcus

Edited by markypooch
1

Share this post


Link to post
Share on other sites
What format do you recommend?

 

 

If you fell yourself comfortable with all the things that obj file can introduce. Try using Assimp/FBX SDK/wateva to load for example a *.fbx scene files. Those file formats can store huge amount of different types of gemoetry/animations/ect., but it will be fine if you slowly start form those basic things like static meshes/the scene graph/trnasforms, basic node animation and so on. Later on you will probably want your own converter form *fbx/dae/wateva to your own custom format, but those are long and abstract talks.

Edited by imoogiBG
0

Share this post


Link to post
Share on other sites

If you are using Visual Studio 2012/2013 it natively supports *.fbx, compiling them into a *.cmo file which can then be read using the DirectXTK library.

 

The animations that are saved within the FBX are then available to you. Just need to apply the transforms correctly based on the current time etc...

 

Although it is in C#, my book linked below has a chapter dedicated to implementing animation with Direct3D (Chapter 4 - Animating Meshes with Vertex Skinning). Using an FBX -> CMO, it shows how to perform interpolation between frames using quaternions and spherical interpolation (Slerp).

 

The basic approach is:

// animation loaded from FBX/CMO file
foreach (keyFrame in animation)
{
    if (keyFrame.Time <= time) {
        // use this keyFrame transform for the appropriate bone index
        transforms[keyFrame.BoneIndex] = keyFrame.Transform;
    }
    else
    {
        // perform interpolation towards next future keyFrame
    }
}

// Apply bone transforms (i.e. apply transform of parent upon each child bone)

// Convert from bind pose into bone space using inverse of bind pose

Some screenshots showing incorrect and correct bone transforms:

[sharedmedia=gallery:images:5182]
[sharedmedia=gallery:images:5181]

 

Edited by spazzarama
1

Share this post


Link to post
Share on other sites

Ok, so I see a strong push for .fbx.

 

Well, thanks to assimp it should be rather simple to just re-export and reload my mesh as a .fbx.

I see you both are recommending skeletal animation over tweening.

 

My main reasoning for tweening was to get something up and going (in the animation department) fast!

But other then that, I'm sure I can opt-out for skeletal animation instead. Assimp will handle all the bone and skeletal loading for me.

My only real challenge then is to actually get it up and going. (I've never done anything more complicated then standard matrice transformations and rotations on single meshes)

 

Thanks for the replies (And especially for the book link!)

 

-Marcus

 

P.s. The image were you show the polarity's between a proper animated mesh and the un-proper. The latter could be used for a glitch level ;)

Edited by markypooch
0

Share this post


Link to post
Share on other sites


P.s. The image were you show the polarity's between a proper animated mesh and the un-proper. The latter could be used for a glitch level ;)

 

Wait until you see what that looks like during an animation!

 

Skeletal animation just makes it so easy once you have it set up! Using Blender, Maya or whatever to do your hardcore animation work and then just bring that in.

 

Assuming you are importing all your animations correctly, it really is as simple as the pseudo code above - oh and then some shader code of course.

0

Share this post


Link to post
Share on other sites

Well I'll have to do it then (as opposed to try to do it)

 

Ill start by importing my meshes as .fbx today. And go from there.

I'll follow along with the e-book. C# in my opinon looks like Java, which I can translate Java to C++ well enough.

 

Once again thanks for pointing out some resources. I suppose Ill keep my static meshes. (i.e. Trees, hedges, and statues) in OBJ. While anything I animate I'll

just use .fbx

 

-Marcus

0

Share this post


Link to post
Share on other sites

One other point to consider is that tweening requires an enormous amount of vertex memory, since you are essentially creating a keyframe that includes every vertex.  If you make a 10 frame animation, then you have 10x the number of vertices to store!  Skeletal animation drastically reduces the amount of required memory, and trades it for a little bit more runtime computation - but it is still very much worth it.

 

If you aren't at all familiar with skinning, then check out the old Cg Tutorial chapter on it, which is where I first learned about it: http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter06.html

2

Share this post


Link to post
Share on other sites

Just a status update, thought you guys might like to know.

 

Though I haven't implmented Skinning yet, I did tweening to work after I implemented a hardware

version (did my tweening in HLSL) So I must have been doing something silly with the dynamic buffers.

 

Kinda off topic but the results aren't bad. (I still plan on doing skinning)

 

awd_zpsf7cbe856.png

1

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