Updating the Plastic Gem #3 to T3D version 3
by JesseL · in Torque 3D Professional · 11/01/2013 (11:37 am) · 11 replies
Hello and Welcome Fellow Torque3D Team Mates,
I am working on porting Plastic Gem #3 (Animation GUI) to the new version of T3D. I noticed that after the port I had an issue. My editor tabs went missing. (I don't personally need them for anything I have the locations memorized) but I would like to understand what I did to make them disappear. I have zipped up the engine change files and attached them to this post. Any assistance would be greatly appreciated. Thank you.
www.pyrotronics-games.com/RevivalPG3EngineChange.zip
I am working on porting Plastic Gem #3 (Animation GUI) to the new version of T3D. I noticed that after the port I had an issue. My editor tabs went missing. (I don't personally need them for anything I have the locations memorized) but I would like to understand what I did to make them disappear. I have zipped up the engine change files and attached them to this post. Any assistance would be greatly appreciated. Thank you.
www.pyrotronics-games.com/RevivalPG3EngineChange.zip
About the author
I just realized that if I wanted to create a cat that caught on fire and ran up a telephone pole and then burst into a blue waterfall. That wouldn't be to hard!
#2


I did not step through it yet, I made all of the changes at once and cleaned up the engine error messages until it worked. I'm fairly busy but I'll try to do a rundown here:
Source/GFX/gfxDrawUtil.h,
I had to add a GFXStateBlockRef named mBitmapStretchRotated.
I had to add the drawBitmapStretchRotated function
Sourece/GFX/gfxDrawUtil.cpp,
I put the //DrawBitmapStretchRotated description at the top of _setupStateBlocks() member function
In source/Materials/materiaList.h and materiaList.cpp:
I was using Faust Logics AFX changes to allow the ability to animate the texture. (I'm not sure if the stock materiaList.h and materiaList.cpp supports the functionality anymore)
In source/gui/core/guiControl.h::
I had to modify how the resources variables go put in, (IE their location into the private, protected, public sections since those were moved around and the original instructions don't work anymore (order wise). I don't remember having any additional issues though.
In source/gui/core/guiControl.cpp::
I added the initializers to the Constructor, I created the animation group and the three types Alpha, Color, UnitClip. I added the getRealClip, changed renderChildControls. I commented out the DefineEngineMethod (getRoot, and getCenter) to use the ConsoleMethods you made. I could have rewritten those but like I said originally I was in a hurry. Then at the bottom of the file I added the member functions definitions as explained in the tutorial.
In addition I had to modify how the guiPlasticBitmapCtrl.h and .cc worked to fit the new structure of the T3D. I don't remember since I don't have the original files to do a diff on.
I hope that helps.
11/05/2013 (10:18 am)
Pictures:

I did not step through it yet, I made all of the changes at once and cleaned up the engine error messages until it worked. I'm fairly busy but I'll try to do a rundown here:
Source/GFX/gfxDrawUtil.h,
I had to add a GFXStateBlockRef named mBitmapStretchRotated.
I had to add the drawBitmapStretchRotated function
Sourece/GFX/gfxDrawUtil.cpp,
I put the //DrawBitmapStretchRotated description at the top of _setupStateBlocks() member function
GFXStateBlockDesc bitmapStretchRotated; bitmapStretchRotated.setCullMode(GFXCullNone); bitmapStretchRotated.setZReadWrite(false); bitmapStretchRotated.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha); bitmapStretchRotated.samplersDefined = true; bitmapStretchRotated.samplers[0].textureColorOp = GFXTOPModulate; bitmapStretchRotated.samplers[1].textureColorOp = GFXTOPDisable; mBitmapStretchRotated = GFX->createStateBlock(bitmapStretchRotated);(I don't know if that messed up anything)
In source/Materials/materiaList.h and materiaList.cpp:
I was using Faust Logics AFX changes to allow the ability to animate the texture. (I'm not sure if the stock materiaList.h and materiaList.cpp supports the functionality anymore)
In source/gui/core/guiControl.h::
I had to modify how the resources variables go put in, (IE their location into the private, protected, public sections since those were moved around and the original instructions don't work anymore (order wise). I don't remember having any additional issues though.
In source/gui/core/guiControl.cpp::
I added the initializers to the Constructor, I created the animation group and the three types Alpha, Color, UnitClip. I added the getRealClip, changed renderChildControls. I commented out the DefineEngineMethod (getRoot, and getCenter) to use the ConsoleMethods you made. I could have rewritten those but like I said originally I was in a hurry. Then at the bottom of the file I added the member functions definitions as explained in the tutorial.
In addition I had to modify how the guiPlasticBitmapCtrl.h and .cc worked to fit the new structure of the T3D. I don't remember since I don't have the original files to do a diff on.
I hope that helps.
#3
I made the materialist.cpp and materialist.h changes and those left the tabs. I'll keep going till I figure out which modification did it.
11/08/2013 (2:01 pm)
Ok, I had a moment,I made the materialist.cpp and materialist.h changes and those left the tabs. I'll keep going till I figure out which modification did it.
#4
11/08/2013 (2:07 pm)
Ok, Just did the gfxDrawUtil.cpp and gfxDrawUtil.h, with the materialist changes everything is still ok.
#5
11/08/2013 (2:08 pm)
doing the guiControl to h. first.
#6
All that's left is to add the:
animation control defaults
the animation group
getRealClip method
and rewrite the renderChildControls method
11/08/2013 (2:23 pm)
ok all of the guiControl.h settings didn't change it. I added the class animation constructor deconstructor and methods and commented out the default getRoot and getCenter defineEngineMethods. and it is still working.All that's left is to add the:
animation control defaults
the animation group
getRealClip method
and rewrite the renderChildControls method
#7
OLD working
NEW not working
11/08/2013 (2:30 pm)
ok I made all of the changes except the renderChildControls method:OLD working
void GuiControl::renderChildControls(Point2I offset, const RectI &updateRect)
{
// Save the current clip rect
// so we can restore it at the end of this method.
RectI savedClipRect = GFX->getClipRect();
// offset is the upper-left corner of this control in screen coordinates
// updateRect is the intersection rectangle in screen coords of the control
// hierarchy. This can be set as the clip rectangle in most cases.
RectI clipRect = updateRect;
iterator i;
for(i = begin(); i != end(); i++)
{
GuiControl *ctrl = static_cast<GuiControl *>(*i);
if (ctrl->mVisible)
{
Point2I childPosition = offset + ctrl->getPosition();
RectI childClip(childPosition, ctrl->getExtent() + Point2I(1,1));
if (childClip.intersect(clipRect))
{
GFX->setClipRect( childClip );
GFX->setStateBlock(mDefaultGuiSB);
ctrl->onRender(childPosition, childClip);
}
}
}
// Restore the clip rect to what it was at the start
// of this method.
GFX->setClipRect( savedClipRect );
}NEW not working
void GuiControl::renderChildControls(Point2I offset, const RectI &updateRect)
{
// offset is the upper-left corner of this control in screen coordinates
// updateRect is the intersection rectangle in screen coords of the control
// hierarchy. This can be set as the clip rectangle in most cases.
// move this into loop...
//RectI clipRect = updateRect;
iterator i;
for(i = begin(); i != end(); i++)
{
GuiControl *ctrl = static_cast<GuiControl *>(*i);
if (ctrl->mVisible)
{
ctrl->updateAnimation();
Point2I childPosition;
RectI childClip;
RectI clipRect;
bool draw;
childPosition = offset + ctrl->getPosition();
if (ctrl->mUnitClip.point.x == 0 && ctrl->mUnitClip.point.y == 0 &&
mUnitClip.extent.x == 1 && ctrl->mUnitClip.extent.y == 1)
{
// no unit clipping...
draw = true;
clipRect = updateRect;
}
else
{
// unit clipping...
RectI realClip = getRealClip(ctrl->mUnitClip,childPosition,ctrl->getExtent());
clipRect = updateRect;
draw = clipRect.intersect(realClip);
}
childClip.point = childPosition;
childClip.extent = ctrl->getExtent();
if (draw && childClip.intersect(clipRect))
{
GFX->setClipRect( childClip );
GFX->setStateBlock(mDefaultGuiSB); // <-----NEW
ctrl->onRender(childPosition, childClip);
}
}
}
}
// <-JJL END
#8
and restored at the bottom
Now everything appears to be working. I don't completely understand what is happening here to make that fix it.
11/08/2013 (2:40 pm)
I took a guess, and saved at the topRectI savedClipRect = GFX->getClipRect();
and restored at the bottom
GFX->setClipRect( savedClipRect );
Now everything appears to be working. I don't completely understand what is happening here to make that fix it.
#9
Looks like all I have to do is procrastinate a few weeks and you will figure it all out on your own! Good work!
I think you just found a general weakness in the Gem and fixed it. That code might not have been *needed* before, but it is likely the right thing to do anyway. One of the features of the Gem is to animate "clipping". The code you added will not break things.
Thanks for sharing, keep up the good work!
11/16/2013 (10:07 am)
Jesse,Looks like all I have to do is procrastinate a few weeks and you will figure it all out on your own! Good work!
I think you just found a general weakness in the Gem and fixed it. That code might not have been *needed* before, but it is likely the right thing to do anyway. One of the features of the Gem is to animate "clipping". The code you added will not break things.
Thanks for sharing, keep up the good work!
#10
11/16/2013 (10:17 am)
ok so do you feel comfortable with me making this into a resource and presenting it to the community as a request to revive the Plastic Gems? and what happened to your tool you were selling, (Ease tool), where did that go?
#11
I am totally comfortable with you making this into a resource. We have updated most of our gems as the engine sources have changed over the years. We are happy also to share with you any changes we have made to any other gems as well.
The Ease gem including the Ease GUI control have always been free. Garage Games stopped selling our tool the Tweaker a while ago, though I am unsure why. Our current plan is to release that tool for *free* to the community, but just haven't gotten around to it yet. Perhaps you would be interested in preparing that as a community resource as well? Email me if you are interested as I might miss it if you just reply to this thread here.
Thanks!
01/16/2014 (7:22 am)
Sorry for the late reply - holidays are always tough.I am totally comfortable with you making this into a resource. We have updated most of our gems as the engine sources have changed over the years. We are happy also to share with you any changes we have made to any other gems as well.
The Ease gem including the Ease GUI control have always been free. Garage Games stopped selling our tool the Tweaker a while ago, though I am unsure why. Our current plan is to release that tool for *free* to the community, but just haven't gotten around to it yet. Perhaps you would be interested in preparing that as a community resource as well? Email me if you are interested as I might miss it if you just reply to this thread here.
Thanks!
Associate Paul Dana
First of all thank you for updating this Plastic Gem.
Can you give us a little more information about what you mean by "editor tabs". It's a bit weird that adding animation to the GUI controls would make that happen. I will not have a chance to download and look at your engine changes for a few days at least. Can you give us any more information on which changes cause the issue? Did you add all changes before testing?