Show Posts
|
|
Pages: [1] 2
|
|
1
|
Developer / Technical / Re: Rotations and quaternions in OGL 3.3
|
on: April 07, 2013, 01:01:26 PM
|
I meant to say, originally, that THIS is what I'm doing: float modelMatrix[16];
BuildIdentityMatrix(modelMatrix); modelMatrix[0] = spriteWidth; modelMatrix[5] = spriteHeight; modelMatrix[12] = xCoordinate; modelMatrix[13] = yCoordinate;
/* Z AXIS ROTATION
| cos(A) -sin(A) 0 0 | M = | sin(A) cos(A) 0 0 | | 0 0 1 0 | | 0 0 0 1 | */
//creates a quaternion like the one shown above MatrixRotationZ(rotMatrix,90);
//multiplcation stored in rotWall matrix MatrixMultiply(rotWall, rotMatrix, modelMatrix);
//final multiplication MatrixMultiply(finalTransform, rotWall, vpMatrix); The only difference with the code I wrote before is that instead of multiplying the rotation matrix by wallMatrix, it is being multiplied by modelMatrix. My bad. I tried the method you posted, but I got literally the exact same thing I've been getting before. I'm looking into it more because I am obviously screwing up bigtime somewhere...
|
|
|
|
|
2
|
Developer / Technical / Rotations and quaternions in OGL 3.3
|
on: April 07, 2013, 10:54:12 AM
|
Hey all, I have been struggling with this for days, and I can't seem to figure out why it won't work. I am using quaternions to do all of the rendering in my 2D game. Currently, the way I'm doing this is by setting up a camera (getting a view matrix) and an orthographic matrix (projection matrix) to obtain the view-projection matrix: Camera->Render(); Camera->GetViewMatrix(viewMatrix); Enable2D(); GetOrthoMatrix(projectionMatrix); MatrixMultiply(vpMatrix, viewMatrix, projectionMatrix); I then create my model matrix and multiply it with the vpMatrix: float modelMatrix[16];
BuildIdentityMatrix(modelMatrix);
modelMatrix[0] = spriteWidth; modelMatrix[5] = spriteHeight; modelMatrix[12] = xCoordinate; modelMatrix[13] = yCoordinate;
MatrixMultiply(finalTransform, modelMatrix, vpMatrix); //send this and UV coords to shader I've been using this code for a while now, and it seems to be working fantastically. I use it to render all of my textures, after calculating correct UV coordinates and sending this information to my shader. The thing I am having problems with is rotation. I have tried doing this: float modelMatrix[16];
BuildIdentityMatrix(modelMatrix); modelMatrix[0] = spriteWidth; modelMatrix[5] = spriteHeight; modelMatrix[12] = xCoordinate; modelMatrix[13] = yCoordinate;
/* Z AXIS ROTATION
| cos(A) -sin(A) 0 0 | M = | sin(A) cos(A) 0 0 | | 0 0 1 0 | | 0 0 0 1 | */
//creates a quaternion like the one shown above MatrixRotationZ(rotMatrix,90);
//multiplcation stored in rotWall matrix MatrixMultiply(rotWall, rotMatrix, wallMatrix);
//final multiplication MatrixMultiply(finalTransform, rotWall, vpMatrix); This code DOES rotate the sprite in question, but it rotates the sprite from its upper left corner... not from the middle of the sprite. I have tried everything to rotate about the middle of my sprite so it doesn't translate, and I can't figure it out! I have been scouring the internet for help. Every example/tutorial I've seen says the following: Translate so that the middle of your quad is at the origin. Then, rotate. Finally, translate back.I get it! I know that I have to do this. But I can't figure out how  . Everything online is written with versions of OGL below 3.3, meaning they have the luxury of using the matrix stack. Am I just being dumb? Am I missing something small or large?... I just don't know! Thanks everyone for any advice/help with this! It is GREATLY appreciated.
|
|
|
|
|
3
|
Developer / Technical / Re: Enemy crowding
|
on: April 02, 2013, 01:54:42 PM
|
|
Thanks for the help/advice everyone!
The main problem is, this is my capstone project, so I'm trying to finish this while holding a small job and doing other schoolwork, and the capstone project must be done in 3 weeks. I was trying to get a simple/quick solution that still looks/feels good.
Right now I am just trying to implement the combat/collision between the player character's sword and the enemies (arguably the most important part of the game). So I just turned off CD between the enemies, allowing them to overlap for the moment. The question is whether or not I want to take the time (or I have the time) to implement velocity/force physics...
The flocking stuff, including the libraries and links above, look super awesome, and if I have enough time I would like to try using them. But given that the project must be 99% done and be damn close to error-free by 3 weeks time, I may not get to it... we still have other outstanding issues.
Thanks again for all the help!
|
|
|
|
|
4
|
Developer / Technical / Re: Enemy crowding
|
on: April 02, 2013, 10:29:50 AM
|
|
I already have something akin to a spring system working. But it doesn't work very well.
I understand how to find the amount of intersection between the 2 boxes I am using to bound my enemies. But I don't understand where/how to move each one.
If two enemies collide, should they each be moved an equal amount in the corresponding directions so they don't intersect anymore? What if one of the enemies is standing still?
I would like to implement flocking behavior for enemies akin to the examples shown in Paul's link, though I don't think I would have time...
|
|
|
|
|
5
|
Developer / Technical / Enemy crowding
|
on: April 02, 2013, 07:04:09 AM
|
|
Hi all!
I'm working on a game akin to LOTZ:LTTP, in C++ and OpenGL. I have some basic collision detection that works great for walls and enemies. The collision REACTION is my problem.
I've noticed that in many games, enemies are allowed to overlap on the screen; there are no collisions between them. I want to allow collision resolution between enemies. I would like them to able to approach the player all at the same time without overlapping; I want to see enemies crowd around the player character.
Right now I don't have a "physics" system in place; all of the movement is done by directly altering player/enemy position information, rather than editing velocity, acceleration, or force. I want to keep everything as simple as possible, so I would like to stick to only editing positional information if I can.
So, my two questions:
Is it possible to have enemy crowding without setting up a more complicated physics scheme? What kind of simple system would lend itself well to enemy crowding behavior?
Thanks for all help/opinions/advice!
|
|
|
|
|
6
|
Developer / Workshop / Help with side view
|
on: February 17, 2013, 10:42:49 PM
|
Hey all! First time posting in the art section, looking for a bit of feedback on stuff I'm making for a school project. I'm really stuck and I was looking for a helpful comment or two. As a side note, I want to dive into the fundamentals and work from the ground up (human anatomy, etc.) but at the moment I'm just trying to get this cranked out for a due date at the end of April. So I'm just trying to draw a blue knight character. I've been using the characters from TLOZ A Link to the Past as a reference in terms of style and sizing. I think I've finally gotten the front and back animations to a point where I am OK with them (I know they look like beginner art, but they are totally good enough for my purposes):  But for the life of me, I can't seem to get the side view right at all:  I've been trying for a few days, and I can't seem to get it to look right. I am trying to get a kind of side/overhead view, but it always looks more like a straight-on side view. It just looks weird. Any tips on getting this to look a bit better. as well as approaching the side view? Thanks everyone!
|
|
|
|
|
7
|
Developer / Technical / Re: Blending and 2D Sprites in OGL 3.3
|
on: February 01, 2013, 08:48:57 AM
|
Is it writing depth and then doing a depth test? You can disable that with glDisable( GL_DEPTH_TEST ).
Wow, I feel stupid that I didn't check that earlier. That fixed everything. Thanks for the help ham and brie!
|
|
|
|
|
8
|
Developer / Technical / Blending and 2D Sprites in OGL 3.3
|
on: February 01, 2013, 12:34:45 AM
|
Hey all, I am trying to draw 2D sprites with transparency in a game I'm working on in OpenGL 3.3. My images are targa files with an alpha channel. I have enabled blending and I am using: glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); as my blend function. Everything is looking great, except for one issue: the transparent part of the image (the box surrounding a sprite) will blend with the background, but it will not blend with another sprite if it is drawn in the same location. It makes sense for the sprites themselves to block each other out when they are overlapping, but the transparent part of the image will just become the same color as the background and won't show any images under it. I am not exactly sure why this is happening. Is this something I need to take care of in my shaders? Or is it the blending function? I can't imagine it is the latter (I already tried some different combinations for that, none of which worked). I am certain the edges are transparent so I'm not sure what is going on. Thanks for any/all help and insight!
|
|
|
|
|
9
|
Developer / Technical / 2D quad size in OpenGL
|
on: January 06, 2013, 09:32:23 AM
|
|
Hi all,
I'm making a 2D game in OpenGL 3.3 with some friends as a capstone project. I am finally, able to map a texture onto a quad and render it to the screen.
Going forward I have 2 things that are bugging me:
I know that ultimately I will have one file containing the vertex buffer objects that I need to access my sprites. Originally I was going to arrange the objects based on character; one VBO would correspond to the protagonist's spritesheet, another VBO would contain Enemy #1's spritesheet... but after seeing the way others do it, I'm not so sure how to organize everything. Would having a spritesheet for each character mean too many vertex buffers? I guess I could pack multiple characters into a single VBO, and I guess it depends on the number of sprites.
I am more concerned with the second issue; what size should I make my quad/triangle strip that I render my sprite to? For example, say my protagonist is in a frame of animation with dimensions 20x20. My VBO would then be set up so that my quad is 20x20. But then, on the next frame, the sprite is 22x23. Now the sprite is larger than the size of the VBO. I wouldn't want to use glBufferSubData to edit the vertices every time the frame changes to be a different size! That would be crazy. One of my friends suggested that in my spritesheet, I should make each sprite for the protagonist the size of his biggest frame. Then the quad for that character would always be the same size. But I feel like there is an easier solution... I feel like I can still keep a spritesheet or texture atlas with a bunch of unevenly sized sprites and still be able to access them without having to change the vertices of the VBO all the time. Is this possible?
Thanks for any/all help. I've posted on TIGsource a few times now and there is always an awesome community willing to help.
-Ethan_Hall
|
|
|
|
|
10
|
Developer / Technical / Re: Pixel Shader Examples
|
on: November 07, 2012, 09:39:25 PM
|
|
Thanks everyone for all of your help! This is exactly the kind of information I was looking for.
I wrote a bit in anger when I called him uppity, but he did brush my opinion aside rather quickly which really pissed me off. I mean... I've been playing games for 15 years, I think I have OK intuition of what looks like epic-shader-magic and what is just pixel art. That being said, I didn't fully understand everything, so I wanted to ask to make sure I wasn't crazy. That normal map for Spelunky is just what I was looking for.
|
|
|
|
|
11
|
Developer / Technical / Pixel Shader Examples
|
on: November 07, 2012, 11:59:30 AM
|
|
Hi all!
I'm working on a game as a college capstone project, and I went in to ask one of the professors in my department about shaders since he does a lot of maya/OpenGL stuff. I am working on a 2D game so I asked if he knew anything about shaders in 2D. I showed him examples of Braid, Spelunky, Limbo, etc. that use shaders to create some really cool 2D lighting effects.
The professor immediately became pretentious and uppity, told me I didn't understand what shaders were, and declared that all of the examples that I showed him were instances of using pre-rendered images that were just made transparent (such as the explosions or glimmering gems in Spelunky).
Now I KNOW Braid, Spelunky, etc. use shaders to do SOMETHING. My guess was the torches in Spelunky and the fire in Braid employ shaders, but I am not experienced enough to know exactly what they're doing.
Could anyone give me a solid example of how the games I listed above employ shaders to create cool effects? Not code examples, just a technical example such that when I point at the game and say "That must have been shaders", I don't sound like an idiot.
Thanks for any help/comments!
|
|
|
|
|
12
|
Developer / Art / spritesheet question
|
on: May 31, 2012, 09:20:01 PM
|
|
Hey all,
Hopefully this question isn't too noob. I'm a programmer, not an artist, so I'm not versed in this stuff.
I made a game a while back using XNA and I'm making one now using Allegron 5. When I made my spritesheets for my game (in MS Paint... see, not an artist) the animation frames had to be lined up perfectly on the spritesheet so that when I switched frames in game, everything would look smooth. Is there a way you could have a spritesheet with frames/images that are relatively in line, but aren't spaced in a pixel perfect way? That would save a bit of manual work on my part.
Not sure if I am making any sense here, but hopefully someone knows what I'm getting at.
Thanks everyone!
|
|
|
|
|
13
|
Developer / Technical / Re: XNA slowdown... garbage collector?
|
on: May 26, 2012, 04:33:24 PM
|
Yeah J-Snake, my bad  my previous method wasn't fixed interp timestep at all... I forgot what I did, haven't looked at the code in a while. I had this: this.IsFixedTimeStep = false; graphics.SynchronizeWithVerticalRetrace = false;
//then later after all updates are finished...
FPSSCALE = (float)gameTime.ElapsedGameTime.TotalSeconds;
so I used TotalSeconds because it represented the number of seconds to pass during that frame, aka the FPS. I used the FPSSCALE for physics calculations throughout my game: ACCELERATION.X = FORCE.X / MASS; ACCELERATION.Y = FORCE.Y / MASS;
VELOCITY += ACCELERATION * Game1.FPSSCALE; COORDINATES += VELOCITY * Game1.FPSSCALE;
so... maybe that screwed it up? But it still doesn't make sense, because the problem behaves in almost the exact same way in both games. I'm about to do a bit of profiling, haven't done it this weekend yet. I'll look into the fixed timestep with interpolation too... EDIT: so after using long gcmem = GC.GetTotalMemory(false)/1024; to get an initial understanding of the memory usage of each project, my large project ran at around 11,000 and 12,000, and the lower numbers were moving hella fast. GC occurred every once in a while. I ran this bit of code on my smaller project, which barely moved from about 610 or so. When I ran the profiler with this bit of code in it, I noticed the slowdown occurred after about 30 seconds... but the GC memory number didn't budge. During the entire lifetime of the application it only went up, and only every 5 or 6 seconds. Totally stumped on the slowdown... I'll try the fixed/interp timestep soon.
|
|
|
|
|
14
|
Developer / Technical / Re: XNA slowdown... garbage collector?
|
on: May 26, 2012, 05:49:41 AM
|
Hope this helps.
Thanks Jase, I'll take a look at those this weekend. I really don't know what is going on... it doesn't make sense that my relatively big application and my small application are hitting the same slowdown. Let me make a reasonable guess. You simply run your game in fixed timestep-mode.
You have to implement your own fixed timestep with interpolation. Whether you use xna or C++ +DX doesn't make any difference here. The problem you have to solve remains the same.
I don't think this is the problem. In my large game I implemented a fixed timestep with interpolation, and in my small game I just ran in fixed mode. The problem occurred in exactly the same way in both cases.
|
|
|
|
|
15
|
Developer / Technical / Re: XNA slowdown... garbage collector?
|
on: May 23, 2012, 05:04:06 PM
|
|
I'm having a hard time understanding the CLR profiler. I've never used it before, so I'm still trying to figure it out.
Apparently the function that was allocating the most was:
Microsoft.Framework.Graphics.SpriteBatch..ctor(class Microsoft.Xna.Framework.Graphics.GraphicsDevice)
at 48.17%.
For CPU usage, the game started at 0%, jumped to 40% after the first two seconds, went back down to 5%, then hovered in the 5-8 range for the first minute. Then the usage spiked to 30% and hovered there for the last 20 seconds of runtime.
When I was running the application I didn't do anything differently than I normally would. Just moved the thumbstick around to move an image on the screen. And then the slowdown burst in after a minute.
Also, the type with the most allocated memory was VertexPositionColorTexture[] at 27.9%.
Any ideas on how to fix this slowdown? I could upload the code if that would help. I think this is a bit beyond my level of expertise... I'm going to read more about using the CLR profiler in the meantime.
Thanks for all of your help so far!
|
|
|
|
|