CoiN

Member

170

122 Neutral

• Rank
Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

1. Ball on terrain physics woes

Thanks for the replies Nypyren, you have helped quite a bit. I've realised that one of the main problems with my code is that I am just grabbing the Y value from the terrain at the location of the X and Z of the ball. So the steeper the wall, the higher the ball will go. I'm researching the ProjectOnto function at the moment so I can try to understand exactly what it does. I am having a bit of difficulty grasping the ideas behind it at the moment. Thanks again...
2. Ball on terrain physics woes

Hi, I tried posting a similar question over in Game Programming last week, but had no luck with responses. I thought I'd have better luck here as it is a more appropriate forum. I've deleted the old thread, so I hope this isn't considered cross posting. Anyway, onto the question... I've been attempting to get a ball to roll over terrain, and react appropriately i.e. Slow down when going up hills, speed up when going down, changing direction according to slope, etc. The best I have come up with is this: Ball.Direction.x = Ball.Direction.x PLUS (Normal.x * GRAVITYCONSTANT * SLOPESCALAR); Ball.Direction.z = Ball.Direction.z PLUS (Normal.z * GRAVITYCONSTANT * SLOPESCALAR); * SLOPESCALAR is a number between 0 and 1 which represents the slope from 0 to 90 degrees. * GRAVITYCONSTANT is just some number I made up (0.2f as it seems to work best). * Ball.Direction is a normalised vector representing the current direction of the ball. * Normal is the normal vector (normalised) of the polygon below the ball. I update my ball position like: Position = Position PLUS (Direction * Velocity); * Velocity is just a float. It does kind of 'work' but it doesn't work well, the ball will roll up and down slopes in a fashion but when it is at rest it won't roll down a hill of its own accord. I can't seem to figure out exactly where Velocity comes into play with all this, and how the Direction vector should change in relation to Velocity, Gradient AND Slope direction. If anyone can give me any advice at all it would be extremely appreciated, my head is hurting. I hope that all made sense. :) Thanks...

Hi, Are you sure NumVertices has a value? I have rewritten your code slightly below and it works fine in place of my terrain loader, it should fill your height map as it does mine. bool GObject::ReadRAWfile(const char *RAWName) { vector<BYTE> in; ifstream inFile(RAWName, ios::binary); // File invalid if( inFile == 0) return false; // Read until EOF while(!inFile.eof()) { m_heightmap.push_back(inFile.get()); } // Close file inFile.close(); return true; } Hope that helped.
4. Simple ball physics over terrain

Hi, I wanted to get a ball to roll over terrain realistically, i.e. Roll up a hill and roll back down when gravity takes over, etc. I have it working with an idea I had, and I just wanted to know if it is generally how it is done before I go and actually start writing some proper code. :) Current Method: * Pre-Calculate the poly normals on the terrain. * Get the normal vector of the poly underneath the ball. * Add the (x, z) values of the normal (multiplied by some constant I made up) to the balls direction vector. This seems to work well, but I was wondering if there is a more common/efficient method I could use for when I actually write a demo/game using this. Any articles on this subject would be awesome. I have searched for some tutorials on this but I haven't been able to turn up much on the specific subject. It might help if I knew the technical names for this type of stuff. :) Thanks, any help is much appreciated.

I've tried another exporter and it seems to have improved things a fair bit. Thanks again for the help, it steered me in the right direction.

Thanks for the replies. I've looked at the model in the DxViewer and the normals all appear to be fine and D3DRS_NORMALIZENORMALS is set to true aswell. I have tried loading some of the model samples from the SDK and they don't actually appear to have this issue, so I guess it must be something to do with how I'm exporting my models from Blender. I'll keep looking and also try another exporter. Thanks

Hi, I'm fairly new to D3D and 3D in general, so bear with me here. :) I've noticed that when rendering things in my programs that jagged edges can be seen on the model where the shading starts. I just put this down all my models being low poly but it happens on the higher poly models aswell. I am using the D3DSHADE_GOURAUD render state. The screenshot below should show the problem. I've adjusted the lighting so it shows up pretty clearly. Example I'm guessing it is the way I have my lighting set up, but I can't seem to solve it. Any help would be much appreciated. Let me know if I need to paste any code or whatever. Thanks
8. Win32 Controls Question

That works fine now using that. Thanks, very much appreciated.
9. Win32 Controls Question

Hi, I'm making a fairly simple game using GDI and I've got a small problem which I can't seem to figure out (I'm not really that experienced with Win32). I'm drawing all my graphics at the moment through my own function (called from inside the message loop) and I've set up a pretty simple backbuffer/flipping system. The thing is I'd like to be able to use windows controls on the screen at the same time, but when I create a button it gets written over by the Clear() and Flip(). Is there anyway to stop this? A way I can redraw the buttons when I want too (i.e. After I have flipped the other graphics to the window)? I know this question probably seems pretty stupid but I have looked around and can't seem to find anything. Thanks, Jon Lowe
10. graphics hate me [still NOT fixed!]

Hi, I'm not exactly sure how Allegro works but I think it could be a problem with your main game loop having no delay. I can see the timer being initialised but I can't see anything in your main loop using the timer. You could try throwing a Sleep(<num of milliseconds>); in the main loop just to test if it is that. Hope that helped.
×

Important Information

GameDev.net 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!