Project

General

Profile

Scol standard library package  0.3.1
Common and usefull functions for all Scol applications
The library : 3d camera API

Functions

 b3d_cameraAdd (strSession, name, flag)
 Add a camera in a given session.
 b3d_cameraDestroy (strSession, cam)
 Destroy a camera.
 b3d_cameraGetFromId (strSession, id)
 Get the camera object from a camera id.
 b3d_cameraGetFromInit (strSession)
 Get the the camera which it created during the 3d session initialization.
 b3d_cameraGetFromName (strSession, name)
 Get the the camera from its name.
 b3d_cameraGetIdFromCamera (strSession, cam)
 Get the name from a camera id.
 b3d_cameraGetNameFromId (strSession, id)
 Get the name from a camera id.
 b3d_cameraGetOrthographicWindow (camera)
 Get the orthographic window settings, for use with orthographic rendering only.
 b3d_cameraGetParams (camera)
 Return the camera parameters.
 b3d_cameraGetProjection (camera)
 Get the current mode of projection to use with this camera.
 b3d_cameraRestoreLast (strSession)
 Restore the last used camera before the current camera.
 b3d_cameraSetDefault (strSession, cam)
 Set a camera as the default camera.
 b3d_cameraSetOrthographicWindow (camera, width, height)
 Sets the orthographic window settings, for use with orthographic rendering only.
 b3d_cameraSetOrthographicWindowFromScale (camera, scale)
 Sets the orthographic window settings, for use with orthographic rendering only.
 b3d_cameraSetParams (camera, focalLength, fovy, near, far)
 Set the camera parameters.
 b3d_cameraSetParamsFromId (strSession, id, focalLength, fovy, near, far)
 Set the camera parameters.
 b3d_cameraSetProjection (camera, mode)
 Set the mode of projection to use with this camera.
 b3d_cameraSetProjectionFromId (strSession, id, mode)
 Set the mode of projection to use with this camera.

Detailed Description

Function Documentation

b3d_cameraAdd ( strSession  ,
name  ,
flag   
)

Add a camera in a given session.

Prototype : fun [LIB3D_Session S I] [SO3_OBJECT I]

Parameters
LIB3D_Session: a session object
S: a name for the new camera
I: define if this camera is (or becomes) the default camera or not. Possible values are : iLIB3S_ISDEFAULT or nil
Returns
[SO3_OBJECT I] : the new camera object and the new camera id or nil if error
b3d_cameraGetNameFromId ( strSession  ,
id   
)

Get the name from a camera id.

Prototype : fun [LIB3D_Session I] S

Parameters
LIB3D_Session: a session object
I: a camera id
Returns
I : the name or nil if error (or not found)
b3d_cameraGetFromId ( strSession  ,
id   
)

Get the camera object from a camera id.

Prototype : fun [LIB3D_Session I] SO3_OBJECT

Parameters
LIB3D_Session: a session object
I: a camera id
Returns
SO3_OBJECT : the camera object or nil if error (or not found)
b3d_cameraGetIdFromCamera ( strSession  ,
cam   
)

Get the name from a camera id.

Prototype : fun [LIB3D_Session SO3_OBJECT] I

Parameters
LIB3D_Session: a session object
SO3_OBJECT: a camera object
Returns
I : the camera id or nil if error (or not found)
b3d_cameraGetFromName ( strSession  ,
name   
)

Get the the camera from its name.

Prototype : fun [LIB3D_Session S] SO3_OBJECT

Parameters
LIB3D_Session: a session object
S: a name
Returns
SO3_OBJECT : the camera or nil if error (or not found)
b3d_cameraGetFromInit ( strSession  )

Get the the camera which it created during the 3d session initialization.

Prototype : fun [LIB3D_Session] SO3_OBJECT

Parameters
LIB3D_Session: a session object
Returns
SO3_OBJECT : the camera or nil if error (or not found)
Examples:
3d_test/test_3d.pkg_.
b3d_cameraRestoreLast ( strSession  )

Restore the last used camera before the current camera.

The current camera is not destroyed : it is stored to be the next last camera, if any. This is similar as an undo/redo.

Prototype : fun [LIB3D_Session SO3_OBJECT] I

Parameters
LIB3D_Session: a session object
SO3_OBJECT: a camera object
Returns
I : 0 if success or a positive value if error :
  • 1 : 3d session object is nil
  • 2 : no default camera set
  • 3 : 3d view object which the 3d session is, is nil
  • 4 : the last stored default camera is nil
b3d_cameraSetDefault ( strSession  ,
cam   
)

Set a camera as the default camera.

Prototype : fun [LIB3D_Session SO3_OBJECT] I

Parameters
LIB3D_Session: a session object
SO3_OBJECT: a camera object
Returns
I : 0 if success or a positive value if error :
  • 1 : 3d session object is nil
  • 2 or 5 : the camera object is nil
  • 3 : no 3D View for this session
  • 4 : the 3d viewport is nil
  • 6 : for an internal reason, the camera can not set to the given 3d viewport.
b3d_cameraDestroy ( strSession  ,
cam   
)

Destroy a camera.

If the camera is destroyed, the last default camera is set to default camera. If no previous camera has been set, the first camera found will be set.

Prototype : fun [LIB3D_Session SO3_OBJECT] I

Parameters
LIB3D_Session: a session object
SO3_OBJECT: a camera object
Returns
I : 0 if success or a positive value if error :
  • 1 or 4 : 3d session object is nil
  • 2 or 5 : the camera object is nil
  • 3 : unable to destroy the camera, probably it was already destroyed
  • 6 : the 3d viewport is nil
  • 7 : for an internal reason, the camera can not set to the given 3d viewport.
  • 9 : no camera object is in this given session, so no camera set.
b3d_cameraSetParams ( camera  ,
focalLength  ,
fovy  ,
near  ,
far   
)

Set the camera parameters.

Prototype : fun [SO3_OBJECT F F F F] I

Parameters
SO3_OBJECT: a camera object.
F: the focal length. If nil, this parameter is unchanged.
F: the FOVy. If nil, this parameter is unchanged.
F: the near clip distance. If nil, this parameter is unchanged.
F: the far clip distance. If nil, this parameter is unchanged.
Returns
I : 0 if success or a positive value if error (these values can be combined) :
  • 16 : camera object is nil
  • 1 : unable to set the focal length
  • 2 : unable to set the FOVy
  • 4 : unable to set the near clip distance
  • 8 : unable to set the far clip distance
Examples:
3d_test/test_3d.pkg_.
b3d_cameraGetParams ( camera  )

Return the camera parameters.

Prototype : fun [SO3_OBJECT] [F F F F]

Parameters
SO3_OBJECT: a camera object.
Returns
[F F F F] : the focal length, the FOVy, the near and the far clip distance or nil if error
b3d_cameraSetParamsFromId ( strSession  ,
id  ,
focalLength  ,
fovy  ,
near  ,
far   
)

Set the camera parameters.

Prototype : fun [I F F F F] I

Parameters
I: a camera id.
F: the focal length. If nil, this parameter is unchanged.
F: the FOVy. If nil, this parameter is unchanged.
F: the near clip distance. If nil, this parameter is unchanged.
F: the far clip distance. If nil, this parameter is unchanged.
Returns
I : 0 if success or a positive value if error (these values can be combined) :
  • 32 : the 3d session is nil
  • 16 : camera object is nil (the given id should be incorrect)
  • 1 : unable to set the focal length
  • 2 : unable to set the FOVy
  • 4 : unable to set the near clip distance
  • 8 : unable to set the far clip distance
b3d_cameraSetProjection ( camera  ,
mode   
)

Set the mode of projection to use with this camera.

Prototype : fun [SO3_OBJECT I] I

Parameters
SO3_OBJECT: a camera object.
I: the choosen mode : SO3_PROJECTION_PERSPECTIVE or SO3_PROJECTION_ORTHOGRAPHIC. SO3_PROJECTION_PERSPECTIVE is the default mode. If another value is given, the camera will set to this default mode.
Returns
I : 0 if success or a positive value if error (these values can be combined) :
  • 1 : camera object is nil
  • 2 : the operation is not performed
b3d_cameraSetProjectionFromId ( strSession  ,
id  ,
mode   
)

Set the mode of projection to use with this camera.

Prototype : fun [SO3_OBJECT I] I

Parameters
SO3_OBJECT: a camera object.
I: the choosen mode : SO3_PROJECTION_PERSPECTIVE or SO3_PROJECTION_ORTHOGRAPHIC. SO3_PROJECTION_PERSPECTIVE is the default mode. If another value is given, the camera will set to this default mode.
Returns
I : 0 if success or a positive value if error (these values can be combined) :
  • 1 : camera object is nil (the given id should be incorrect)
  • 2 : the operation is not performed
  • 3 : the given 3d session is nil
b3d_cameraGetProjection ( camera  )

Get the current mode of projection to use with this camera.

Prototype : fun [SO3_OBJECT] I

Parameters
SO3_OBJECT: a camera object.
Returns
I : SO3_PROJECTION_PERSPECTIVE or SO3_PROJECTION_ORTHOGRAPHIC if success or nil if error
b3d_cameraSetOrthographicWindow ( camera  ,
width  ,
height   
)

Sets the orthographic window settings, for use with orthographic rendering only.

Prototype : fun [SO3_OBJECT F F] I

Parameters
SO3_OBJECT: a camera object.
F: the width in world unit.
F: the height in world unit.
Returns
I : 0 if success or a positive value if error :
  • 1 : the camera opbject is nil
  • 2 : the mode of the given camera is not 'orthographic'
  • 3 : the operation has not been performed
b3d_cameraSetOrthographicWindowFromScale ( camera  ,
scale   
)

Sets the orthographic window settings, for use with orthographic rendering only.

Prototype : fun [SO3_OBJECT F] I

Parameters
SO3_OBJECT: a camera object.
F: a scale ratio.
Returns
I : 0 if success or a positive value if error :
  • 1 : the camera opbject is nil
  • 2 : the mode of the given camera is not 'orthographic'
  • 3 : the operation has not been performed
Remarks
b3d_cameraSetOrthographicWindow is recommended instead.
See Also
b3d_cameraSetOrthographicWindow
b3d_cameraGetOrthographicWindow ( camera  )

Get the orthographic window settings, for use with orthographic rendering only.

Prototype : fun [SO3_OBJECT] [F F]

Parameters
SO3_OBJECT: a camera object.
Returns
[F F] : the result (width, height) or nil if error