Ecere SDK/eC Forums • View topic - Cameras, Skyboxes

Ecere SDK/eC Forums

Ecere Developers Community

Cameras, Skyboxes

Help with the Ecere 3D Graphics Engine: Camera, Mesh, Object, Material, OpenGL integration, etc.

Cameras, Skyboxes

Postby sacrebleu » Thu Jan 21, 2010 12:33 am

Tell me about controlling and using Cameras with background skyboxes. :shock:
Posts: 27
Joined: Sun Jan 17, 2010 12:37 pm

Re: Cameras, Skyboxes

Postby jerome » Fri Mar 12, 2010 1:24 am

Sorry for the long delay :)

Let's start with the Camera API.

You must create a Camera object. You then use this camera object in a Window's OnRedraw method by 'setting it' on the surface to enter '3D graphics' mode, and then unsetting it to return to 2D mode:
Code: Select all
void OnRedraw(Surface surface)
   display.SetCamera(surface, camera);
   // --> Draw 3D things here <--
   display.SetCamera(surface, null);

A sample camera object instantiation could look like this:
Code: Select all
Camera camera
   type = fixed;
   position = { 0, 0, -300 };
   orientation = Euler { 0, 0, 0 };
   zMax = 340000;

This creates a fixed camera, at position (0, 0, -300) and looking straight ahead. It also sets the maximum depth range value to 340,000.

The Camera class as some sensible defaults (fixed, position of (0,0,0), orientation of (0,0,0), 90 degrees field of view, zMin = 5, zMax = 10000) which could let you get by with a simple "Camera { }" assuming there is something to see from the (0,0,0) location in your scene.

Note that you will need to call Camera::Setup() with the width and height of the viewport in which you wish to use the camera, for example in a Window's OnResize() event. You will also need to call Camera::Update() prior to using it after any modification to the camera's settings.
Code: Select all
void OnResize(int w, int h)
   camera.Setup(w, h, null);

The camera defines the following properties:

Camera Type
The type can be:
    fixed: Simple position and orientation.
    fixedQuaternion: Same as fixed, except orientation will be stored and modified as a quaternion.
    attached: Always at a specific position offset from a target object (Specified in 'target' property), and rotation object to that object's orientation. Changing the orientation spins around the center of that object, increasing the z component of the position brings the camera further away from the center of the object.
    attachedQuaternion: Same as attached, except the orientation is combined with the target object through quaternion multiplication.
    lookAt: The camera looks from its position and orientation towards the 'target' object's position.
    lookAtObject: The camera is defined itself as an Object, and looking towards another 'target' Object. This is generated by camera objects loaded from 3DS files.

... To be continued...

Checkout the terrain & camera sample.


Computed Position (cPosition)
Computed Orientation (cOrientation)
Field of View (fov)
Object targe
FovDirection fovDirection
Screen shot of terrain & camera sample
Site Admin
Posts: 621
Joined: Sat Jan 16, 2010 11:16 pm

Return to 3D Graphics

Who is online

Users browsing this forum: No registered users and 1 guest