Archived

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

orcblood

A few problems

Recommended Posts

Ok, so after many hours of reading and writing code Ive come to an almost stand still... Ive added in model support, texture support, lighting and controls (though their messed up) and Im working on collision detection. I have a few problems, however: When I try to run my opengl program everything goes perfectly. The level''s map loads (its actually a MS3D model), the lighting works nicely and everything seems to be in order. However, the controls seem to not work quite right. When you press the up arrow key you move foward but once you make it to a certain point you move backwards (in the opposite direction). When you press back you move out of the world (as expected with absolutly no collision detection) and you flip upside down and stop moving.... Now, both of these are problems that I must fix - I dont know how to program controls and Ive tried to base my controls on those of Lesson 10 Loading And Moving Through A 3D World. Unfortunatly, the entire code doesnt seem to work with my program... Ive made it so the uparrow/downarrow moves the view backwards.fowards, the left/right arrows will rotate the player model and the view (once added) and the mouse will rotate the camera (but thats not even added to the code yet). The left/right arrow keys do not turn the view by any means... Are there any good tutorials that deal with working with an OpenGL camera? And prehaps controls and an opengl camera? I will making it so the player can move the mouse and rotate the camera later on so adding in the base code for a camera now would save me time I suppose.... Any help would be greatly appreciated. You can find the demo for the little program here: www.orcish-design.net/LoK.zip I have reports for some people that winzip may or may not like unzipping the file - I dont know why but its a minor % of the people who have actually tried to unzip the program.

Share this post


Link to post
Share on other sites
There''s no such thing as an OpenGL camera, you have to make one of your own that answers to your needs. For example let''s say you make a 2D scroller then you need to keep your player in view at all times. You also want the camera to track a tad ahead of the player so you can see more clearly.

So you wanna define a new camera class:


class MyCamera {
public:
MyCamera();

float X;
float Y;
float Buffer;
float Zoom;

Update();
};

MyCamera::MyCamera()
{
X = Y = 0.0f;
Buffer = 5.0f // The amount in which you want to lead your character by

Zoom = -10.0f;
}

MyCamera::Update()
{
if(Player.Heading == TRUE) // If he is heading to the right

{
X = Player.X + Buffer;
}

else // If he is heading to the left

{
X = Player.X - Buffer;
}


Y = Player.Y;
}


In every game loop iteration you run Camera.Update()
and right before you draw your entire game you translate by the current X, Y, and Zoom values of your global camera instance.

Of course you also want the Zoom value to be more dynamic and responsive to the game. For example if your player jumps up then you wanna zoom out so the player can still see what''s under him. That way he can know where to land, very helpful!

Anyhow, you don''t need a tutorial for this one. Create your own Camera will ya =)

Share this post


Link to post
Share on other sites
Hmm thanks for the tip. I asked my friends brother and he pointed me towards some source code and tutorials that he found on the net. Ive written a camera because of that, although now Im getting some linker errors... Would anyone have the gl/glut.h files sitting around somewhere? My computer doesnt appear to have them - which makes sense with an 11MB on board video card ...

Share this post


Link to post
Share on other sites
quote:
Original post by orcblood
Would anyone have the gl/glut.h files sitting around somewhere? My computer doesnt appear to have them - which makes sense with an 11MB on board video card ...

I guess they could be downloaded from opengl.org and searching a bit.

Don''t make a problem of having a 11MB video card (I don''t even see how this could be possible however...), this is actually very uninportant. It is much worse if it doesn''t support some features like VBO or something.

Share this post


Link to post
Share on other sites
I''m not sure there are any video cards that are shiped with 11 Mb of memory , and even for motherboard integrated video chipsets I had the impression that you can choose 4,8,16,32,64 Mb of shared ram/vram memory.Anyways glut is not shiped as part of opengl and all you need to get started with glut can be found here

Share this post


Link to post
Share on other sites
Hey, I have an 8MB video card and I''m still designing my engine with pluggable shader support in mind.. but then again I''m planning to get a new video card as soon as the REF device capabilities give me a frame rate less than 10. (AMD Athlon XP 1700+, and an ATI RAGE IIC.. damn my comp is weird.)

Share this post


Link to post
Share on other sites