For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Testing a level surface for room for a decal

The section related to UnrealScript and modding. This board is for coders to discuss and exchange experiences or ask questions.
Post Reply
User avatar
gopostal
OldUnreal Member
Posts: 1005
Joined: Thu Jul 31, 2008 9:29 pm

Testing a level surface for room for a decal

Post by gopostal »

Is this possible? Meaning if I want to apply a random scorch to a wall is there a way to pre-test it to see if there is enough flat wall space to handle the decal?
I don't want to give the end away
but we're all going to die one day
User avatar
Bleeder91[NL]
OldUnreal Member
Posts: 1062
Joined: Sun Oct 04, 2009 7:22 pm

Re: Testing a level surface for room for a decal

Post by Bleeder91[NL] »

Projectors perhaps. Or do you mean through code?
Last edited by Bleeder91[NL] on Mon Oct 15, 2018 9:42 am, edited 1 time in total.
Image
User avatar
gopostal
OldUnreal Member
Posts: 1005
Joined: Thu Jul 31, 2008 9:29 pm

Re: Testing a level surface for room for a decal

Post by gopostal »

I'm spawning a set of persistent decal graffiti across the level at map start. It uses random playerstarts and random direction to find a spot on the wall close by. In practice it works nicely about 60% of the time. On the rest the graffiti is over a corner, 2 sprays will end up overlapping, or the texture is applied in a spot that's just not flat and large enough.

Ferali mentioned that a trace done in four directions (U,D,L,R) from the point of application which are then traced down to find if they all share the same HitNormal would weed out a good chunk of the problem areas. I have done normal tracing but this math is seriously confusing to me, not to mention there is just not a lot of good tutorials on how to work out the proper tracing math on a more complex issue like this.

If anyone can spare the time to explain I'd be a very attentive audience. I run a private teamspeak if you'd rather just talk it out, whatever is easiest on you and your time. I'd like to get this bulletproof because the graffiti is all from active and retired Unreal people and groups and I admire them all. They deserve it to be perfect.
I don't want to give the end away
but we're all going to die one day
User avatar
yrex .
OldUnreal Member
Posts: 275
Joined: Wed May 06, 2015 6:46 am
Contact:

Re: Testing a level surface for room for a decal

Post by yrex . »

Code: Select all

GetAxes( rotator(surfNormal), unused, Y, Z );
Now Y and Z are parallel to the surface...
My work | contact: ampoyrex at wp dot pl
User avatar
gopostal
OldUnreal Member
Posts: 1005
Joined: Thu Jul 31, 2008 9:29 pm

Re: Testing a level surface for room for a decal

Post by gopostal »

Just a follow-up in case anyone else wants to use the code. I worked this out as a series of traces and it functions very well. The source code for the checks will be included in the battle royale game mode but here is the function that is used:

Code: Select all

//Contains a series of traces to find if the area is clear, flat, and continuous. If it passes
//all the checks then it spawns the graffiti there. The checks are hard coded to 128X128 but you 
//can easily change the default and have it check for other size decals.
function SpawnGraffiti()
{
   local int PointCount;
   local NavigationPoint NP;
   local rotator newRot;
      local vector HitLocation, HitNormal, FireDir, X, Y, Z, Origin, StartTrace, EndTrace;
   local actor HitActor, Other;
   local int i, j, N, M, SpriteX, SpriteY;
   local float yOffset, zOffset;
   local cpanel Spawnedcpanel;
   local GraffitiLight b, q;
   local bool AreaClear;
   local bool FireAway;

   NavPoint = int(RandRange(0,NumNodes));
   FireAway = False;
   for (NP = Level.NavigationPointList; NP != None; NP = NP.NextNavigationPoint)
   {
      if (NP.IsA('PathNode'))
      {
         if (PointCount == NavPoint)
         {
                        newRot.Yaw = Rand(65535); //360 degrees around
                        newRot.Pitch = Rand(1820); //from 0 to roughly 10 degrees upward angle
                        newRot.Roll = 0;
                        FireDir = vector(newRot);
                        HitActor = Trace(HitLocation, HitNormal, location + FireDir * 1500, Location, false);
                        if(( HitActor == Level) && ( HitNormal.Z < 0.03 ) && ( HitNormal.Z > -0.03 ))
                        {
                            GetAxes( rotator(-HitNormal), X, Y, Z);
                           Origin = HitLocation + HitNormal;
                              //Pass 1
                              StartTrace = Origin;
                              EndTrace =  Origin + Y * 64 + Z * 64;
                              Other = Trace(HitLocation, HitNormal, EndTrace, StartTrace, true);
                              if (Other != none)
                                 return;
                              else
                              {
                                 StartTrace = Origin + Y * 64 + Z * 64;
                                 EndTrace = StartTrace + X * 3;
                                 Other = Trace(HitLocation, HitNormal, EndTrace, StartTrace, true);
                                    if (Other != none)
                                    {
                     //Pass 2
                     StartTrace = Origin;
                                          EndTrace =  Origin + Y * -64 + Z * 64;
                                          Other = Trace(HitLocation, HitNormal, EndTrace, StartTrace, true);
                                          if (Other != none)
                                             return;
                                          else
                                          {
                                             StartTrace = Origin + Y * -64 + Z * 64;
                                             EndTrace = StartTrace + X * 3;
                                             Other = Trace(HitLocation, HitNormal, EndTrace, StartTrace, true);
                                                if (Other != none)
                                                {
                                                      //Pass 3
                                                      StartTrace = Origin;
                                                      EndTrace =  Origin + Y * 64 + Z * -64;
                                                      Other = Trace(HitLocation, HitNormal, EndTrace, StartTrace, true);
                                                      if (Other != none)
                                                         return;
                                                      else
                                                      {
                                                         StartTrace = Origin + Y * 64 + Z * -64;
                                                         EndTrace = StartTrace + X * 3;
                                                         Other = Trace(HitLocation, HitNormal, EndTrace, StartTrace, true);
                                                            if (Other != none)
                                                            {
                                                                  //Pass4
                                                                  StartTrace = Origin;
                                                                  EndTrace =  Origin + Y * -64 + Z * -64;
                                                                  Other = Trace(HitLocation, HitNormal, EndTrace, StartTrace, true);
                                                                  if (Other != none)
                                                                     return;
                                                                  else
                                                                  {
                                                                     StartTrace = Origin + Y * -64 + Z * -64;
                                                                     EndTrace = StartTrace + X * 3;
                                                                     Other = Trace(HitLocation, HitNormal, EndTrace, StartTrace, true);
                                                                        if (Other != none)
                                                                              FireAway = True;
                                                         }
                                                   }  else return;
                                             }
                                       } else return;
                                 }
                           } else return;
                     }
               } else return;
                    } PointCount++;
      }
   }
   if(FireAway)
   {
      AreaClear = True;
      //Check the local area for existing sprays, skip if there are any
          foreach RadiusActors(class 'GraffitiLight', q, 256, Origin)
             if( Q != none)
                AreaClear = False;
            if(AreaClear)
            {
                  b = Spawn(class'GraffitiLight',self,,Origin + HitNormal*32);
              b.remoterole=ROLE_simulatedproxy;
                        
                  Spawnedcpanel = Spawn(class'cpanel',,, Origin,  rotator(HitNormal));
      }
   }
}
cpanel is simply panel subclassed to use random textures. GraffitiLight is a small light used to illuminate the panel very lightly and it also allows an easy check for existing graffiti so there's no overlap.

Thank you guys for your help!
Last edited by gopostal on Fri Nov 30, 2018 2:11 pm, edited 1 time in total.
I don't want to give the end away
but we're all going to die one day
Post Reply

Return to “UScript Board”