This project is read-only.

HeightmapObject - Multiple Instances and Initial Position

Dec 4, 2007 at 8:06 AM
Edited Dec 4, 2007 at 8:50 AM
In messing around with your fantastic engine, I was trying to create multiple heightmaps in order to create a rather large world that was spliced up into segments so different LOD effects could be applied to each map etc. I have created a new collision detection that uses heightmap heightmap collisions and pretty much just returns right away because they are both static objects and who cares if they touch or not. I was wondering if one could change the position of the heightmap? I kept getting this error in the CollisionSystem class:

public DetectFunctor GetCollDetectFunctor(int type0, int type1)
KeyValuePair<int, int> kp = new KeyValuePair<int, int>(type0, type1);
return detectionFunctorskp;
where it wouldnt return right, I would assume because there wasn't a definition for the heightmap on heightmap collisions. I was wondering though, could you make it so that two static objects don't check collisions? If they are both static they would never touch, of if they did nothing would happen anyway right?

Also I was using the HeightmapObject.body.Position variable, which works good for moving the visible mesh, but not so good for moving the collision mesh. Is there a way to do this? Also you guys might want to create your own heightmap on heightmap collision class, or make it so they don't check each other if there is more than one heightmap.

I am a total newb, but I was just playing around and found these things confusing, so please take with a grain, or mine full of salt.


EDIT: I know you guys were working on making collisions based on meshes. I'm not sure if you're familiar with Valve and their Steam engine that powers the Half Life series as well as Portal , Team Fortress 2 among others, they have a display mesh and a collision mesh for nearly every object. It seems to work good for them so continued development seems like a great idea. I actually did find in your code that you do have some lists set in place to ignore objects (noCollide stuff), although accessing them seems slightly tricky, but extremely useful for the creation of custom vehicles that can be defined by basic shapes then bound to a display mesh. Thanks again.
Dec 4, 2007 at 10:12 PM
Edited Dec 4, 2007 at 10:13 PM
Well, collision shouldn't be checked between two heightmap objects because there's no CollDetectHeightmapHeightmap class, and it's not a registered functor, so nothing should happen. But, I don't know why the box - heightmap collision doesn't work when I add two heightmaps, one besides the other... The collision detection works only with the first, but not with the second... Will experiment :)

About the mesh based collision, when we implement it and it's fully working, nothing will stop you to make the collision skin and pass another model. So you could like, use one model for rendering, and one for collision, because you know that when you create the collision skin, you can do whatever you want, but in the samples we just create the collision skin based on the object.
Dec 4, 2007 at 10:46 PM
Yeah collision shouldn't be checked between the two, but it was trying to check it, so I made my own CollDetectHeightmapHeightmap class to get around the error, its crappy though and you guys should make your own or make it not check between the two.

Awesome, thanks for the update. I'm excited for this project. When you guys get it stable enough for a release you should make a Wiki for it, I would add stuff all the time, ha ha. I'm still messing around with those heightmaps and stuff now, its fun though, thanks again,
Dec 6, 2007 at 11:25 AM
yeah, mess around with it. We can't give you serious help with anything because it's all pre alpha and everything is experimental. Iam continuing working on it on saturday.

You can try to modify the nonCollidable property of the collisionSkin to prevent collision detection. I dont really understand why several heightmaps used at once doesn't work - I will have a look at it.

Nice to hear that you have fun with the engine, i hope you will have even more fun when the engine is alpha.

Dec 6, 2007 at 6:06 PM
Yeah I was looking at all your guy's latest release and tons of stuff was like different, I was like OH NO! Ha ha, I guess thats a good thing though. If I stumble upon anything I will be sure to let you know. Looking at the "Heightmap" class it looks like everything should would, but it doesn't, isn't that programming for you? Good luck in the development, I'll be checking back often.
Dec 10, 2007 at 4:24 AM
I think I got an idea of where the problem might start. One problem is that apparently there can only be one "Body" at a time in a physics system. I am trying to create 16 with my many heightmaps that I'm trying to use, so that could be a problem. Translation is also an issue still. So what I was thinking was just writing another Content Pipeline class, or improve the one we have to just make vertex and indice based mesh out of a heightmap then run it through the new collisionmodel pipeline too. Any thoughts? Your the experts, I'm a just a newbie.
Dec 10, 2007 at 11:25 PM
There can be multiple "Body"s of Heightmaps I guess. I turned on the debug drawer and realized that none of the collision boxes are where they should be, just centered around the origin, so they heightmaps just look like they need to be translated in the engine itself not necessarily in the HeightmapObject class or the Heightmap class but the bounding box in the engine. Thats way above my head though so I will leave that to you folks, good luck with that, ha ha.
Dec 13, 2007 at 1:13 PM
haha :) I think that it was not intended by the author of JigLib to move the heightmap. JigLibX is currently in the porting phase. So I will not change any code until this is completed. If you want multiple heightmaps at the moment you have to workarround the 'problem'.

"So what I was thinking was just writing another Content Pipeline class, or improve the one we have to just make vertex and indice based mesh out of a heightmap then run it through the new collisionmodel pipeline too."

Seems to be a good idea and should not be to hard.
Dec 13, 2007 at 2:18 PM
Download the latest source code and use the Array2D.Shift function to move the heightmap. (Use body.MoveTo to move the rendered heightmap)

Dec 13, 2007 at 6:47 PM
You guys rock, I'll give that a shot, thanks.
Dec 20, 2007 at 8:08 AM
That still doesnt work super great. Its like the Heightmap class has all the variables to make it work, it just...doesn't. Like it has offset and dx/dz stuff too for the terrain scaling, but it just doesn't expand the bounding box right for it. Anyways congrats on the near alpha status, stay off the computer for a while (ha ha, I need to take some of my own advice), hang out with the family, and have a merry Christmas, -Seth
Dec 20, 2007 at 3:59 PM
omg... the bug was accidently added to the current source code again. argh. I fixed it again. Download the latest one. Iam sorry! If it doesn't work this time. I will write an sample code for you.
Dec 21, 2007 at 6:28 PM
Alright, I still can't get it to work, I think I'm retarded ha ha. Here's what I have:
After passing in a Vector3 called "position" in the constructor of the HeightmapObject class I have:

field.Shift((int)position.X, (int)position.Z);
collision.AddPrimitive(new Heightmap(field, position.X, position.Z, 1, 1), (int)MaterialTable.MaterialID.BouncyNormal, new MaterialProperties(0.0f, 1f, 1f));
body.MoveTo(position, Matrix.Identity);

Am I putting those in the right place? I tried this in your example game your including in the engine and it seems to work, but in my game thing its just going to hell, lol. So it might be my error somewhere else.

Oh and another thing that is quite histerical, if you drive the car off the edge of the heightmap it starts flingging around all funny. I was laughing so hard. Just a heads up, not sure if you tested that lately. After much frustration with my code I stomped on the gas i your game and shot of the map then proceeded to jerk around like a mad man. I laughed and that eased my frustration. I would assume that's not the goal though, lol. Good luck, thanks again.
Dec 21, 2007 at 6:33 PM
Yet another thing, I'm not sure if that field.Shift thing is necessary, it seems to work the same with or without it. Food for thought....
Dec 22, 2007 at 11:37 AM
I added a second heightmap to the sample. Just download the latest source.

>>Oh and another thing that is quite histerical, if you drive the car off the edge of the heightmap it starts flingging around all funny.
Its more or less correct behavior. The heightmap class "asks" the Array2D class for heights which are outside the arrays bounds. And the array class doesn't throw a error - it just modified the values to be in the array and returns strange heights. This doesn't happen any longer because i modiefied the bounding box of each heightmap, so if the car goes off there will be no more collision checks and the array2d class is not asked any longer for values which arent in its bounds.
Dec 22, 2007 at 11:24 PM
Thats cool, just kind of loops it then. I like the way you have it now though, leaves it up to the user of the engine to make it continuous or not. thanks for throwing that example in it now, I'll play with it a bit, thanks again. -Seth