collisions with terrain
Hi, I would like to implement collisions with terrain in my game.
but the problem is that terrain has mountains too!!
so I would like to know if you have any guide or any tip to help me making my objects stop at mountains (or climb).
I'm using Direct3D 9.0 with C# .NET
thank you.
.Raw file terrain?
start by writing a method which takes as input a position on the map (float/int/double X,Y) and returns the height of the ground at that point.
start by writing a method which takes as input a position on the map (float/int/double X,Y) and returns the height of the ground at that point.
Quote:Original post by TheUmpteenth
.Raw file terrain?
start by writing a method which takes as input a position on the map (float/int/double X,Y) and returns the height of the ground at that point.
well, I'm actually a beginner with this stuff... I didn't know anything about .raw terrain files
O.o well I'm gonna see what I can find on the net.
It took me a while to figure this one out too... I had to dig out some wonky algebra book that I remembered taking in school way back when. As it turns out, it was some very tricky(for me) parametric math that calculated to see if a vector intersected a triangle. Which it worked great... alas it's the getting the determinant of a 4x4(3x3?) matrix that was a hoot.
As stated above, have a point in triangle algorithm and that should get you atarted on the getHeightAtLocation() method for bumping around. There should be plenty abouts. Just think about liking at your terrain straight downwards and then you may be able to calculate it more easily with pile of 2d math on it.
I dunno... I just remember that solving this problem made me feel that my whole acedemic stay in school with respect to math was well worth it. I had one of them eureka moments y'know.
As stated above, have a point in triangle algorithm and that should get you atarted on the getHeightAtLocation() method for bumping around. There should be plenty abouts. Just think about liking at your terrain straight downwards and then you may be able to calculate it more easily with pile of 2d math on it.
I dunno... I just remember that solving this problem made me feel that my whole acedemic stay in school with respect to math was well worth it. I had one of them eureka moments y'know.
There's a pretty good terrain creation tutorial with C# does a bruteforce method and a heightmapped method.
http://www.riemers.net/eng/Tutorials/DirectX/Csharp/Series1/tut7.php
Here's a link from M$ Coding4Fun blog on terrain following.
http://blogs.msdn.com/coding4fun/archive/2006/11/09/1044454.aspx
DirectX 9.0c a shader approach or whatever it's called has a good section on this, I imagine the one before it would too if you don't like shaders. Andre' LaMothe's book Tricks of the 3D Game Programming Gurus also has a good section on terrain following suitable for bipedal characters.
http://www.riemers.net/eng/Tutorials/DirectX/Csharp/Series1/tut7.php
Here's a link from M$ Coding4Fun blog on terrain following.
http://blogs.msdn.com/coding4fun/archive/2006/11/09/1044454.aspx
DirectX 9.0c a shader approach or whatever it's called has a good section on this, I imagine the one before it would too if you don't like shaders. Andre' LaMothe's book Tricks of the 3D Game Programming Gurus also has a good section on terrain following suitable for bipedal characters.
Well, I did it. Now i learnt how to use raw maps and I made a really basic function to calculate height, basing on a char array in which the raw map is loaded. But the problem is that height only changes when the camera coordinates are the same of a vertex, if camera is on a line which links two vertices or in any other point on the map, height is not calculated :/
So if you know any method to calculate height in a 3d space and you want to post it, I'll be thankful to you.
So if you know any method to calculate height in a 3d space and you want to post it, I'll be thankful to you.
of course I did, even if I must read better the second tutorial.
maybe the answer to my question is buried in that second tutorial..
but..why this question? O.o
maybe the answer to my question is buried in that second tutorial..
but..why this question? O.o
look up "ray/line intersecting a triangle", "equation of a plane" and "dot product". The line/ray (object up/down vector) is exactly vertical. Once you have your plane equation plug in your x and y position and out should come z.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement