May 22, 2012, 05:07:17 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Please report any bugs or issues that you might be encountering with the Beta in the Support System so that we can better keep track of any oustanding issues that may come up.

GameCore Support System
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Decals  (Read 2176 times)
Ransom
Full Member
***
Posts: 132



View Profile
« on: September 10, 2008, 01:50:03 AM »

Hey, I'm the first to post in this forum  Huh

I posted this in the support/feature requests forum, but I figured I'd open it up for public discussion as well.

Quote
I've tried to simulate decals using the current fx system, but my efforts have been less than adequate. The problem is getting the image to lay flat on the surface it was applied to. If you make the fx a "billboard", than it rotates with the camera and looks odd. And if you don't make it a billboard than there is no way (that I know of) to set the angle of the image to match that of the surface it is being applied to.

I can see numerous benefits to this... bullet holes in geometry, stains or other unique decoration to spice up tiled textures, just to name a couple.

Also, there should be a way to force an fx to stick to an object via script, rather than setting it up through the OPR.
Logged
Ron
Sr. Member
****
Posts: 326


View Profile
« Reply #1 on: September 10, 2008, 02:49:58 AM »

Update: to see the marks on the demo, you have to be rolling, the press the spacebar and forward key at the same time

I had the same trouble with the fx route.

Not sure if this will help or not, but I use the following code for burnout / skid marks in the DynamicsAdvance. It just takes the wheel position and puts a tiny plane with a skidmark texture on the pavement right under it. All of the texture is made transparent except for the tire tread itself.

With bullet holes, I think you could use the raycasting to determine position?
Code:
Vector Pos = object.GetPosition();
float Rot = object.GetRotation().x;
Vector Pos2 = object.GetMesh("Back_Wheel_Right").GetPosition();

Object@ BurnoutObjectR = GetGameManager().GetWorld().AddObject( "BurnoutObjectR", "../Burnout/Burnout.opr");
BurnoutObjectR.SetPosition(Pos.x-Pos2.x-Pos2.z*tan(Rot),0.05,Pos.z-Pos2.z-Pos2.x*tan(Rot));

Object@ BurnoutObjectL = GetGameManager().GetWorld().AddObject( "BurnoutObjectL", "../Burnout/Burnout.opr");
BurnoutObjectL.SetPosition(Pos.x+Pos2.x-Pos2.z*tan(Rot),0.05,Pos.z-Pos2.z-Pos2.x*tan(Rot));

« Last Edit: September 10, 2008, 02:54:00 AM by Ron » Logged
Ransom
Full Member
***
Posts: 132



View Profile
« Reply #2 on: September 10, 2008, 02:54:37 AM »

Cool.

Yeah, setting the position isn't the problem, its the rotation thats the issue.  I'll try using a simply object and report back my results.
Logged
Ransom
Full Member
***
Posts: 132



View Profile
« Reply #3 on: September 10, 2008, 11:28:07 AM »

Okay, thats better but still not quite right.  What I did was cast a ray and set the position at the intersect point of the ray and the object it hit.  I then set the rotation to the same as the camera.

What really needs to be done is to access the rotation of the specific face of geometry that's being hit.  Surely GC can already do this (at least internally) for lighting values and what not, but I don't think this info is exposed to us users via scripting...?  Maybe Gekido could get look at this?
Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #4 on: September 10, 2008, 12:49:47 PM »

I'm asking for the very same exact piece of information to get wall walking working. Again, it'll need to read the surface angle of whatever you're connected to. Decals is another thing we need it for. As I see things, all FX that are currently in the game are world-YAxis-UP.
Logged
Ransom
Full Member
***
Posts: 132



View Profile
« Reply #5 on: September 10, 2008, 01:06:57 PM »

Yep.  You can set the rotation when you make the fx in the fx editor, but you after that you're stuck with it. 
Logged
gekido
Guest
« Reply #6 on: September 16, 2008, 02:18:27 AM »

will discuss with john tomorrow and see what we can come up with.
Logged
gekido
Guest
« Reply #7 on: January 28, 2009, 09:04:52 PM »

I've been working on an updated version of the default library scripts - particularly the character & weapons.  The next version will support decals as a part of the 'HitFX' effect that the weapons fire.

Next step is to do a per-material lookup of what you are shooting to place appropriate decals, but the basic framework is there.

For the scripting types, it's pretty simple.  I've also added a small AreaForce to the location that the shot occurs so that you can have physics-based objects react to being shot etc.

This is a snippet from the weapon_handheld.gsl script (around line 515):

Code:
Object@ hitObject = GetGameManager().GetWorld().RayCast( muzzlePos, shotDirection, distance, intersect, normal, false);
if (wasVisible) object.Show();
if (hitObject != null)
{
// special fx for bullet hit
String str = hitObject.GetControllerSettingString( "HitFX");
if (str.IsEmpty())
str = defaultHitFX;

if (!str.IsEmpty())
{
// do hit effect and bullet hole
PushFullPath( hitObject.GetFullPath());
//DebugPrint("HitObject path: " + hitObject.GetFullPath(), true);
// spawn the effect
FXObject fxObject = GetFXManager().CreateFXAtPosition( str, intersect);
// update it's matrix based on what we hit
Matrix fx;
fx.ZAxis = -normal;
// check and see if we are shooting the ground or a wall
if (normal.y > 0.7)
fx.YAxis.Set(1,0,0);
else
fx.YAxis.Set(0,1,0);
fx.Orthogonalize(2, 1);
// adjust it's position so we don't have z-fighting
fx.T = intersect + (normal * 0.01);
// and update the effect
fxObject.SetMatrix( fx);
PopPath();
}

// tell the object it was hit
if (damage > 0)
{
hitObject.SetControllerVariable( "HitNormal", normal);
hitObject.SetControllerVariable( "HitPosition", intersect);
hitObject.SetControllerVariable( "HitDamage", damage);
}

// add a small force so physics objects look like they were shot
            GetGameManager().GetWorld().AddAreaForce( intersect, 2, 1500);

Logged
gekido
Guest
« Reply #8 on: January 28, 2009, 09:13:24 PM »

as a quick followup - in the 2.1 update, there is now an FXObject script class that you can use to manipulate your fx - including setting the matrix (ie rotation etc), so doing decals is pretty easy now.
Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #9 on: January 28, 2009, 10:38:03 PM »

Just setting the angle of a flat texture plane cannot work for decals. They need to be "projected" onto the surface so that they take on the contour. Also, what about against animated objects? In the end, if the decal image isn't overlayed onto the objects at the texture level, it's never going to be a decal. Is there a way to read the point of contact on the texture coordinates and add a new material layer with an appropriate UV offset? I'm pretty certain the other games are doing it that way.
Logged
gekido
Guest
« Reply #10 on: February 10, 2009, 10:12:04 PM »

yes the system I've mentioned doesn't work for animated / moving objects, but it does perfectly fine for 99% of the environments that i've been testing it in.
Logged
steenosterby
Newbie
*
Posts: 26


View Profile
« Reply #11 on: August 10, 2009, 06:12:21 AM »

Hello GameCore

Regarding:

as a quick followup - in the 2.1 update, there is now an FXObject script class that you can use to manipulate your fx - including setting the matrix (ie rotation etc), so doing decals is pretty easy now.

Do you have an example for this.

Regards Steen Osterby
Logged
Pages: [1]
  Print  
 
Jump to:  

 
Powered by MySQL Powered by PHP bluBlur Skin © 2006, hbSkins
Powered by SMF 1.1.14 | SMF © 2006-2011, Simple Machines LLC
Valid XHTML 1.0! Valid CSS!