If you are using the lab machines they are set up to do exports.
If you are using your own machine and you downloaded Blender, you also
need to download and install the exporter.
You can get it here:
Blender To Torque Exporter
Note, if you have not gotten blender yet (It is FREE, you should), it
is downloadable from:
Blender Download Site
We will first just create a simple cone in blender, export it to a DTS file, and then put it in the right place in the Torque directory structure to be able to include it in a game. Note, this first cone will NOT be textured, so it will just be an ugly grey in the torque game.
I can not improve on this tutorial, but I will summarize the steps:
File->export->Torque Shape
Go to general, and select the "Write Shape Script" and "Write TSE Materials" buttons. Click export
You should now have a DTS file ready to be put in Torque.
exec("./cylinder.cs") ;
Make sure that in the game.cs file just about the ~/...GameTestModel directory that you reset the $defaultGame variable to be "GameTestModel". Now start up torque. You should be able to go into Window->World Editor Creator and then in the bottom right panel open up Shapes/Items and see your ClinderItem and click on it to add. If you want to check out why you created the collision mesh, just add a call to onCollision. For example, to delete the cylinder object when the player runs into them, here is the contents of my cylinder.cs file:
datablock StaticShapeData(CylinderItem) { category = "Items"; shapeFile = "~/data/shapes/cylinder/cylinder.dts"; }; function CylinderItem::onCollision(%this, %obj, %col) { if(%col.getClassName() $= "Player") { %obj.delete(); } }Also, rather than place them by hand, you can place them using code with something like the following. The tricky part is getting the Z-coordinate correct!
//----------------------------------------------------------------------------- // Add dropCylinders and spawnClylinder to the AIManager static functions //----------------------------------------------------------------------------- function AIManager::dropCylinders( %this ) { echo("\n\nInside AIMangager::dropCylinders\n\n") ; for (%i = 0 ; %i < 9 ; %i++) %temp = %this.spawnCylinder( i ); echo ("\n\n Called AIManager::startBots\n\n") ; } function AIManager::spawnCylinder( %this , %name ) // %name is an integer, the number of the NPC { %offset = getRandom(-10,10) SPC getRandom(-10,10) SPC 0 ; // %sp1 = pickSpawnPoint() ; %sp1 = "25 -410 65 1 0 0 0" ; // %theSpawnPoint = VectorAdd(pickSpawnPoint(), %offset) ; %theSpawnPoint = VectorAdd(%sp1, %offset) ; %cyl = new StaticShape() { dataBlock = CylinderItem; mass = 10 ; }; MissionCleanup.add( %cyl ); %cyl.setName( %name ); %cyl.setTransform( %theSpawnPoint ); return %cyl; }Only problem is it is an ugly grey, now cool colors/textures, to get those you need to learn how to texture and export with the texture.
Again, I can not improve on this tutorial, but I will summarize the steps:
The export will create a .dts and and .log file. Check out the .log file. The .log file should mention two objects: both the one you textured and the collision cube. Also, a material should be mentioned. Here is a sample log file:
Torque Exporter 0.94 Using blender, version 243 Loaded Preferences. Processing Scene... Cleaning Preference Keys Exporting... Writing shape to '/Users/scottleutenegger/Awork/teach/3821/Blender/simple2\texturedCone.dts'. Processing... > Shape Details > Nodes ^^ Bone [Exp-Catch-Root] (parent -1) > Objects 'Cone' : Standard 'Cube' : Null Standard > Materials yellowGrass > Detail Levels Detail-1 (size : 32) Collision-1 (size : -1) Smallest : Detail-1 (size : 32) > Internal Sequences Writing out DTS... Done. Finished.
You have created the files you need but unless you have "showtool" you can not see the textured model. Again you need to put the file into Torque. This is pretty much the same as before, but this time you also need to put the texture file in the directory as well as the .dts file. Try it, go into world creator, and create some textured objects in your game.