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

What on earth is wrong with this really basic rotation?

4 posts in this topic

I have a nice little fireworks demo running, and I thought for the heck of it I'd spin the "ball of particles" that comprises the fireworks.  To do this, I assumed that the steps were:

 

- Translate back to origin from where it lives in space

- Apply rotation matrices for X, Y, Z

- Translate back to where object lived in space

- Set that as the World matrix before drawing the object (leaving projection and view completely alone)

 

It does not work as I would expect (or at all, really).  It just jumps around a bunch but largely stays put (no rotation).  I'm placing that new world matrix into the shader before drawing the instance.  I know all that works, as it draws them without rotation exactly as I'd hoped.  It's just my application of rotation that has broken everything...

 

Either I've got a really ugly bug or a very poor grasp of how to compose such a matrix.  A prod in either direction would be very much appreciated!

D3DXMATRIX matrixTranslateBefore;
D3DXMATRIX matrixRotationX;
D3DXMATRIX matrixRotationY;
D3DXMATRIX matrixRotationZ;
D3DXMATRIX matrixTranslateAfter;

float rads = fElapsedTime * 50.0f;

D3DXMatrixTranslation(&matrixTranslateBefore,  -pExplosion->_centerPosition.x, 
                      -pExplosion->_centerPosition.y, -pExplosion->_centerPosition.z);
D3DXMatrixRotationX(&matrixRotationX, rads);
D3DXMatrixRotationY(&matrixRotationY, rads);
D3DXMatrixRotationZ(&matrixRotationZ, rads);
D3DXMatrixTranslation(&matrixTranslateAfter, pExplosion->_centerPosition.x,
pExplosion->_centerPosition.y, pExplosion->_centerPosition.z);

pCameraManager->_worldMatrix = matrixTranslateBefore * matrixRotationX * matrixRotationY * matrixRotationZ * matrixTranslateAfter; 

 

2

Share this post


Link to post
Share on other sites

How exactly are you using the world matrix in your shader? It may be you're doing it wrong there and this more complex transformation has revealed a bug.

 

Also, are you sure your centerPosition field is correct, have you checked it? 

1

Share this post


Link to post
Share on other sites

What is in matrixTranslateBefore? Is it just translation or is there scaling, rotation, etc? Just to test, you might want to try:

D3DXVECTOR4 pos(0.0f, 0.0f, 0.0f, 1.0f);
D3DXVec4Transform(&pos, &pos, &(matrixTranslateBefore * matrixTranslateAfter));
// pos should be (0.0f, 0.0f, 0.0f, 1.0f) after this

If matrixTranslateBefore is just a translation, why don't you just use pExplosion->_centerPosition to translate once?

 

Also, you could simplify this:

D3DXMATRIX matrixRotationX;
D3DXMATRIX matrixRotationY;
D3DXMATRIX matrixRotationZ;

float rads = fElapsedTime * 50.0f;

D3DXMatrixRotationX(&matrixRotationX, rads);
D3DXMatrixRotationY(&matrixRotationY, rads);
D3DXMatrixRotationZ(&matrixRotationZ, rads);

into this:

D3DXMATRIX matrixRotation;

float rads = fElapsedTime * 50.0f;

D3DXMatrixRotationYawPitchRoll(&matrixRotation, rads, rads, rads);
0

Share this post


Link to post
Share on other sites

50 radians per second is really fast. Have you tried doing something like 1.0 radian per second?

 

Are you sure you want to rotate on all three axes like that? The results can be pretty unpredictable. Have you tried rotating on just one axis to start?

 

I am not sure I understand why you want to pre-translate (matrixTranslateBefore). If your verts are defined in model space, then you shouldn't need to do this. In fact, it would make things look glitchy, because you'd be translating away from the origin, rotating, and then translating again. Unless you have a really good reason to do this, consider removing that pre-translation.

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