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

Perspective to Ortho Collision fails.

6 posts in this topic

I guess the topic says it all. The problem that i am having is that i am creating a 3d editor, where you can switch from perspective to ortho or ortho to perspective however you see fit. Now the problem that i am having is that my collision code for the RayToOOBB works fine as long as i have a perspective matrix set up. As soon as i change the matrix to Ortho. The algorithm does not work, How does tool like 3d max handles that. I kind of figure that the same algorithm would work in ortho mode. If anyone have any idea on how to solve that problem i would be greatly appreciated. Here is the piece of code that is converting my mouse from 2d to 3d.

GLGXVECTOR3 mouseInWorld;
GLGXVECTOR3 rayPosition;
GLGXVECTOR3 rayDirection;

GLint viewport[4];glGetIntegerv(GL_VIEWPORT,viewport);

mouseInWorld.x = ((((2.0f*mousex)/(float)viewport[2])-1.0f)/perspectiveMatrix._11);
mouseInWorld.y = ((((2.0f*((float)viewport[3]-mousey))/(float)viewport[3])-1.0f)/perspectiveMatrix._22);
mouseInWorld.z = -1.0f;

GLGXMATRIX IViewInverse;
GLGXMatrixInverse(&IViewInverse,NULL,&cameraMatrix);
GLGXVec3TransformNormal(&rayDirection,&mouseInWorld,&IViewInverse);
rayPosition.x = IViewInverse._41;
rayPosition.y = IViewInverse._42;
rayPosition.z = IViewInverse._43; Edited by BornToCode
0

Share this post


Link to post
Share on other sites
My matrix math is a bit rusty, but I think the problem is your calculation of rayposition.
For perspective projection viewray indeed starts from the point of camera and you only have to calculate the endpoint of ray.
For orthographic projection you have to calculate both the starting and endpoint of viewray from screen coordinates because each ray starts from different point.
0

Share this post


Link to post
Share on other sites
It's not a matter of converting ray position to screen space. It's a matter of generating a ray for every screen position. For perspective, imagine the rays as streams of water squirting from a single nozzle and fanning out in a cone shape. The rays start from a common point and diverge. For orthographic, imagine the rays as coming from one of those fancy shower heads with hundreds of little nozzles all in a neat array. All the streams are parallel to each other, and the resulting spray shape is more cylindrical than conic. The rays never start from the same point, and in fact never cross each other (barring gravity, of course). It's the same idea with an ortho matrix. The idea of a single ray start position really makes no sense for an ortho projection. If you move your camera straight back, things on the screen remain exactly the same; there is no dwindling in size with distance, as there would be with rays that diverge from a single point.
2

Share this post


Link to post
Share on other sites
From what I understood from your post is that I need to figure out two different points in screen space. One at the camera position And one at the object position. If that is bot the case can you show me an example on how you would do it. Or do you mean I need to test multiple rays per object. If that is the case how do I compute those rays then.

Thanks.
0

Share this post


Link to post
Share on other sites
No, you have to start from two points in screen space:
One at mouse position (x,y) and near plane (1) - this will be ray starting point if transformed to world space
Another at mouse position (x,y) and far plane (-1) - this will be ray endpoint if transformed to world space
Now after transforming these points to world space use these to construct your view ray.
2

Share this post


Link to post
Share on other sites
Thanks alot. I got it working. Lauris Kaplinski i tried to give you a thumbs up but it was not letting me boost your reputation.
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