SpazmoJones Posted August 5, 2015 Share Posted August 5, 2015 I've just finished updating my Enhanced Customisation mod to allow custom weapon size and colours for SHIVs. Everything works well except for when I set the material colour of a single SHIV pawn - for some reason the colour change gets applied to every other SHIV pawn. It's as if there's just a single global SHIV material that's attached to every SHIV mesh. Is there some sort of setting or way to define a material that would make it behave in such a "global" way. If I understood this better I'd know what to look for in the code to fix it. Link to comment Share on other sites More sharing options...
Krazyguy75 Posted August 6, 2015 Share Posted August 6, 2015 Are you changing the material applied, or the material itself? If the latter, it is often smart to use materials multiple times, as it saves time, effort, and space. Link to comment Share on other sites More sharing options...
Zyxpsilon Posted August 6, 2015 Share Posted August 6, 2015 (edited) Speaking of materials... The weapons have a secondary channel (IIRC from a theory by Drakous79 -- some red alpha) that somehow maintains a strictly direct connection with the current armor tints -- so, this would probably explain why SHIV might also apply their own (structurally defined within their own 3D model principles) materials via a straight-off call to the generic data pool that they're (all) linked with -- which includes the "Texturing" process. Another issue, i've been trying to tackle lately are the "Moves Wires (aka-Yellow & Blue)", the tiles Grid, any of the Troopers "Circles", and possibly the pathway Cover indicators. Each of these seem to use a 3d model system as well ( X was certainly right about these! )... but i just can't find the exact code function that declares their persistent colors (cyan+yellow, etc).Ideally, i'd want "Green+Red Move Wires" instead & so on. If anything to match with the new UnitFlags (Bars & EKG) concept i'm planning to integrate into the ReCLR-LW6 mod. Any ideas, someone? :wink: Edited August 6, 2015 by Zyxpsilon Link to comment Share on other sites More sharing options...
SpazmoJones Posted August 6, 2015 Author Share Posted August 6, 2015 The setting of the color happens in my modified XComTank.OnArmorLoaded function. If it's called with a "none" ArmorArcheType then it sets the main mesh color and the attached weapon color. Mesh is the main SHIV. It then finds the attached weapon mesh and sets the colours there too. The regular soldier armor tint setting is done in a similar way yet each soldier's armor keeps it's unique color. This tells me that the SHIV mesh must be constructed in a slightly different way for it to behave like it does. simulated function OnArmorLoaded(Object ArmorArchetype, int ContentId, int SubID) { local XComTank PawnArchetype; local int MatIdx; local SkeletalMesh WeaponMesh; local SkeletalMeshActor NewWeapon; local editinline MeshComponent FoundMeshComponent; local name SocketName; // End:0x3C9 if(ArmorArchetype == none) { MaterialInstanceConstant(Mesh.SkeletalMesh.Materials[0]).SetVectorParameterValue(name("CMOD"), ((ContentId == -1) ? MakeLinearColor(0.50, 0.50, 0.50, 1.0) : XComContentManager(class'Engine'.static.GetEngine().GetContentManager()).GetColorPalette(9).Entries[ContentId].Primary)); MaterialInstanceConstant(Mesh.SkeletalMesh.Materials[0]).SetVectorParameterValue(name("CMODB"), ((ContentId == -1) ? MakeLinearColor(0.250, 0.250, 0.250, 1.0) : XComContentManager(class'Engine'.static.GetEngine().GetContentManager()).GetColorPalette(9).Entries[ContentId].Secondary)); // End:0x3C5 foreach Mesh.AttachedComponents(class'SkeletalMeshComponent', FoundMeshComponent) { FoundMeshComponent.SetScale(-0.020 + (0.020 * float(SubID))); MaterialInstanceConstant(FoundMeshComponent.SkeletalMesh.Materials[0]).SetVectorParameterValue(name("CMOD"), ((ContentId == -1) ? MakeLinearColor(0.250, 0.250, 0.250, 1.0) : XComContentManager(class'Engine'.static.GetEngine().GetContentManager()).GetColorPalette(9).Entries[ContentId].Primary)); } } // End:0x705 else { PawnArchetype = XComTank(ArmorArchetype); // End:0x5C5 if(PawnArchetype.Mesh.SkeletalMesh != Mesh.SkeletalMesh) { Mesh.SetSkeletalMesh(PawnArchetype.Mesh.SkeletalMesh); MatIdx = 0; J0x499: // End:0x54E [Loop If] if(MatIdx < PawnArchetype.Mesh.Materials.Length) { Mesh.SetMaterial(MatIdx, PawnArchetype.Mesh.Materials[MatIdx]); ++ MatIdx; // [Loop Continue] goto J0x499; } Mesh.PrestreamTextures(10.0, true); Mesh.SetLightEnvironment(LightEnvironment); LightEnvironment.ResetEnvironment(); CacheTreads(); } WeaponMesh = SkeletalMesh(XComContentManager(class'Engine'.static.GetEngine().GetContentManager()).GetGameContent(string(PrimaryWeapon))); // End:0x6F9 if(WeaponMesh != none) { NewWeapon = Spawn(class'SkeletalMeshActorSpawnable', self,,,,, true); NewWeapon.SkeletalMeshComponent.SetSkeletalMesh(WeaponMesh); SocketName = class'XGInventory'.default.m_SocketNames[3]; AttachItem(NewWeapon, SocketName, false, FoundMeshComponent); } m_bUnitContentLoaded = true; } //return; } Link to comment Share on other sites More sharing options...
SpazmoJones Posted August 6, 2015 Author Share Posted August 6, 2015 I've just been going through the soldier side code again and I think I've found out what's happening. The XComHumanPawn.UpdateMeshMaterials function appears to create new material instances for each soldier and then set the colors of the new instances. The tank code doesn't do this. It's amazing what you miss when you don't get enough sleep. :) Link to comment Share on other sites More sharing options...
Amineri Posted August 6, 2015 Share Posted August 6, 2015 I was just going to point this out, that the XComHumanPawn has the following code to duplicate the material to avoid precisely the effect your are seeing. if(InStr(string(MIC.Name), "MaterialInstanceConstant") == -1) { newMIC = new (self) class'MaterialInstanceConstant'; newMIC.SetParent(MIC); MeshComp.SetMaterial(Idx, newMIC); MIC = newMIC; } ParentMat = MIC.Parent; Link to comment Share on other sites More sharing options...
SpazmoJones Posted August 6, 2015 Author Share Posted August 6, 2015 I was just going to point this out, that the XComHumanPawn has the following code to duplicate the material to avoid precisely the effect your are seeing. if(InStr(string(MIC.Name), "MaterialInstanceConstant") == -1) { newMIC = new (self) class'MaterialInstanceConstant'; newMIC.SetParent(MIC); MeshComp.SetMaterial(Idx, newMIC); MIC = newMIC; } ParentMat = MIC.Parent; Yep that's right. I modified the tank code to do something similar with it's mesh and weapon mesh and it works correctly now. Version 1.0f just released 5 minutes ago...! :) Link to comment Share on other sites More sharing options...
dubiousintent Posted August 7, 2015 Share Posted August 7, 2015 @SpazmoJones: Now that you worked this out, would you consider writing up a tutorital style section for the "Adding and changing art assets" wiki article on this, for the benefit of others? You can either add it directly to the article yourself, or post it here and I'll stuff it into the article for you. Also anything else you think would help the article. -Dubious- Link to comment Share on other sites More sharing options...
amaciel81 Posted August 8, 2015 Share Posted August 8, 2015 @SpazmoJones, you did great, this go beyond most of us though as possible; so, I'm asking for curiosity sake only, ok? Besides making models bigger or smaller (as I understand, soldier bodies and heads, and SHIVs and its weapons are different models), can you resize them across a single axis? Like making soldiers fatter or thiner, maybe making thin men like soldiers? Regards, Link to comment Share on other sites More sharing options...
SpazmoJones Posted August 8, 2015 Author Share Posted August 8, 2015 @SpazmoJones, you did great, this go beyond most of us though as possible; so, I'm asking for curiosity sake only, ok? Besides making models bigger or smaller (as I understand, soldier bodies and heads, and SHIVs and its weapons are different models), can you resize them across a single axis? Like making soldiers fatter or thiner, maybe making thin men like soldiers? Regards,Yes it would be possible. I'm currently using the SetScale function which scales the entire mesh equally. There's a SetScale3D function that lets you scale the x, y and z axis independently. I might add that as a feature in the future actually. The main pain would be to update the UI to make space for the extra setting. Link to comment Share on other sites More sharing options...
Recommended Posts