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

Archived

This topic is now archived and is closed to further replies.

StiNKy

3d camera

15 posts in this topic

How can I do a 1st person view so the user can move forward in the exact direction they are looking at? without using freaking glu commands??? All the damn results for what I''m looking for is glu this, glu that. Some people don''t want to freaking use glu! Thanks in advanced.
0

Share this post


Link to post
Share on other sites
Sorry, but...

gluLookAt() is the best way to do that. Why would you want to rewrite all of the code that is already written for you?
0

Share this post


Link to post
Share on other sites
Cause I''m trying to write an engine using nothing but gl, ie no glu, no glut, nothing else but your standard gl. Working damn well so far.... Surely there IS a way.
0

Share this post


Link to post
Share on other sites
glu is standard gl. It''s supported by the maintainers of OpenGL. it *is* gl. Why would you not want to use it??

With that said, some not-too-complex matrix math will give you your very own lookAt function. use gramm-schmidt orthonormalization to get three orthogonal unit vectors from your passed-in two(eye to target, and eye to up), make ''em into a matrix, and then use the eyepoint as a translation.
0

Share this post


Link to post
Share on other sites
Well, this seems to be working for me so far:
glRotatef(rot.X, 0.1f, 0.0f, 0.0f);
glRotatef(rot.Y, 0.0f, 0.1f, 0.0f);
with rot.X being how much to rotate around the X axis, and rot.Y how much around the Y axis.
But if I''m storing the position at pos.X, pos.Y, and pos.Z how can I modify the pos.X, pos.Y, and pos.Z values so it moves forward in the world to exactly where the user is looking at? You can''t do that with gluLookAt()
0

Share this post


Link to post
Share on other sites
easy find the direction the person is looking at
Dir = camera/person(first person) direction
cam = camera/person
gluLookAt( cam.x, cam.y, cam.z, cam.x+dir.x, cam.y+dir.y, cam.z+dir.z, 0,1,0 );

0

Share this post


Link to post
Share on other sites
I don''t like gluLookAt, glRotate, glTranslate, whatever. I compute my own camera matrix and load it via glLoadMatrix(), that''s it.
0

Share this post


Link to post
Share on other sites
glRotatef(camera.yaw, 1, 0, 0);
glRotatef(camera.pitch, 0, 1, 0);
glRotatef(camera.roll, 0, 0, 1);
glTranslatef(-camera.x, -camera.y, -camera.z);
0

Share this post


Link to post
Share on other sites
the above method will suffer from gimbal lock (unless u limit the values passed)
check my camera rotation post below
0

Share this post


Link to post
Share on other sites
I can do this if you only want to move along the y=0 plane, like in a first-person-shooter where you are only moving along the floor. I don''t know how to do full 3D, like counter-strike free-look-mode.

You want to know how much to add to the x and z coordinates of your camera position. Use Sine and Cosine. they give you the x and z coordinates of the point on a circle of radius 1. Just input your angle of rotation.

If your angle of rotation (Yaw) is measured from the Z axis...

Camera.PositionX += sinf( Camera.Yaw );
Camera.PositionZ += cosf( Camera.Yaw );

Hope this helps you
0

Share this post


Link to post
Share on other sites
I can do this if you only want to move along the y=0 plane, like in a first-person-shooter where you are only moving along the floor. I don''t know how to do full 3D, like counter-strike free-look-mode.

You want to know how much to add to the x and z coordinates of your camera position. Use Sine and Cosine. they give you the x and z coordinates of the point on a circle of radius 1. Just input your angle of rotation.

If your angle of rotation (Yaw) is measured from the Z axis...

Camera.PositionX += sinf( Camera.Yaw );
Camera.PositionZ += cosf( Camera.Yaw );

Hope this helps you
0

Share this post


Link to post
Share on other sites
ive never seen cs but if its anything like q3 when u do a flythrough with the camera.

it is possible just use
camPOS += camDIR;
ie not
camera.PositionX += sinf( Camera.Yaw );
Camera.PositionZ += cosf( Camera.Yaw );

the reason u can do this is the camera doesnt do roll or loop, thus u can get away with usiong eulars.
0

Share this post


Link to post
Share on other sites
Using camPOS += camDIR recommends camDIR to be a unit-size vector which contains the rotation of the player. if you''re storing the rotation value around the x and y axis seperatly you could do it this way:

posx -= sinf(roty) * cosf(rotx);
posy -= sinf(rotx);
posz -= cosf(roty) * cosf(rotx);

The method Sir Melvalot posted just uses the Yaw value.

(you might have to change some of the -= operators to += operators)
0

Share this post


Link to post
Share on other sites
I have a function in my game engine which does this, but it''s VB DirectX code, so you''ll have to translate it since I''m not too familiar with OpenGL.

Hopefully it is formatted correctly below.



'' gets the translation relative to the direction the frame is facing
Public Property Get RelativeVector(Velocity As D3DVECTOR, Optional deltaTime As Single = 1) As D3DVECTOR
Dim matView As D3DMATRIX, matTrans As D3DMATRIX, matRot As D3DMATRIX
Dim Translation As D3DVECTOR
On Error Resume Next
'' multiply matrices together to create rotation matrix
D3DXMatrixRotationYawPitchRoll matRot, vecOrientation.y, vecOrientation.x, vecOrientation.z
'' translate
D3DXVec3Scale Translation, Velocity, deltaTime
D3DXMatrixTranslation matTrans, Translation.x, Translation.y, Translation.z
'' multiply that translation and rotation
D3DXMatrixMultiply matView, matTrans, matRot
'' translate by matrix
D3DXVec3TransformCoord RelativeVector, RelativeVector, matView
End Property



You have to supply the direction you want the camera to move in as a velocity (for example (0,0,1) will move the camera foward 1 unit).

It returns the vector by which the frame (or camera) needs to be translated in order to move in the correct direction.

Explanations of variables out of scope of this function for you:

vecOrientation is the orientation (direction it is facing) of the frame (or in your case, camera).

The D3DX functions have long descriptive names I hope it''s clear what they do, and can be replaced with your own code?

I don''t think I''ve been too helpful but I hope that makes some sort of sense. I tried my best anyway.

0

Share this post


Link to post
Share on other sites