Game Development Community

T2dShape3D

by Ryan McKenzie · in Torque Game Builder · 01/28/2007 (3:05 pm) · 10 replies

When using 3d shapes in TGB, do the shapes have depth or do they just become flat sprites? If you are not exactly sure what I mean, I made a small example below of a static sprite (the car) moving past a 3d building.

Example

I would have to end up downloading the demo of TGE, learn how to do some simple modling to create a rendered building, load into TGB, code in camera movement controlled with the direction keys, and see if this idea works. Instead, it may of been easier to ask such a minor question here at the forum :)

#1
01/28/2007 (4:18 pm)
The short answer is no, you won't get the perspective shift that you have shown in your sample image. The 3D object does become a flat sprite when you have it in the scene and although you can manipulate its rotation it will not have perspective depth, but more of an isometric feel.
#2
01/28/2007 (4:29 pm)
What if I did this the wrong way round. Like creating the buildings in TGE and then importing the static images into TGE. To get a better idea of what I am aiming for here, I am creating a top-down view of a racing game. So I could create a flat image on the ground line of the 2d scene, then any objects with major depth could be in 3d to give more realism.

So would this work?
#3
01/28/2007 (5:35 pm)
I sort of follow what you're saying, and I think the result would still be the same. Here's an example of what you get from a 3D DTS object in TGB.

www.donhogan.com/Torque/DTS_in_TGB.jpg
Now, perhaps if you built the object with forced perspective - i.e. tapered a cube - and rotated it based on the player's position you could get that illusion. One last thing comes to mind as well. You would need to dray any sort of lighting / shading effects into the textures of the 3D object as TGB can't pass any lighting info to the DTS.

By the way, I'm not trying to be negative, I've just already brainstormed on this somewhat for my project and couldn't get a process that wasn't more work that just making a nice 2D image. However, it's nice to talk through it with someone else and see what new ideas surface.
#4
01/29/2007 (9:33 am)
Well. Supposing I created my game in TGE. Is it possible to import a level created in TGB? Or infact importing the whole game?

This seems like a hard trick to fake which I cant figure out. So does anyone have any suggestions?
#5
01/29/2007 (10:26 am)
I just want to add that it *is* possible to get what is suggested in the original image in TGB, however it requires digging into the engine. The default way T2dShape3D shapes are rendered is with an orthographic projection. However, with a little openGL you can change that to a perspective projection.

I did this awhile back and haven't revisited it in awhile... There are some complexities to sort out to make all this work in a 2D game viewport, which I can't all remember right now. The big thing is determining how your shapes should sort with other 3D shapes. I did something with renderSets: any T2dShape3D shapes in the same set would depth sort properly, while any not would just get composited over one another in the usual way.

Anyway I never messed with this enough to really sort out all the issues, but my initial tests were positive, so I bet it can be done.

- Matthew Durante
#6
01/29/2007 (2:09 pm)
Another (possibly easier) way to do it: render out stills of the 3d object at a grid of different locations in the viewport, align them all in photoshop, and set them each to a frame of animation. Then just set the frame based on their x/y location in the camera.
#7
01/29/2007 (2:15 pm)
@Matthew, I'm not familiar with changing parts of the engine and havn't a clue how to change the orthographic projection to a perspective using OpenGL. I would even have to upgrade to pro. But I was wondering if you could maybe give me some personal help, as I seem quite determined to make this work. Just some basics to help me get an understanding of how to do this.
#8
01/29/2007 (4:06 pm)
@Ryan,

The changes I've made to the T2dShape3D class aren't exceptionally complicated but they aren't trivial either, and I wouldn't have time to walk you through it -- especially if you're not experienced with C++, the TGB engine or graphics programming.

However at some point I could post it as a Resource or whatever for other people to play with... But it would need a bit more testing. If I get a chance in the near future I'll have a look, but I can't make promises. Regardless it would not be production-proven code, and could break some things.

Don't plan your project around this! Definitely consider some of the other suggestions mentioned here...

- Matthew Durante
#9
01/29/2007 (5:13 pm)
@Matthew, I may give this idea a shot sometime. Though I am still deciding what root I should take here. I could attempt your idea and upgrade to pro. Then understand basic c++, the TGB engine and then figure out this puzzle.
Or, I could go with creating a very simple 3D game and would have to purchase TGE in the proccess and learn that.
What's your suggestion?

@Nick, I'm afraid your idea wouldn't work very well for my project. My example picture showed a building from the side, which in this case, your idea would work great. But since you are seeing the building from the top. I would have to render a frame every x/y location on the camera. That would be alot of frames to create and become very time consuming.
#10
01/29/2007 (5:36 pm)
You would really only need enough angles to make it convincing, and for rendering just animate it (or the camera) moving up, down, left, and right, and there you go.