Game Development Community

DayOfWar Interior Portal Render Test

by Bill Vee · 01/27/2008 (2:04 pm) · 14 comments

This is kind of a justification to my earlier pain killer induced blog/rant about portals.

What I needed was to have interiors with large open doors with most of the interior to be in or under the terrain for hanger type structure. The problem as many know is the terrain will render inside of the interior if viewed from outside the interior looking in and ruin the effect. After searching the site for an answer I finally settled on this.
This video is a small test I created to show it off.

Now that fixes the appearance but objects will still collide with the terrain.
Not a problem.
Consider the following code
datablock TriggerData(TerrainMaskTrigger)
{
   // 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; // 1 Sec
};

function TerrainMaskTrigger::onEnterTrigger(%this,%trigger,%obj)
{
   Parent::onEnterTrigger(%this,%trigger,%obj);
   error("%con1.className= "@%obj.getClassName());
   if(%obj.getClassName() $= "Player" | %obj.getClassName() $= "FlyingVehicle")
   {
   %obj.setMaskNoTerrain();
   }
   }

function TerrainMaskTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
   Parent::onEnterTrigger(%this,%trigger,%obj);
   if(%obj.getClassName() $= "Player" | %obj.getClassName() $= "FlyingVehicle")
   {
   %obj.setMaskNormal();
   }
}

This is the script for a trigger that basically changes the collisionmask to remove the legacy and atlas terrains from the mask.
Arrange the trigger around the terrian inside the interior and as the player steps into the trigger it "turns" off terrain collision and when it leaves it "turns" it back on.

The setMaskNoTerrain and setMaskNormal function are ConsoleMethods added to the the player and FlyingVehicle classes that handle the turning off and on of the terrain collision.

Some more work is needed but you get the idea.

If the community finds this useful I could post a resource for it.

#1
01/27/2008 (2:35 pm)
man that smaller passage had me thinking "how will players fit in there". Until the player was atthe other end and then i was like "ohh so that big pipe is actualy bloody huge". Nice job with the interiors!
#2
01/27/2008 (3:58 pm)
I think a resource would be great!
#3
01/27/2008 (4:34 pm)
Wow, neat solution!
#4
01/27/2008 (6:47 pm)
Now that is some nice looking code fixing. I second the request for a code resource for this. dont know why but I believe some very awarkward design problems just got 90% wipe out. Dif type caves that fit a bit more snugly then they do now. The dungeon pack places dts rocks around the entrance. But with this you dont need the extra hide the horrible gap stuff to make a nice entrance.
#5
01/27/2008 (7:43 pm)
Bill:

I'm with Andrew on this... looks sharp and yes it should be released to help us better understand the engine. Looking forward to more of your tips... keep it up.

Will
dlstorminc@yahoo.com
Waskom, Tx
#6
01/28/2008 (8:03 am)
I would love this as a resource, one of the biggest "problems" with using atlas is that you can't cut holes in the terrain like you can with legacy, this would really really help! Thanks.
#7
01/28/2008 (11:20 am)
You've got my vote for resource.
#8
01/29/2008 (7:32 am)
I will clean the code up a little and post a resource as soon as I can.
I needed one more feature added so I am currently coding it to take a "stencil" texture to be used for irregular shaped openings.

Just so everyone knows this is a TGEA solution.
If I could figure out how to do a render-to-texture in TGE I would post a resource for that.
#9
01/29/2008 (9:39 pm)
I got a question ... Does projectiles still collide with the terrain if fired from within/outside the trigger/portal?
#10
01/30/2008 (5:22 am)
@Mikael Yes they do but I just about have that solved by making projectiles trigger "aware".
It kinda works now but high speed projectiles are hitting the the terrain before the trigger event.
The solution will have to be another resource. I am experimenting with ray casting before firing the projectiles to see if terrain collision can be turned off there.
#11
01/30/2008 (10:32 pm)
ok.
Well .. i dropped you a mail last night about helping out with a website for you ... i will await your reply.
#12
01/31/2008 (4:59 am)
Ok just about done with the resource. I got projectiles playing nice with triggers now.

Didn't realize until last night that it is 3 separate resources.

1. Terrain occluding portal.
2. Trigger aware projectiles.
3. Script changeable collision masks.

I think I will post it as one resource for now since the desired effect is to be able to look into an interior from the outside and not see the terrain as well as shoot into it and the projectile not hit the terrain and for player/vehicles to go into it and not collide with the terrain.

I still have a little coding left on the portal to do. Just to clean it up a little, it is based off the waterblock code and I need to remove a lot of stuff not related to the portal.
I should be able to post it by this weekend.

@Mikael I sent you a reply.
#13
02/08/2008 (11:07 pm)
Sorry for the delay.
I just finished my demo for the instantaction contest and its 1:00AM now.
I need some sleep. I will try and finish the resource as soon as I can.
#14
02/10/2008 (2:21 pm)
Ok the resource is done.

It hasn't been approved yet but the link is here