Shape3ds - 3ds shapes for TGE
by Matt Fairfax · 04/08/2004 (10:57 am) · 68 comments
Download Code File
Here is a precompiled version (based off 7/30/04 HEAD).
Usage:
* Install the code using the directions below
* Copy a .3ds file and any corresponding textures into your \data\shapes\ folder
* Open up the mission of your choice and hit F11 for the Mission Editor, then F4 for the World Editor Creator, drill
down into Static Objects and drill down into the path of your .3ds file. Click on it and it should be added to the
mission!
Important Notes:
* Texture names are limited to 8.3 (it is an old format)
* You *must* assign a material to any face that you want to be rendered
* If a texture is not assigned to a material then the diffuse color is used to color the material
* Transparency can be used with png textures
* To add a collision mesh simply start the name of the object with "Col-" (i.e. Col-1). There are no hard limits
on the number of these you can use.
* The collision meshes *must* convex (no creases) and *must* be closed (no holes)
* If the mesh is rendering oddly try resetting the pivot points to their default locations
Useful Rendering Modes:
* %obj.showMesh(bool) - hides/reveals the mesh
* %obj.showCollision(bool) - renders/hides the collision meshes
* %obj.showEdges(bool) - renders/hides the edges (green = convex or coplanar, blue = not shared, red = concave)
* %obj.showNormals(bool) - render the vertex normals
Future:
* Load collision meshes into a bsp for much faster results
* Basic animation support
* Make use of ResourceManager properly
* Lighting/shadowing properly
Installation:
* Copy shape3ds.cc/.h into anywhere in the engine folder (like TGE\engine\game\)
* Add them to your project/solution in the IDE of your choice
* Add the lines below to your code
Credits:
* Melv May
* Tim Gift
Author:
Matthew Fairfax
matt@rustycode.com
(the line numbers are based off version 1.2 code but this code should work with older versions)
+------------------------------------------------------+
in collision\convex.h
-- line 64 (in enum ConvexType)
change
to
+------------------------------------------------------+
in /example/common/editor/ObjectBuilderGui.gui
-- line 461
add
+------------------------------------------------------+
in /example/common/editor/EditorGui.cs
-- line 1130 (in function Creator::init( %this ))
add
-- line 1270
add
Here is a precompiled version (based off 7/30/04 HEAD).
Usage:
* Install the code using the directions below
* Copy a .3ds file and any corresponding textures into your \data\shapes\ folder
* Open up the mission of your choice and hit F11 for the Mission Editor, then F4 for the World Editor Creator, drill
down into Static Objects and drill down into the path of your .3ds file. Click on it and it should be added to the
mission!
Important Notes:
* Texture names are limited to 8.3 (it is an old format)
* You *must* assign a material to any face that you want to be rendered
* If a texture is not assigned to a material then the diffuse color is used to color the material
* Transparency can be used with png textures
* To add a collision mesh simply start the name of the object with "Col-" (i.e. Col-1). There are no hard limits
on the number of these you can use.
* The collision meshes *must* convex (no creases) and *must* be closed (no holes)
* If the mesh is rendering oddly try resetting the pivot points to their default locations
Useful Rendering Modes:
* %obj.showMesh(bool) - hides/reveals the mesh
* %obj.showCollision(bool) - renders/hides the collision meshes
* %obj.showEdges(bool) - renders/hides the edges (green = convex or coplanar, blue = not shared, red = concave)
* %obj.showNormals(bool) - render the vertex normals
Future:
* Load collision meshes into a bsp for much faster results
* Basic animation support
* Make use of ResourceManager properly
* Lighting/shadowing properly
Installation:
* Copy shape3ds.cc/.h into anywhere in the engine folder (like TGE\engine\game\)
* Add them to your project/solution in the IDE of your choice
* Add the lines below to your code
Credits:
* Melv May
* Tim Gift
Author:
Matthew Fairfax
matt@rustycode.com
(the line numbers are based off version 1.2 code but this code should work with older versions)
+------------------------------------------------------+
in collision\convex.h
-- line 64 (in enum ConvexType)
change
TSStaticConvexType };
to
TSStaticConvexType, Shape3dsConvexType };
+------------------------------------------------------+
in /example/common/editor/ObjectBuilderGui.gui
-- line 461
add
function ObjectBuilderGui::buildShape3ds(%this)
{
%this.className = "Shape3ds";
%this.process();
}+------------------------------------------------------+
in /example/common/editor/EditorGui.cs
-- line 1130 (in function Creator::init( %this ))
add
// walk all the statics and add them to the correct group
%staticId = "";
%file = findFirstFile( "*.3ds" );
while( %file !$= "" )
{
// Determine which group to put the file in
// and build the group heirarchy as we go
%split = strreplace(%file, "/", " ");
%dirCount = getWordCount(%split)-1;
%parentId = %base;
for(%i=0; %i<%dirCount; %i++)
{
%parent = getWords(%split, 0, %i);
// if the group doesn't exist create it
if ( !%staticId[%parent] )
%staticId[%parent] = %this.addGroup( %parentId, getWord(%split, %i));
%parentId = %staticId[%parent];
}
// Add the file to the group
%create = "create3ds(\"" @ %file @ "\");";
%this.addItem( %parentId, fileBase( %file ), %create );
%file = findNextFile( "*.3ds" );
}-- line 1270
add
function create3ds(%name)
{
%obj = new Shape3ds()
{
position = "0 0 0";
rotation = "0 0 0";
shapeFile = %name;
};
return(%obj);
}About the author
By day, I am a senior programmer at The Playforge, makers of the popular iPhone game Zombie Farm. By night, I work on my own games as Night Heron Games. I am an ex-GarageGames employee who helped ship TGE, TGEA, Torque 3D, and Constructor.
#2
04/08/2004 (2:40 pm)
Wow Matt, that was quick! Thanks a lot for posting this. Looks like I am going to have some new stuff to play with this weekend.
#3
04/08/2004 (5:06 pm)
Great job Matthew!
#4
04/08/2004 (5:44 pm)
YES! Well done :)
#5
04/10/2004 (8:26 am)
This is awesome, I know it will help me quite a bit. :)
#6
The error message is Declaration Syntax Error on the 'Side'.
Any guesses as to what is going on here?
(I'm compiling on a windows XP machine using CW 9.2.)
04/12/2004 (2:58 pm)
I'm getting a compile error when I try to compile shape3ds.cc. The error is on line 506:if (whereAt == PlaneF::Side::Front)
The error message is Declaration Syntax Error on the 'Side'.
Any guesses as to what is going on here?
(I'm compiling on a windows XP machine using CW 9.2.)
#7
04/12/2004 (3:53 pm)
Got this compiling by hardcoding in a '1'. Kludgy, but it works. Great resource. Looking forward to the things on your future list. Any thoughts about submitting this to be added to head? Thanks.
#8
Yeah...a 1 would work =) Maybe some kinda include snafu with CW? Or a namespace issue with the compiler? No biggy though =)
There are a few bugs I have found that need to be fixed (doh! can anyone say memory leak?) and a few more features I'd like to add in time (better collision, using the resource manager, read/write, some more console funcs, scripting callback hooks, limited animation, better/smarter texture loading) before I would suggest adding this to HEAD.
There has been a great amount of debate in the community on the value of opening up Torque to different file formats vs converting other formats to dts/dif. Obviously, you can see which side I am on =) Really, this resource wasn't only about adding .3ds support. It was also meant to demonstrate how to bring other file formats into TGE. I think .dts is a great format...it just isn't always suitable for the needs at hand (can be overkill at times). I also think there is great value in being able to quickly and easily use art assets found in other places or in other games, if for nothing else but placehodler art. The easier it is on an artist to bring their current skills and assets into TGE the better. The easier it is on a programmer to find and use placeholder art the better.
04/13/2004 (4:53 am)
Steve,Yeah...a 1 would work =) Maybe some kinda include snafu with CW? Or a namespace issue with the compiler? No biggy though =)
There are a few bugs I have found that need to be fixed (doh! can anyone say memory leak?) and a few more features I'd like to add in time (better collision, using the resource manager, read/write, some more console funcs, scripting callback hooks, limited animation, better/smarter texture loading) before I would suggest adding this to HEAD.
There has been a great amount of debate in the community on the value of opening up Torque to different file formats vs converting other formats to dts/dif. Obviously, you can see which side I am on =) Really, this resource wasn't only about adding .3ds support. It was also meant to demonstrate how to bring other file formats into TGE. I think .dts is a great format...it just isn't always suitable for the needs at hand (can be overkill at times). I also think there is great value in being able to quickly and easily use art assets found in other places or in other games, if for nothing else but placehodler art. The easier it is on an artist to bring their current skills and assets into TGE the better. The easier it is on a programmer to find and use placeholder art the better.
#9
05/10/2004 (1:50 pm)
Matthew, have you had any time to work on the collision handling ??
#10
Got it working in just a few minutes. Exported from AutoCAD real easy using AutoLISP. Will try the standard exporter later.
06/28/2004 (7:39 pm)
Nice job Matthew!!!!Got it working in just a few minutes. Exported from AutoCAD real easy using AutoLISP. Will try the standard exporter later.
#11
06/28/2004 (7:45 pm)
One question though...how do you add the collision? Would this be when exporting from Max?
#12
Max isn't required to create the collision meshes. Any app that allows you to name the objects in the .3ds will suffice.
07/02/2004 (9:25 am)
Quote:
* To add a collision mesh simply start the name of the object with "Col-" (i.e. Col-1). There are no hard limits
on the number of these you can use.
* The collision meshes *must* convex (no creases) and *must* be closed (no holes)
Max isn't required to create the collision meshes. Any app that allows you to name the objects in the .3ds will suffice.
#13
07/02/2004 (10:12 am)
ok, I looked at your code more closely and that makes sense. What app did you use that allows you to name the object?
#14
However, I just looked and you can use Milkshape ($25). I would also be highly surprised if Blender (free) didn't support it. I have also heard tell of Wings3D.
07/02/2004 (10:29 am)
I was using max =)However, I just looked and you can use Milkshape ($25). I would also be highly surprised if Blender (free) didn't support it. I have also heard tell of Wings3D.
#15
07/02/2004 (10:30 am)
Btw...I am still planning on beefing up the collision code for this soon. I have also added proper resource handling (so that it can be read in and out of a .zip file).
#16
Hey Matthew, sorry for not getting back at you, been swamped lately!! The map2max app works great(with 2 tiny flaws, I'll mail you a description later), I can't thank you enough!!!
A question regarding this (shape3DS) resource: When I tried it I noticed it didn't support lights (didn't seem to recieve any light nor cast any shadows). I looked how .dts does this but haven't had time to properly learn how these things work so I am way off at every atempt of fixing this on my own.
Any chance that this feature might get included in the future??
I am totally addicted to lights since adding the SG Light pack by Mr.Kabus, realizing just how much lights does for the athmospere of a game.
Anyhoo, thanks again Matt, you are truly a godsend!
[EDIT]
Duh, when I say "didn't seem to recieve any light", I naturally mean that it doesn't conform to the general lighting model of TGE or the features added by the SG Lightpack.
Writing without thinking!!
[/EDIT]
07/02/2004 (8:43 pm)
@Desmond: I used Caligari gameSpace to export to .3DS, worked great (if my memory serves me right I did collision aswell)..Hey Matthew, sorry for not getting back at you, been swamped lately!! The map2max app works great(with 2 tiny flaws, I'll mail you a description later), I can't thank you enough!!!
A question regarding this (shape3DS) resource: When I tried it I noticed it didn't support lights (didn't seem to recieve any light nor cast any shadows). I looked how .dts does this but haven't had time to properly learn how these things work so I am way off at every atempt of fixing this on my own.
Any chance that this feature might get included in the future??
I am totally addicted to lights since adding the SG Light pack by Mr.Kabus, realizing just how much lights does for the athmospere of a game.
Anyhoo, thanks again Matt, you are truly a godsend!
[EDIT]
Duh, when I say "didn't seem to recieve any light", I naturally mean that it doesn't conform to the general lighting model of TGE or the features added by the SG Lightpack.
Writing without thinking!!
[/EDIT]
#17
07/02/2004 (9:40 pm)
I am going to address lighting in the future...however, I thought I saw John mention that his lighting pack worked for my resource? I could be wrong though...I haven't yet purchased the lighting pack myself (next week).
#18
I.E.
* Load collision meshes into a bsp for much faster results
* Basic animation support
* Make use of ResourceManager properly
* Lighting/shadowing properly
Thanks again for this contribution.
08/04/2004 (4:05 pm)
Excellent, this is a great contribution. Do you have any idea when the other features will be completed? I.E.
* Load collision meshes into a bsp for much faster results
* Basic animation support
* Make use of ResourceManager properly
* Lighting/shadowing properly
Thanks again for this contribution.
#19
Thanks in advance,
Sylker Teles.
08/17/2004 (1:46 pm)
When I try to export more than 9 collision objects the follow error appear: "Assertion failed: too many details for mesh". I'm using 3D Max 5.Thanks in advance,
Sylker Teles.
#20
08/17/2004 (4:33 pm)
Are you exporting to a .3ds or to a .dts?
Torque Owner Jorgen Ewelonn
Keep up the good work !!