GuiObjectView skin
by Banshee · in Torque Game Engine · 07/19/2004 (8:06 am) · 6 replies
Hmm... I have a problem with the guiObjectView resource(http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4063) and its not a mounting problems(thank god).
If you set the skin for an object it requires the exact name for the file(not for the start of it, like, base.josh.jpg, the name of the skin would be josh) and only applys it to the skin you say. But, this is unlike the Player class which when you use .setSkinName it applys it to all the textures and only needs to know the name of it and it will replace the word "base" on all your textures to get the files needed.
Has anyone ever come across this problem and if so how can I fix it?
If you set the skin for an object it requires the exact name for the file(not for the start of it, like, base.josh.jpg, the name of the skin would be josh) and only applys it to the skin you say. But, this is unlike the Player class which when you use .setSkinName it applys it to all the textures and only needs to know the name of it and it will replace the word "base" on all your textures to get the files needed.
Has anyone ever come across this problem and if so how can I fix it?
About the author
#2
Add this into guiObjectView.cc
Add this to guiObjectView.h
With this implemented, whenever you want to change the skin of an object from the script use:
09/02/2004 (10:40 am)
I was just working on a project today with the guiObjectView resource, when i had the same problem. This is the solution i came up with:Add this into guiObjectView.cc
void GuiObjectView::setSkinName(const char* name,const char* skin)
{
StringHandle mSkinNameHandle;
if (skin[0] != '[[628181bf65ecc]]') {
if (skin[0] == StringTagPrefixByte) {
mSkinNameHandle = StringHandle(U32(dAtoi(skin + 1)));
}
else {
mSkinNameHandle = StringHandle(skin);
}
}
else {
mSkinNameHandle = StringHandle();
}
S32 index = mMeshObjects.findMeshByName(name);
if (index != -1)
{
mMeshObjects.mMesh[index].mesh->reSkin(mSkinNameHandle);
}
else
{
Con::printf("Error: Could not find object %s", name);
}
}ConsoleMethod( GuiObjectView, setSkinName, void, 4, 4, "ObjectView.setSkinName(name, skin)" ) {
argc;
GuiObjectView* view = static_cast<GuiObjectView*>( object );
view->setSkinName(argv[2],argv[3]);
}Add this to guiObjectView.h
void setSkinName(const char* name,const char* skin);
With this implemented, whenever you want to change the skin of an object from the script use:
view.setSkinName("player","base");Being "view" the name of the control, "player" the name of the object and "base" the name of the skin.
#3
Before I found this thread, i'm very confused how to set the skin. Great Job!
09/12/2006 (2:39 am)
Great resource ! thanks for the code.Before I found this thread, i'm very confused how to set the skin. Great Job!
#4
04/09/2008 (6:17 am)
This changed a little in TGEA v1.7.0void GuiObjectView::setSkinName(const char* name,const char* skin)
{
//StringHandle mSkinNameHandle;
NetStringHandle mSkinNameHandle;
if (skin[0] != '[[628181bf92fce]]') {
if (skin[0] == StringTagPrefixByte) {
mSkinNameHandle = NetStringHandle(U32(dAtoi(skin + 1)));
}
else {
mSkinNameHandle = NetStringHandle(skin);
}
}
else {
mSkinNameHandle = NetStringHandle();
}
mModel->reSkin(mSkinNameHandle);
}
#5
Hiding Mesh Resource
09/24/2008 (2:11 am)
Would it also be possible to combine it with the "Hiding Mesh" Resource?Hiding Mesh Resource
#6
So the code will become like this.
in guiObjectView.h, declaration will become:
From script, you can use like this.
06/09/2009 (2:30 am)
For TGEA v1.7.1 which is I'm using, you can strip out the const char* name part.So the code will become like this.
void GuiObjectView::setSkinName(const char* skin)
{
//StringHandle mSkinNameHandle;
NetStringHandle mSkinNameHandle;
if (skin[0] != NULL) {
if (skin[0] == StringTagPrefixByte) {
mSkinNameHandle = NetStringHandle(U32(dAtoi(skin + 1)));
}
else {
mSkinNameHandle = NetStringHandle(skin);
}
}
else {
mSkinNameHandle = NetStringHandle();
}
mModel->reSkin(mSkinNameHandle);
}ConsoleMethod( GuiObjectView, setSkinName, void, 3, 3, "ObjectView.setSkinName(skin)" ) {
argc;
GuiObjectView* view = static_cast<GuiObjectView*>( object );
view->setSkinName(argv[2]);
}in guiObjectView.h, declaration will become:
void setSkinName(const char* skin);
From script, you can use like this.
view.setSkinName("skin0");
Associate Kyle Carter