Game Development Community

NoRenderMask isn't working

by Matt Delph · in Torque X 2D · 08/31/2010 (7:49 pm) · 10 replies

I've been wrestling with TX2D trying to figure out how to make a HUD. I got it to where it's moves with the player, but there's still a copy of my HUD components stuck to the level where they were originally created. I tried using the NoRenderMask = HUD (I made sure my HUD components are set to the HUD object type), but it doesn't change anything. Then I tried using the red dot in Visual Studio to pause the game and look at some values (thanks Aaron), and "HUD" shows up in the members of NoRenderMask. So my question is, If the object type shows up as a member of NoRenderMask, why is it still showing up on the screen?

#1
08/31/2010 (8:19 pm)
Hey Matt,
Did you add a "HUD" object type in TX2D and then apply object type "HUD" to your hud scene objects?

The main camera needs:
NoRenderMask = HUD
This will remove the objects with object type "HUD"

The HUD camera needs:
RenderMask = HUD
This will only render objects with object type "HUD"
#2
08/31/2010 (9:45 pm)
What's confusing me is that the NoRenderMask command can only be applied to a GUISceneView, but the only GUISceneView I defined is the one attached to the HUD camera, which has RenderMask = HUD. So what GUISceneView do I have to attach NoRenderMask = HUD to?
#3
08/31/2010 (11:07 pm)
In the Airplane tutorial there is a section Mounting a camera to our plane this is were NoRenderMask would go if following the tutorial.

Or you might try this. Define it for the main scene camera? When you click a blank area in the editor and have the edit tab selected you can give the camera a name, then you should be able to set it up with some GUISceneView code similar to what you used for the hud. Just guessing on this one.

Alternatively, if everything is working how you like, you could place the original hud in TXB outside the world limits so you wont see it when navigating around.
#4
09/01/2010 (11:43 pm)
Here's what I got so far. It's all in a Component that is attached to the airplane. What looks like whats happening is that the 1st camera is following the player around, but still rendering the compass on a fixed point of the map. And it doesn't look like the HUD camera is doing anything at all, the compass isn't following the camera.

What makes me believe the HUD camera isn't doing anything is because I tried defining the HUD camera far outside the map (adjusting the camera's CenterPosition and the HUD objects' position accordingly), but still got nothing. All it did was make the compass go away.

Here's what happens and where I believe the problem is.

It starts when I select "Play Game".
private void On_Option1_Select()
        {
            GuiPlay playGUI = new GuiPlay();
            GUICanvas.Instance.SetContentControl(playGUI);

            Game.Instance.SceneLoader.Load(@"data\levels\levelData.txscene");
        }
Which then runs this code in playGUI (Which looks like it's setting up a GUISceneView that may be conflicting with my cameras & SceneViews).
public class GuiPlay : GUISceneview, IGUIScreen
    {
        public GuiPlay()
        {
            GUIStyle playStyle = new GUIStyle();
            Name = "GuiPlay";
            Style = playStyle;
            Size = new Vector2(1280, 720);
            Folder = GUICanvas.Instance;
        }

        public override void OnRender(Vector2 offset, GarageGames.Torque.MathUtil.RectangleF updateRect)
        {
            base.OnRender(offset, updateRect);
        }

    }
Then my code, which is attached to my airplane in the form of a Component, is run.
TorqueObjectType HUD = TorqueObjectDatabase.Instance.GetObjectType("HUD");

            #region PlayerCamera
            //Create the camera that follows the airplane
            T2DSceneCamera WorldCam = new T2DSceneCamera();
            WorldCam.CenterPosition = new Vector2(0.0f, 0.0f);
            WorldCam.Extent = new Vector2(160.0f, 90.0f);
            TorqueObjectDatabase.Instance.Register(WorldCam);
            WorldCam.Mount(SceneObject, "", false);

            // display the camera on screen
            GUIStyle WorldStyle = new GUIStyle();
            GUISceneview WorldView = new GUISceneview();
            WorldView.Style = WorldStyle;
            WorldView.Camera = WorldCam;
            WorldView.NoRenderMask = HUD;
            GUICanvas.Instance.SetContentControl(WorldView);
            #endregion

            #region HUDCamera
            // Create the camera that displays the HUD onjects
            T2DSceneCamera HUDCam = new T2DSceneCamera();
            HUDCam.CenterPosition = new Vector2(0.0f, 0.0f);
            HUDCam.Extent = new Vector2(160.0f, 90.0f);
            TorqueObjectDatabase.Instance.Register(HUDCam);
            HUDCam.Mount(SceneObject, "", false);

            // display the instrument camera on screen
            GUIStyle HUDStyle = new GUIStyle();
            GUISceneview HUDView = new GUISceneview();
            HUDView.Style = HUDStyle;
            HUDView.Camera = HUDCam;
            HUDView.RenderMask = HUD;
            HUDView.Visible = true;
            HUDView.Folder = WorldView;
            #endregion
(9/2/10 @ 4:51pm) Edited to show the flow of code and what might be going wrong.
#5
09/04/2010 (12:43 am)
I haven't figured this out yet, can someone look through this and tell me what might be going wrong.
#6
09/06/2010 (2:03 am)
I tried disabling the entire camera that draws all "HUD" type objects, and using the NoRenderMask = HUD on the camera that follows the airplane, but the HUD objects still show up anyway. The only reason the HUD components are still showing up is because the NoRenderMask command isn't doing its job.

Should I report this as a bug, or am I just using it wrong?
#7
09/06/2010 (2:33 am)
Hi Matt, sorry I haven't got back to you in a few days. I will be adding something similar to my game tomorrow and let you know my results.
#8
09/06/2010 (7:35 am)
Hey guys,

just seen this thread. What are you assigning to the NoRenderMask? AFAIK that's used only for the GUI objects, not any scene object. The T2DSceneGraph only manages the render mask, not the no-render mask.
#9
09/06/2010 (6:06 pm)
As I was digging around in the code (right-click & "Go To Definition" on NoRenderMask), I noticed that both RenderMask & NoRenderMask can only be set to TorqueObjectType's. Not sure if this is what you're referring to, but this was what led me to believe they would both function the same way.

@Aaron, I'll be impatiently waiting for those results (joking, :P).
#10
09/10/2010 (4:09 pm)
I've been stuck on this for about 3 weeks. Has anyone made any progress in figuring out what I could be doing wrong, or if theres a much better way of doing this. The only reason I thought this was the best approach was because it was in the Airplane Tutorial. If the tutorial is outdated or just plain wrong, can someone tell me, or just point me in the right direction? Im just grasping at straws here, and it's getting kinda frustrating...

NOTE: Just noticed some talk about the CEV, and was wondering if that would help me out any. I don't have a Torque X license yet (I'm still using the trial), but if that CEV will help I'll get it very soon.