Is there a way to swap textures or a material on a player model?
by Daniel Peavey · in Torque Game Engine Advanced · 03/30/2009 (5:51 pm) · 18 replies
Hey everyone.
Posting here is a bit of a last resort for me, having poured over all the resources with no luck.
Is there a way to swap the material or texture on a player model? I'm trying to make my player's texture change to a different material or texture when switching to a specific weapon. As far as I can tell right now, I can't just swap out an entire player model with a material in runtime, nor can I actually dynamically access the material.cs file attached to my player.
Any advice?
Posting here is a bit of a last resort for me, having poured over all the resources with no luck.
Is there a way to swap the material or texture on a player model? I'm trying to make my player's texture change to a different material or texture when switching to a specific weapon. As far as I can tell right now, I can't just swap out an entire player model with a material in runtime, nor can I actually dynamically access the material.cs file attached to my player.
Any advice?
About the author
#2
03/31/2009 (4:26 am)
setskin(), eh? Is there any documentation on that anywhere?
#3
03/31/2009 (6:17 am)
I don't have TGEA in front of me at the but its either setskin or setskinname.
#4
I'm using %player.setSkinName("stringofskin") with a filename of the texture literally set to base.mytex.dds, and setting it in my material file with no luck. I'm not sure how to handle the material naming convention, either.
03/31/2009 (9:15 am)
Do I literally format the texture as base.mytex.dds, or are you referring to the material name? Sorry, I am not clear on the instruction.I'm using %player.setSkinName("stringofskin") with a filename of the texture literally set to base.mytex.dds, and setting it in my material file with no luck. I'm not sure how to handle the material naming convention, either.
#5
03/31/2009 (9:53 am)
The original should be like base.mytex.dds and then with oyur above call it would use the stringofskin.mytex.dds file.
#6
Without setting %player.setSkinName in my GameConnection::createPlayer function, the base.mytex.dds works just fine. However, testing %player.setSkinName("red") (which is, theoretically, directing to red.mytex.dds) provides me with the engine's error texture. I tried for several other randomlyNamed.mytex.dds files with their appropriate "randomlyNamed" strings within %player.setSkinName(, and no luck.
Also, thanks to you, I was able to get the right info to search the forums for other similiar posts. Unfortunately none have been able to explain my problem I'm having now.
http://www.garagegames.com/community/forums/viewthread/7346
http://www.garagegames.com/community/forums/viewthread/37328
https://www.garagegames.com/community/forums/viewthread/6617
http://www.garagegames.com/community/resources/view/2405
Replicating the issue, it occurs with and without a material.cs file. For reference, here is the current material.cs file I'm using to work on this.
new Material(AVmaterial)
{
mapTo = "base.mytex.dds";
baseTex[0] = "base.mytex.dds";
//bumpTex[0] = "lol_bumpmap.dds";
pixelSpecular[0] = true;
specular[0] = "1.0 1.0 1.0 1.0";
specularPower[0] = 32.0;
};
I'll keep trying everything I can think of until this works. Your help so far has been greatly appreciated, J.C. Smith. Further insight will not go unnoticed! :D
03/31/2009 (10:28 am)
Okay, I made some progress on this attempt. Without setting %player.setSkinName in my GameConnection::createPlayer function, the base.mytex.dds works just fine. However, testing %player.setSkinName("red") (which is, theoretically, directing to red.mytex.dds) provides me with the engine's error texture. I tried for several other randomlyNamed.mytex.dds files with their appropriate "randomlyNamed" strings within %player.setSkinName(, and no luck.
Also, thanks to you, I was able to get the right info to search the forums for other similiar posts. Unfortunately none have been able to explain my problem I'm having now.
http://www.garagegames.com/community/forums/viewthread/7346
http://www.garagegames.com/community/forums/viewthread/37328
https://www.garagegames.com/community/forums/viewthread/6617
http://www.garagegames.com/community/resources/view/2405
Replicating the issue, it occurs with and without a material.cs file. For reference, here is the current material.cs file I'm using to work on this.
new Material(AVmaterial)
{
mapTo = "base.mytex.dds";
baseTex[0] = "base.mytex.dds";
//bumpTex[0] = "lol_bumpmap.dds";
pixelSpecular[0] = true;
specular[0] = "1.0 1.0 1.0 1.0";
specularPower[0] = 32.0;
};
I'll keep trying everything I can think of until this works. Your help so far has been greatly appreciated, J.C. Smith. Further insight will not go unnoticed! :D
#7
THe only difference I can see really betwee the two is that you referred to the .dds extension and I didn't maybe try it without the extension.
03/31/2009 (10:43 am)
Mind you, I haven't tested this with 1.8/1.81 could be a bug related to 1.8, but this material is what I used in something for 1.7 and worked fine:new Material(basesf01)
{
baseTex[0] = "base.sf-01";
pixelSpecular[0] = true;
specular[0] = "0.5 0.5 0.5 0.5";
specularPower[0] = 16.0;
bumpTex[0] = "sf01_nm";
preload = false;
mapTo = "base.sf-01";
};THe only difference I can see really betwee the two is that you referred to the .dds extension and I didn't maybe try it without the extension.
#8
Anyways, because I am using Maya to build my assets and using Danny Ngugen's Maya2DTS_2008 and dtsUtility exporter, I have to direct the mapTo= with the full filename designated within the app, including the file extension. Other than that, under baseTex[0], having the extension on and off has shown the same result. Granted, it is worthy to point out that both base.mytex.dds and base.mytex work just fine with %player.setSkinName("blue") commented out.
I will test this on an old exercise I did on 1.7 and see if it works there. I really hope this is not a bug or else that just shot down an entire game mechanic. xD
03/31/2009 (10:50 am)
I sure hope it isn't! I am using 1.8, for the record. I should probably look into that....Anyways, because I am using Maya to build my assets and using Danny Ngugen's Maya2DTS_2008 and dtsUtility exporter, I have to direct the mapTo= with the full filename designated within the app, including the file extension. Other than that, under baseTex[0], having the extension on and off has shown the same result. Granted, it is worthy to point out that both base.mytex.dds and base.mytex work just fine with %player.setSkinName("blue") commented out.
I will test this on an old exercise I did on 1.7 and see if it works there. I really hope this is not a bug or else that just shot down an entire game mechanic. xD
#9
03/31/2009 (11:19 am)
Well I don't think it's a bug with the engine. I just tested it in 1.7.1 and replicated the same results. Now I'm mildly worried! The last thing I'm going to test out is the maya-exporter, and see if I can get the material.cs file to work like 3DSmax's.
#10
Problem still persists in both 1.7.1 and 1.8. Oyyy. I have a couple more ideas involving how I'm calling the string.
03/31/2009 (11:41 am)
I was able to adjust the exporter so it wouldn't care about the file extension in the mapTo anymore.Problem still persists in both 1.7.1 and 1.8. Oyyy. I have a couple more ideas involving how I'm calling the string.
#11
http://www.garagegames.com/community/blogs/view/4051
03/31/2009 (12:00 pm)
Should I be adding these "skins" as a skin set in my player.cs code?http://www.garagegames.com/community/blogs/view/4051
#12
After a lot of work, my team and I got setSkinName() to work and point to the proper texture.
I don't know if you're aware, but we literally had to make a material for each texture:
new Material(base_AVmaterial)
{
mapTo = "base.avmaterial.dds";
baseTex[0] = "base.avmaterial.dds";
pixelSpecular[0] = true;
specular[0] = "1.0 1.0 1.0 1.0";
specularPower[0] = 32.0;
};
new Material(red_AVmaterial)
{
mapTo = "red.avmaterial.dds";
baseTex[0] = "red.avmaterial.dds";
pixelSpecular[0] = true;
specular[0] = "1.0 1.0 1.0 1.0";
specularPower[0] = 32.0;
};
new Material(blue_AVmaterial)
{
mapTo = "blue.avmaterial.dds";
baseTex[0] = "blue.avmaterial.dds";
pixelSpecular[0] = true;
specular[0] = "1.0 1.0 1.0 1.0";
specularPower[0] = 32.0;
};
Now %playerid.setSkinName("blue"); works just fine.
However we're running into a new issue: we are able to change the skin during run time... but only once. Is this the way the function is meant to behave?
04/02/2009 (11:18 am)
Good news!After a lot of work, my team and I got setSkinName() to work and point to the proper texture.
I don't know if you're aware, but we literally had to make a material for each texture:
new Material(base_AVmaterial)
{
mapTo = "base.avmaterial.dds";
baseTex[0] = "base.avmaterial.dds";
pixelSpecular[0] = true;
specular[0] = "1.0 1.0 1.0 1.0";
specularPower[0] = 32.0;
};
new Material(red_AVmaterial)
{
mapTo = "red.avmaterial.dds";
baseTex[0] = "red.avmaterial.dds";
pixelSpecular[0] = true;
specular[0] = "1.0 1.0 1.0 1.0";
specularPower[0] = 32.0;
};
new Material(blue_AVmaterial)
{
mapTo = "blue.avmaterial.dds";
baseTex[0] = "blue.avmaterial.dds";
pixelSpecular[0] = true;
specular[0] = "1.0 1.0 1.0 1.0";
specularPower[0] = 32.0;
};
Now %playerid.setSkinName("blue"); works just fine.
However we're running into a new issue: we are able to change the skin during run time... but only once. Is this the way the function is meant to behave?
#13
This is a confirmed bug. I see you're not a TGEA licence holder, but if you have someone on your team who is, point them to this thread which contains solutions.
04/02/2009 (8:05 pm)
Quote:However we're running into a new issue: we are able to change the skin during run time... but only once. Is this the way the function is meant to behave?
This is a confirmed bug. I see you're not a TGEA licence holder, but if you have someone on your team who is, point them to this thread which contains solutions.
#14
04/02/2009 (8:26 pm)
Will do.
#15
04/07/2009 (9:32 am)
Got it working. Thanks for your help everyone. :)
#16
04/07/2009 (11:01 am)
Grats.
#18
Here is a whole bunch of stuff for team based addons.
www.garagegames.com/community/blogs/view/15915
Chris
04/12/2009 (11:44 pm)
Hello,Here is a whole bunch of stuff for team based addons.
www.garagegames.com/community/blogs/view/15915
Chris
Torque 3D Owner J.C. Smith