Converting Txscene v.1.0.1 -> v.2
by Josh Butterworth · in Torque X 2D · 03/15/2008 (6:50 am) · 16 replies
I know I'm a little late on this (never needed it before), I know a lot of changes were made in the txscene files included in TX1.5, but is there a way to convert from version 1.0.1? The beta scene converter tool only seems to go to 1.0.1.
#2
When they should look like this:
This is using the ConvertBetaTXScene converter in the TX2.0Pro install directory.
Am I going to have to make these changes manually? (I have a LOT of scene files)
03/18/2008 (7:24 am)
Ok I tried this and changing the XML version does allow the new version of Torque to read my files but that wasn't my main problem, the converter doesnt seem to do anything to correct and update the object definitions, a quick look at the generated txscene files reveals that all my material declarations still look like this:<DefaultEffect name="PlayerShipMaterial">
<BaseTex>data/images/arrow.png</BaseTex>
<Translucent>true</Translucent>
</DefaultEffect>When they should look like this:
<SimpleMaterial name="TanketteCannonMaterial" type="GarageGames.Torque.Materials.SimpleMaterial">
<TextureFilename>data/images/NewTanketteCannon.png</TextureFilename>
<IsTranslucent>true</IsTranslucent>
<IsAdditive>false</IsAdditive>
</SimpleMaterial>This is using the ConvertBetaTXScene converter in the TX2.0Pro install directory.
Am I going to have to make these changes manually? (I have a LOT of scene files)
#3
John K.
03/18/2008 (8:56 am)
Did you run ConvertBetaTXScene before changing manually the version number? The purpose of ConvertBetaTXScene is to make these material definition and structural changes for you. But, if the version number is already incremented, it will probably ignore everything.John K.
#4
The output log on the converter looks like this (I've taken out the backup and save lines)
On that last line, It DOES change all the PhysicsMaterial references to CollisionMaterial ones, but no changes at all to the Material data.
Looking at the source for the converter, I think I must be using the wrong version because it doesnt seem to be looking for the material elements...but this is what was in my C:\Program Files\GarageGames\Torque X 2.0 Pro\v2.0.0.0\Tools\ Directory
03/18/2008 (9:39 am)
It was before, but I just went and changed them all back to 1.0.1 and tried again, same thing, no changes to the materials.The output log on the converter looks like this (I've taken out the backup and save lines)
Found AnimatedSprite with collision component. Found AnimatedSprite with physics component. Found StaticSprite with collision component. Found StaticSprite with physics component. Found StaticSprite with collision component. Found StaticSprite with physics component. Found StaticSprite with collision component. Found StaticSprite with physics component. Found StaticSprite with collision component. Found StaticSprite with physics component. Found StaticSprite with collision component. Found StaticSprite with physics component. Found AnimatedSprite with collision component. Found AnimatedSprite with physics component. Found AnimatedSprite with collision component. Found AnimatedSprite with physics component. Found AnimatedSprite with physics component. Found AnimatedSprite with collision component. Found AnimatedSprite with physics component. Found AnimatedSprite with collision component. Found AnimatedSprite with physics component. Found AnimatedSprite with collision component. Found AnimatedSprite with physics component. Replacing all instances of T2DPhysicsMaterial with T2DCollisionMaterial.
On that last line, It DOES change all the PhysicsMaterial references to CollisionMaterial ones, but no changes at all to the Material data.
Looking at the source for the converter, I think I must be using the wrong version because it doesnt seem to be looking for the material elements...but this is what was in my C:\Program Files\GarageGames\Torque X 2.0 Pro\v2.0.0.0\Tools\ Directory
#5
John K.
03/18/2008 (10:44 pm)
Hmmm... Should be the right one. Would you mind emailing the .txscene file to me? Maybe I can see what's going on by examining the file.John K.
#6
03/19/2008 (2:39 am)
Thanks John, I've sent the file.
#7
John K.
03/19/2008 (8:26 am)
Josh, just received the email. I'll take a look and see what's going on.John K.
#8
John K.
03/19/2008 (4:33 pm)
Josh, it looks like you're right. I don't see the conversion code in there either, since I thought it was added back in 1.5. I'll take a look and see if it can be added in pretty easily. If so, I'll just send you a new .cs file for now and then see that it works its way into the next release.John K.
#9
www.envygames.com/share/ConvertBetaTXSCENE.exe
www.envygames.com/share/ConvertScene.txt (remember to rename the 'txt' to '.cs' at the end)
John K.
03/19/2008 (5:44 pm)
Okay, I added some code to the ConvertScene.cs file and built a new ConvertBetaTXSCENE.exe file that now converts the old material definitions to the new simpleeffect format. I haven't had time to really test it out, so please let me know how it works out, or if more changes are necessary. You can download the relevant files from here...www.envygames.com/share/ConvertBetaTXSCENE.exe
www.envygames.com/share/ConvertScene.txt (remember to rename the 'txt' to '.cs' at the end)
John K.
#10
This one works a lot better, there's a couple of tags that still need fixing (e.g. I think Translucent is now IsTranslucent), but I see how you've done it so I should be able to add those myself now.
Thanks a lot for your help.
03/20/2008 (3:43 am)
Hi John, thanks for that, no idea how Ive ended up with an old version of the converter. This one works a lot better, there's a couple of tags that still need fixing (e.g. I think Translucent is now IsTranslucent), but I see how you've done it so I should be able to add those myself now.
Thanks a lot for your help.
#11
John K.
03/20/2008 (8:50 am)
Again, for clarification. You did not 'end up with the old converter'. Rather, the converter was never updated. I made these code changes yesterday in response to your post. I'll see that they make it into the next release of Torque X. In my rush, I probably missed a few tags. I can add the IsTranslucent fix - are there any others that you spotted? Thanks...John K.
#12
Then theres the animations (dont know if the old method still works here):
OLD:
NEW:
03/20/2008 (9:30 am)
IsAdditive is the other basic one.Then theres the animations (dont know if the old method still works here):
OLD:
<DefaultEffect name="L1_E3Material">
<BaseTex>data/images/enemies/L1/L1_E3.png</BaseTex>
<Translucent>true</Translucent>
</DefaultEffect>
<AnimationData name="L1_E3AnimationData">
<Material nameRef="L1_E3Material" />
<AnimationFrames>0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20</AnimationFrames>
<CellCountX>5</CellCountX>
<CellCountY>5</CellCountY>
<CellWidth>64</CellWidth>
<CellHeight>64</CellHeight>
<AnimationDuration>1</AnimationDuration>
<AnimationCycle>true</AnimationCycle>
</AnimationData>NEW:
<SimpleMaterial name="propellerMaterial" type="GarageGames.Torque.Materials.SimpleMaterial">
<TextureFilename>data/images/propeller.png</TextureFilename>
<IsTranslucent>true</IsTranslucent>
<IsAdditive>false</IsAdditive>
<TextureDivider type="GarageGames.Torque.Materials.CellCountDivider">
<CellCountX>3</CellCountX>
<CellCountY>1</CellCountY>
</TextureDivider>
</SimpleMaterial>
<AnimationData name="propellerAnimationData">
<Material nameRef="propellerMaterial" />
<AnimationDuration>0.3</AnimationDuration>
<AnimationCycle>true</AnimationCycle>
</AnimationData>
#13
element, and the .txscene files should define their schema version too.
Then for each XSD version you create an XSLT that knows how to translate from the old to the new. Now you have a way to continuously refine the schema with a clear upgrade path over time.
eg:
*.txscene file v1.0 --> schema def txscene_1_0.XSD
*.txscene file v2.0 --> schema def txscene_2_0.XSD
upgrade_1_0_2_0.XSLT converts from v1.0 to v2.0
Also, assuming the XSD exists for all the various file types with appropriate comments, when TorqueX installs it just needs to drop the files in the correct location and setup the associations and you can have full intelli-sense completion for all the various file types (like .txscene) in Visual Studio, just like you do for web.config in an ASP.Net application.
03/20/2008 (1:19 pm)
Why wouldn't the tool use an XSLT to do this? The XSD should define a version attribute on the Then for each XSD version you create an XSLT that knows how to translate from the old to the new. Now you have a way to continuously refine the schema with a clear upgrade path over time.
eg:
*.txscene file v1.0 --> schema def txscene_1_0.XSD
*.txscene file v2.0 --> schema def txscene_2_0.XSD
upgrade_1_0_2_0.XSLT converts from v1.0 to v2.0
Also, assuming the XSD exists for all the various file types with appropriate comments, when TorqueX installs it just needs to drop the files in the correct location and setup the associations and you can have full intelli-sense completion for all the various file types (like .txscene) in Visual Studio, just like you do for web.config in an ASP.Net application.
#14
If anyone else needs it, I've made a ConvertScene.cs that now changes all the animation information over into the new format as well (seems to convert everything vital now). Just post here if it's needed.
03/25/2008 (5:00 am)
I agree Russell, a Schema based system would be very helpful in a lot of ways.If anyone else needs it, I've made a ConvertScene.cs that now changes all the animation information over into the new format as well (seems to convert everything vital now). Just post here if it's needed.
#15
John K.
03/25/2008 (8:10 pm)
Josh, does your version add anything more than the IsAdditive changes above. I'm updating the converter code in the Torque X master code base to capture these updates.John K.
#16
(sorry it's a bit rough)
www.grassrootsgames.co.uk/filesforever/ConvertScene.cs
03/26/2008 (12:33 pm)
Yeah it adds a few other things, namely it does all the animation conversions I described above.(sorry it's a bit rough)
www.grassrootsgames.co.uk/filesforever/ConvertScene.cs
Torque Owner Sean Dinwiddie