Previous Blog Next Blog
Prev/Next Blog
by date

work on programmatic DTS billboards

work on programmatic DTS billboards
Name:Geom
Date Posted:May 31, 2007
Rating:Not Rated
Public:YES
Comments:YES
RSS Feed:GarageGames Blog feedor Subscribe with .
Profile Page:View profile page for Geom

Blog post
A while back I mentioned I had been experimenting with adding billboards to DTS shapes, programmatically. This is the idea where your game code can add billboards to any DTS shape, without involving an art tool (Blender, Max, etc.) exporter. You'd simply write Torquescript calls (or something) to add the billboards at run-time. This seems like something that would make a useful resource.



So finally, I've gotten around to working on this idea in earnest.

The good news is, I've got it working - in certain cases. It works when the DTS shape is used by Player / AIPlayer objects, or by RTSUnit objects (from the RTS-Starter Kit).

The bad news is, this resource doesn't work for all cases. The biggest problem is that it doesn't work when the DTS is used by a TSStatic. That's a pretty big drawback, if I understand the purpose of TSStatics correctly. TSStatics are for when you've got lots of a certain kind of object in a game, like trees. Unfortunately, that's exactly the situation where billboards are most likely to be wanted.

The resource can also crash if the billboard is for a Player object, and the Player object has shadows turned on.

I think I know what the problem is (or at least one of them) with TSStatics, so I'm going to keep trying to get this resource working with TSStatics.

Despite its current limitations, I thought I'd go ahead and post the code I have, so that anyone who wants to can play with it or comment on it can do that. I should note that the code *sometimes* works with TSStatics. In fact the example below uses TSStatics from the Stronghold mission; by luck those don't seem to crash it. But it's definitely not guaranteed to be stable.

For more info about DTS billboards in general, check out e.g. the docs on the Blender .dts exporter.

Here's what I've got so far for the resource. Again, this is only a prototype, hopefully in the future there'll be a more bulletproof version.

--------

Programmatic DTS billboards

Summary:
This resource allows you to programmatically add billboards to a DTS shape. The DTS shape does not need to have been exported with billboards.

Article:
Torque DTS shapes support a nifty feature called "billboards". A billboard is a 2-D representation of what the DTS shape looks like when viewed from a long way away. If a DTS shape has billboards turned on, then Torque will render the DTS as a 2-D bitmap (billboard) when the DTS reaches it's lowest detail level. This can can result in huge speed-ups, since rendering a 2-D bitmap is much faster than rendering a 3-D shape.

Until now, billboards had to be turned on or off at the time the DTS was exported from the art tool (Blender, Max, etc) that created the DTS. With this resource, you can now turn on billboards in your game rather than in the art tool. This can be done for any DTS shape that doesn't already have billboards. The programmatic API supports all the same parameters that the art tool exporters support (and, arguably, slightly more).

API:
This resource adds a single Torquescript function (brackets denote optional params):

setupBillboards(shapeName, numEquatorSteps, numPolarSteps, bitmapSize, detailSize [, polarAngle [, includePoles [, bitmapDetailLevel ]]] )

For more info on the parameters, see the Blender DTS exporter docs.

Code
snipped - see comments below

Example
You can test this resource using the starter.fps example in Torque 1.5. Run Starter.FPS.bat, and start the mission "A Stronghold". Once in the mission, bring down the console window (~) and type

setupBillboards("starter.fps/data/shapes/Winter/TreeNoSnow03.dts",8,4,32,64);
setupBillboards("starter.fps/data/shapes/Winter/TreeNoSnow04.dts",8,4,32,64);
setupBillboards("starter.fps/data/shapes/Winter/TreeNoSnow05.dts",8,4,32,64);

That'll create billboards for three of the tree models. As you run around the mission area you should notice some of the trees transition between 3-D shapes and billboards. The billboards will be pretty ugly, but that's intentional to make them more noticable. (normally, of course, you'd select the billboard parameters to make the transition as invisible as possible).

up-close: 3-D shapes.


step back a bit: they become billboards.

Recent Blog Posts
List:10/04/08 - RTS game features and when to tie a bow
01/02/08 - Old fonts, new fonts
11/29/07 - Tab Control WIP
11/11/07 - OVM Beta1 test!
07/11/07 - Orcs vs. Martians
05/31/07 - work on programmatic DTS billboards
02/14/07 - Recoloring DTS shapes
01/24/07 - Orcs vs. Martians alpha

Submit ResourceSubmit your own resources!

Alan James   (May 31, 2007 at 03:21 GMT)
Geom,

Really cool work may eventually save everyone quite a bit of work on the art pipeline end with some tweaking, but I'd suggest submitting this right away as a resource considering you've posted snipets of source code in a public blog and I would imagine GG is going to pull this very quickly.
Edited on May 31, 2007 03:24 GMT

Michael Perry   (May 31, 2007 at 12:33 GMT)
Awesome code work there Geom. Very useful overall, and quite clever. Alan has a point, though. I'd yank out the code from this blog and put it in as a resource and just provide a link to it from here.

Good work!

Geom   (May 31, 2007 at 14:54 GMT)
@Alan, Michael
thanks guys, for the heads-up about posting code. Sorry GG! Code yanked. I'll try to get the idea shaped up and resourced soon.

James Laker (BurNinG)   (May 31, 2007 at 15:22 GMT)
Post got swallowed again... Grrrrr

Short version:
Sweeeet! Should go in HEAD when all the bugs have been straighted out.
Will test with TGEA when I get home.

Post link to resource here too pls.

Clint Herron   (Jun 01, 2007 at 18:19 GMT)
Looks really good! Fantastic job!

If you happen to have a polished setup done, I'd be interested in knowing what a good quality transition between dts/billboard looked like. Nothing huge though -- I'm sure a lot more people are waiting on the code as a resource.

Geom   (Jun 01, 2007 at 21:48 GMT)
@James
Thanks! Yeah it'd be cool if it eventually got into HEAD.

I think this will be most helpful to people who like buying art packs, like myself. For those people it makes more sense to allow the developer to tinker with the billboard parameters rather than the artist doing it. Lots of people buy the same art pack, but different people are going to want different billboard setups depending on how they use the art (or none at all, since billboards can be such memory hogs). I think it makes a lot of sense to allow the programmer to control them.

@Clint
Thanks! I don't currently have any screenshots of polished transitions, I'm working through a number of issues atm that prevent getting them. iirc the demo of Dark Horizons: Lore Invasion has some good transistions with some of their trees.

Geom   (Jun 05, 2007 at 00:03 GMT)
w00t! The issue with TSStatics is now fixed. I had to go with a different approach, but the code should be really robust now. Resource is submitted and I'll post a link if it gets approved.

James Laker (BurNinG)   (Jun 05, 2007 at 08:01 GMT)
Yeah! That is good news! You can post the link, dont need to wait for it to get approved. That can take weeks.

Can't wait to go test the new code!

Geom   (Jun 05, 2007 at 14:29 GMT)
how would I find that link?

James Laker (BurNinG)   (Jun 06, 2007 at 06:23 GMT)
Hehe...You lost it? :-/

Maybe try searching for it... or check your history?

James Laker (BurNinG)   (Jun 06, 2007 at 06:33 GMT)
Btw... I'm unable to get this working with TGEA (yet)... I'll see if can spot anything.

James Laker (BurNinG)   (Jun 06, 2007 at 12:36 GMT)
Have you sorted out the Shadow Crash bug with the resource?

Geom   (Jun 06, 2007 at 14:50 GMT)
After I posted it, I remember seeing this message about "If you want to see your resource while it's pending moderation, turn on such-and-such an option in your profile". But I can't find any option like that (and searching doesn't turn it up either). If you want, I can email it to you.

Yeah, let us know if it works in TGEA! I don't own it so I can't test with it.

Shadow crash is still there...I think it's a bug/limitation with billboards, that doesn't have anything to do with this resource.

James Laker (BurNinG)   (Jun 06, 2007 at 20:22 GMT)
I'm playing a bit more with it now, but I can only test it on StaticShapes, without initial success. The model Just dissapears atm.

To view your resources, click on "My Account", "My Posts, Resources, ...", then look for "You have submitted xx resources..." Click there, and you should see it. :)

James Laker (BurNinG)   (Jun 18, 2007 at 15:04 GMT)
Geom... Still waiting for that link ;-)

Geom   (Jun 20, 2007 at 01:25 GMT)
Argh. I think the GG website ate my original resource submission. I remember clearly being told "Submission successful", but then, the unapproved resource never showed up on my account page.

Ok. I've re-submitted it now. And this time, it is actually showing up , so I think all's good this time.

You must be a member and be logged in to either append comments or rate this resource.