Player object "setTransform" seems to ignore Z axis setting
by Norv Brooks · in Technical Issues · 08/29/2006 (10:27 am) · 5 replies
Using the code from "levelLoader.cs" in the Game Programmer's Guide to Torque" I'm trying to create to NPC characters using the Player class. The 2 npc's appear on screen but half of their bodies is below ground. (see below). It doesn't seem to matter if I change the "z" element in "setTransform"; it just appears to ignore the setting. I've tried several different things, but nothing seems to work. Looked through "player.cc" line by line but couldn't find anything, nor searching the forums didn't find anything. I'm probably missing something very simple.

exerpt from the "layOutNPC" function in "levelLoader.cs":
exerpt from "console" log showing echo's from above code:
Thanks for any help.
Norv

//-----------------------------------------------------------------------------
// NPC datablocks
//------------------------------------------------------------------------------
// Female Camper datablock
datablock PlayerData(FemaleCamper : PlayerBody)
{
shapeFile = "~/data/shapes/player/ChilaoFlats/CFcamperWoman.dts";
scale = "0.12 0.12 0.12";
};
// Male Camper datablock
datablock PlayerData(MaleCamper : PlayerBody)
{
shapeFile = "~/data/shapes/player/ChilaoFlats/CFcamper.dts";
scale = "0.12 0.12 0.12";
};exerpt from the "layOutNPC" function in "levelLoader.cs":
switch$($NPCCLASS[%blockType])
{
//2a
case MELANIE:
echo("Loading NPC");
%dblock = "FemaleCamper";
%rot = "0 0 1 .7501";
%name = "Melanie";
%player = new Player(CFfemaleCamper)
{
datablock = %dblock;
position = "-30.5281 -183.094 48.5536";
rotation = "0 0 -1 25.2101";
shapeName = %name;
//shapeName = "~/data/shapes/player/ChilaoFlats/CFcamperWoman.dts";
};
%curPos = %player.getPosition();
%posZ = getWord(%curPos,2);
%adjustedElevation = %posZ + $npcCentroidOffset;
echo("%adjustedElevation = ",%adjustedElevation," %posZ = ",%posZ);
%curPos = setWord(%curPos,2,%adjustedElevation);
serverCMDNPCsetTransform(%player,%curPos);
echo("Melanie 2 - adjusted Transform = ",%player.getTransform());
echo("Melanie Centroid = ",getBoxCenter(%player.getWorldBox()));
npcGroup.add(%player);
case TOM:
%dblock = "MaleCamper";
%rot = "0 0 1 .7501";
%name = "Tom";
%player = new Player(CFMaleCamper)
{
datablock = %dblock;
position = "-32.5281 -183.194 49.0536";
rotation = "0 0 -1 25.2101";
//scale = "1 1 1";
//shapeName = %name;
shapeName = "~/data/shapes/player/ChilaoFlats/CFcamper.dts";
};
%curPos = %player.getPosition();
%posZ = getWord(%curPos,2);
%adjustedElevation = %posZ + $npcCentroidOffset;
echo("%adjustedElevation = ",%adjustedElevation," %posZ = ",%posZ);
%curPos = setWord(%curPos,2,%adjustedElevation);
%player.setTransform(%curPos);
%player.setTransform("-32.5281 -183.194 55.0536 0 0 -1 25.2101");
echo("Tom 2 - adjusted Transform = ",%player.getTransform());
echo("Tom Centroid = ",getBoxCenter(%player.getWorldBox()));
npcGroup.add(%player);
}exerpt from "console" log showing echo's from above code:
Quote://-------------------------------------------------------
// console log exerpt
//------------------------------------------------------
Loading NPC
%adjustedElevation = 58.5536 %posZ = 48.5536
Melanie 2 - adjusted Transform = -30.5281 -183.094 58.5536 0 0 -1 0.439999
Melanie Centroid = -30.5281 -183.094 59.7036
%adjustedElevation = 59.0536 %posZ = 49.0536
Tom 2 - adjusted Transform = -32.5281 -183.194 55.0536 0 0 -0.999986 0.07736
Tom Centroid = -32.5281 -183.194 56.2036
Thanks for any help.
Norv
About the author
#2
Interesting observation. It does appear like the bounding boxes are positioned correctly and the models are to low. I originally set these characters up using the mission editor (see below) and they were fine. So, I'm not sure what may have changed. Any suggestions as to what to check in the model?

Thanks for the help, Paul.
Norv
08/29/2006 (11:07 am)
Interesting observation. It does appear like the bounding boxes are positioned correctly and the models are to low. I originally set these characters up using the mission editor (see below) and they were fine. So, I'm not sure what may have changed. Any suggestions as to what to check in the model?
Thanks for the help, Paul.
Norv
#3
08/29/2006 (11:24 am)
Maybe they need skis?
#4
Ashtara
08/29/2006 (11:30 am)
Make sure you export the dts and then export the dsqs. Make sure the you have the dsqs linked correctly. I just had this problemwith some characters. Also make sure your characters' feet are on line with the bottom of the bounds box. Make sure that you are exporting the bounds box.Ashtara
#5
08/29/2006 (3:11 pm)
I was able to get into Milshape3d and fix the dts/dsq files and it works fine now. Thanks to everyone for your info.
Torque Owner Paul /*Wedge*/ DElia