Game Development Community

fxDecal

by Joshua "The Power Nap" Taylor · in Torque Game Engine · 03/12/2003 (2:47 pm) · 34 replies

I've been working with the decal code this past week, adding in new features that I feel are nessesary for my game.

This mainly focuses on decal smearing. Blood running down walls via Hitman 2.

Blood pooling up under players.

I decided to make a "new" decal class, instead of modifying the old one. I did this because the old one in a lot of ways does it's job just fine. I didn't want to add in a bunch of useless data members for the 30,000 bullet holes that will be strewn around the level.

That, and a designer could add a "gore" control, to tone down the blood content without reducing the other details.

So far I have three different types:

Drip - drip stretches the decal down by its lowest points along the surface it's on. The magnitued of the stretch is determined by how vertical the decal is.

Pool - pool spreads the decal out by its corners.

Slide - slide moves the decal down along a surface. I did this one so people could "double up" decals, mainly if "drip" provided undesirable effects to the texture.

I've added the variables "smearVelocity" and "smearAcceleration" to the datablock. The acceleration is to provide a non-linear look to the effect.

What needs to be done is some sort of binding to the surface that the decal is on, so it doesn't fan out past its edge. I don't know if any functionality like that is in the Torque allready.

Oh, and yeah, the name of this thing is a nod to Melv May.

-Josh
Page «Previous 1 2
#1
03/12/2003 (3:16 pm)
Sounds good cant wait to try it out
#2
03/12/2003 (11:53 pm)
Maybe I should do fx(tm)?

Just kidding, good luck Joshua. :)

- Melv.
#3
03/13/2003 (11:34 am)
Hey,

If anyone would like to donate some splat .png's for this I would be MOST gratefull. I want to have some Tolerable art when I release this as a resource.

Otherwise you'll be stuck with my art talents, and I don't want that to have an impact on this.

-Josh
#4
03/13/2003 (4:44 pm)
Okay,

Now how should I package this resouce.

Should I give instruction on how to use it via projectiles?

I know it's main use is players, but I don't know in what ways people will want to use this.

A few suggestions would be welcome.

-Josh
#5
03/13/2003 (5:28 pm)
Thanx for the art, I'll give credit in the resource.

-Josh
#6
03/13/2003 (7:02 pm)
I have a few questions about use.

Could this be used to create something like an oilslick?

Is there a way to detect if the decal is present at a particular location? If this was possible it could be useful for all number of things.

eg. Player steps in pool of blood and tracks red footprints down hall

Is this a possibility with your fx?
#7
03/13/2003 (7:55 pm)
You know,

It's something I haven't considered, but I don't think it's impossible. We'd just have to create a zone that's created when a blood patch is on the ground. We'd then have to add some code to the player to tell it when to track blood.

I'd have to look into creating a "zone" serverside for collision checking with players. If anyone could help, I'd be more than happy to add this functionality.

-Josh
#8
03/13/2003 (8:05 pm)
It could be as easy as adding a trigger above the pool of blood?
as long as there is some way to detect that the player just encountered the object.
#9
03/13/2003 (9:17 pm)
Some sort of "box" could do it.

I'd just need to know where to start.

-Josh
#10
03/13/2003 (9:22 pm)
I think you either do one of two things.

1) Create a function that will test for the occurance of your "puddle" at a particular point
or
2) Create a trigger.

For the trigger, I am not sure how you can do it in the engine but you could simply output the xyz position and the size to a script function from where people can do with it what they like.
(ie dynamically make a trigger in script)
#11
03/13/2003 (9:25 pm)
Could I see an example of that?
#12
03/13/2003 (9:33 pm)
No! I am the example Nazi!
NO EXAMPLE FOR YOU!

(Sorry, soup nazi episode was on last night ;)

I am at work at the moment so I dont have any code handy.
Some good examples of how to run a script function from the engine can be found in shapebase.cc. If you do a search for "oncollission" or "onadd" you will see some examples of how to pass values out to a function.

For the actual script I have never made a trigger dynamically but there should be no reason why it wouldnt work like any other object.

I will do an example when I get home and have some code to look at :)
#13
03/14/2003 (12:47 pm)
Something like this should work for adding a trigger in game dynamically.

datablock TriggerData(BloodTrigger)
{
   // The period is value is used to control how often the console
   // onTriggerTick callback is called while there are any objects
   // in the trigger.  The default value is 100 MS.
   tickPeriodMS = 100;
};

function BloodTrigger::onEnterTrigger(%this,%trigger,%obj)
{
     //do whatever you like here
     Parent::onEnterTrigger(%this,%trigger,%obj);
}



   %this.bloodTrigger = new Trigger() {
      dataBlock = BloodTrigger;
   };
   MissionCleanup.add( %this.bloodTrigger );

Hope that helps :)
#14
03/14/2003 (4:28 pm)
How do you set up the dimensions of the trigger?

I'd be nice to make it the size of the puddle, and have the same lifespan.

As far as having it called from the C++ code, I have it covered. I just know squat about triggers at this point.

-Josh

-==BIG FAT EDIT==-

My bad, I guess I should read the resources on triggers! That would help MUCHO!

I'm kinda tired from moving dressers all day, since I can't get a job with my computer science degree. So don't be too hard on me.
#15
03/14/2003 (5:17 pm)
Hey Josh....
Sounds great can't wait to see it!!!!


MJ....
#16
03/14/2003 (5:34 pm)
You should be able to make it similiar to this....

%client.trigger= new Trigger(MyNewTrigger) {
	  dataBlock = BloodTrigger;
          position = "425.6 1258.2 205.2";
          rotation = "1 0 0 0";
          scale = "40 50 1";
          polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000
          0.0000000 0.0000000 0.0000000 0.0000000 1.0000000
          0.0000000 1.0000000 0.0000000";
	};
	MissionCleanup.add( %client.camera );

I havnt tried this but it should work
Obviously...just set your scale to the size and the position and rotation to suit
#17
03/14/2003 (6:00 pm)
Yeah,

I just went through Trigger.h/.cc. So now I understand.

Thanx for all the help!

I'll try to knock it out sunday.

-Josh
#18
03/16/2003 (4:56 pm)
fxDecal resource is now uploaded,

I'll get the "tracking the blood around that you've just walked through" tutorial up monday or tuesday.

-Josh
#19
03/16/2003 (5:00 pm)
I will definetly grab it when it become available.

I am actually going to try and apply it to wheeledvehicles as an oilslick. Should be interesting to see how it works :)
#20
03/16/2003 (6:23 pm)
Looking forward to getting it! I have some ideas of my own I'd like to try out. I'll let you know how it goes.

Thanks!

MJ....
Page «Previous 1 2