Conforming to a mesh

Blitz3D Forums/Blitz3D Programming/Conforming to a mesh

Liberator(Posted 2005) [#1]
Hi!

I've been trying to figure this one out for a looonng time, but I can't seem to figure out how its done.

What I'm lookin to do is have a sprite/plane conform to a 3d mesh, but conform exactly to its faces.

Some examples of some real-life uses of this are bullet holes...for example, let's say you shot the edge of a crate, now assuming the game engine uses a textured sprite or flat plane as the bullet hole, the bullet hole will go off the edge of the crate because it was shot right at the edge. Now in real games, they somehow cut off the bullet hole, so it only shows up on the crate and not in the air! How is this done???

Another example is in almost any 3d RTS game, when you select a unit and a selection ring appears under the unit indicating they are selected. If you then move that unit over a bumpy area of the mesh the selection ring will conform perfectly to the ground mesh - no matter where on the mesh it is! Its like the sprite/plane gains and destroys verticies as its moving over the mesh so it may correctly layer itself on top of the ground....

Last example is when you throw a grenade in an FPS near a corner, where the bottom of a wall meets the floor, the scortch mark that appears when the grenade has detonated will be half on the floor and half on the wall! How did this get layered correctly? How did they figure it out?

Can anyone please explain how this is done and how its done in blitz? This one has been stumping me for a long time and its about time i put an end to this mystery...


Ross C(Posted 2005) [#2]
Look at the align to vector command. You can use the normals of the collision or pick, or get the normals yourself, and slot them into the align to vector command :o)


Liberator(Posted 2005) [#3]
Right, now woulden't this just rotate a model to align it to the vector? A vector is just a direction in 3d space represented by 3 values, what im talking about is having a mesh conform to another mesh, much the way a scorch mark appears and layers itself on the ground in a game...


Zethrax(Posted 2005) [#4]
I think what you're after is commonly referred to as a 'towel mesh', also known as a 'decal'.

I think you basically need to turn your decal image into polygons which conform to the shape, size, position, and direction of the polygons that the decal image will apear on, but positioned slightly away from the original polygons, along their normal direction, to prevent z-fighting.

Try searching http://www.gamedev.net/ , http://www.gamasutra.com/ and similar sites for more information.

-


Liberator(Posted 2005) [#5]
Decals, yes that's what I'm looking for! Thanks, I'll check out those sites...however if in the mean time anyone has done this already in blitz theres no use in re-inventing the wheel so please post if you have seen this effect duplicated in blitz :)


ozak(Posted 2005) [#6]
Actually the castle example that comes with Blitz3D have decals (burnmarks when shooting in this case)


BlitzSupport(Posted 2005) [#7]
There are a few examples in the Code Archives that sound like they'd be relevant:

FLEX - proper shadows, lights and shaped shadows
move object shadow along terrains
Sticky Shadow