Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


3D Scrolling


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 andfol   Members   -  Reputation: 103

Like
0Likes
Like

Posted 12 March 2012 - 03:40 PM

Can anybody point me in the direction for beginners tutorials on 3D scrolling. I have a window created for OpenGL also have a player that moves no collision detection yet. I would be grateful for any feedback.

Sponsor:

#2 Manabreak   Members   -  Reputation: 141

Like
0Likes
Like

Posted 12 March 2012 - 11:30 PM

You probably already have the values you need to change in order to "scroll" your camera around. You may have used the GluLookAt() -method, so just change the position and rotation values in the method call. :)

#3 andfol   Members   -  Reputation: 103

Like
0Likes
Like

Posted 13 March 2012 - 09:57 AM

I am not quite sure what you mean Manabreak don't have a camera class as such and I not too familiar with GluLookAt() method.

#4 Manabreak   Members   -  Reputation: 141

Like
0Likes
Like

Posted 13 March 2012 - 10:21 AM

Sorry for not making myself clear, I didn't literally mean a camera class, but instead the "view" you get on your screen. Do you use the GluLookAt() method? If you do, it has several parameters, the first three ones are the position, the next three are the "target" position and the last three are the "up" vector. By changing the first three, you can change the view position. They're all in the good old X, Y, Z -order, so by changing the first number, you can pan the screen sideways, and so on.

#5 andfol   Members   -  Reputation: 103

Like
0Likes
Like

Posted 14 March 2012 - 07:24 AM

Hi Manabreak,

Hope you pick up this post, I tried using the GluLookAt() function like you suggested above:

gluLookAt(g_Player1.getPosX()+g_Player2.getPosX(),g_Player1.getPosY()+g_Player2.getPosY(),g_Player1.getPosZ()+g_Player2.getPosZ(),0.0f,0.0f,0.0f,0.0f,1.0f,0.0f);

I know this code is a bit messy, I have used my player objects to call the getPos variables. When I compile it it seems to work player2 moves across the screen as if scrolling although I have no movement on it, but player1 that does move according to keypresses just rotates around the screen and a primitive triangle I have drawn moves with it. Do you have a fix would be grateful.

#6 Manabreak   Members   -  Reputation: 141

Like
0Likes
Like

Posted 14 March 2012 - 10:18 AM

I think the problem is how you use the player positions. I think you're trying to get the midpoint between the players, right? Then you should do something like this:
float camX = (g_Player1.getPosX() + g_Player2.getPosX()) / 2;
float camY = (g_Player1.getPosY() + g_Player2.getPosY()) / 2;
float camZ = (g_Player1.getPosZ() + g_Player2.getPosZ()) / 2;

gluLookAt(camX, camY, camZ, 0f, 0f, 0f, 0f, 1f, 0f);

This isn't tested code, just something I threw out of my head. Hopefully it is what you're trying to do. :)

#7 andfol   Members   -  Reputation: 103

Like
0Likes
Like

Posted 20 March 2012 - 02:52 PM

Hi Manabreak,

Sorry its been so long what you suggested above worked it moves the player in and out keeping perspective but I was wondering is it possible to move the static objects in the scene so they appear to be moving past the moving players. I hope you are still following this I know its been a long time anyway I would be grateful for your feedback.

Thanks andfol.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS