This project is read-only.

Can we have mulitple scene node?

Jun 18, 2010 at 3:34 AM


Can we create more than one scene in a 3D world?

Jun 21, 2010 at 7:45 AM

You can create multiple scene tree by setting up multiple branch nodes which each scene, but you can only render one scene at a time. If you want to switch between scenes, then remove that scene root from RootNode and add another scene to the root. I haven't tested it that way yet, but I believe it should work.


May 9, 2011 at 3:39 PM

Is it possible to render one scene transparent? And then render one of the scenes over the other? (i have something complex in my mind using two cameras.)

Jul 26, 2012 at 6:21 PM

My case is a kind of similar.

I need to have two camera views. One as the background and the other is smaller and show on top left corner of the others. User can switch between the two views.

Any one tried this yet?

Jul 26, 2012 at 6:48 PM

Just add two camera nodes in the scene and simply switch between them by setting scene.CameraNode to whichever camera node you want to use.


Jul 26, 2012 at 6:54 PM

Thank ohan.

Just correct me if I am wrong. By setting scene.CameraNode, you are swithing between the camera and only one is showing?

I want to show both cameras at the same time. On is the background take full screen and the other is smaller (1/9th of the full screen) and show on the top left that overlay the background. User can switch between these two camera views?


Jul 26, 2012 at 9:14 PM

See Tutorial 16, multi-viewport example.

Jul 26, 2012 at 10:42 PM

Oh. you mean 4.0 version? I'm using 3.5. Can we do this in 3.5 or I have to upgrade to 4.0?


Jul 27, 2012 at 5:43 AM

Yes, you can do it in any version, but you may need to change some lines of codes. Tutorial 16 only comes from version 4.0. You can download it and see if the exact same code will work on 3.5. Of course, the API calls for GoblinXNA has changed a little from 3.x version to 4.x version, so you need to figure out the appropriate way yourself.


Jul 30, 2012 at 3:26 PM

Thank Ohan, give it a try now and update if it works.


Jul 31, 2012 at 5:04 PM
Edited Jul 31, 2012 at 5:24 PM

Hi Ohan,

I'm trying to replace vrCameraNode by another real arCameraNode, but I can't figure out how to link arCameraNode and the second real camera? Here is what I did

1. Since I don't use vrCameraNode, so I comment this method CreateVirtualCameraRepresentation(); out

2. Under SetupMarkerTracking()

I init another camera and add to the scence as


DirectShowCapture captureDevice1 = new DirectShowCapture();  

captureDevice1.InitVideoCapture(1,FrameRate._60Hz, Resolution._1024x768, ImageFormat.R8G8B8_24, false);


DirectShowCapture captureDevice = new DirectShowCapture(); FrameRate._60Hz, Resolution._640x480, ImageFormat.R8G8B8_24, false);  



// Use ALVAR marker tracker  

ALVARMarkerTracker tracker = new ALVARMarkerTracker();

tracker.MaxMarkerError = 0.02f;

tracker.ZNearPlane = arCameraNode.Camera.ZNearPlane;

tracker.ZFarPlane = arCameraNode.Camera.ZFarPlane;

tracker.InitTracker(captureDevice.Width, captureDevice.Height,"default_calib.xml", 32.4f);

// Set the marker tracker to use for our scene

scene.MarkerTracker = tracker;// Display the camera image in the background. Note that this parameter should

// be set after adding at least one video capture device to the Scene class.

scene.ShowCameraImage = true ;

// Create a marker node to track a ground marker array.

groundMarkerNode = new MarkerNode(scene.MarkerTracker, "ALVARGroundArray.xml");


3. My intention is that captureDevice will be the first arCamera1 while the captureDevice1 is the second arCamera2, how do I make this relation? Can't figure out how did you relate arCamera to captureDevice in the code?

 sorry for my multi-viewport newbie question?





Jul 31, 2012 at 8:47 PM

Oh, i thought you meant for virtual camera befores, but you meant for real cameras. In that case, you only need one CameraNode instance, and you don't need to switch that. The only thing you need to switch is the scene.LeftEyeVideoID at the lines where CameraNode is switched in the original code. You should keep ShowCameraImage to true at all time. And of course, you need two IVideoCapture instances for each real cameras and added to the scene.


Jul 31, 2012 at 8:51 PM
Edited Jul 31, 2012 at 11:50 PM

Thank ohan, I think I got it as your instruction.

Same as tutorial 16 but do the following to archieve what I need

1. Remove all instances of

CameraNode vrCameraNode;





GeometryNode vrCameraRepNode;

2. Comment this method


 3. Add one more IVieoCapture to SetupMarkerTracking() as:

DirectShowCapture captureDevice1 = new DirectShowCapture



captureDevice1.InitVideoCapture(1,FrameRate._60Hz, Resolution._1280x720,ImageFormat.R8G8B8_24,false ); 



DirectShowCapture captureDevice = new DirectShowCapture();

captureDevice.InitVideoCapture(0, FrameRate._60Hz, Resolution._1280x720,ImageFormat.R8G8B8_24,false); 


4. Change this under Draw() method

scene.CameraNode = arCameraNode;


 scene.CameraNode = vrCameraNode;

scene.LeftEyeVideoID = 1;




 scene.LeftEyeVideoID = 0;" line

scene.LeftEyeVideoID = 0;

In addition,

add this line (important) below this "

scene.Draw(gameTime.ElapsedGameTime, gameTime.IsRunningSlowly);

Then I got what I want.

Thank you so much Ohan.



Aug 1, 2012 at 4:48 PM


I got a weird behavior on this.

If I set the viewport rectangle as

vrViewRect =

new Rectangle(0, 0, topViewRenderTarget.Width, topViewRenderTarget.Height);

 Then I see the view of two real cameras one on left top overlaid on top of the other as background for the fullscreen.

If I change the first two value of the above as

vrViewRect = new Rectangle(State.Width - vrViewRenderTarget.Width, 0, topViewRenderTarget.Width, topViewRenderTarget.Height);

then I don't get the second camera view on left but a blue screen?

Any idea that how to fix this? Thank

Aug 1, 2012 at 10:32 PM

Can you screen capture them and put here or provide a link to the screen captures?


Aug 1, 2012 at 10:48 PM

Here are the captures



Aug 2, 2012 at 10:28 AM

I think I know the solution to it since I've had similar issue before, and I made it work, but I need to check. It's not a bug by the way, but more of a viewport bound setting.


Aug 3, 2012 at 5:34 PM

Oh, did you have time to check this yet. Still trying to figure out. Thanks

Aug 3, 2012 at 6:52 PM

I think I got it. Under Draw() method, change this

State.SharedSpriteBatch.Draw(topViewRenderTarget, topViewRect, Color.White);



So instead of using rectangle for the second argument, we should change it to Vector2 position. This will allow you to move the overlaid view to wherever you want without causing the above issue.



.SharedSpriteBatch.Draw(topViewRenderTarget, new Vector2(State.Width * 1 / 5, 0), Color.White);



Aug 4, 2012 at 10:13 PM

I haven't had chance to look into it, but that's great!!

Aug 17, 2012 at 4:08 PM

I got another question regarding this multiple viewport.

For the two real cameras I have as above, the frames in cameras are display in two different viewport. If I set viewport 1 as a smaller and place it on the top, viewport 2 as a full window size, that works just fine. The issue is when I change the size of viewport 2 to also a smaller size (not full windowsize), then I see the purple background as in this image

I am trying to place a texture image instead of purple background, but I still can't find a way.

Setting scene.BackgroundTexture in the Draw() doesn't help.



Aug 17, 2012 at 7:55 PM

Purple background means there is nothing drawn on that part. Setting scene.BackgroundTexture won't do anything when you set ShowCameraImage to true. What you need to do is to use SpriteBatch.Draw(...) to draw something before drawing the two viewports.


Aug 17, 2012 at 8:10 PM

In other words, do the following:

State.SharedSpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque);
// Draw some texture here before drawing the two viewports below
State.SharedSpriteBatch.Draw(arViewRenderTarget, arViewRect, Color.White);
State.SharedSpriteBatch.Draw(vrViewRenderTarget, vrViewRect, Color.White);

Aug 18, 2012 at 12:03 AM

Awesome saver. You save my day again.

Thanks and have a nice weekend.