Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
duck monster
Dec 15, 2004

Been playing with PyODE, the python wrappers for the ODE physics engine. Plays real nice with PyGame.

http://pyode.sourceforge.net/tutorials/tutorial2.html

Added a bunch of nodes and motors and poo poo to the tutorial, and just watch it flail around. Neat as hell. Putting extreme values into things makes some pretty loopy 'physics'.

Adbot
ADBOT LOVES YOU

Thug Bonnet
Sep 22, 2004

anime tits ftw

Why is my perspective projection matrix looking down positive z rather than negative z?
code:
float n, f, r;
/* near and far clip */
n = 0.1;
f = 500.0;
/* ratio of viewport */
r = ( float ) glWidth / ( float ) glHeight;


float mp[16];
mp[0] = (1.0/r)*-(1.0/(tan(fov * 3.14159 / 360.0 ))); mp[4] = 0.0;				  mp[8] = 0.0;	    mp[12] = 0.0;
mp[1] = 0.0;					      mp[5] = 1.0/(tan(fov * (3.14159 / 360.0))); mp[9] = 0.0;	    mp[13] = 0.0;
mp[2] = 0.0;					      mp[6] = 0.0;				  mp[10] = f/(f-n); mp[14] = -((f*n)/(f-n));
mp[3] = 0.0;					      mp[7] = 0.0; 				  mp[11] = 1.0;     mp[15] = 0.0;
When i use glFrustum it works fine (looks down negative z):
code:
glFrustum(
		( ( float ) glWidth / ( float ) glHeight ) * - ( tan ( fov * 3.14159 / 360.0 ) * .1 ),
		( ( float ) glWidth / ( float ) glHeight ) * ( tan ( fov * 3.14159 / 360.0 ) * .1 ),
		- ( tan ( fov * 3.14159 / 360.0 ) * .1 ),
		tan( fov * 3.14159 / 360.0 ) * .1,
		0.1,
		500.0f
);

Thug Bonnet fucked around with this message at 23:00 on Dec 10, 2007

haveblue
Aug 15, 2005



Toilet Rascal
Well, the first thing I notice is that your degree/radian conversion is wrong- all those 360s should be 180.

haveblue fucked around with this message at 23:04 on Dec 10, 2007

TSDK
Nov 24, 2003

I got a wooden uploading this one
f and n need to be negated before being passed in, by the looks of it. Since you're looking down negative Z, then the clip planes are actually at -0.1 and -500.0.

Doc Block
Apr 15, 2003
Fun Shoe
Does anybody know how far back ATI hardware supports FBOs and non-power-of-two textures (or at least texture rectangles)?

Professional Lamer
May 11, 2004

by mons al-madeen
I've been learning C++ for a while now hoping to get started writing meaningful games myself, and I think I have a good enough grasp of the language to start applying it. (I have some experience with Java, so I had a decent knowledge of OOP before I even looked at C++).

I am not interested in 3D games at all really, 2D is more my sort of thing. Are there any decent tutorials out there for using DirectX (or hell, OpenGL or some other graphics API) in a 2D context? Most of the ones I find seem to focus on 3D, and that seems like a gigantic branch of games development that I'ld rather not go near if I can help it.

Benji the Blade
Jun 22, 2004
Plate of shrimp.

Danbo Daxter! posted:

I am not interested in 3D games at all really, 2D is more my sort of thing. Are there any decent tutorials out there for using DirectX (or hell, OpenGL or some other graphics API) in a 2D context? Most of the ones I find seem to focus on 3D, and that seems like a gigantic branch of games development that I'ld rather not go near if I can help it.

If you've already done some 2D programming with a 2D graphics library, feel free to disregard the next paragraph.

I haven't seen any such tutorials myself, though they may very well be out there. If you're looking for a quick way to start, I'd suggest looking up some SDL tutorials, and going from there. For high-performance 2D, you'll still want to use Direct3D or OpenGL, but 3D libraries are significantly more complicated than straight 2D blitting libraries, in my opinion.

To go ahead using a 3D library, if you can't find some good tutorials on using OpenGL or Direct3D for 2D display or a library that does it for you, the best way would probably just be to start with normal 3D tutorials. Once you've got a grasp on the concepts, it's pretty easy to just draw lots of screen-aligned polygons with an orthographic projection matrix.

voodoo dog
Jun 6, 2001

Gun Saliva

Danbo Daxter! posted:

I've been learning C++ for a while now hoping to get started writing meaningful games myself, and I think I have a good enough grasp of the language to start applying it. (I have some experience with Java, so I had a decent knowledge of OOP before I even looked at C++).

I am not interested in 3D games at all really, 2D is more my sort of thing. Are there any decent tutorials out there for using DirectX (or hell, OpenGL or some other graphics API) in a 2D context? Most of the ones I find seem to focus on 3D, and that seems like a gigantic branch of games development that I'ld rather not go near if I can help it.
I agree with Benji that you should definitely look at existing 2D graphics libraries and use those instead. SDL would be a pretty good choice (certainly better than using DirectDraw), but if you want a more complete package, I'd strongly recommend ClanLib. It has a lot of useful stuff (such as GUI, network, sound etc.), is easy to use and also quite a lot faster than SDL as it's using opengl to render stuff.

It's also written in C++ and not in C like SDL is, which I prefer. I've been using it on and off for a few years now and in my opinion it is really well done and also quite mature at this point. I've always been wondering why there don't seem to be many people using it, the only reason I can come up with is that some people like to do lower-level stuff themselves as well. It may look overwhelming at first, but the good thing is that it's very modular so you don't have to use it all at once.

Paradoxish
Dec 19, 2003

Will you stop going crazy in there?

Danbo Daxter! posted:

I am not interested in 3D games at all really, 2D is more my sort of thing. Are there any decent tutorials out there for using DirectX (or hell, OpenGL or some other graphics API) in a 2D context? Most of the ones I find seem to focus on 3D, and that seems like a gigantic branch of games development that I'ld rather not go near if I can help it.

Part of the reason you'll see so few tutorials is because 2d projects, at least in Direct3d (I'm not terribly familiar with OpenGL), are relatively straightforward. Books like this spend about one chapter covering the D3DXSprite and D3DXFont interfaces because they really are that simple. Anything you need to know about their usage can be gleaned fairly easily from the actual DirectX SDK documentation once you're past all the normal DirectX boilerplate code. If you're going to go beyond D3DXFont/D3DXSprite* you'll need to know at least the basics of working with Direct3d "normally" so any tutorial or book will do.

Other than that, I agree that using SDL or Clanlib is a good idea, but learning to use Direct3d or OpenGL "raw" at some point wouldn't hurt either.

*In my experience D3DXSprite should pretty much be sufficient for anything. The only good reason I can imagine to roll your own sprite class/library would be if the D3DXSprite interface was missing some feature you needed. D3DXFont, on the other hand, is still abysmally slow for text-heavy projects.

Benji the Blade
Jun 22, 2004
Plate of shrimp.

Wuntvor posted:

ClanLib

Wow, this sure has come a long way since I looked at it ~5 years ago, though still no version 1.0 (for whatever that's worth). I'll definitely have to look into it more when I get a chance, but if it's as good as you say, then this seems like a good choice for Danbo Daxter!

samiamwork
Dec 23, 2006

kewlpc posted:

Does anybody know how far back ATI hardware supports FBOs and non-power-of-two textures (or at least texture rectangles)?

I don't have the answer, but you could probably find out with the database in the OpenGL Extension Viewer

http://www.realtech-vr.com/glview/

A pretty useful application especially for that kind of thing.

Doc Block
Apr 15, 2003
Fun Shoe
Awesome, thanks.

Looks like I'm going to have to use texture rectangles instead of NPOT textures, though :(

tyrelhill
Jul 30, 2006

kewlpc posted:

Awesome, thanks.

Looks like I'm going to have to use texture rectangles instead of NPOT textures, though :(

The hardware usually pads NPOT textures to POT textures anyway, might as well remove that overhead and do it yourself.

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

tyrelhill posted:

The hardware usually pads NPOT textures to POT textures anyway, might as well remove that overhead and do it yourself.

Do you have any literature backing this claim up?

Specifically OpenGL 2.0 on Nvidia.

Sex Bumbo
Aug 14, 2004
Isn't that fairly well known? At least for older cards, which is what most people have.

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

Stanlo posted:

Isn't that fairly well known? At least for older cards, which is what most people have.

I've not seen any official documentation stating this and would be VERY interested in reading some.

It's pretty important to me that I can keep an accurate handle on GPU memory usage. Yay for not having a glGetTextureMemoryUsage method.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

So I'm working on a browser based game and can't decide how to implement a fog of war on the game map.

If you don't know what a fog of war is, it basically means that every player sees the map but they don't know what's surrounding them until they go there.

The map runs on a coordinate system like this:

0,0 1,0 2,0 3,0 4,0
0,1 1,1 2,1 3,1 4,1
0,2 1,2 2,2 3,2 4,2
0,3 1,3 2,3 3,3 4,3

Each coordinate pair would be assigned a number, eg. 1,2,4, etc...

What would be the best way to implement a fog of war? I'm thinking store the visited sectors onto a list and store that into a MySQL Text field and explode/implode them.

t_rf
Nov 24, 2006

drcru posted:

What would be the best way to implement a fog of war? I'm thinking store the visited sectors onto a list and store that into a MySQL Text field and explode/implode them.

Well, it depends on what you mean by best. You have several options for representing maps and at different points you may want to use them all:

-List or 1d array of references to given locations, what you have. In this case probably the best because you're only returning a list of what you need to know, so you don't waste your processing power and bandwidth on the remainder. The list/array consideration has to do with how your data gets accessed and rewritten.

-2d array of references. Not hugely different to the list, but semantically easier when working with known sizes of map.

-Graphs where each location references other locations near it. This is a good way to search and navigate a map, but inflicts serious penalities when one tries to grab the entire graph at once. So not good for getting a fog of war or other "summary" data.

-Other data structures? You can put caching and lower-resolution versions and other things on top of the others, but these are mainly used as optimizations. I don't know of other (sane) ways to represent tiled maps in games.

And there's a basic decision underlying all of these - whether to dump all the data in each location into a single structured data type, or to parcel out some of the data into their own maps independent of the others, using primitive data types. In some cases you could see a speed boost from the many-maps/primitive-types approach, but it's much harder to maintain a unified structure that way, and the optimization comes mostly from reducing indirection(which has to be weighted against the cost of doing the same lookup amongst multiple maps).

Ultimately it's an architectural decision to figure out the data representation(s) your game needs. There's no one right answer, and most games will use some kind of mixed approach, like an array of terrain and a list of units.

Barrackas
Aug 12, 2007

tyrelhill posted:

The hardware usually pads NPOT textures to POT textures anyway, might as well remove that overhead and do it yourself.
I can't remember where I picked this up, but it's in the back of my head somewhere that older cards that don't support with NPOT textures will actually deal with them by breaking the NPOT texture down into the a series of POT textures.

So, for example, 100x100 texture gets broken into 9 POT textures, as follows;

64x64
64x32
64x4
32x64
32x32
32x4
4x64
4x32
4x4

Hence the performance hit related to NPOT texture use. This may just have been something that Java3D did (that was the platform I developed on), before sending textures to the GPU, but it's been over a year since I looked at this so I can't really remember.

Barrackas fucked around with this message at 16:58 on Dec 20, 2007

Ferg
May 6, 2007

Lipstick Apathy

duck monster posted:

Been playing with PyODE, the python wrappers for the ODE physics engine. Plays real nice with PyGame.

http://pyode.sourceforge.net/tutorials/tutorial2.html

Added a bunch of nodes and motors and poo poo to the tutorial, and just watch it flail around. Neat as hell. Putting extreme values into things makes some pretty loopy 'physics'.
This is probably a shot in the dark, but has anybody had luck with getting OgreOde to compile on Linux? I'm trying to find a physics wrapper for my OGRE-based engine on Linux but I can't seem to get OgreOde to build and OgreNewt is only pre-compiled for Windows (from what I've found).

haveblue
Aug 15, 2005



Toilet Rascal

Barrackas posted:

I can't remember where I picked this up, but it's in the back of my head somewhere that older cards that don't support with NPOT textures will actually deal with them by breaking the NPOT texture down into the a series of POT textures.

So, for example, 100x100 texture gets broken into 9 POT textures, as follows;

64x64
64x32
64x4
32x64
32x32
32x4
4x64
4x32
4x4

Hence the performance hit related to NPOT texture use. This may just have been something that Java3D did (that was the platform I developed on), before sending textures to the GPU, but it's been over a year since I looked at this so I can't really remember.

I think it's something Java3D did. If a graphics card doesn't support rectangular textures then they can't be used in OpenGL, it's an optional extension (at least, it used to be, and rectangular texture support has been present in all 3D cards for the past several generations).

IcePotato
Dec 29, 2003

There was nothing to fear
Nothing to fear
I'm a comp sci junior and I want to do an independent study for next semester. I'm thinking making a video game because it will be a learning process with a very concrete result, I've talked to my advisor about it and he agrees that it's a good foundation. However, I'm not really sure what is in or out of my scope.

Right now I'm thinking about using C# and the XNA platform (which I know.. exists, and that's all I know about it). I'm very experienced in Java, I'm very familiar with C# syntax and features, so that's not going to be the hard part. The hard part is defining a project that has significant milestones that I can complete in a reasonable amount of time. I've never done a game from scratch before so I really have no gauge on what I can accomplish in a semester.

Right now I'm thinking that creating a platformer is a good simple task to start out with. Anyone have any advice on the subject? I'm, of course, open to using other languages and frameworks (Except Python. I'm a Perl guy. And I'd like to move past Java) or even creating multiple small game platforms (IE a demo Pong, a demo Asteroids, a demo platformer, and a demo RPG/RPG engine). Basically I just need some guidance because I have no idea where to get started.

Also how screwed am I if I hate linear algebra? :)

Sex Bumbo
Aug 14, 2004

IcePotato posted:

Right now I'm thinking about using C# and the XNA platform (which I know.. exists, and that's all I know about it). I'm very experienced in Java, I'm very familiar with C# syntax and features, so that's not going to be the hard part. The hard part is defining a project that has significant milestones that I can complete in a reasonable amount of time. I've never done a game from scratch before so I really have no gauge on what I can accomplish in a semester.

Right now I'm thinking that creating a platformer is a good simple task to start out with. Anyone have any advice on the subject? I'm, of course, open to using other languages and frameworks (Except Python. I'm a Perl guy. And I'd like to move past Java) or even creating multiple small game platforms (IE a demo Pong, a demo Asteroids, a demo platformer, and a demo RPG/RPG engine). Basically I just need some guidance because I have no idea where to get started.

Also how screwed am I if I hate linear algebra? :)

If you know C#, you should be fine with XNA. At least, if you have problems, it won't be because of the platform or the language. You're really just limited by your own software engineering skills. I can say with mild confidence that forums.xna.com has better support than probably any other platform you might consider.

A small platformer is probably a good idea. I don't think people will be impressed by pong or asteroids, as they can be made in an afternoon. And, not to be a jerk, but even if you come up with a decent RPG engine, any game you make for it is going to suck if you're working by yourself and have a single semester.

If you're making a 2D game you don't really need to know any linear algebra at all.

If you make a 3D game you don't need to know much. Any competent person can learn the basics.

Doc Block
Apr 15, 2003
Fun Shoe

HB posted:

I think it's something Java3D did. If a graphics card doesn't support rectangular textures then they can't be used in OpenGL, it's an optional extension (at least, it used to be, and rectangular texture support has been present in all 3D cards for the past several generations).

There's nothing stopping the driver (for non-NPOT hardware) from claiming NPOT support and then just padding NPOT textures out to POT ones, or doing what Barrackas said, or some other method.

Just like drivers could claim FBO support when the underlying hardware doesn't and then just do a copy operation behind the scenes.

Texture rectangles are a different beast than NPOT textures, BTW.

tyrelhill
Jul 30, 2006

forelle posted:

Do you have any literature backing this claim up?

Specifically OpenGL 2.0 on Nvidia.

Not exactly what I said, but this quote is from this book:
http://www.amazon.com/gp/product/im...82225765&sr=1-3

stuff on loading textures posted:

It is important to note that prior to OpenGL 2.0, these dimensions must be integer powers of 2. There is no requirement that texture maps be square, but a texture loaded with non-power of two dimensions on older OpenGL implementations will cause texturing to be implicitly disabled. Even though OpenGL 2.0 (and later) allows non-power of two textures, there is no guarantee that they will necessarily be fast on the underlying hardware. Many performance-minded developers still avoid non-power of two textures for this reason.

I am actually taking a class where the author of this book is lecturing so I'll ask him tomorrow what exactly happens.

tyrelhill
Jul 30, 2006

IcePotato posted:

XNA Stuff...

Yes, use XNA. If you're going to do anything complicated with translation and rotation you're probably going to have to have at least a little understanding of linear algebra. As long as you stay 2D, you can keep things pretty simple math wise.
I would also suggest you try out using just the DirectX SDK instead of XNA. There's alot more you have to do yourself with DirectX that XNA usually handles but you'll learn a million times more about graphics programming using DirectX than XNA.

stramit
Dec 9, 2004
Ask me about making games instead of gains.

quote:

It is important to note that prior to OpenGL 2.0, these dimensions must be integer powers of 2. There is no requirement that texture maps be square, but a texture loaded with non-power of two dimensions on older OpenGL implementations will cause texturing to be implicitly disabled.

This isn't true. There are a few OpenGL 2.0 cards that don't support npot textures (I'm looking at you ATi X800). I got bitten by this pretty badly about a year ago when I made the assumption that any OpenGL2.0 card can support npot textures. Always make sure that the GL_ARB_texture_non_power_of_two is present, at least until ATi get themselves in line with their old graphics drivers (unlikely).

Sex Bumbo
Aug 14, 2004

tyrelhill posted:

I would also suggest you try out using just the DirectX SDK instead of XNA. There's alot more you have to do yourself with DirectX that XNA usually handles but you'll learn a million times more about graphics programming using DirectX than XNA.

I disagree. I think you'll end up wasting time on unimportant details if what you want to do is make a game. It doesn't really hide that much either. It will setup D3D for you - not very exciting, and setup a render loop for you - trivial. You can override device creation too and just a tiny bit of hacking, use your own render loop if you really want too. Render targets are a little weird since they need to be compatible with the 360, but nothing too fancy is going on.

I can't really think of anything else it does that D3DX doesn't already do. You'll probably have a better understanding of DirectX too since you're doing a lot of the same things while not getting frustrated with reference counting or lost devices.

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

tyrelhill posted:

Not exactly what I said, but this quote is from this book:
http://www.amazon.com/gp/product/im...82225765&sr=1-3


I am actually taking a class where the author of this book is lecturing so I'll ask him tomorrow what exactly happens.

Cool, Sounds like an interesting course.

I'm not really bothered about pre-2.0 cards or low end cards either.

Doc Block
Apr 15, 2003
Fun Shoe
We can't all target Quadros :argh:

StickGuy
Dec 9, 2000

We are on an expedicion. Find the moon is our mission.
Some time ago, I wrote an application that renders some 2D polygons. I was lazy about handling complex cases so I used the GLU tesselator to handle drawing them. I'm rewriting the rendering code using DirectX as a learning experience, but I can't find a DirectX equivalent to the tesselator. As a stop gap measure, I've used the tesselator to do the tesselation and then just render the primitives with DirectX. I'm hoping there's a better way though. Does anyone have any experience with this sort of thing in DirectX?

IcePotato
Dec 29, 2003

There was nothing to fear
Nothing to fear

Stanlo posted:

If you know C#, you should be fine with XNA. At least, if you have problems, it won't be because of the platform or the language. You're really just limited by your own software engineering skills. I can say with mild confidence that forums.xna.com has better support than probably any other platform you might consider.

A small platformer is probably a good idea. I don't think people will be impressed by pong or asteroids, as they can be made in an afternoon. And, not to be a jerk, but even if you come up with a decent RPG engine, any game you make for it is going to suck if you're working by yourself and have a single semester.

If you're making a 2D game you don't really need to know any linear algebra at all.

If you make a 3D game you don't need to know much. Any competent person can learn the basics.

Sweet, thanks.

I'm assuming the normal track is to create an engine, create editing tools, and then make levels using the tools?

POKEMAN SAM
Jul 8, 2004

IcePotato posted:

Sweet, thanks.

I'm assuming the normal track is to create an engine, create editing tools, and then make levels using the tools?

Probably more likely that you'll create the engine, create some content manually, and then make the content editing tools.

Ferg
May 6, 2007

Lipstick Apathy

Ugg boots posted:

Probably more likely that you'll create the engine, create some content manually, and then make the content editing tools.
Definitely the case. Usually after spending some time with the masochistic method of hand-building your content it will drive you to the point of creating your own tools.

haveblue
Aug 15, 2005



Toilet Rascal
Even better, you write the loading (and storing) code for the editor and then add those files to the game engine project.

IcePotato
Dec 29, 2003

There was nothing to fear
Nothing to fear
Thanks for all the help guys, I'll write up my proposal over break and probably be back with questions once the semester starts again :)

SnakeByte
Mar 20, 2004
FUCK THIS COMPANY THAT HASNT PRODUCED THE GAME IN QUESTION FOR YEARS BECAUSE THEY SUSPENDED ME FOR EXPLOITING A BUG FUCK THEM IN THE ASS I AM A MORON
http://www.amazon.com/Introduction-Game-Programming-Direct-9-0c/dp/1598220160/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1198303208&sr=8-1

Just bought this book from Barnes & Noble. You can get it for $30 on Amazon. So far it's been an incredible read. The first three chapters went from vectors, to rays, to matrices, and it never lost me! I'm about to get into Part II (Nerdy DX Goodness.)

Paradoxish
Dec 19, 2003

Will you stop going crazy in there?

SnakeByte posted:

http://www.amazon.com/Introduction-Game-Programming-Direct-9-0c/dp/1598220160/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1198303208&sr=8-1

Just bought this book from Barnes & Noble. You can get it for $30 on Amazon. So far it's been an incredible read. The first three chapters went from vectors, to rays, to matrices, and it never lost me! I'm about to get into Part II (Nerdy DX Goodness.)

Yeah, I've recommended this book here before and I still say it's the only C++/DirectX book that's actually worth buying. Most online tutorials are terrible, so if you can't get what you need from the SDK documentation it's probably the best way to learn the API. The math coverage is a little light, though, so I think picking up something to supplement that (assuming you don't already know everything you need) isn't a bad idea.

FlyingDodo
Jan 22, 2005
Not Extinct
I've just finished writing Vector,Quaternion and Matrix classes (c++). I understand vectors and matrices (well I hope I understand enough). I want to make a class which can be used to rotate things through 6dof. I can use the quaternions to make a basic fps camera which works fine but I have no idea how I am supposed to make a 6dof camera.

Adbot
ADBOT LOVES YOU

haveblue
Aug 15, 2005



Toilet Rascal

FlyingDodo posted:

I've just finished writing Vector,Quaternion and Matrix classes (c++). I understand vectors and matrices (well I hope I understand enough). I want to make a class which can be used to rotate things through 6dof. I can use the quaternions to make a basic fps camera which works fine but I have no idea how I am supposed to make a 6dof camera.

By "basic fps camera" do you mean a camera that uses Euler angles? If you can convert the angle and axis from a quaternion to an orientation matrix, you can use it to transform the camera just like any other object.

Then, to spin the camera around a relative axis like in Descent, you transform the target axis with the camera quaternion, convert the result and the magnitude to a quaternion, and multiply it back into the camera orientation.

If that didn't make any sense, I can try to find the book I got this from in the first place. It's been a really long time since I had to work with quaternions.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply