HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Maths Problem! (3d flavoured)

03-04-2004, 03:32 PM#1
Remy
I have been working on an fpv (first person view) for some time now. And I have now figured out a way to determine the height of a variable point on the map. But I still need determine the angle of attack of the camera. When the unit is walking up a mountain the camera should face a bit upward. The camera currently only moves along up with the unit while remeaning to point exactly forward (into the mountain) instead of pointing along with the angle of the mountain (what a normal human would do). This looks pretty messy ingame. o_O

My guess was to compare the height of a point in front of the unit with a point behind the unit. This would give me the angle between those points, which is exactly what I need. ^_^
But which points should I use? And how do I determine them?!
I need a formulae which represents the direction where the unit is facing through a line, this way I can easily pick a point in front and behind the unit.
Now the standard formulae for a strait line is Y-B = (X-A) multiplied by a constant. Now the constant determines the angle of the line and B and A determine the location of the line on a grid.

From the game I can only retrieve the X and Y of a unit and the angle it is facing. Inserting X and Y into the basic straight line formulae is no problem, they are inserted where A and B stand. But converting the facing angle to a constant is proving more difficult. I thought I could do this by using tangens.
So I would get this formulae:
Y = (X-(X of unit)) multiplied by tangens(facing of unit) + (Y of unit)

But this formulae isn't any good :(, cause what would happen if the unit facing becomes 0 or 180? tangens 0 and 180 outputs 0. This means that X is multiplied by 0 and that the valua of X has no meaning, while this should not be the case :\. When the unit facing is 0 or 180 we should get a vertical line, in which the valua of Y has no meaning.

Well.. I guess my story seems rather difficult to understand, I have really tried to explain it properly but this is just very hard :(. I hope someone out there understands and is able to help me with this. Thanks, Remy.
03-04-2004, 04:49 PM#2
Captain Griffen
well...you could get the points just infront and behind the unit using a polar offset (sorry if this does not help, i did not understand very well).

PS: How did you work out the height???
03-04-2004, 05:06 PM#3
Remy
Quote:
Originally Posted by Captain Griffen
well...you could get the points just infront and behind the unit using a polar offset (sorry if this does not help, i did not understand very well).

PS: How did you work out the height???

Hmm yes, I could just get them by using a polar offset. But the problem is I do not want 'just' 2 points. I want the 2points that are on the line that defines the units facing and on a grid line.
Like this:


Zoom (requires log in)


Getting these two points is 'a bit' more difficult. ;)

Now for the height thing:
I am using a height map. I suppose you know what this is? It's a string array that contains the height valuas of all the tiles in the map. Using these heights and a nice formulae I can determine the height of any point on the map. Just check out my map to see it working ^_^. If you want a bit of a deeper explanation go to my fpv thread. I've got an explanation there. You could also check out my map, it's not protected.

Thanks for spreading the thougts ;), byebye, Remy.
03-04-2004, 08:42 PM#4
LegolasArcher
Semi offtopic, I just reformatted, so I need that program that extracts the height map again, could you link me to it?
03-05-2004, 03:37 PM#5
Remy
Quote:
Originally Posted by LegolasArcher
Semi offtopic, I just reformatted, so I need that program that extracts the height map again, could you link me to it?

Sorry I don't know where to get it, I'll give it to next time when you come online, exactly when you will give me the 10x better turning system ;)

Remy out.
03-05-2004, 03:42 PM#6
Remy
Quote:
Originally Posted by Esoteric Potentate
Polar offsets would work.

Just get the polar coordinate facing the unit's facing angle, offset by 32.

The second, back point, can be found doing the same thing, except using the unit's facing angle plus 180 degrees.

Take these two points, and get the height angle using your height map.

Now as I already explained, polar offsets will not work. Why are you offsetting by 32? this would only work if the unit is exactly in the middle of the tile and when he is facing 0,90,180 or 270 degrees.
Polar offsets do not help me. They do not provide the points that cross with a grid line and the line that represents the facing of the unit.

Please, Remy.
03-06-2004, 03:50 AM#7
LegolasArcher
I've been messing around with this so long, I hardly remember what ive done, but here is the map. Turning works, andI have some AoA judging 'stuff' in there, but It needs a nice coating of polish. I think I did it somehow by finding the length between the position of the unit in the tile and the point where it would cross a line nearby. I'm not sure anymore, for its late, if it works with the units facing. I think it does. Maybe this could help somehow.