Jump to content
Sign in to follow this  
AirwolfPL

Replacing textures on models by *.cpp directives?

Recommended Posts

What's the idea?

I have made some selection in the p3d file, let's call it "fuselage". Some faces in this selection are textured with

(for example) "fuselage.pac" texture...

Is it possible to replace this texture with another one by some sort of directive in addon's config file? (It's retoric question a bit, I suppose it's not possible, maybe I'm mistaken, but I've never saw anything like it in any addon).

It should work similar to 'wounds' textures and textures which are switched when whindshild is broken...

It would give us possibility to make many paintschemes when using only one p3d file (less memory needed, less time needed, much more flexible!wink.gif.

Example - Instead of using:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

class SokolSAR: Helicopter

{

  .

  .

  model="sokol\SokolSAR";

  .

  .

  .

};

class SokolMedEvac: SokolSAR

{

  model="sokol\SokolMedEvac";

};

<span id='postcolor'>

etc.

it would be possible to use:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

class SokolSAR: Helicopter

{

  .

  .

  model="sokol\Sokol";

  ReplaceTexture={"Fuselage","fuselage.pac","fuselagesar.pac"};

  .

  .

  .

};

class SokolMedEvac: SokolSAR

{

  ReplaceTexture={"Fuselage","fuselage.pac","fuselagemedevac.pac"};

};

<span id='postcolor'>

Much better, isn't it?

(of course "ReplaceTexture" thing above is totally fictional)

Share this post


Link to post
Share on other sites

Good idea. Even being able to assign different unit insignia and other markings on vehicles ie number plates on cars etc.

Putting different numbers on the same aircraft would be cool.

Share this post


Link to post
Share on other sites

While it is not possible to retexture directly from config, it is possible to do this with config and scripting.

There is config entry called hiddenSelections (check Truck5T for very simple example).

All selections listed in this section are hidden by default and can be retextured using scripting function

vehicle setObjectTexture [hidearrayindex,texturename]

Note: selections must be properly defined in CfgModels, otherwise they are not hideable and cannot be retextured.

Consider hiddenSelections defined like this:

hiddenSelections[]=

{

  "doorSelectionName","windowSelectionName"

};

You can change textures mapped on those selections using

Change door texture:

house setObjectTexture [0,"addon\new_door_texture.paa"]

Change window texture:

house setObjectTexture [1,"addon\new_window_texture.paa"]

With the help of init event handler, which can be defined in addon config, you can do scripting directly in the addon. Unfortunatelly init event is not triggered on remote computers in multiplayer, therefore this solution is not MP correct.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Suma @ Nov. 21 2002,11:12)</td></tr><tr><td id="QUOTE">While it is not possible to retexture directly from config, it is possible to do this with config and scripting. (...)<span id='postcolor'>

Thank you for reply.

So I understand I can't "unhide" this hiddenSelection directly in unit's class with proper texture for this class applied, but I have to do that through the script (or init handler which as you said doesn't work in MP)...

Hmmm...

Would it be really so hard to add some config entries or structures (just like one which defines textures for wounds or damage textures) for replacing textures directly in the addon's config (in unit's class)? (I suppose, the answer is "yes" but I can always ask, can't I? wink.gif

Share this post


Link to post
Share on other sites

So, we have to remind player who had our addons about how to script the correct texture in readme, right?

And the setobjecttexture script is for over version 1.75 not for 1.46 or below.

As I tested the solution, we cann't do the same way automatically and randomly.

Maybe BIS will save us in some other time, I hope.

Thanks anyway. wink.gif

Share this post


Link to post
Share on other sites

Bit confused here,

if the setObjectTexture works off the hidearryindex as set out in the vehicles cpp then if the vehicle has

hiddenSelections[] = {};

ie is showing the textures, then what is the hidearrayindex?

Does this mean we can't use this to "swap" textures but only display new textures as set in the setObjectTexture line?

eg say I had a unit symbol on the front of a jeep which i have showing, would I be able (by defining the selection properly) to enable a person to script their own unit symbol to replace it?

SelectThis

Share this post


Link to post
Share on other sites

I'm pretty sure this means:

hiddenSelections[]=

{

"doorSelectionName","windowSelectionName"

};

the hiddenselections index is an array of hidden selections.

an index value of 0 is the first element of the hidden selections array, an index value of 1 is the second element, etc. Just like when you use arrays in scripting.

THis is really great as it allows us to have multiple retextured units without having to include multiple models in an addon.

The big question is: "Just how much can we get away with?"

Can we set the majority of a unit up with hidden selections and give them an entirely different camoflague scheme? Or for people, can we let them change clothes in the field, like a spy would do?

Share this post


Link to post
Share on other sites

Hmm..Suma I have a question...

we are currently working on US WWII marines and i would really love to make them as accurate as possible, this includes having shoulder isignia patches for different ranks, how can I have one model with a hidden selection and if in the mission editor I would place that soldier and select a rank for him, the shoulder patch would change? and on the helmet as well.

Share this post


Link to post
Share on other sites

Yes, this thing about the hidden selection as been in my mind since I had a look at the "medic" selection in the west soldier P3D in O2.

It should be possible to do the same thing for the shoulder patches and rank badges easily. After all, even in multiplayer we're able to see the patch on the medic's arm; and this seems to be activated in the cpp file. it should be possible to activate the rank badges/shoulder patches/aicraft number ...etc... in the same way if I'm not mistaken?

-Horrido

Share this post


Link to post
Share on other sites

Well yes thats all true but a medic is selected by choosing "Medic" in the editor and a soldier is choosen "Soldier", what I want is the same result but having only choosen "Soldier" and different Ranks

Share this post


Link to post
Share on other sites

Could'nt this be set in the class CfgVehicles?

you call the soldier with the corporal badge something like "corporal", give him an hidden selection to have the badge and then in the CfgGroup, you give him the rank "corporal".

This will work only for group, though.

-Horrido

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Tanelorn @ Nov. 23 2002,21:47)</td></tr><tr><td id="QUOTE">(...)

The big question is: "Just how much can we get away with?"

Can we set the majority of a unit up with hidden selections and give them an entirely different camoflague scheme? Or for people, can we let them change clothes in the field, like a spy would do?<span id='postcolor'>

Heh, but remember that it will not work in MP mode sad.gif

Share this post


Link to post
Share on other sites

@horrido

unpractical, imagine for every unit a different rank...if we make 8 units thats gonna be...damn i aint counting...

in other words ull be lsot in ur editor

Share this post


Link to post
Share on other sites

Actually, I tested this solution, and it works fine.

But I need to define all soldiers in Initialization feld one by one.

It tooks me a lot of time to set all each others in one mission, you know.

It will be nice if we can load that automatically and they will set the rank randomly like random face, isn't it?

wink.gif

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (andylee054 @ Nov. 25 2002,06:28)</td></tr><tr><td id="QUOTE">Actually, I tested this solution, and it works fine.

But I need to define all soldiers in Initialization feld one by one.

It tooks me a lot of time to set all each others in one mission, you know.

It will be nice if we can load that automatically and they will set the rank randomly like random face, isn't it?

wink.gif<span id='postcolor'>

Hi

Look here you can do it from the init in the config.cpp

Running a script from the init in the config.cpp

Regards walker

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (walker @ Nov. 26 2002,19:52)</td></tr><tr><td id="QUOTE">Look here you can do it from the init in the config.cpp

Running a script from the init in the config.cpp

Regards walker<span id='postcolor'>

But I will not work for Multiplayer mode, as Suma informed...

Share this post


Link to post
Share on other sites

I setted a soldier's badge as named "rank" in 3D model.

Then I worte that model in cfgmodels too.

Also I did hiden selection {"rank"}.

All I need is replace the texture into sod1.paa.

So, I added the script as below:

class EventHandlers

{

init = this setObjectTexture [0, "\roctest1\sod1.paa"];

};

But, I saw some error message everytime when I load this addon.

The message like setobjectTexture need Bool or object ...some thing like that.

Did I make anything wrong?

confused.gif

Share this post


Link to post
Share on other sites

Hi AirwolfPL

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">But I will not work for Multiplayer mode, as Suma informed...<span id='postcolor'>

Yes that is because init runs on the local machine only in the case of MP that is the server. You need to have the clients run a version of the script as well wink.gif

Your bright work it out. biggrin.gif

Kind Regards walker

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×