realbasic-games
[Top] [All Lists]

Re: opengl camera troubles

To: "REALbasic Games" <REALbasic-Games at lists dot realsoftware dot com>
Subject: Re: opengl camera troubles
From: Chris Dillman <chrisd at plaidworld dot com>
Date: Tue, 23 Mar 2004 11:51:19 -0600
References: <fc dot 004c566902fc6a89004c566902fc6a89 dot 2fc6be2 at sad17 dot k12 dot me dot us>
Hello everyone, I'm back with more OpenGL problems.
I will explain the problem, and then give the code.

The Problem: I have a camera class, and if I move the camera back some so
I can see stuff, it doesn't behave as expected. With camera.z at -10,
"camera.yaw 0.5 "and "cube_in_the_middle.yaw 0.5" produce the exact same
result; the cube spins. With cube.yaw, the cube should spin. With
camera.yaw, the cube should seem to move back and forth, because the
camera is changing direction, correct?

I'm sure my yaw-pitch-roll code is correct. I tested it visually against
rb3d before I started working on a camera.

The Code (mContext as glContext is a property):

  mContext.use
  call mContext.update
  glClear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT)

  glMatrixMode(GL_PROJECTION)
  glLoadIdentity
  gluPerspective(45, me.width / me.height, 0.1, 1000)

  glTranslated(camera.position.x, camera.position.y, camera.position.z)
  glMultMatrixd(camera.orientation.createMatrix)

  glMatrixMode(GL_MODELVIEW)
  glLoadIdentity

  //draw stuff

  glFlush

For better game speed REMOVE glFlush


  mContext.swapBuffers

Please keep in mind that this is not _exactly_ how I do things. This code
is spread over several functions in real life.

Why is it doing this?
I also have camera.moveForward that is not working correctly.

 Sub MoveForward(Distance As Double)
   dim forward as vector3D
   forward = me.orientation.transform(kVecForward)
   me.position.add(forward.times(distance))
End Sub

This behaves exactly like "camera.position.z = camera.position.z +
distance", instead of transforming the forward vector by
camera.orientation like it should.

What's going on???

Asher



 - - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


--
Email: chrisd at plaidworld dot com
iChat / AIM: crackbunny at mac dot com

Buy Art : http://www.starbounce.com
Listen to Music: http://www.trance-o-matic.com
Play Games: Plaid World Studios http://www.plaidworld.com
Learn game programming at http://www.idevgames.com
Day job: Software Engineer for http://www.riskwise.com, Part of LexisNexis




- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>