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

Make perspective appear ortho?

5 posts in this topic

so, here's what i want to do:

I have an picture, i split it into a 10 x 10 grid, I then randomly move these tiles back/forward along the z axis.  What i want to achieve is when the camera is looking down the z axis, the picture would look like it was in an ortho projection.

 

basically, what i need to know, is how to translate each tiles size and position, so that they perfectly align to a picture from only the one perspective.

 

also, i plan to rotate each tile to face the camera, i'm assuming to make this work, each tile well have to have a slight offset for looking at the camera, otherwise when i do align the camera in that one spot, all the tiles well be slighlty mis-aligned since their trying to look at the center point.

 

anyway, i need some pointers, the only thing i've found on this is: [url="http://stackoverflow.com/questions/6962992/orthographic-to-perspective-adjustment-calculation"]http://stackoverflow.com/questions/6962992/orthographic-to-perspective-adjustment-calculation[/url] but I can't figure out how to apply the information.  I'm assuming it's because i'm not taking into account the view matrix?

 

right now i'm not worrying about rotating the camera, or rotating the tiles to face the camera, so my first step is trying to figure out how to make the tile's align and size correctly.

0

Share this post


Link to post
Share on other sites

Billboarding will solve the problem on making sure the tiles always face the camera.  A quick web search should provide you with plenty of information on billboarding techniques.   

 

The main question that's going through my head right now:  Why are you not just using an orthographic projection for the tiles, and a perspective projection for everything else?  There is nothing illegal about having mutliple projection matrices (for instance, games can render the game world using a perspective projection, and the game UI or HUD using an ortho projection).

0

Share this post


Link to post
Share on other sites

Billboarding will solve the problem on making sure the tiles always face the camera.  A quick web search should provide you with plenty of information on billboarding techniques.   

 

The main question that's going through my head right now:  Why are you not just using an orthographic projection for the tiles, and a perspective projection for everything else?  There is nothing illegal about having mutliple projection matrices (for instance, games can render the game world using a perspective projection, and the game UI or HUD using an ortho projection).

Billboarding does not suit this problem, as the goal is that at one particular camera angle, the image is absolutely perfect, this means each tile needs to be appropiatly positioned, and scaled, so the result is as if it were an ortho projection.  also mate, i completely understand that i can change matrix's at will, this is not a hud element, this is simply an illusion that is absolutely critical mechanic for my gameplay.

Edited by slicer4ever
0

Share this post


Link to post
Share on other sites

At the depth Z of the perspective view frustum, the total range of the frustum is +/- tan(fov/2*Z), where fov is the field of view. Keep in mind that the vertical and horizontal FOV is different unless the aspect ratio is unity so make sure you take that into account; hfov=2*atan(aspect*tan(vfov/2)).

 

So, based on this, you can get the horizontal and vertical range at any depth of the perspective view. Split that range up into your 10x10 grid to figure out a specific grids corners at any depth.

0

Share this post


Link to post
Share on other sites

alright, so i've been playing with this, i do believe i understand the concept.

 

first off i've reduced the problem to a 3x3 grid to make life a bit easier, now basically, my thought process is this, get the vertical ratio of the perspective camera, and the  horizontal ratio.  I know that the image should appear as it is when the each tile's z axis is 0, which is 60 units from the camera.  so what i've been first trying to achieve is making the tile's center align(i don't care about resizing the tile's at the moment.)  I moved one tile(directly above the center tile) by 10 units toward the camera, this is what my code looks like at the moment:

 

 

            Vector2 PartDistance = new Vector2(TotalWidth/m_Width, TotalHeight/m_Height);
            Vector2 UpperLeft   = new Vector2(-30.0f, -30.0f)+PartDistance*0.5f;
            float vRatio = FMath.Tan(FMath.PI*0.175f); //get my FOV ratio which Math.PI*0.35(63 degrees) * 0.5
            Console.WriteLine("vRatio: "+vRatio);
            int Target = 1;
            for(int x=0;x<m_Width;x++){ //m_Width = 3
                for(int y=0;y<m_Height;y++){ //m_Height = 3
                    int Tile = x+y*m_Width;
                    Vector3 Center = new Vector3(UpperLeft.X+x*PartDistance.X, UpperLeft.Y+y*PartDistance.Y, (Tile==Target)?10.0f:0.0f);
                    float vRat = Center.Z==0.0f?1.0f: vRatio*Center.Z;
                   
                    Vector3 NewCtr = new Vector3(Center.X, Center.Y*vRat, Center.Z);
                    if(Tile==Target) Console.WriteLine("X: "+hRat+" "+vRat);
                    m_Tiles[x+y*m_Width] = new Tile(NewCtr, new Vector2(5.0f, 5.0f)); //Vector3 for position, vector2 for size, which for now is just 5x5 tiles.
                    if(Tile==Target) Console.WriteLine("X: "+m_Tiles[Target].m_Position.X+" "+m_Tiles[Target].m_Position.Y+" "+m_Tiles[Target].m_Position.Z);
                }
            }

 

This is my current result:

 

23gzcld.png

 

if you zoom into the tile(top middle), you can see that it's not exactly center, I think it's more dumb-luck that it looks so close.

Edited by slicer4ever
0

Share this post


Link to post
Share on other sites

so, i decided to hack around this using Project/UnProject, and modifying the screen's depth position, then mapping back.

 

I'm fairly certain this should be possible without having to go through the project/unproject process, but it's just beyond me on how to achieve it.

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