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

I cannot seem to translate any of my models on the z axis using a model translation

3 posts in this topic

I had a question up on stackoverflow where a user and myself were able to dig through an issue, and determined it must be an issue with either how I am transposing my matrices, or multiplying them.

 

To summarize the problem I'm having, I can set a model at a fixed z position without any problem by setting the actual model origin z coordinate value to any non-zero value, and this works, however, if I try to create a model with with an origin of [0,0,0] and use a model matrix to transform it, I can transform the x and y coordinates with no problems, but if my z value is not between 0.0f and -0.9999f it just disappears.  pivotnig (the user that was helping me on stackoverflow) had suggested it may be a matrix multiplication order issue, so I tried reversing the order, and just experimenting with different orderings, which mostly just made my scene disappear.

 

To jump back an idea for a second, another suspicion was that I maybe shouldn't be transposing the matrices before sending them to the vertex shader.  The reason I am is because every example I have came across on msdn and some other places have always sent the matrices to the vertex shader after a XMMatrixTranspose().

 

Another thing that I haven't tried because I do not have a great understanding of it is using the camera's inverse matrix.  I noticed that some samples I looked at used it, but some did not.  I don't know if the issue resides in the camera matrix, however, because while running the application, I can move the camera without any problems, and the scene seems to response appropriately in terms of distance and projection.

 

I have no found any other person with a similar issue in DirectX 11, and any similar issues otherwise are with versions of DirectX where the matrices were managed internally.

 

For the sake of convenience, here are my code snippets that I'm possibly having trouble with - I can upload other snippets if anyone thinks the problem is elsewhere.

I'll admit that I'm not particularly skilled in 3d math, so if anyone has a very mathy answer, can you try and simplify it as much as possible for me please.

0

Share this post


Link to post
Share on other sites

Are you sure about what do you want to do in this code:

 

void TransformMatrix::Rotate( float x, float y, float z, float ang )
{
    if ( x * ang != 0.0f ) rotate *= XMMatrixRotationX( x * ang );
    if ( y * ang != 0.0f ) rotate *= XMMatrixRotationY( y * ang );
    if ( z * ang != 0.0f ) rotate *= XMMatrixRotationZ( z * ang );
}
 

 

Don't you want to rotate around vector with x, y, z coordinates actually? Because if so, rotating around each orthogonal axis for angle `ang` is not the same as rotating around specified vector for angle `ang` and you should use XMMatrixRotationAxis instead.

 

Also, I couldn't find any code, responsible for view and projection matrix creation.

 

To jump back an idea for a second, another suspicion was that I maybe shouldn't be transposing the matrices before sending them to the vertex shader.  The reason I am is because every example I have came across on msdn and some other places have always sent the matrices to the vertex shader after a XMMatrixTranspose().

 

You must use XMMatrixTranspose(), because matrices in shaders are transposed version of XNA SSE matrices by default.

 

Also make sure that you constant buffer structure has the same member's order as your shader constant buffer:

 

cbuffer ProjectionBuffer : register(b0)
{
    matrix p;
    matrix m;
    matrix v;
}; 
Edited by GuardianX
2

Share this post


Link to post
Share on other sites

Ah, your last point may have fixed it.  I could have sworn that they were the same order, but I hadn't really checked it or thought about it.  Thanks for that catch, I'll test it out soon.

 

That rotation function was mostly put there out of frustration; I was originally using XMMatrixRotationAxis, but was having some issues with rotation that was a result from some other odd behaviour I was having a while ago.  I haven't been doing a lot of rotation with my models yet so I didn't get around to fixing it.  Thanks for the catch on that one, too, I can mark it as a todo task for me.

0

Share this post


Link to post
Share on other sites

What vertex shader are you using? objects disappearing as you describe lead me to believe that perhaps your projection is not correct, as alluded to by GuardianX. Projective space spans from 0->1 ranging from near plane to far plane, anything outside of that range will not be visible.

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