Dynamic Meshes and Skins Update
by game4Rest · 03/27/2010 (9:13 am) · 23 comments
As someone including me has problem with seeing the body of this resource, I decided to rewrite it. The previous one was really long as I wrote down every codes in it. But this time, I decided to upload every related codes onto my web server. Hope to I can managed to maintain that web server without an end.
Show/hiding meshes and dynamic material change are inherent in T3D. I decided to make use
of these features to give my game players a little pleasure when they are watching
their actors' appearance change.
Show/hiding meshes and dynamic material change are inherent in T3D. I decided to make use
of these features to give my game players a little pleasure when they are watching
their actors' appearance change.
As mesh show/hiding is rather simple to implement on script side, I'm not going to add
any special comments.
Disclamour: This is not a Drag & Drop and ready to go resource. It is because we
have completely different player models with completely different textures on
them.
The gui images you can download are not identical to mine. I made a little change from mine
as I have to use the original in my own game. It will not be difficult for you to understand
what I'm doing even with the changed images.
This is a single player version. The multiplayer version will be released very soon.
This resource is made of three parts. The first one is camera. It has thease features.
1. Rotate around the target
2. Go up and down
3. Zoom in/out
4. Reset
The camera system is simple too. When the customization gui awakes, it finds its
initial position with the player eye vector's reverse vector. And then, everything
is done by some math. If you need to move its initial position higher, you will need to
change this part in function GameConnection::viewFront(%this, %camDistance).
Next part is mesh show/hide. But I'm going to skip this part.
The last part is material change. At first, we need very simple engine code change.
It is just to save indices. If you're feel comfortable with many global variables,
you don't need this. I just have a tendency not to use global variables too many.
In guiBitmapButtonCtrl.h, add these variables and methods just after
In GuiBitmapButtonCtrl::GuiBitmapButtonCtrl(), add this.
Finally, somewhere in the guiBitmapButtonCtrl.cpp, add this.
Now, download all the related files from here and execute all of them.
Also, download the related gui images from here, and locate them in the art directory. In gui directory, you can find the demo video too.
In these files, server decides what material should be assigned to the clients when it is requested. To do it, server
has four script Objects. In these script objects, neccessary textures and mesh names are saved as strings.
To make it easier to understand, let's suppose a client requests the server to change its mesh from A to B.
When being asked, server tries to find out the mesh B in the meshObjectArray. When it finds it, the server changes every
textures from those of A to B. Now, if clients ask the server to change their texture, server can update them with the
changed texture data.
When doing the material change things, we have to pay special attention to naming convention.
We have to talk to the artists about this too. When we have proper, concisive and coherent naming
convention, we can make this customization process easier.
Maybe you'll wonder why I include 'c0' file so many places like in FirstMarkArray0 = "c0 f11";.
It is a kind of placeholder. It is very small image which is commonly used in many places.
It is because we have undesirable result when we try to insert image in a slot when there are
any empty slots with lower indices. In other words, if we want to add images in slot 3, the slot 0
to 2 must have any images.
Finally, you can test this resource by calling showCustomGui(true);.
Here is some test video.
Enjoy.
Show/hiding meshes and dynamic material change are inherent in T3D. I decided to make use
of these features to give my game players a little pleasure when they are watching
their actors' appearance change.
Show/hiding meshes and dynamic material change are inherent in T3D. I decided to make use
of these features to give my game players a little pleasure when they are watching
their actors' appearance change.
As mesh show/hiding is rather simple to implement on script side, I'm not going to add
any special comments.
Disclamour: This is not a Drag & Drop and ready to go resource. It is because we
have completely different player models with completely different textures on
them.
The gui images you can download are not identical to mine. I made a little change from mine
as I have to use the original in my own game. It will not be difficult for you to understand
what I'm doing even with the changed images.
This is a single player version. The multiplayer version will be released very soon.
This resource is made of three parts. The first one is camera. It has thease features.
1. Rotate around the target
2. Go up and down
3. Zoom in/out
4. Reset
The camera system is simple too. When the customization gui awakes, it finds its
initial position with the player eye vector's reverse vector. And then, everything
is done by some math. If you need to move its initial position higher, you will need to
change this part in function GameConnection::viewFront(%this, %camDistance).
%camAngle = %eyeRotationAngle + mDegToRad(180); //Opposite direction
Next part is mesh show/hide. But I'm going to skip this part.
The last part is material change. At first, we need very simple engine code change.
It is just to save indices. If you're feel comfortable with many global variables,
you don't need this. I just have a tendency not to use global variables too many.
In guiBitmapButtonCtrl.h, add these variables and methods just after
public:
GuiBitmapButtonCtrl();//<HONG> For Cutomization
S32 mCurrentIndex;
S32 mMaxIndex;
inline void setCurrentIndex(S32 idx){mCurrentIndex = idx;}
inline void setMaxIndex(S32 idx){mMaxIndex = idx;}
inline S32 getCurrentIndex(){ return mCurrentIndex;}
inline S32 getMaxIndex() { return mMaxIndex;}
//<@--In GuiBitmapButtonCtrl::GuiBitmapButtonCtrl(), add this.
//<HONG> For Cutomization mCurrentIndex = 0; mMaxIndex = 0; //<@--
Finally, somewhere in the guiBitmapButtonCtrl.cpp, add this.
//<HONG>
ConsoleMethod( GuiBitmapButtonCtrl, setCurrentIndex, void, 3, 3, "(S32 index) - save the current index")
{
S32 index = dAtoi(argv[2]);
object->setCurrentIndex(index);
}
ConsoleMethod( GuiBitmapButtonCtrl, setMaxIndex, void, 3, 3, "(S32 index) - save the max index")
{
S32 index = dAtoi(argv[2]);
object->setMaxIndex(index);
}
ConsoleMethod( GuiBitmapButtonCtrl, getCurrentIndex, S32, 2, 2, "return current index")
{
return object->getCurrentIndex();
}
ConsoleMethod( GuiBitmapButtonCtrl, getMaxIndex, S32, 2, 2, "return max index")
{
return object->getMaxIndex();
}
//<@--Now, download all the related files from here and execute all of them.
Also, download the related gui images from here, and locate them in the art directory. In gui directory, you can find the demo video too.
In these files, server decides what material should be assigned to the clients when it is requested. To do it, server
has four script Objects. In these script objects, neccessary textures and mesh names are saved as strings.
To make it easier to understand, let's suppose a client requests the server to change its mesh from A to B.
When being asked, server tries to find out the mesh B in the meshObjectArray. When it finds it, the server changes every
textures from those of A to B. Now, if clients ask the server to change their texture, server can update them with the
changed texture data.
When doing the material change things, we have to pay special attention to naming convention.
We have to talk to the artists about this too. When we have proper, concisive and coherent naming
convention, we can make this customization process easier.
Maybe you'll wonder why I include 'c0' file so many places like in FirstMarkArray0 = "c0 f11";.
It is a kind of placeholder. It is very small image which is commonly used in many places.
It is because we have undesirable result when we try to insert image in a slot when there are
any empty slots with lower indices. In other words, if we want to add images in slot 3, the slot 0
to 2 must have any images.
Finally, you can test this resource by calling showCustomGui(true);.
Here is some test video.
Enjoy.
#2
03/27/2010 (12:58 pm)
Sweet I took the code and dropped it in as the instructions said and it worked out of the box as advertised. My lawn is now greener and the paint on my house looks as fresh as the first day :)
#4
It's strange. I cannot see the body of this resource either. At first, I thought it was a kind of preview process by the GG as I was able to see the body of it when I tried to edit it.
I became to know it is not the case as someone still can see it now. I don't know why. Maybe we need a help from GG staff.
03/27/2010 (4:33 pm)
@Sean,It's strange. I cannot see the body of this resource either. At first, I thought it was a kind of preview process by the GG as I was able to see the body of it when I tried to edit it.
I became to know it is not the case as someone still can see it now. I don't know why. Maybe we need a help from GG staff.
#5
03/27/2010 (6:19 pm)
i can't see the resorce either.
#6
03/27/2010 (8:05 pm)
Now it works.
#7
03/27/2010 (8:15 pm)
I rewrote the body of my resource and it works fine now.
#8
There doesn't seem to be any .gui files in the zip.
03/27/2010 (9:51 pm)
Sick, looking forward to multiplayer support for this!There doesn't seem to be any .gui files in the zip.
#10
03/28/2010 (12:10 am)
Hmm Thanks thats something I am looking for at first I thought it was not but after watching vidio it is. :P Perfect timeing I would have to say to as I was going to work on that first for my characters.
#11
You're right. I forgot to include the .gui file. I made a new zip file, and uploaded again.
03/28/2010 (2:28 am)
@BrokeAss Games,You're right. I forgot to include the .gui file. I made a new zip file, and uploaded again.
#12
03/31/2010 (3:12 am)
Looking forward to the multiplayer version of this ;)
#13
Thanks for posting this resource.
I tried to implement and play with it a little bit... but honestly I'm confused.
After changes all paths to my shape, I tried to understand the texture name (should be something like h_0_1_0 for Head 2nd layer.. but not sure).
So I try to look how it works and try to get information by echo some variable.
But when I load the gui all the buttons have a max index to 0 and the initialize function (clientCmdInitHeadMaterialGuiValues) is not called.
So how/where do you set the number of skin you have for faces by example?
Is it possible to take some time to review this resource with Gideon? I mean just plug your gui to gideon and give us 1 or 2 texture with the good names. This will clearly help us to use your resource, and as you see people are clearly interested by it.
Thanks in advance,
03/31/2010 (11:49 pm)
Hi,Thanks for posting this resource.
I tried to implement and play with it a little bit... but honestly I'm confused.
After changes all paths to my shape, I tried to understand the texture name (should be something like h_0_1_0 for Head 2nd layer.. but not sure).
So I try to look how it works and try to get information by echo some variable.
But when I load the gui all the buttons have a max index to 0 and the initialize function (clientCmdInitHeadMaterialGuiValues) is not called.
So how/where do you set the number of skin you have for faces by example?
Is it possible to take some time to review this resource with Gideon? I mean just plug your gui to gideon and give us 1 or 2 texture with the good names. This will clearly help us to use your resource, and as you see people are clearly interested by it.
Thanks in advance,
#14
You're right with the material name. Every material name contains four texture names for 4 layers. So, let's say we have h_0_2_0_1. It has meaning like this.
h: this material is for head.
0: first layer texture name. It is the 1st element of 'baseTexArray'
from 'HeadObj', which we define at the top of
the ArrowCustomizationLook.cs. In other words, it is baseTexArray[0].
In my case, it is 'helmet.png'.
Please notice that this is the base texture. It is different from
following 3 mark textures. It is because in the mark textures array we have 'C0', which is a kind of place holder. Basetexture doesn't have it.
2: second layer texture name. It is the 3rd elment of 'FirstMarkArray0', which is FirstMarkArray0[2]. In my case, It is 'b12.png'.
0: third layer texture name. It is the 1st elment of 'SecondMarkArray0'. Please notice I didn't define this for my model. I don't have it at this moment.
1: Fourth layer texture name. Now you'll understand what it means?
When you look into FaceObj, you will find another define block like this.
I just finished writing engine code changes for mutiplayer version of this resource. When I come out with this version, I'm going to use Gideon to give the reader more general understanding.
04/01/2010 (6:06 pm)
@elvince,You're right with the material name. Every material name contains four texture names for 4 layers. So, let's say we have h_0_2_0_1. It has meaning like this.
h: this material is for head.
0: first layer texture name. It is the 1st element of 'baseTexArray'
from 'HeadObj', which we define at the top of
the ArrowCustomizationLook.cs. In other words, it is baseTexArray[0].
In my case, it is 'helmet.png'.
Please notice that this is the base texture. It is different from
following 3 mark textures. It is because in the mark textures array we have 'C0', which is a kind of place holder. Basetexture doesn't have it.
2: second layer texture name. It is the 3rd elment of 'FirstMarkArray0', which is FirstMarkArray0[2]. In my case, It is 'b12.png'.
0: third layer texture name. It is the 1st elment of 'SecondMarkArray0'. Please notice I didn't define this for my model. I don't have it at this moment.
1: Fourth layer texture name. Now you'll understand what it means?
When you look into FaceObj, you will find another define block like this.
FirstMarkArray1 = "c0 f11"; SecondMarkArray1 = "c0 f12"; ThirdMarkArray1 = "c0 f21 f22";Please notice arrays index is 1. It is for second baseTexture. At this moment, every base texture has same kind of marks. But I believe we may need to change marks according to base texure. It is for that purpose. So if we need to define marks for 3rd base texture, we will need to define arrays like this.
FirstMarkArray2 = "c0 f51"; SecondMarkArray2 = "c0 f62"; ThirdMarkArray2 = "c0 f51 f52";I hope this makes sense.
I just finished writing engine code changes for mutiplayer version of this resource. When I come out with this version, I'm going to use Gideon to give the reader more general understanding.
#15
I will wait for your multiplayer implementation before implementing it and see how Gideon is setup :D
I'm sure things will become more straightforward.
04/02/2010 (10:33 am)
Thanks for this clarification.I will wait for your multiplayer implementation before implementing it and see how Gideon is setup :D
I'm sure things will become more straightforward.
#16
Last weekend, I tested multiplayer version of my resource using my model. It worked as I expected. But I saw a small bug too. I think I can handle it without great difficulty. I hope I can post a new resource by this weekend, using Gideon.
04/04/2010 (5:48 pm)
Progress!Last weekend, I tested multiplayer version of my resource using my model. It worked as I expected. But I saw a small bug too. I think I can handle it without great difficulty. I hope I can post a new resource by this weekend, using Gideon.
#18
08/16/2010 (12:51 pm)
Is the resource still available? The links don't seem to work.
#19
the link is not working. if you reposted the code. It would be helpful for all.
09/15/2010 (9:22 am)
Quote:Now, download all the related files from here and execute all of them.
Also, download the related gui images from here, and locate them in the art directory. In gui directory, you can find the demo video too.
the link is not working. if you reposted the code. It would be helpful for all.
#20
Currently my server is down. Please let me know your e-mail addresses to send those files?
10/04/2010 (4:29 am)
@Michael and TigerHeros,Currently my server is down. Please let me know your e-mail addresses to send those files?
Torque Owner Christian S
Oak-Entertainment