It is currently Thu Dec 05, 2013 2:39 am

 All times are UTC

 Page 1 of 1 [ 9 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Custom projection to gluPerspective.Posted: Wed Jun 27, 2012 5:06 am
Okay, so right now, I have a piece of code in a no-name programming language that can project the 3D coordinates on to 2D screen.

It uses these following values:
ScreenSizeX - Integer
ScreenSizeY - Integer
Zoom - Float, Usually 0.
Perspective - Float, which is currently 256

The calculations go something like this:
ScreenX=ScreenSizeX+(VectorX*Perspective /(VectorZ+Zoom))
ScreenY=ScreenSizeY+(VectorY*Perspective /(VectorZ+Zoom))

Now I'm trying to figure out how to convert this to gluPerspective() which contain these values:
fovy, aspect, zNear, zFar

In which the input values look like this:
gluPerspective 45.0, 640/480, 0.1, 100.0

Please note that Perspective, and fovy are not the same values when it comes to getting the viewing perspective right.

So if "Perspective" = 256, what value would "fovy" be on the gluPerspective side?
And would it apply to the three other variables too?

I hope this question is understandable.

Top

 Post subject: Re: Custom projection to gluPerspective.Posted: Wed Jun 27, 2012 11:02 am
 Cubic Contributor

Joined: Sun May 27, 2012 6:01 pm
Posts: 66
MrThat wrote:
It uses these following values:
ScreenSizeX - Integer
ScreenSizeY - Integer
Zoom - Float, Usually 0.
Perspective - Float, which is currently 256

The calculations go something like this:
Screen.X=Screen.Width+(Vector.X*Perspective /(Vector.Z+Zoom))
Screen.Y=Screen.Height+(Vector.Y*Perspective /(Vector.Z+Zoom))

Im not sure myself, but this doesn't look right?

cxzuk

Top

 Post subject: Re: Custom projection to gluPerspective.Posted: Thu Jul 05, 2012 7:45 pm
Yeah, it does look right.

So anyways, what I meant to say was, that I have a custom code(a simple) that will do with projecting 3D coordinates on to 2D screen.

Now when I use OpenGL, what related command like the "gluPerspective", will make the 3D scene projection look like with the values I use for my own custom projection code(Screen Width, Screen Height, Zoom, Perspective)?

If I can find something like this, I could save a lot of time from trying to write my own pseudo 3D engine without GL.

I apologize if I went a little bit off topic.

Top

 Post subject: Re: Custom projection to gluPerspective.Posted: Thu Jul 05, 2012 7:57 pm
 Funky Monkey

Joined: Thu Sep 09, 2004 1:17 pm
Posts: 1638
Location: burrowed

_________________
Long pork is people!

wzl's burrow

Top

 Post subject: Re: Custom projection to gluPerspective.Posted: Fri Jul 06, 2012 7:42 am
 Bibliotherapist

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6868
Location: Wilts, Englandshire
MrThat, can I ask why you want to do 3D without using GL?

I ask because I spent (i.e. wasted) a lot of time writing a 3D engine before moving to DirectX/OpenGL. If I had the time again, I'd go straight to a mature API and skip the year or so that I spent re-inventing the wheel while pulling my hair out trying to get perspective, texture mapping and z-buffers to work properly in my own engine.

Just trying to save you some pain.

_________________
20 GOTO 10

Top

 Post subject: Re: Custom projection to gluPerspective.Posted: Fri Jul 06, 2012 9:12 am
 Source Code Swashbuckler

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
I have to say that Codehead is right, because I spent some time writting a 3D engine a long time ago. I think that the problem is not the math, but the fact that you will write a abstract code, in other words, a code using a high level language, without hardware specifications, leaving the processing for the software instead for the graphic hardware. The result will be a slow 3D engine. The fact that DirectX and OpenGL can do it in a fast way is because the industry follows a standard of hardware architectures and these libraries(OpenGL and DirectX) are huge and adjusted for each specification.

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.

Top

 Post subject: Re: Custom projection to gluPerspective.Posted: Fri Jul 06, 2012 9:16 am
 Source Code Swashbuckler

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
...so that I spent re-inventing the wheel...

I love to reinvent the wheel...

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.

Top

 Post subject: Re: Custom projection to gluPerspective.Posted: Fri Jul 06, 2012 5:07 pm
 Obfuscation Ogre

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 298
Location: Here (where else?)
From a learning perspective, reinventing wheels is very useful, as you get good quality information what the solutions actually do, and where their weak spots are.

Just be sure to throw your code away when you want to do something "real" :D

_________________
My project: Messing about in FreeRCT, dev blog, and IRC #freerct at oftc.net

Top

 Post subject: Re: Custom projection to gluPerspective.Posted: Thu Jul 19, 2012 1:34 am
Unfortunately, I would have to re-invent the wheel when it comes to using a non-C related programming language that I know how to use a lot.

So anyways, as I already know how to project the 3D vector using the camera eye view.

All I need to know is, what do I do with the projected vector? Do I translate it or multiply it with the projection matrix that comes with OpenGL?

I'm pretty sure that there's one more calculated formula for it's final touch after this.
Will be looking into this. I can understand math code better than traditional math, so I apologize for that.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 9 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forum

Search for:
 Jump to:  Select a forum ------------------ Forums    Forum Rules and Posting Guidelines Wiki Discussion    Help    Content Issues Game Programming Discussion    C and C++ Game Programming    Java Game Programming    Language Agnostic Programming    .NET Game Programming    VB Game Programming    Mobile Game Programming    Web-Based Game Programming    Other Languages    OpenGL Development    Direct X Development Game Development Discussion    Game Design    Game Media Off-Topic Discussion    Announcements    Off-Topic    Community Projects    News