Objects disapearing when actually running game
by Ian Omroth Hardingham · in Torque Game Builder · 01/02/2008 (7:13 am) · 12 replies
Hey guys, pretty sure this is going to have a simple answer.
I design a simple level with the editor, but when I actually run the game any objects outside of the camera view have been deleted, and don't show up when I move the camera in-game.
Any ideas?
Cheers,
Ian
I design a simple level with the editor, but when I actually run the game any objects outside of the camera view have been deleted, and don't show up when I move the camera in-game.
Any ideas?
Cheers,
Ian
About the author
Designer and lead programmer on Frozen Synapse, Frozen Endzone, and Determinance. Co-owner of Mode 7 Games.
#2
That's not the problem - I haven't changed the "world limits mode".
The objects aren't getting deleted; they're still available to call through the console. But they just aren't rendering.
Here's an example of the kind of object:
And the definition of blueDotImageMap:
Any help would be hugely appreciated.
01/28/2008 (2:29 pm)
Hi Patrick.That's not the problem - I haven't changed the "world limits mode".
The objects aren't getting deleted; they're still available to call through the console. But they just aren't rendering.
Here's an example of the kind of object:
new Wall(Bergy) {
imageMap = "blueDotImageMap";
frame = "0";
canSaveDynamicFields = "1";
Position = "-196.618 938.326";
size = "1466.765 226.651";
WorldLimitMin = "-18531.180 -9547.988";
WorldLimitMax = "18137.945 9973.705";
CollisionActiveSend = "1";
CollisionActiveReceive = "1";
CollisionPhysicsSend = "0";
CollisionPhysicsReceive = "0";
lowWall = "0";
mountID = "30";
};And the definition of blueDotImageMap:
new t2dImageMapDatablock(blueDotImageMap) {
imageName = "psychoff/data/images/blueDot";
imageMode = "FULL";
frameCount = "-1";
filterMode = "SMOOTH";
filterPad = "1";
preferPerf = "1";
cellRowOrder = "1";
cellOffsetX = "0";
cellOffsetY = "0";
cellStrideX = "0";
cellStrideY = "0";
cellCountX = "-1";
cellCountY = "-1";
cellWidth = "0";
cellHeight = "0";
preload = "1";
allowUnload = "0";
};Any help would be hugely appreciated.
#3
01/28/2008 (2:46 pm)
Have you made source code changes? "Wall" is not a valid t2d base object type, so I'm not sure how it's even rendering at all?
#4
Wall is a new class extended straight from t2dStaticSprite:
and the implementation is fairly standard:
01/28/2008 (2:50 pm)
Hey Stephen.Wall is a new class extended straight from t2dStaticSprite:
class Wall : public t2dStaticSprite
{
public:
typedef t2dStaticSprite Parent;
Wall();
bool onAdd();
static void initPersistFields();
bool mLowWall;
DECLARE_T2D_SERIALISE( Wall );
DECLARE_T2D_LOADSAVE_METHOD( Wall, 3 );
DECLARE_CONOBJECT( Wall );
};and the implementation is fairly standard:
IMPLEMENT_CONOBJECT(Wall);
Wall::Wall() : T2D_Stream_HeaderID(makeFourCCTag('2','D','S','X'))
{
mLowWall = false;
}
bool Wall::onAdd()
{
return Parent::onAdd();
}
void Wall::initPersistFields()
{
Parent::initPersistFields();
addField("lowWall", TypeBool, Offset(mLowWall, Wall));
}
// Register Handlers.
REGISTER_SERIALISE_START( Wall )
REGISTER_SERIALISE_VERSION( Wall, 3, false )
REGISTER_SERIALISE_END()
// Implement Parent Serialisation.
IMPLEMENT_T2D_SERIALISE_PARENT( Wall, 3 )
IMPLEMENT_T2D_LOAD_METHOD( Wall, 3 )
{
U32 frame;
bool imageMapFlag;
char imageMapName[256];
// Read Ad-Hoc Info.
if ( !stream.read( &imageMapFlag ) )
return false;
// Do we have an imageMap?
if ( imageMapFlag )
{
// Yes, so read ImageMap Name.
stream.readString( imageMapName );
// Read Frame.
if ( !stream.read( &frame ) )
return false;
// Set ImageMap/Frame.
object->setImageMap( imageMapName, frame );
}
// Return Okay.
return true;
}
//-----------------------------------------------------------------------------
// Save v3
//-----------------------------------------------------------------------------
IMPLEMENT_T2D_SAVE_METHOD( Wall, 3 )
{
// Ad-Hoc Info.
if ( object->mImageMapDataBlock )
{
// Write ImageMap Datablock Name.
if ( !stream.write( true ) )
return false;
// Write ImageMap Datablock Name.
stream.writeString( object->mImageMapDataBlock->getName() );
// Write Frame.
if ( !stream.write( object->mFrame ) )
return false;
}
else
{
// Write "No ImageMap Datablock".
if ( !stream.write( false ) )
return false;
}
// Return Okay.
return true;
}
#5
However, looking again at your object, those world position and size coordinates are HUGE. I've never really seen any game, ever, go beyond more than a couple of k MAX world units away from origin.
If your level is really that big, you might want to consider breaking it up some. I've got no clue if that is your issue or not, but it screams "problem!" to me, hehe.
Another issue might be sort/render order. Do you have any objects that might possibly be overlapping that one, and not have set up your render layers?
01/28/2008 (2:55 pm)
I've not had to ever do a new class in TGB (it's not the intended workflow), but I don't see anything blatantly obvious in the source.However, looking again at your object, those world position and size coordinates are HUGE. I've never really seen any game, ever, go beyond more than a couple of k MAX world units away from origin.
If your level is really that big, you might want to consider breaking it up some. I've got no clue if that is your issue or not, but it screams "problem!" to me, hehe.
Another issue might be sort/render order. Do you have any objects that might possibly be overlapping that one, and not have set up your render layers?
#6
I haven't used TGB that much to be honest, but I've been fairly careful with my engine changes. Guess I have some debugging to do ;)
Ian
01/28/2008 (2:58 pm)
The world limits are pretty large, but is the actual size that surprising? I'm not using a lot of TGB's features for this prototype, but given my screen resolution is 1920x1200, is a level that size especially unusual?I haven't used TGB that much to be honest, but I've been fairly careful with my engine changes. Guess I have some debugging to do ;)
Ian
#7
A more common utilization would be to grid out your screen in a more abstract way, "I want to have room for 10 sprites across my screen, and plan on using 256x256 textures for my sprites, then setting a "size" in the 20-40 range, and using setCameraCurrentArea to get a good view. Rinse and repeat as necessary.
01/28/2008 (3:19 pm)
Size/Position/World Limit are in Torque World units, not pixels. Your sizes imply that you are going to be creating very large sprites with huge textures, which your video card will very much not like.A more common utilization would be to grid out your screen in a more abstract way, "I want to have room for 10 sprites across my screen, and plan on using 256x256 textures for my sprites, then setting a "size" in the 20-40 range, and using setCameraCurrentArea to get a good view. Rinse and repeat as necessary.
#8
01/28/2008 (3:21 pm)
Ah ok, thanks Stephen. I'm currently prototyping with some new things, and wanted one pixel to equal one torque unit to make some stuff easier. I need to think of a way of dealing with the texture issue.
#9
Ian
01/29/2008 (8:44 am)
If the object is changed to a t2dStaticSprite the problem remains, and even more bizzarely if the object is half off screen it's cut off, so only the bit originally on screen renders... I'm baffled.Ian
#10
01/29/2008 (11:13 am)
It's possibly culling the shape if the center isn't in the camera view area?
#11
Anyway, I was using "sceneWindow2d.setposition" when I needed to use "sceneWindow2d.setCurrentCameraArea".
Ian
01/29/2008 (12:40 pm)
Ok, I've fixed it. I was using an older version of TGB (1.1.1) so that may have been part of the problem.Anyway, I was using "sceneWindow2d.setposition" when I needed to use "sceneWindow2d.setCurrentCameraArea".
Ian
#12
01/29/2008 (1:03 pm)
Heh..we're on 1.6 man, 1.1.1 was so last century!
Torque 3D Owner Patrick Shaw
My first thought is that you perhaps set on the object's "world limits mode" to something other than "off" without defining the object's world limit area (I've done this several times!).
Otherwise, can you provide some more information about these simple objects, including any behaviors you've attached to these simple objects?