Game Development Community

Creating Shapes via code?

by Timothy Volpe · in Torque Game Engine Advanced · 07/04/2010 (6:09 pm) · 6 replies

Is it possible to define shapes with code? This could be in C++ or TS, but heres what I'm trying to do. My game has lists of simple blocks that are in to much mass to create each one in a modeling program. I also want to define each in a file "say a file that reads "BLOCK: 1 1 5" so it creates a 1x1x5 block shape. I can do it with scale, but it stretches the textures, doesn't tile them. How do I do this? Code would be nice :)

#1
07/05/2010 (5:33 am)
One of the torque books does something similar to this, think it might be the game programmers guide to torque.. you create your level in a text file with block types, etc and it creates them when it loads the mission.

Rather than stretching a single block it did it by placing blocks next to each other.

It also supported being able to place items like coins to collect, transporters, etc to build a little platformer
#2
07/05/2010 (9:14 am)
But in that they give you DTSs. I have that book.

Heres a more detailed version of what I'm trying to do:
In my game, you build levels with blocks. Theres probably like 200 options of blocks that the user can create their level with. The users can also create custom blocks. But, the blocks have to fit together perfectly. So modelling each one-and having custom ones, gets messy. So, I wanted a simple way to create these blocks, where you define 3 values, X Y and Z. It creates a block with the values, X Y and Z. So, if you entered 1 1 5, it would create a 1x1x5 block. A good idea I had for this system, is you make a txt file. In that file it says:
"X: 1
Y: 1
Z: 5"
Then you create a datablock. Something like,

datablock blockData(TestBlock)
{
name = "My Block"; //What comes up on the GUI
blockFile = "./MyBlock.txt"; //The file that has the values above
blockCatagory = "Normal Blocks"; //For the GUI
};
#3
07/05/2010 (5:38 pm)
Check out fxRenderObject- it's a great tutorial on how objects are rendered in Torque. If you want to get down and dirty, coding your own variable-sized, tiling-textured block class based on fxRenderObject shouldn't be *too* difficult, and it'd be a great learning experience.
I was actually thinking of doing basically exactly what you described as a prototyping tool for level design. I might bump that up higher on the to-do list if you want ;).
#4
07/05/2010 (6:24 pm)
Ok, thanks!
#5
07/06/2010 (6:08 am)
*Actually, I have no idea if fxRenderObject still exists in TGEA. If not, try to find the original resource, it should still be here somewhere. You may have to adapt it for TGEA's rendering pipeline, which I believe is somewhat different to TGE, being not-GL-specific and all.
#6
07/06/2010 (12:51 pm)
Didn't TGEA use GFX? If so, you can create primitives with those functions... But yeah, you want to go the route of creating something like fxRenderObject, if not just using that implementation.