Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

IGVisualEffectsSubsystem.ProjectedDecal


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
// WARNING: ProjectedDecals should not be placeable; only spawned at runtime by the IGVisualEffectsSubsystem 
// for things like bullet decals, explosion marks, etc. ProjectedDecals just attach to the Target actor, then
// destroy themselves. Because of the changes made via IG_FASTER_PROJECTORS_ON_DYNAMIC_GEOMETRY, they
// will leave behind proper clipped decals on the static meshes they attach to.
//
// WARNING: ProjectedDecals will never work on SkeletalMeshes (at least, never work correctly!).

class ProjectedDecal extends Engine.Projector
	notplaceable;

var() float PreferredDistance "The distance away from the target (in the direction of the normal to the surface) at which the decal will be located. WARNING! This value must be smaller than MaxTraceDistance, or else you will not see the decal.";
var() bool  RandomOrient "If true, the decal will be given a random rotation around the normal to the surface";

var Actor Target;

simulated event PostBeginPlay()
{
	// We purposefully do not call super.PostBeginPlay() because
	// we don't want to attach and change collision settings until
	// we get to Init(). This is because the effects system positions
	// the projector after it is spawned, and if we attach before
	// init is called then the projector will not be in the correct
	// position at the time of attachment
}

simulated function Init()
{
    local Vector RX, RY, RZ;
    local Rotator R;

	// Note: UT2K3 does this is PreBeginPlay, which is probably more efficient. 
	// However, if the projector is destroyed in PreBeginPlay/PostBeginPlay, then the Spawn()
	// call that created it will return None, thus causing the Effects system 
	// to treat it as an error.
    if ( (Level.DecalStayScale == 0.f) || Level.NetMode == NM_DedicatedServer )
    {
		//Log("++++++++++++++++ PostBeginPlay() Destroying newborn ProjectedDecal "$self$" because Level.DecalStayScale="$Level.DecalStayScale$" and Level.NetMode="$Level.NetMode);
        Destroy();
        return;
    }
    
    // adjust initial orientation
    if( RandomOrient )
    {
        R.Yaw = 0;
        R.Pitch = 0;
        R.Roll = Rand(65535);
        GetAxes(R,RX,RY,RZ);
        RX = RX >> Rotation;
        RY = RY >> Rotation;
        RZ = RZ >> Rotation;         
        R = OrthoRotation(RX,RY,RZ);
        SetRotation(R);
    }
		
	// Set preferred distance from hit location
    SetLocation( Location - Vector(Rotation)*PreferredDistance );   

    
    AttachProjector();

	if( bProjectActor )
	{
		// necessary when bHardAttach is true
		SetCollision(True, False, False);
    }

    SetBase(Target);

	// Additional scale factor on the decal stay scale
    if ( Level.bDropDetail )
		LifeSpan *= 0.5;
    
    // Set max lifespan of the decal
    AbandonProjector(LifeSpan*Level.DecalStayScale);
	
	// Destroy the projector actor (the actual decal geometry will stick around 
	// for the LifeSpan that was passed to AbandonProjector)
    Destroy();
}

event Tick(float DeltaTime)
{
	//AddDebugMessage(""$self);
	//log("++++++++++++++++ Tick() called on ProjectedDecal "$self);
	Super.Tick(DeltaTime);
}
event Destroyed()
{
	//log("++++++++++++++++ Destroyed() called on "$self);
	Super.Destroyed();
}

defaultproperties
{
    bNoDelete=false
    bStatic=false

    PreferredDistance=1
	FOV=1
	MaxTraceDistance=2
	bProjectBSP=true
	bProjectTerrain=true
	bProjectStaticMesh=true
	bClipBSP=true
	bClipStaticMesh=true

    MaterialBlendingOp=PB_None
	FrameBufferBlendingOp=PB_AlphaBlend

    RandomOrient=true

    bHardAttach=true

    LifeSpan = 15

	// Projected decals like bullet hits should not attach to skeletal mesh,
	// because it won't look right when the mesh animates and it's also 
	// REALLY slow. 
	bProjectActor=false
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: ne 5.9.2004 16:02:14.000 - Creation time: st 23.5.2018 00:10:46.611 - Created with UnCodeX