Game Development Community

Dynamic Skin StaticShape Billboard Wierdness

by Charlie Sibbach · in Torque Game Engine · 06/27/2008 (11:29 pm) · 0 replies

Hey all,

I've been working with the engine for a long time, heavily modded at this point, but this question should pertain only to the scripting engine so I'm putting it in the public forums.

Here's what I'm doing- my game is a space game, with the player moving primarily along the XY axis. I want to display "Planets" programmatically underneath the player, along the -Z axis. To do this, I am using StaticShape objects, with a single DTS and datablock, but I am using dynamic skins (setSkinName()) to change what the planet looks like. The planet DTS is a billboard object, although maybe it's not being exported correctly, more later. The idea is that these nice big planets show up under the player, and I can change what the planet looks like just by making new skin .pngs instead of having a whole bunch of extra datablocks (planets can't really be interacted with, you're not going to run into them), and making it easier to add new planets (no need to go into the modeler and export).

So here's what I'm getting- first, when the datablock (PlanetShapeData) is created, it throws out the error:

Error: shape Scenarios/Sephil Saga/planets/planet.dts-collision detail 1 (Collision-1) bounds box invalid!

As a billboard object, it seems this shouldn't be a problem- I don't want it to have a collision mesh- nobody will be running into it, it's eye candy only. We followed all the advice we could find (forums here, 3DGPAI1 and Advanced 3DGPAI1). The dynamic skins are working, after figuring out the naming convention and what to pass to the object.

The real weirdness begins after I create a planet:

function PlanetResource::displayPlanet(%this)
{
%planet = new StaticShape() {
datablock = PlanetShapeData;
position = %this.position SPC $PlanetResource::planetZPosition;
rotation = "1 0 0 0";
scale = %this.scale SPC %this.scale SPC $PlanetResource::planetZScale;
};

%planet.setSkinName(%this.picture);

$SystemGroup.add(%planet);
}

Which creates a StaticShape in SystemGroup just like it should. Problem 1: It's tiny! In Torque Show Tool, the object is 2 units across- we intend to use the scale parameter to adjust the actual visible size of the planet- if we can't do that it's back to the drawing board and having to make bloody new DTS files for each planet, which is less than ideal for what we're trying to do. The default scale is something like "150 150 1", so the planet should be huge, but it is sitting there at only 2 units across- we're lucky to have found the darn thing. I have done %object.setScale(), I've done %object.scale =, I've done all sorts of things, but it won't scale at all.

The second problem is more disturbing. When I fly in near to the planet (exact distance TBD), the game crashes, hard! We're having issues with debug builds right now (Torque 1.5 on Windows only, possibly something I introduced but the function it dies on is unmodified), something I'm going to have to fix sooner rather than later apparently, so I don't know what function it's actually crashing on, but I don't think this has to do with a bug in the engine- I think this might have something to do with the screwed up collision mesh. I have a notion that the scale is affecting a non-existant collision mesh, so it's crashing some distance from the planet, but it also seems to be more of a problem when I try to PASS the planet, rather than approach it, so it may not be rotating to face the player or camera correctly. I am using the advanced camera resource, FYI.

Anybody have any ideas? Both problems are really messing with my head, and have turned what should have been a trivial coding exercise into something I've had to come to the forums for! Embarrassing when you're trying to teach other people about this stuff... Thanks for any help!