flopoloco's picture

Smart Camera System and FPS example

Hello I just made a smart camera system that is using very high level functions (e.g. Turn, Position, Rotate) and it's wrapped in a very simple FPS example. The bad news is that I fight with my code for the last two hours and I've reached a dead end, now I'm too lazy to finish it :P. However, it would be very cool if you guys can modify everything from scratch in order to make it better.

Instructions:
I forgot to do it... you'll have to comment out something by yourself. Go to the 'Camera' class, locate the 'Update' method and comment out the method call 'Turn()' in order to run it properly (else it will spinning all the way around).

Constrols: Use WASD, Arrows, Space and C to move around.

P.S. Warning... very dirty code. ;)

AttachmentSize
OpenTK_FPS_Test.rar295.43 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Thanks, just tested and works fine! This could act as the basis for a camera tutorial (explaining how to create a simple camera, then how to achieve different motion models, e.g. first person, third person, top-down etc).

Unfortunately, I don't have the time for something like this right now (too busy with the core library!), but it's something to consider playing with if you feel like it (there's a section for such experiments in this site: Create->Book Page) ;)

The code's fine, too. You might consider dropping the "Get" prefixes from properties (in .Net people prefer to add a doc string that starts with "Get", as in "Gets a System.Int32 indicating the number of blah blah blah" for getters, and "Gets or sets a System.Boolean indicating blah blah" for getters/setters). It might also be worth creating an abstract "Camera" class with specific implementations for the different motion models, but that's not any big priority.

Anyway, thanks for the code :)

flopoloco's picture

Basically I started this as to a tutorial to myself, but it could be handy for the community. Anyway, thanks I can work further on this now since I have the approval from an experienced developer. This piece of code can be turned into a shiny and well-documented tutorial.

I will try to fix some problems and soon post a new version, in the mean time if anyone wish can freely make any comments or further suggestions.

Cya!

Inertia's picture

Good job, nice prototype :)

You might want to check http://www.opentk.com/node/211 out and play a .wav file looped at the position where the triangle is located (it's center or something like that). The other OpenAL related pages demonstrate how to do that, and I'd really appreciate some feedback regarding OpenAL - Fiddler gets all the bug reports/attention atm >.<

flopoloco's picture

OK, nice idea Inertia, thanks.