Decals on DTS objects?
by Jack Stone · in Torque Game Engine · 10/26/2005 (5:21 pm) · 4 replies
I implemented a basic decal to my game yesterday, where id just makes a black mark when I shoot a wall or the terrain. That looks very good, and im happy with it. (Except its not lit, so it looks out-of-place in shadows or places with low light)
However I dont know how to get Decals to appear on DTS objects, and I need this feature for my game. I need it mostly for players, having a blood or a guts decal remaining after they've been shot, but I also need it for general things in my environment.
This seems to be a pretty standard requirment for a 3d game, so Im sure theres a resource or something, but I couldnt find anything. Got a lot of stuff on decals generally, but nothing on painting them onto DTS objects.
I gathered its possible, since I read about using decals to portray damage, but they didnt actually say HOW you would do that.
Any links, or ideas? I searched already, but couldnt find anything on DTS object decals.
Thanks in advance,
JS
EDIT:
One of the bullet hole resources said to remove this line from projectile.cc: if (hitObject->getType() & (InteriorObjectType|TerrainObjectType))
in order to get decals showing up on a player. This code works, but the decal appears at the bounding box of the player, meaning its floating in the air, and when the player dies the decal stays floating in mid air till it fades out. Anyway I can get this to create the decal when it hits the detail mesh or maybe the collision shape without too much c++?
However I dont know how to get Decals to appear on DTS objects, and I need this feature for my game. I need it mostly for players, having a blood or a guts decal remaining after they've been shot, but I also need it for general things in my environment.
This seems to be a pretty standard requirment for a 3d game, so Im sure theres a resource or something, but I couldnt find anything. Got a lot of stuff on decals generally, but nothing on painting them onto DTS objects.
I gathered its possible, since I read about using decals to portray damage, but they didnt actually say HOW you would do that.
Any links, or ideas? I searched already, but couldnt find anything on DTS object decals.
Thanks in advance,
JS
EDIT:
One of the bullet hole resources said to remove this line from projectile.cc: if (hitObject->getType() & (InteriorObjectType|TerrainObjectType))
in order to get decals showing up on a player. This code works, but the decal appears at the bounding box of the player, meaning its floating in the air, and when the player dies the decal stays floating in mid air till it fades out. Anyway I can get this to create the decal when it hits the detail mesh or maybe the collision shape without too much c++?
#2
I don't just need to be able to put a decal on the visible surface of the object, I need to be able to read the surface to get material information.
12/11/2006 (10:01 am)
I am totally cool with that when it comes to the player itself. However, I would really like to be able to apply the bullet holes to a DTS object for objects like cars and rigidshape objects. However since it always collides against the bounding box or collision, and doesn't actually hit the visible mesh, you are right it looks bad. As for the particles idea, already there, I have a nice blood spray system already in place. Hell I even have working armor piercing rounds that can detect surface types and emit particles and sound based upon that. DTS objects are the one big fly in the ointment for my system though. I don't just need to be able to put a decal on the visible surface of the object, I need to be able to read the surface to get material information.
#3
I shoot a projectile. When it collides with an objects bounding box, we have a hit. We take the projectile's orientation (position, rotation, vectors), and create a ray cast out of that. The ray cast is performed on the the texture of the DTS object, thus getting UV coordinates back. Using the UV coordinates as a position, we can draw a decal texture over the object's texture. Probably will have to make use of the DynamicTexture class, right?
This is the general idea, how about some feedback before getting into the code of it?
12/11/2006 (10:40 am)
I'm toying with an idea here, so try to stay with me:I shoot a projectile. When it collides with an objects bounding box, we have a hit. We take the projectile's orientation (position, rotation, vectors), and create a ray cast out of that. The ray cast is performed on the the texture of the DTS object, thus getting UV coordinates back. Using the UV coordinates as a position, we can draw a decal texture over the object's texture. Probably will have to make use of the DynamicTexture class, right?
This is the general idea, how about some feedback before getting into the code of it?
#4
With some work you could simply extend the ray cast once it hit the collision hull and align it to the actual underlying tris, or if you were really ambitious project the decal onto underlying tris ;p
As far as I know TGE does not use vertex buffers etc so the tri data should be in system memory anyway.
12/11/2006 (10:47 am)
Well that would add the decal to all instances that use that texture as the texture is shared. If you copied the texture each time and applied it for instances with decals you would eventually run out of texture memory.With some work you could simply extend the ray cast once it hit the collision hull and align it to the actual underlying tris, or if you were really ambitious project the decal onto underlying tris ;p
As far as I know TGE does not use vertex buffers etc so the tri data should be in system memory anyway.
Torque Owner Ronald J Nelson
Code Hammer Games