Game Development Community

Help with Changing Textures please

by Gregory Dudding · in Torque Game Engine · 02/07/2005 (11:27 pm) · 7 replies

Now that i've dealt with most of my mounting problems and questions... I am on to the next portion of my game, and I find myself without a plethora of helpful resources this time...

What I need to do is make it so that I can easily add a single texture to a player model without replacing all of the textures on that model...

Currently, my textures are set up so I have a face texture, a hair texture, and a body texture for my characters... I need a method of simply changing the player's face... I looked into setskinname I think it was, but it seemed like it was going to change the whole model if I just wanted to stick a new face on?

Has anyone seen a good resource or have gone through this that could lend me some direction as to where I should begin my quest?

Thank you!
-Greg

#1
02/10/2005 (3:26 am)
SetSKinName should only replace one material on the model... so it ought to be a pretty good base for what you're doing.
#2
02/11/2005 (6:10 am)
I thought SetSkinName changed the first part of skinname.texture1.ext to whatever you put in... for all textures? Maybe I misread somewhere... but the usage I saw correllated to having textures like this:

Say you had 2 sets of textures:
red.hair.jpg
red.face.jpg
red.legs.jpg

and

blue.hair.jpg
blue.face.jpg
blue.legs.jpg

SetSkinName(blue); would make it use all the textures that started with blue...

I could be 100% wrong though...

I did find this resource:
www.garagegames.com/mg/forums/result.thread.php?qt=22471

But I am unsure as of how to actually use it after I implement it (there aren't many notes, and I'm still but a learner)... So, help with that would probably solve my issue...

Thank you,
-Greg
#3
02/11/2005 (3:03 pm)
I was under the impression that setSkinName only modified textures that had been indicated as "skin" textures, ie, followed the naming convention. So that "common" textures would get shared properly. I've never used it, just read the code a bit, so you are quite likely more knowledgeable about the specifics than I. :)
#4
02/12/2005 (9:08 pm)
@Ben: You are quite right - setSkinName will only affect 'skin' textures, and in it's default form, will apply to ALL skin textures in a model.

In the resource Greg mentioned, I have extended the naming convention to allow for an arbitrary number of skin 'groups' that can be modified independently using setSkinName.

The only downside is that the default ShapeBase only transmits one skin name per update, so you have to wait for an update, or modify the shapebase code to send more than one skin at a time.
#5
02/12/2005 (9:22 pm)
Can you explain how that resource is utilized? I am fairly new to the scripting engine and I need a little help on how to take the base player model and swap in a new face png using what's shown there...

Also, waiting for an update? How does that work exactly? Sorry for the n00bish questions...

-Greg
#6
02/13/2005 (11:23 am)
@Greg:

The resource is for SDK owners only. You will need to modify the C++ engine code to apply it. I would suggest getting the default skin behaviour to work before worrying about multiple skins.

To use skins, you need to name your model textures like this eg:

base.hair.human.jpg or .png
brown.hair.human.jpg
black.hair.human.jpg

The 'base.hair.human' texture is the one you apply to the model. When a new 'skin' is applied, it searches for all textures that start with 'base', and replaces that part of the texture name with the new skin name.

eg.

%obj.setSkinName("brown") would change:

base.hair.human to brown.hair.human.

My resource allows you to extend the search/replace pattern to change groups of textures independently. eg.

%obj.setSkinName("brown.hair") would change all textures whose names started with 'base.hair' to 'brown.hair'.

You can only call setSkinName on the server, which then transmits the new skin name to the client (this happens even if you have created a single player server).

This means that you either need to wait for that update to occur before sending the next skin, or modify ShapeBase to allow multiple skins to be sent at once.

There are many ways you could do this. eg:
- send all skins within a single tab delimited string
- send an array of strings
#7
02/13/2005 (11:57 am)
I am an SDK owner :).

Thank you for that... I just wasn't sure from reading the code how to implement it. I think I understand now... thank you for taking the time to explain it to me. This does exactly what I need. I'll experiment with it and figure out the nuances of the update issue you're talking about. If it means only waiting a few seconds between changes, that won't be a problem at all :).

-Greg