Decals Attached to Actors

A refuge for those migrating from the fallen DXEditing.com and a place for general discussion relating to Deus Ex editing (coding, mapping, etc).
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Decals Attached to Actors

Post by Cybernetic pig »

Is it possible, or do the primitive collision cylinders prevent (as usual) any sensible execution of it?
Hanfling
MJ12
Posts: 406
Joined: Sun Oct 04, 2009 6:54 pm

Re: Decals Attached to Actors

Post by Hanfling »

The FDecal/ADecal are features for bsp surfaces and not for meshes, so one cannot use them for them.

If you want to do things like exact placement for bullet hits, etc. you would end up having to run extremly expansive checks for correct placement of the decals, and the whole thing would be at least technically difficult.

However one thing one could actually do is to use a ScriptedTexture for meshes, use the same approximation code for areas hit as in tracing shots, and change that part of the texture. While beeing not quite as fancy, this is easily to add with a few lines of uc code only, but can yield some appealing results if proper used.
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.
DDL
Traditional Evil Scientist
Traditional Evil Scientist
Posts: 3791
Joined: Mon Oct 17, 2005 10:03 am

Re: Decals Attached to Actors

Post by DDL »

It doesn't, I've tried. It's yet another total scripting nightmare ("how does position XYZ on a mesh transpose to texture coordinates U and V on this meshmap?"), plus requires a unique set of scripted textures for each actor. With potentially 8 multiskins per NPC, this gets very silly, very quickly.

Unless I was simply approaching the problem from the wrong angle?

I gave up, anyway.
Hanfling
MJ12
Posts: 406
Joined: Sun Oct 04, 2009 6:54 pm

Re: Decals Attached to Actors

Post by Hanfling »

Well i thought of nothing exact, just like: If head is hit you put in the injured textures bit for that part. E.g. you have like the base texture + one texture with injuries + some info about where to blit the damaged parts, e.g. where the head area is on the skin, etc.

Mh but, yeah it ends up in having many scriptedtextures per actor. Probably having a ScriptedTexture subclass with appropreciate default values for size and using uc's new could work, if not just a few lines of C++ code to create new scriptedtextures on the fly.
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Re: Decals Attached to Actors

Post by Cybernetic pig »

I've never used scriptedtexture before, should be pretty self explanatory from the name, but just to confirm can it also be used to access the texture effects (upan, unlit, translucent etc) and modify them dynamically?

Edit: could have just looked myself beforehand. Doesn't seem so, you can just draw on it akin to a canvas...interesting. And yeah, probably is very nightmarish when considering all the multiskins. However, it could be good for having Decals on everything other than pawns at least? Still sounds like a pain in the ass though and probably not worth it without the pawns too.
DDL
Traditional Evil Scientist
Traditional Evil Scientist
Posts: 3791
Joined: Mon Oct 17, 2005 10:03 am

Re: Decals Attached to Actors

Post by DDL »

No, see the problem is when you draw to a scripted texture, it draws to ALL incidences of that texture.

So if you have a texture for a dustbin and you code it so a bullet hole appears in it when shot, it will appear on every single dustbin.

You need to pre-import enough identical (but uniquely named) textures to cover every dustbin you could ever have in a single level.

Which is when I started backing away slowly... :)
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Re: Decals Attached to Actors

Post by Cybernetic pig »

Well, that's that then. Unless there's some other way to do hack it via Uscript.
Hanfling
MJ12
Posts: 406
Joined: Sun Oct 04, 2009 6:54 pm

Re: Decals Attached to Actors

Post by Hanfling »

I would give new class'ScriptedTexture' a try in unrealscript. Maybe a subclass of it with appropreciate settings for width and height. Put this in PreBeginPlay().
Last edited by Hanfling on Fri May 22, 2015 1:31 am, edited 2 times in total.
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Re: Decals Attached to Actors

Post by Cybernetic pig »

Hanfling wrote:I would give new class'ScriptedTexture' a try in unrealscript. Maybe a subclass of it with appropreciate settings for width and height. Put this in PreBeginPlay().
So, to be clear:

1. Subclass ScriptedTexture in DeusEx.u.
2. from there it can then be modified to apply to textures that are instances of a class, rather than the class itself.
3. Profit???
Hanfling
MJ12
Posts: 406
Joined: Sun Oct 04, 2009 6:54 pm

Re: Decals Attached to Actors

Post by Hanfling »

Profit does not seem to work out. Apperantly the UTexture::Init() call is missing/the Texture created with uc new gets no mipmaps which result in crash. Basic plan was:

Code: Select all

//=============================================================================
// UNATCOTroop.
//=============================================================================
class UNATCOTroop extends HumanMilitary;

// ----------------------------------------------------------------------
// PreBeginPlay()
// ----------------------------------------------------------------------

simulated function PreBeginPlay()
{
	Super.PreBeginPlay();

	if ( !bDeleteMe )
	{
		MultiSkins[1] = new Class'UNATCOTroopScrTex1';
		MultiSkins[2] = new Class'UNATCOTroopScrTex2';
		MultiSkins[6] = new Class'UNATCOTroopScrTex3';

		ScriptedTexture(MultiSkins[1]).NotifyActor = Self;
		ScriptedTexture(MultiSkins[2]).NotifyActor = Self;
		ScriptedTexture(MultiSkins[6]).NotifyActor = Self;
	}
}

// ----------------------------------------------------------------------
// RenderTexture()
// ----------------------------------------------------------------------

simulated event RenderTexture( ScriptedTexture Tex )
{
	Log( Self $ ".RenderTexture( " $ Tex $ " )", Self.Name );
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

defaultproperties
{
	CarcassType=Class'DeusEx.UNATCOTroopCarcass'
	WalkingSpeed=0.296000
	InitialInventory(0)=(Inventory=Class'DeusEx.WeaponAssaultGun')
	InitialInventory(1)=(Inventory=Class'DeusEx.Ammo762mm',Count=12)
	InitialInventory(2)=(Inventory=Class'DeusEx.WeaponCombatKnife')
	walkAnimMult=0.780000
	GroundSpeed=200.000000
	Texture=Texture'DeusExItems.Skins.PinkMaskTex'
	Mesh=LodMesh'DeusExCharacters.GM_Jumpsuit'
	MultiSkins(0)=Texture'DeusExCharacters.Skins.MiscTex1'
	MultiSkins(1)=Texture'DeusExCharacters.Skins.UNATCOTroopTex1'
	MultiSkins(2)=Texture'DeusExCharacters.Skins.UNATCOTroopTex2'
	MultiSkins(3)=Texture'DeusExCharacters.Skins.MiscTex1'
	MultiSkins(4)=Texture'DeusExCharacters.Skins.MiscTex1'
	MultiSkins(5)=Texture'DeusExItems.Skins.GrayMaskTex'
	MultiSkins(6)=Texture'DeusExCharacters.Skins.UNATCOTroopTex3'
	MultiSkins(7)=Texture'DeusExItems.Skins.PinkMaskTex'
	CollisionRadius=20.000000
	CollisionHeight=47.500000
	BindName="UNATCOTroop"
	FamiliarName="UNATCO Troop"
	UnfamiliarName="UNATCO Troop"
}

Code: Select all

//=============================================================================
// UNATCOTroopScrTex1.
//=============================================================================
class UNATCOTroopScrTex1 extends ScriptedTexture;

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

defaultproperties
{
	Palette=Palette'DeusExCharacters.Skins.Palette1447'
	UBits=7
	VBits=7
	USize=128
	VSize=128
	UClamp=128
	VClamp=128
	SourceTexture=Texture'DeusExCharacters.Skins.UNATCOTroopTex1'
}
So one seems to really need some few line C++ function to create new ScriptedTextures on the fly. Or come up with a better trick ^^
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.
Hanfling
MJ12
Posts: 406
Joined: Sun Oct 04, 2009 6:54 pm

Re: Decals Attached to Actors

Post by Hanfling »

Okay finally figured it out. Basically i made a small extended scriptedtexture class which exposes the C++ Init() and PostLoad() functions, nothing more.
http://coding.hanfling.de/launch/releas ... 150522.zip

And for usage of it:

Code: Select all

//=============================================================================
// UNATCOTroop.
//=============================================================================
class UNATCOTroop extends HumanMilitary;

// ----------------------------------------------------------------------
// PostPostBeginPlay()
// ----------------------------------------------------------------------

simulated function PostPostBeginPlay()
{
	local ScriptedTextureExt ScrTex[3];
	local int i;

	Super.PostPostBeginPlay();

	if ( !bDeleteMe )
	{
		for ( i=0; i<ArrayCount(ScrTex); i++ )
			ScrTex[i] = new(None,'',RF_Transient) Class'ScriptedTextureExt';

		ScrTex[0].Init( 128, 128 );
		ScrTex[1].Init( 256, 128 );
		ScrTex[2].Init(  64, 128 );

		ScrTex[0].SourceTexture = Texture'DeusExCharacters.Skins.UNATCOTroopTex1';
		ScrTex[1].SourceTexture = Texture'DeusExCharacters.Skins.UNATCOTroopTex2';
		ScrTex[2].SourceTexture = Texture'DeusExCharacters.Skins.UNATCOTroopTex3';

		for ( i=0; i<ArrayCount(ScrTex); i++ )
		{
			ScrTex[i].PostLoad();
			ScrTex[i].NotifyActor = Self;
		}

		MultiSkins[1] = ScrTex[0];
		MultiSkins[2] = ScrTex[1];
		MultiSkins[6] = ScrTex[2];
	}
}

// ----------------------------------------------------------------------
// RenderTexture()
// ----------------------------------------------------------------------

simulated event RenderTexture( ScriptedTexture Tex )
{
	Log( Self $ ".RenderTexture( " $ Tex $ " )", Self.Name );
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

defaultproperties
{
	CarcassType=Class'DeusEx.UNATCOTroopCarcass'
	WalkingSpeed=0.296000
	InitialInventory(0)=(Inventory=Class'DeusEx.WeaponAssaultGun')
	InitialInventory(1)=(Inventory=Class'DeusEx.Ammo762mm',Count=12)
	InitialInventory(2)=(Inventory=Class'DeusEx.WeaponCombatKnife')
	walkAnimMult=0.780000
	GroundSpeed=200.000000
	Texture=Texture'DeusExItems.Skins.PinkMaskTex'
	Mesh=LodMesh'DeusExCharacters.GM_Jumpsuit'
	MultiSkins(0)=Texture'DeusExCharacters.Skins.MiscTex1'
	MultiSkins(1)=Texture'DeusExCharacters.Skins.UNATCOTroopTex1'
	MultiSkins(2)=Texture'DeusExCharacters.Skins.UNATCOTroopTex2'
	MultiSkins(3)=Texture'DeusExCharacters.Skins.MiscTex1'
	MultiSkins(4)=Texture'DeusExCharacters.Skins.MiscTex1'
	MultiSkins(5)=Texture'DeusExItems.Skins.GrayMaskTex'
	MultiSkins(6)=Texture'DeusExCharacters.Skins.UNATCOTroopTex3'
	MultiSkins(7)=Texture'DeusExItems.Skins.PinkMaskTex'
	CollisionRadius=20.000000
	CollisionHeight=47.500000
	BindName="UNATCOTroop"
	FamiliarName="UNATCO Troop"
	UnfamiliarName="UNATCO Troop"
}
And this gives me quite some logspam, so it works and you have scripted textures created at runtime per actor.
Last edited by Hanfling on Wed Nov 04, 2015 7:41 am, edited 1 time in total.
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Re: Decals Attached to Actors

Post by Cybernetic pig »

Nice.

So your code there initializes the scriptedTextureExt to be used with the UNATCO troop. So what else would be needed?
For location-based drawing, as DDL said you have to transpose 3D vector coordinates (hitlocation) to 2D on the texture canvas,
for perfectionism you'd also have to pass the scripted texture onto the carcass (and make the carcass able to accept scriptedTextureExt too, so when we shoot the carcass they still get decals/drawn on), and we'd have to make every single individual Pawn class accept scriptedTextureExt directly in their class, not from the parent? I guess it would be possible to do in ScriptedPawn preBeginPlay, but you'd still have to pass in the correct texture via all the children.
Hanfling
MJ12
Posts: 406
Joined: Sun Oct 04, 2009 6:54 pm

Re: Decals Attached to Actors

Post by Hanfling »

Again i suggested no exact solution, rather take the rough approximation code whether the head, chest, legs are hit and use that to draw damage for a specific part of the texture. E.g. have a second set of textures with damage, some config properties like struct Box { var Float X, Y, XL, YT; } AreaRemap[5]; (like 0 is for head, 1 for left arm, etc.). And blit over that are of the texture with damage. So you can kinda much relate it directly to the different health variables or add it to the rought approximation code for damage which guesses the hit area. And there is no big deal in passing the texture set to the carcass in SpawnCarcass() as it uses the same texture set anyway.

Again, I never said anything about getting the exact spot you hit, but iirc in DeusEx not even the tracers for shots actually have the same direction as the actual shots, etc..
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Re: Decals Attached to Actors

Post by Cybernetic pig »

Hmm...I'm not sure it will be adequate enough on pawns, but now that we know it is seemingly possible to draw on individual actors there's surely some use that can be made out of this.
Hanfling
MJ12
Posts: 406
Joined: Sun Oct 04, 2009 6:54 pm

Re: Decals Attached to Actors

Post by Hanfling »

It works fine for Kingpin.
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.
Post Reply