Advertisement

Moving 2D sprites on a 3D Heightmap

Started by March 01, 2000 09:49 AM
3 comments, last by mmrpg 24 years, 9 months ago
Just wondering if anyone has figured this out already. Most likely there is. My first thought was to make a flat quad(rect) primitive in d3d and texture map the current sprite frame onto it. Then take that object and place it on the 3D map. The question I have concerning this would be. How would I know where the ground is ? when each vertice for the four corners of a tile has a height value you could have the upper 2 points of a tile at say value 10 and the lower 2 at 30 ( incline or decline). I would like to be able to move the sprite along the ground path so that it touches the ground at all times. This includes when a "single" tile has a /- shape. ( please excuse the ascii art I know im making this more difficult than needs be so someone please save me ...
I''m wondering too. And Bracket said this would be really easy to do :sarcastic...
But hey mmrpg, perhaps we could make a team, because we''re both programming with the same engine.
Advertisement
Sounds good to me..now we need to get Bracket hehe.

I modified the code to allow for scrolling in any direction smoothly and also to wrap the map so you could go in one direction forever. I wanted to be able to load map chunks at (64,64) at a time and merge them together to make a large scale world on the order of ultima or asherons.

Ill be adding the ability to make a greyscale image in any graphics program and make a mapfile out of it. Basing the pixel location in refrence to the grid number and the color its height value.

Let me know if ya find anything on the positioning thing. If I find something out ill surely post it.


pete@prounix.com
I''m sleep depped right now, so this may not make much sense.... I''ll drop some code examples later if people want. (I''ll need to write them, and a nap first sounds like a really good idea).

You are always going to have some imperfection with a sprite on a heightmap - unless you want to start getting into rotation, the sprite won''t change its angle to actually LOOK like its climbing a hill, for example. Thats one of the big advantages of actual 3D - although its a ridiculous amount of work for small projects. And mmrpg - you are right, plotting a flat quad with a texture is the easiest way to place a sprite. You may want to enable source colour keying, so your sprite can have holes in it.

That said, you can achieve realistic looking movements on tiles. The trick is to focus on what you already know about each tile. You have the heights of each of the 4 vertices. Depending upon how much info you want to store, and how important speed is, you could either:
* Precalculate heights throughout the tile at map-design time. This is the fastest, but requires a lot of extra information for each tile. You probably don''t need to store height for every pixel - depending upon how accurate you want to be.
* Since you have the locations (in 3D space) of each of the vertices that makes up the 2 triangles, you can use one of the commonly published collision detection/clipping algoritms just checking a point on the sprite with the triangle planes. Slower, but should work fine. I can''t remember a good routine for this off the top of my head, but when I''ve had some sleep I''ll see if I can find one to post.

Hope this makes some sense. SLEEP. Weddings do this to a man.
Actually that helps alot, maybe lack of sleep makes ya think better sometimes :o

That is basically what I had planned on doing with the sprites maybe calcualting a few data points between the vertex heighs and running an algorithm to determine the path. Maybe spline path ? not sure but I have a whole book of neat little math things hehe.

Anyway thanks for the help bracket and yes if you have any sample code you could post or email me I would appreciate it.

In the mean time heres alittle code snippet for ya.

Counter=24hrs
do While Counter > 0 hrs
If Alarm.State=vbWake then
if Bracket.State=vbTired then
Alarm.State=vbSnooze
Else
Counter = 0hrs
End if
End if
Counter =Counter - 1hrs
loop

''in other words SLEEP

This topic is closed to new replies.

Advertisement