background image behind 3d scene
by ArchieMD User · in Torque 3D Professional · 02/01/2010 (12:07 pm) · 9 replies
I need to draw a background image behind my 3d scene in T3D. The background's texture is being written to every frame (video). I've done this in 4 other graphics/game engines and the solution *should* be to draw a full screen quad w/ orthographic projection w/ depth read and no depth write. This DOES NOT WORK in Torque3D. Please help, I can't proceed with a hard deadline project until this is working.
#2
02/01/2010 (1:36 pm)
Hmm, I was hoping not to have to go the route of gui objects, because it's counter intuitive. Gui objects sit on top of the 3d scene. On the other hand, this is really part of the scene. So it's weird sw engineering to subclass a guicontrol instead of a sceneobject in this case. Oh well... will try your approach, thanks!
#3
Actually GUIs in Torque don't sit on top of a 3D scene. The entire scene is rendered through a control that's placed on the canvas(*). Take a look at PlayGui to see how it's done.
So, by placing the video control on the canvas and making the 3D render control (GameTSCtrl) a child of it, you actually get a very elegant and natural solution to this.
(*) To emphasize this point: It pretty much means that 3D sits on top of 2D in Torque.
02/01/2010 (1:38 pm)
Actually GUIs in Torque don't sit on top of a 3D scene. The entire scene is rendered through a control that's placed on the canvas(*). Take a look at PlayGui to see how it's done.
So, by placing the video control on the canvas and making the 3D render control (GameTSCtrl) a child of it, you actually get a very elegant and natural solution to this.
(*) To emphasize this point: It pretty much means that 3D sits on top of 2D in Torque.
#4
02/01/2010 (1:42 pm)
So Torque's view is that 2D interface elements should not conceptually be "on top" of the 3d world. Pretty sure that's not what I'd call intuitive. But thanks again, will try it.
#5
Torque's view is that there need not be a 3D world at all.
Whether you are in the main menu or in the game, the high-level rendering path is the same and it all happens through GuiControls. This is a pretty powerful system. No one keeps you from nesting GuiTSCtrl 3D rendering controls inside of other controls to make HUDs or for creating character setup screens where a single character object is the only 3D object
Also, it allows for a pretty elegant input setup. etc.
BTW, if you prefer, nothing keeps you from going the SceneObject route. You have the source, do it the way that you are most comfortable with.
02/01/2010 (1:50 pm)
Torque's view is that there need not be a 3D world at all.
Whether you are in the main menu or in the game, the high-level rendering path is the same and it all happens through GuiControls. This is a pretty powerful system. No one keeps you from nesting GuiTSCtrl 3D rendering controls inside of other controls to make HUDs or for creating character setup screens where a single character object is the only 3D object
Also, it allows for a pretty elegant input setup. etc.
BTW, if you prefer, nothing keeps you from going the SceneObject route. You have the source, do it the way that you are most comfortable with.
#6
02/01/2010 (2:54 pm)
@Aaron: the 3D view *is* just a GUI element. So it's completely intuitive that you can place other GUI elements behind it if you want.
#7
02/01/2010 (3:00 pm)
Your bias is showing. Sure it's intuitive if you were the one that designed torque that way. But it's completely unintuitive if you've used any other graphics/game engine and/or ogl/d3d/etc. I'll try to keep that in mind as I learn Torque. Torque has a mind of its own
#8
in your render callback,
1)unproject screen to world for the 4 corners of the viewport
2)apply the camera's pose to your object and multworld
3)render a quad with those unprojected coords
seems like an expensive soln, but it works. also tried extending a guicontrol as suggested but ran into rendering issues
02/02/2010 (10:43 am)
fyi, to do this as a sceneobject:in your render callback,
1)unproject screen to world for the 4 corners of the viewport
2)apply the camera's pose to your object and multworld
3)render a quad with those unprojected coords
seems like an expensive soln, but it works. also tried extending a guicontrol as suggested but ran into rendering issues
#9
02/04/2010 (2:47 pm)
The skybox object may have some useful code you could take a look at, at least for how to render a constant-scale object which is always rendered "first" in the scene regardless of its actual position. I hijacked this code for my planet objects in space scenes, which need to appear to be extremely far away without breaking the 32 bit float rendering code. Not quite what you need, but a start. Aaron's post covers how to actually get your object to act like a background.
Associate Rene Damm
Rather than putting this directly into Torque's rendering code, the clean and easy solution is to use the GUI system for this.
If this is Theora video, you could just put a GuiTheoraCtrl as the canvas content and have the GameTSCtrl as its child control. However, in your case the video is probably streaming so the best way is to implement your own GuiControl, hook up your video streaming code to its rendering, and use that control as the canvas content.
If you already have the video available as a texture, then this is just several lines of code.