|
Would anyone be interested in sharing resources like textures and models? I just made a 4096 concrete texture and a 2048 metal floor texture.
|
# ? Apr 5, 2010 15:11 |
|
|
# ? May 26, 2024 07:29 |
|
https://opengameart.org is probably a good place to put things like that.
|
# ? Apr 5, 2010 18:48 |
|
So I've been doing some random collision detection stuff, testing out 2D collision on rotatable objects with a rectangular bounding box, squares, circles, all that stuff. And it got me thinking about how one would do something else: I'm kind of curious how to do collision detection with something that doesn't rotate around a central pivot. Like a door. Lets say you had a door that could open and close, but you wanted the player to collide with it even if it was open. What would you do for that? What I am thinking of, with my limited experience, is simply having the Door return a different bounding box depending on if it's opened of not. If it's closed, then return a rectangle near the 'bottom' of the door. Otherwise, return a rectangle to the 'side' of the door if it's opened. Does this make any sense? This does allow the player to walk through the door as it's animating, but that shouldn't be too much of a problem unless it's sloooow.
|
# ? Apr 7, 2010 17:52 |
|
Morpheus posted:So I've been doing some random collision detection stuff, testing out 2D collision on rotatable objects with a rectangular bounding box, squares, circles, all that stuff. And it got me thinking about how one would do something else: I'm kind of curious how to do collision detection with something that doesn't rotate around a central pivot. Like a door. Lets say you had a door that could open and close, but you wanted the player to collide with it even if it was open. What would you do for that? A quick and dirty way of handling it is to do multiple passes. Have a single bounding box that encompasses both open and closed states. If it collides with that then investigate further into what state is the door in (It could be transitioning states) and what would the size of the box be for that state.
|
# ? Apr 7, 2010 18:52 |
|
Why not just use OBBs?
|
# ? Apr 7, 2010 19:59 |
|
Avenging Dentist posted:Why not just use OBBs? No reason, per se. All of my bounding boxes have rotation applied to them, the only reason I don't do it in this case is because there's nothing set up to rotate around a point that isn't the center of the bounding box. I could, I guess, set up the door to change it's RotationPoint (or whatever) to be its hinge, and then when it enters the 'opening' state, rotate it every tick until it's open (ie rotated at 90 degrees or so), then say it's at its Open state. Hmm. I guess I'll see if that works.
|
# ? Apr 7, 2010 20:41 |
|
Morpheus posted:So I've been doing some random collision detection stuff, testing out 2D collision on rotatable objects with a rectangular bounding box, squares, circles, all that stuff. And it got me thinking about how one would do something else: I'm kind of curious how to do collision detection with something that doesn't rotate around a central pivot. Like a door. Lets say you had a door that could open and close, but you wanted the player to collide with it even if it was open. What would you do for that? You must be doing some sort of coordinate transform to move the door from it's closed to open state. A solution would be to take the inverse transform matrix of the door and multiply whatever the door is colliding against by it. Then do a normal cube check as if the door were sitting in the middle of 0,0,0 (or wherever it's modeled from).
|
# ? Apr 8, 2010 16:13 |
|
I'm making a small pac-man clone in C++, using SFML. Right now the map is grid based, loading all of the background images from a single file and then creating a sprite for each at the start. These are then drawn every frame. The thing is, with a 28 by 31 grid - and nothing else whatsoever - I'm getting about 10 FPS. Now I know that I don't need super high frame-rates for pacman, and I've heard of the evils of premature optimization, but this still makes me feel like the way I'm approaching it is fundamentally flawed. Some ideas that I've had are: - Only updating the screen every other frame - Drawing the map to a surface at the start, and then just drawing this surface each time (would drawing one big thing be quicker than drawing lots of little things?) - Storing the pointers to the sprites in a format other than: code:
|
# ? Apr 8, 2010 19:29 |
|
Staggy posted:Storing the pointers to the sprites in a format other than: Please don't tell me those ints are the coordinates because that would be silly. Assuming the ints are the tile coordinates - i.e. ([0-28), [0-31)) - you probably aren't dealing with "sparse" data. In fact, all the coordinates might have a sprite in them (or more if you count the player/ghosts/pellets). You should just use a simple 2D array for this. 28*31*4 bytes = 3.4 KB so you're really not spending much memory anyway, and it'll be faster. That said, I can just about guarantee that this isn't your problem. You really need to get a profiler and check where you're spending the most time because otherwise you're just jumping at shadows.
|
# ? Apr 8, 2010 19:38 |
|
Yeah, assuming your tiles aren't dynamically scaling down from 1024x768 every frame or something weird like that, nothing you've listed is suspicious.
Mustach fucked around with this message at 19:46 on Apr 8, 2010 |
# ? Apr 8, 2010 19:44 |
|
Avenging Dentist posted:Please don't tell me those ints are the coordinates because that would be silly. Assuming the ints are the tile coordinates - i.e. ([0-28), [0-31)) - you probably aren't dealing with "sparse" data. In fact, all the coordinates might have a sprite in them (or more if you count the player/ghosts/pellets). You should just use a simple 2D array for this. 28*31*4 bytes = 3.4 KB so you're really not spending much memory anyway, and it'll be faster. Yeah, you pretty much hit the nail on the head. They were the coordinates, and I see what you mean about using std::map for this. And when I changed this there was no difference - right again. I'll have a look at a profiler, thanks.
|
# ? Apr 8, 2010 20:07 |
|
Your code can't be that complex, if all you are doing is drawing a sprites. My guess is you've made a mistake somewhere that we could catch just by eyeballing it. A profiler at this stage is probably a little overkill. Maybe toss it up on pastebin or something and I'd be happy to take a look.
|
# ? Apr 8, 2010 20:54 |
|
Pfhreak posted:Your code can't be that complex, if all you are doing is drawing a sprites. My guess is you've made a mistake somewhere that we could catch just by eyeballing it. A profiler at this stage is probably a little overkill. Maybe toss it up on pastebin or something and I'd be happy to take a look. How is a profiler overkill? You run with a profiler enabled and it spits out a graph and then you look at it. Boy that sure is complicated. (Granted, you'll have to find something if you're programming on Windows, but I know people have linked Windows C++ profilers before.)
|
# ? Apr 8, 2010 21:02 |
|
VS doesn't come with a profiler?
|
# ? Apr 8, 2010 21:06 |
|
Otto Skorzeny posted:VS doesn't come with a profiler? There's this but it doesn't come with VS and I haven't actually tried it: http://msdn.microsoft.com/en-us/performance/default.aspx
|
# ? Apr 8, 2010 21:13 |
|
Avenging Dentist posted:How is a profiler overkill? You run with a profiler enabled and it spits out a graph and then you look at it. Boy that sure is complicated. (Granted, you'll have to find something if you're programming on Windows, but I know people have linked Windows C++ profilers before.) Because he'll have to go find one, hook it up, configure it, make sure it works, then dig through a graph that's likely WAY more granular than he needs (or spits out a bunch of info about the libraries he's using) when the problem is most likely he's reloading the image from the hard disk every frame or something. I fail to see how suggesting he go out and get a tool, yet providing no information on where such a tool might be found except for a link that leads to a whole bunch of 'Content has been removed' pages helps. Or were you suggesting he download the Windows SDK? Because I think that's the very definition of overkill. I suppose he could write his own quick profiler in a static class. (I have the code around here somewhere to do this using SFML...) But once again, it's probably just some novice mistake any one of us could point out with our eyes on the code.
|
# ? Apr 8, 2010 21:26 |
|
Otto Skorzeny posted:VS doesn't come with a profiler? edit: What Dentist linked to is good, but only runs on Vista+, if that's a problem for you. Here's a decent overview, since the MSDN pages are busted. Mustach fucked around with this message at 21:40 on Apr 8, 2010 |
# ? Apr 8, 2010 21:32 |
|
Pfhreak posted:Because he'll have to go find one, hook it up, configure it, make sure it works, then dig through a graph that's likely WAY more granular than he needs (or spits out a bunch of info about the libraries he's using) when the problem is most likely he's reloading the image from the hard disk every frame or something. Yeah, god forbid someone learn how to do something useful that will serve them well in the future instead of letting you show off.
|
# ? Apr 8, 2010 21:50 |
|
Mustach posted:It only comes with the Premium and Ultimate editions for some goofy reason. I'm on Win7 and have VS Ult anyways (MSDN), but I generally do coding work on *nix, thus my lack of familiarity with VS's capabilities. Good to know regardless.
|
# ? Apr 8, 2010 21:59 |
|
Avenging Dentist posted:Yeah, god forbid someone learn how to do something useful that will serve them well in the future instead of letting you show off. You're adorable. Of course, it'd be nice if VS just included this functionality in the first place.
|
# ? Apr 8, 2010 23:10 |
|
Man it must be great living in your world where mediocrity is something to aspire to
|
# ? Apr 8, 2010 23:15 |
|
Staggy posted:I'm making a small pac-man clone in C++, using SFML. Right now the map is grid based, loading all of the background images from a single file and then creating a sprite for each at the start. These are then drawn every frame. The thing is, with a 28 by 31 grid - and nothing else whatsoever - I'm getting about 10 FPS. I've choked my semi-decent graphics card down to 10 fps before on a 3D scene containing 100 verticies. The problem ended up being that I was creating the HLSL effect file within the draw loop and once I moved it to a more appropriate spot the framerate locked right back to 60 fps.
|
# ? Apr 8, 2010 23:19 |
|
Edited out, problem solved.
LightReaper fucked around with this message at 16:04 on Apr 19, 2010 |
# ? Apr 12, 2010 02:53 |
|
I don't think this:code:
HappyHippo fucked around with this message at 04:39 on Apr 12, 2010 |
# ? Apr 12, 2010 04:31 |
|
HappyHippo posted:I don't think this:
|
# ? Apr 12, 2010 05:06 |
|
Is the BB appearing somewhere significant? Like at the origin, for example?
|
# ? Apr 12, 2010 06:12 |
|
You're not even using the center variable in UpdateBoundingBox. You use position instead. Anyway, your problem is probably something to do with transforms. Like, the model vertex coordinates need to be transformed into world coordinates or something.
|
# ? Apr 12, 2010 06:22 |
|
Edited out, problem solved.
LightReaper fucked around with this message at 16:05 on Apr 19, 2010 |
# ? Apr 12, 2010 07:03 |
|
LightReaper posted:Thanks for that, amended it to this which I think is right but it's prob best I run it by you to ensure I don't make another dumb mistake: Actually, yeah, this is still wrong That is, if you're still adding offset to the bounding box like you do in the original code. It should be Vector3 offset = position - centerofObject; Alternatively, you could subtract offset from the box after that. Just think about it in the 1D case: Imagine centerofObject is 5 and position is 3. offset, as you have it, would then be 5 - 3 = 2. Then you do (effectively) centerofObject += 2, which results in 7, whereas it should be 3. quote:As for the model vertex coordinates, the code to create the bounding box isn't my own so I'm not really sure how to transform it into world co-ordinates... I took a stab in the dark with these changes to the renderer, marked the added code: Sorry, I wasn't very clear. What I was referring to was that in some model formats, like fbx, the vertices aren't necessarily stored at their final, true position. They may be at some "default" or other position, but then have a transformation specified for the object. The vertices you get programmatically then, will be those "default" positions. You may need to subsequently extract the transforms from the file and apply them to the vertices to get their true positions. An example might be where you create a sphere in an editor, then scale it to make it bigger. It could be that only the "original" sphere's coordinates are saved in the file as the vertices, but have along with them, a transformation that describes the fact that the sphere is bigger. Screeb fucked around with this message at 09:42 on Apr 12, 2010 |
# ? Apr 12, 2010 09:38 |
|
Edited out, problem solved.
LightReaper fucked around with this message at 16:05 on Apr 19, 2010 |
# ? Apr 12, 2010 18:39 |
|
I'm a beginner to OpenGL, and I'm having a lot of trouble getting images loaded into memory to use as textures. Right now I'm trying to get the following code from the OpenGL SuperBible to work correctly:code:
Could anyone tell me if it's the code that's the problem, or if it looks fine, is there a good program I can use to save specific kinds of TGA? (GIMP won't let you specify header info as far as I can tell) Barring that, does someone know of a good tutorial for loading images into memory that has code they know for a fact works? I've tried using a few other methods I found using Google search (for TGA and for BMP formats) and they're all poorly explained tutorials with incomplete code, or they give code that has no explanation and gives 1001 errors when trying to compile with Visual Studio.
|
# ? Apr 12, 2010 22:51 |
|
Spare yourself a shitload of pain and use FreeImage as your image loader.
|
# ? Apr 12, 2010 23:11 |
|
That looks like it might be a problem with the byte alignment of the struct. A padding byte will be inserted by the compiler after imageType and colorMapBits to keep the struct aligned on 16-bit boundaries. If you're using Visual C++, you could try the following to use 1 byte alignment for the struct:code:
Some more info, in case your curious (you should be): http://en.wikipedia.org/wiki/Data_structure_alignment chglcu fucked around with this message at 03:25 on Apr 13, 2010 |
# ? Apr 13, 2010 03:17 |
|
LightReaper posted:I understand what you mean here but if that is the case, why can I correctly get bounding spheres from these models? Hmm, well the only thing I can think of right now is in http://pastebin.com/pMKn0qGs, you only look at the node's children for the bounding box, and never the node itself. Also, I think the transforms should be applied to each MeshContent child, not just the parent (each has one of its own).
|
# ? Apr 13, 2010 04:25 |
|
Edited out, problem solved.
LightReaper fucked around with this message at 16:05 on Apr 19, 2010 |
# ? Apr 13, 2010 06:04 |
|
The error you get is because the line should be center = boundingBox.Min + (boundingBox.Max - boundingBox.Min) * 0.5f; (note case). BoundingBox is the type, boundingBox is the variable. I've dug up some old code which may be of use: code:
In the Process function of your BoxProcessor: code:
|
# ? Apr 13, 2010 06:27 |
|
I already am using the vertices processor for a similar function, so I modified it to suit these needs like so http://pastebin.com/FpaUC1nY Then getting the relevant info: Dictionary<string, object> tagData = (Dictionary<string, object>)testPlatform.Model.Tag; testPlatform.BoundingBox = (BoundingBox)tagData["BoundingBox"]; But now I'm getting this for my Max and Min values for the boundingbox after inserting a breakpoint after I update said bounding box Max: {X:-3.402823E+38 Y:-3.402823E+38 Z:-3.402823E+38} Min: {X:3.402823E+38 Y:3.402823E+38 Z:3.402823E+38} Which strikes me as being wrong in a whole new way (yes, the bounding box doesn't even render at that size). I assume I've done something wrong in the modification of my verticesprocessor.
|
# ? Apr 13, 2010 07:17 |
|
Ok I tried FreeImage and it seems like it worked pretty well for getting the image, but now I'm having trouble setting it as a texture with OpenGL.code:
|
# ? Apr 13, 2010 08:22 |
|
Stavros posted:Everything works fine until the last line; adding that gives me a memory access violation error. Any ideas what I'm doing wrong? I'm not familiar with the library you're using, but it's probably one of two things: either one of the FreeImage_ functions is returning a null pointer (you aren't checking return values! Bad!) or glTexImage2D is trying to read past the end of the data you're providing it which typically means you're specifying the wrong format.
|
# ? Apr 13, 2010 08:31 |
|
|
# ? May 26, 2024 07:29 |
|
LightReaper posted:I already am using the vertices processor for a similar function, so I modified it to suit these needs like so http://pastebin.com/FpaUC1nY Yeah, you've made a mistake. You've put the vertices into your vertices collection (vertices.Add(vertex);) but then test against vertexList to construct the bounding box. vertexList has nothing in it, cause like I said, you're putting it into vertices instead. Since you're using that vertices collection elsewhere, just replace all references to vertexList with vertices. Like so: code:
Screeb fucked around with this message at 09:46 on Apr 13, 2010 |
# ? Apr 13, 2010 09:39 |