Advertisement Jump to content
  • Advertisement

The Rug

  • Content Count

  • Joined

  • Last visited

Community Reputation

628 Good

About The Rug

  • Rank
    Advanced Member
  1. Thanks guys, it was a carriage return '\r' that needed removing. I'm not sure why this makes the comparison equal to one though. Anyhow, my solution (incase anyone else has this problem) was simply to remove any carriage returns from the string. This code did the trick: collidableType.erase (std::remove (collidableType.begin(), collidableType.end(), '\r'), collidableType.end());
  2. Hi Gamedev, I'm currently writing a little multi-platform game using C++ and I've encountered a problem with parsing the text file that contains the level data. std::string collidableType; std::getline( input, collidableType ); // Input is a istream object // Print the sresult of the string::compare operation std::cout << "Collidable type: '" << collidableType << "'" << std::endl; std::cout << "Compare collidableType to 'poly': " << "poly" ) << std::endl; The line read from the file contains the word "poly." Console output: Collidable type: 'poly' Compare collidableType to 'poly': 1 Under windows, the value is 0, as expected. But compiled for my iPhone it's 1. If I initialise collidableType to "poly" rather than reading it from the istream, the result is 0 and it works. So I'm assuming it's to do with how the string is read from getline but I can't figure out what. Can anyone offer me some advice?
  3. I'm having real problems with this one, the information available on Google is really confusing and incomplete. Basically what I want is a bunch of controls grouped together under a panels, with several of these panels. I want to be able to switch between these panels easily. Currently, I create a "static" window, with WndProc's HWND as the parent. I then add some buttons, with this "static" window as their parent. This means when I send the "static" window a hide message, all of its children (the buttons) are hidden. This is great. Except the buttons I added don't do anything, so they're useless. Surely any messages would be passed from the button to the its parent the "static" window, then from the static window to its parent the HWND object, ending up at WndProc as a WM_COMMAND message? I'm really stuck with this and I feel crap for asking what is probably a quite routine question for you guys. Thanks for any help you can give.
  4. In my game I'm going to have levels stored (at least initially) in ASCII files, and read them in using an input stream in order to easily extract the tokens as floats, ints, etc. For instance, I open an input stream and pass it to the level loader. Is it possible to manually append stuff to this stream, or even put stuff into the stream without opening a file (perhaps for testing purposes) ? The level loader would then read from whatever is in the stream, regardless of where it came from. Basically what I'm I think what I'm trying to do is similar to piping. One way I thought of was to use a string stream in the file loader. The source of this string stream could then be easily interchanged between strings hard-coded into my source, or by reading a file (using a file input stream) into one large string. Are there any immediate problems with this approach? Thanks to anyone who can help!
  5. The Rug

    Spring Damping

    Hi I'm having some trouble understanding spring damping, in particular, this document. Can anyone help explain where the second part of that equation comes from? I (think) understand the first part (before the + sign,) is Hooke's law, Fs=-kx (where k is spring constant and x is displacement.) With just this, the spring seems to work OK. The problem is the second part. I tried just implementing Fd = -cv for damping, then adding to Fs to get the total force, but everything went totally haywire. I took v to mean the velocity of the spring's current expansion, which is calculated using the velocities of the particles attached to the ends of the spring. So I rewrote the code as per the second part of that equation and now it works, but why? Why didn't the damping force work as calculated before? I really don't like simply taking code for granted... Clearly I am a physics noob and have done something very wrong, so be kind :)
  6. Alrighty, all I want to do is to draw a textured scene with the pixels drawn using a shader. I have both approaches- the usual D3D fixed function way, and a pixel shader that is as follows: sampler2D diffuseSampler = sampler_state { Texture = <diffuseTexture>; } void PsColor( float4 texCoord : TEXCOORD0, out float4 oColor : COLOR0 ) { oColor = tex2D( diffuseSampler, texCoord ); } technique ColorShader { pass p0 { PixelShader = compile ps_3_0 PsColor(); } } Its from memory so it might not be totally right. The upshot is, its just one texture sample per pixel. Unfortunately when I do this, my framerate drops from 320 to 280, which isn't a showstopper but its still got me a bit worried. I'm pretty sure the difference is not a timing error either. The worst part is, its not even got any lighting calculations in yet. Its just texture sampling. Is this performance hit normal? How can the FFP do texturing with lighting faster than the shader can do texturing without lighting? I'm setting the texture by iterating through the subsets in my mesh (LPD3DXMESH) and using effect->settexture with the appropriate parameters. I apologise for just dumping code and asking for answers, but I'm really stuck here and maybe there's some little thing I've missed. Thanks!
  7. Cheers, that's a bit of a pain but not too bad. Now my problem is the resolution of my depth texture. Only things really close to the camera are producing enough contrast to be visible. Am I correct in understanding that this is because depth is not stored in a linear fashion? Is there anything I can do about this? I've tried Googling but I'm not really sure what I'm after. Can you guys point me in the right direction?
  8. Edit: This was previously called Replacing depth stencil surface with a texture, then using that texture but I changed the subject :) I'm writing a program where I need to store the depth of each pixel. At the moment I'm using a pixel shader to write the z value of each pixel into a render target. I was wondering if it's possible to simply replace the depth stencil surface with a texture, and use that? My current method strikes me as wasteful, as the z value is being written to both the depth stencil surface by D3D and my render target by the pixel shader. Am I barking up the wrong tree here? Unfortunately I'm stuck in the past with DirectX 9. Thanks a lot peeps :) [Edited by - The Rug on May 20, 2009 11:05:00 AM]
  9. Thanks guys :) Ezbez: That's odd, I've seen that kind of behavior once before when I tested it using a netbook. I was unable to repeat it though, all subsequent visits it ran fine. Not sure what's wrong really. Has anyone else tried it?
  10. Hi everyone Just released my latest game: Its not particularly sophisticated, there's only two enemy types but I cant really be bothered to improve it any further, you guys probably know the feeling >_< Thanks for looking :) PS. video here if you'd rather just watch.
  11. Hello Is there a way to render a scene with shadow maps without using shaders? I have my scene being rendered to a depth texture (texture created with D3DUSAGE_DEPTHSTENCIL), but I'm unsure how to actually do the comparison between the z-value of the pixel being written and the z-value in the depth texture. I mean I know the theory, but not the d3d commands, and the only stuff I can find uses shaders. I remember doing this in OpenGL a few years back, using texture combiners IIRC- is there an equivalent in D3D? I will be using shaders at some point but since this is for an assignment, I really want to show as many approaches as possible. Thanks a lot :)
  12. I don't think that would work, since its not only the normal but also the distance that needs to be taken into account. The object would still end up partially inside the wall(s). Thanks for the suggestion though :) I will test it when I get home just incase. Has this problem not come up for anyone else? Or have I chosen a design which is flawed from the outset?
  13. Thanks++, I think I located the problem. As far as I can tell it was because I was not rounding properly when drawing. Now I have a new problem. When my object collides with two surfaces that are not perpendicular (ie. goes into a corner) the object jitters about wildly. I drew this diagram to help explain: Basically, the object moves down and right, thus overlapping 2 surfaces. As the collision response moves the object out of one surface (along that surface normal, picture in red) it gets pushed futher into the other surface. It is then moved out of this surface, but its final position is not at rest in the corner. The next frame, this repeats, so the object never seems to stop jumping around. You can probably picture what happens. Is this a common problem? Or am I uniquely bad at figuring these things out? ;)
  14. Hi I currently have a collision system written in Java whereby if 2 shapes are found to intersect, they are moved apart along shortest distance possible. For example, box A moves towards box B at 0.1 unit per frame. When they collide they will overlap by 0.1 units, so box A should be moved back by 0.1 units. Except my program is telling them to move apart by a value which is only approximately 0.1, and moves it back too far, leaving a small gap. This causes the objects to seemingly vibrate against each other. This seems to be because of a floating point inaccuracy when calculating the distance. Hopefully that explanation was good enough. Can anyone shed any light on what I might have done wrong here? thanks everyone
  15. Hello peeps :) This is a real noob question, but basically I have a sprite represented by a 2D AABB, and some terrain represented by a 2D poly. I want the sprite to run around on the terrain. In my head, this seemed easy, but then I realised I have only ever dealt with tile based levels which were made up of AABBs. Can anyone help me out? The best I can think of is using seperating axis theorem, testing the box against each line in the polygon. Then, if one is found, moving the box outward along the line's normal by the distance the box had crossed that line. The problems with this method are: - Wont my sprite slide down any sloped surface, due to gravity? - I have no idea how to handle the endpoints of the line I'm really stuck here. Is there any standard way to do this? I have a tendency to overthink things and maybe this is one of those times... Thanks!
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!