3D Shapes not working
by Mark Harmer · in Torque Game Builder · 03/11/2006 (12:49 pm) · 7 replies
I know it's something I'm doing wrong, but I can't figure it out. I've tried adding the 3d shape code from the tutorial to the fish game, here's my code:
reinstatedsoldier.dts is in the correct directory, along with with texture and dsq animation files. When I run the game, it doesn't show up - so I use toggleDebugInfo(); on the console, and it display it's bounding box. No errors in the console after I load the game, so I imagine it loaded it correctly. I've also tried commenting out all of the ocean and fish, with a blank white canvas it still doesn't appear.
EDIT: Aligned the above code block.
%soldier = new t2dShape3D() { scenegraph = fishSceneGraph2D; };
%soldier.setShape("./models/reinstatedsoldier.dts");reinstatedsoldier.dts is in the correct directory, along with with texture and dsq animation files. When I run the game, it doesn't show up - so I use toggleDebugInfo(); on the console, and it display it's bounding box. No errors in the console after I load the game, so I imagine it loaded it correctly. I've also tried commenting out all of the ocean and fish, with a blank white canvas it still doesn't appear.
EDIT: Aligned the above code block.
#2
But it still has the same problem, and no errors in the console.
03/11/2006 (1:50 pm)
I added the tilde in, and then I needed to add the /client/ to the path:%soldier = new t2dShape3D() { scenegraph = fishSceneGraph2D; };
%soldier.setShape("~/client/models/reinstatedsoldier.dts");But it still has the same problem, and no errors in the console.
#3
03/13/2006 (3:36 pm)
Does anyone have a suggestion? If not, can someone email their test project that has models working (drivehappy -at- gmail -dot- com)? I can't for the life of me figure out what is causing it not to display.
#4
I'll repost my code tonight when I get home (it's on my home dev box).
03/13/2006 (3:48 pm)
Man I thought I posted this last night--it must not have took.I'll repost my code tonight when I get home (it's on my home dev box).
#5
Maybe check and see if you are in D3D and if you are, try switching over to OpenGL.
I also had to resize the model to get it to the right size...but at least I was able to see it.
Hope this helps a little.
Justin Johnson
03/13/2006 (6:51 pm)
I have an issue where in D3D mode, the model will not show up. Drove me up a wall until I switched over to OpenGL and saw a very small spec in the middle of my screen and realized this was my model.Maybe check and see if you are in D3D and if you are, try switching over to OpenGL.
I also had to resize the model to get it to the right size...but at least I was able to see it.
Hope this helps a little.
Justin Johnson
#6
And the spawn call:
This gave me a nice, animation-playable "blue guy" from the tutorial. Note that I dumped all of the dts, skinning jpg, and .dsq's into their own directory under images called 3dalien.
Also please note that the "class" stuff was for an intermediate build that isn't available to the public yet, testing out the namespace modifications. It may/may not work with the current build, but isn't really needed for what we're purposing here.
03/13/2006 (10:41 pm)
Well, it sounds like you had a different issue, but here is the base code (in all it's glory--not guaranteed to be "best practices with TGB" since I threw this in at the last minute for demo purposes!):new t2dShape3D(EnemyBaseClass)
{
name = "EnemyBaseClass";
isSelectable = false;
canSaveDynamicFields = "1";
enabled = "1";
Visible = "1";
lifetime = "0";
rotation = "0";
autoRotation = "0";
flipX = "0";
flipY = "0";
layer = "0";
group = "0";
worldLimitMode = "OFF";
worldLimitMin = "0 0";
worldLimitMax = "0 0";
worldLimitCallback = "0";
collisionDetectionMode = "POLYGON";
collisionResponseMode = "CLAMP";
collisionActiveSend = "1";
collisionActiveReceive = "1";
collisionPhysicsSend = "1";
collisionPhysicsReceive = "1";
collisionLayers = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31";
collisionGroups = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31";
linearVelocity = "0 0";
minlinearVelocity = "0";
maxLinearVelocity = "10000";
angularVelocity = "0";
minAngularVelocity = "0";
maxAngularVelocity = "10000";
immovable = "1";
constantForce = "0 0";
graviticConstantForce = "0";
forwardOnly = "0";
forceScale = "1";
density = "0.01";
autoMassInertia = "1";
mass = "0.045176";
inertialMoment = "0.0341391";
damping = "0";
friction = "0.3";
restitution = "1";
blendingOn = "1";
srcBlendFactor = "SRC_ALPHA";
dstBlendFactor = "ONE_MINUS_SRC_ALPHA";
blendColor = "1 1 1 1";
mountRotation = "0";
autoMountRotation = "0";
mountID = "123";
mountToID = "0";
mountToNode = "0";
mountOffset = "0 0";
mountForce = "0";
trackRotation = "1";
ownedByMount = "1";
inheritAttributes = "1";
size = "1 1";
};new t2dShape3D(Alien : EnemyBaseClass)
{
name = "Alien";
collisionCallback = "1";
collisionPolyList = "-1.00 -1.00 1.00 -1.00 1.00 1.00 -1.00 1.00";
collisionCircleScale = "1";
collisionPolyScale = "1 1";
collisionCircleSuperscribed = "1";
shapeFileName = "~/data/images/3dalien/alien.dts";
skinName = "player";
};function spawnEnemy(%type, %pos, %name)
{
%obj = new t2dShape3D(%name)
{
sceneGraph = t2dScene;
class = %type;
};
echo("ShapeFile should be: (" @ %type.shapeFileName @ ")");
echo("And just for grins our current class is :(" @ %obj.class @ ")");
// echo("And just for grins our current install Slots are :(" @ %obj.installSlots @ ")");
%obj.setShape(%type.shapeFileName);
// %obj.setSkin("skins", %type.skinName );
%obj.setShapeScale( 1,1.2,1 );
%obj.setSize( 20,40 );
%obj.setCollisionActive(true, true);
%obj.setCollisionPhysics(false, false);
%obj.setCollisionDetection(POLYGON);
%obj.setCollisionResponse(CLAMP);
%obj.setCollisionGroups( $playerGroup SPC $playerProjectileGroup );
%obj.setCollisionCallback(true);
%obj.setCollisionMaxIterations(2);
%obj.setLayer($enemyLayer);
%obj.setGraphGroup($enemyGroup);
%obj.setDamping(".2");
%obj.setPosition(%pos);
%obj.PlayAnimation( root );
%obj.setShapeRotation("0 180 0");
// %obj.setShapeAngularVelocity("0 90 0");
%obj.setDetailLevel(0);
%obj.setDebugOn(5);
}And the spawn call:
spawnEnemy(Alien, "-55, 230", Alien1);
This gave me a nice, animation-playable "blue guy" from the tutorial. Note that I dumped all of the dts, skinning jpg, and .dsq's into their own directory under images called 3dalien.
Also please note that the "class" stuff was for an intermediate build that isn't available to the public yet, testing out the namespace modifications. It may/may not work with the current build, but isn't really needed for what we're purposing here.
#7
03/15/2006 (2:43 pm)
Justin was correct, I had it on D3D and switched to OGL and it works perfectly, probably something that needs to be fixed. Thanks for the code Stephen, I'll play around with it later.
Torque 3D Owner Stephen Zepp
I personally had this issue as well (for the same reason!) and was able to get it working with the following shape directory and path:
"~/data/images/3dalien/alien.dts"
Basically, use the ~ (which tells the code to change the working directory to the allowed root, which is your primary game directory), and then trace down from there.