Author Topic: Texture Replacement! Yay!  (Read 6374 times)

0 Members and 1 Guest are viewing this topic.

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Essentially, I just added an array to the ship structure:

Code: [Select]
int replacement_textures[MAX_MODEL_TEXTURES];

I initialized the array to -1.  Then when the mission ran through the parsing routine, I loaded the duplicate textures and assigned their ID numbers to the replacement texture array with a one-to-one correspondence to the textures in the polymodel struct.

In the model render routine, it checks to see if the texture it's currently rendering has a positive (greater than -1) ID number in the associated replacement texture array.  If it does, it renders that texture instead of the texture in the polymodel struct.

That's the gist of it.  I also made some special fiddly code that would skip completely over the replacement texture check if the object had absolutely no replacement textures whatsoever, in order to optimize the thing for asteroids, debris, jump nodes, and so on. :)

I changed the model parsing routine to load the substitute textures if it encounters a $Texture Replace entry, and to reskin a duplicate model if it encounters a $Duplicate Model Texture Replace entry.  (The format of the two is exactly the same, with the +old and +new lines following the heading.)

You'll need to reskin a duplicate model if you want to substitute animated or transparent textures, but this is probably the optimal solution if you want to add cockpit kill count art, custom ship nameplates, or any stuff like that.  Of course, mission designers can experiment on their own to see which method plays better in a given mission. :)
« Last Edit: January 16, 2003, 11:28:46 pm by 561 »

 

Offline EdrickV

  • Valued
  • 29
    • http://members.aol.com/HunterComputers
Hmm. Sounds like there might be a slight in game preformance hit when rendering reskinned models, but with decent computers we probably won't even notice. Will have to see if there's any noticable preformance problems.
Ground - "Let me help you out, you're clear to taxi any way you can, to any runway you see."

Mesh Gallery/Downloads:
http://members.aol.com/ArisKalzar/Gallery.html
Turreting 101:
http://members.aol.com/EdrickV/FS2/Turreting.html

http://members.aol.com/HunterComputers

 

Offline ZylonBane

  • The Infamous
  • 29
Quote
Originally posted by Goober5000
(The format of the two is exactly the same, with the +old and +new lines following the heading.)

You'll need to reskin a duplicate model if you want to substitute animated or transparent textures
Then shouldn't the code automatically determine and use the correct method? No point in concerning the FREDder with neepish internal details.
ZylonBane's opinions do not represent those of the management.

 

Offline Nico

  • Venom
    Parlez-vous Model Magician?
  • 212
Quote
Originally posted by Goober5000
Well, I'm dumb.  You can put multiple substitute textures on a ship without requiring an extra model.  So, I did. :) Here's the alternate (debug) version...

http://fs2source.warpcore.org/exes/alt_fs2_open_3.41_debug.exe

You can use it exactly the same way as the other one; it's just a difference in implementation.

I think I'll still keep the other method in the codebase, and call it $Duplicate Model or something.  The duplicate model method is the only way to reskin animated or transparent textures, so people may need that instead.


yes, keep them both with two different entries, that way one could make alpha wing blue, beta wing red, and alpha1 having shark jaws on the ship, and beta one having  pink dots everywhere!!! yay! ok, the exemples aren't the best ever, but you get what I mean :p
SCREW CANON!

 

Offline Anaz

  • 210
the Robotech TC (if it wasn't dead...) would love this stuff...
Arrr. I'm a pirate.

AotD, DatDB, TVWP, LM. Ph34r.

You WILL go to warpstorm...

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Quote
Originally posted by ZylonBane
Then shouldn't the code automatically determine and use the correct method? No point in concerning the FREDder with neepish internal details.


:wtf:

Because there's no easy way for the code to do this, and anyway it's only a two-word difference in the file.  The FREDder is the best judge - not the code.

:rolleyes:

  

Offline EdrickV

  • Valued
  • 29
    • http://members.aol.com/HunterComputers
When you get right down to basics, electronic computers don't think. They just do what they are told. (Even if what they are told to do isn't what they should do, which is how computer crashes happen.) The best computer ever invented is still the human brain. (At least on this planet. ;) )
Ground - "Let me help you out, you're clear to taxi any way you can, to any runway you see."

Mesh Gallery/Downloads:
http://members.aol.com/ArisKalzar/Gallery.html
Turreting 101:
http://members.aol.com/EdrickV/FS2/Turreting.html

http://members.aol.com/HunterComputers