Tutorial 06 - Camera Setup

Now we're going to start with a very important subject: Cameras. Do you still remember the layer composition example of the first tutorial? We will use it here. Right now, only one camera is used. Let's add another one:

SDE.Graphic.Camera3 cam2 gMan.CreateCamera3D();
cam.AddToScene(decal);
cam2.Position = new Vector3(1,1,-3);
cam2.Target = new Vector3();
cam2.Background System.Drawing.Color.Red;

cam2.AddLight(light1);
cam2.AddLight(light2);
gMan.AddCamera(cam2);

So we've got another camera but... what's the problem now? the second camera, overlaps the image rendered with the first camera. And there's another problem: the billboard allways looks to the camera, so we're going to change it and use a DecalNode, which is also a plane, but doesn't look at the camera. Furthermore, cameras have got an Id, and the engine sorts them using that Id. If both Ids are zero (by default) the order could be different each frame. Let's fix everything:

cam.Id 0;
cam2.Id 1;

// Decal creation
SDE.Graphic.DecalNode decal gMan.CreateDecalNode();
decal.Position = new Vector3(0,0,-2);
decal.Normal = new Vector3(0,0,-1);
decal.Material gMan.Core.CreateMaterial("decal");
decal.Material.Textures[0gMan.Core.GetTexture("../../../Bin/Media/sde-logo.png");
decal.Material.Type SDE.Graphic.Material.Blending.Transparent;
decal.Material.Lighting = true;

// Lights must be added to the 2nd camera just like the objects
cam2.AddToScene(decal);

// We can do a 'mini-window' setting the size of the viewport (rendering size)
cam2.ViewPortSize = new Vector2(400,300);

Both cameras are shown

Now we've got a little part of the screen rendered by the second camera, so we can see both scenes (or the same scene in a different point of view). The other way of solve the overlapping problem is to make the background color of the second camera transparent. This way:

cam2.Background System.Drawing.Color.Transparent;

The second camera with a transparent background color

This technique is very useful with GUIs, that will be explained in another tutorial. Cameras have other interesting properties like AspectRatio, Fov or Fog related properties. You can play a little bit with them and see how affect the scene.