ParaScripting::ParaMiniSceneGraph Class Reference
[ParaScene]

List of all members.

Detailed Description

ParaMiniSceneGraph class:.


Public Member Functions

 ParaMiniSceneGraph (CMiniSceneGraph *pGraph)
const char * GetName ()
 get name
void SetName (const char *sName)
 set the object name.
bool IsValid ()
 check if the object is valid
ParaAttributeObject GetAttributeObject ()
 get the attribute object associated with the global scene.
void GetAttributeObject_ (ParaAttributeObject &output)
 used for API exportation.
ParaAttributeObject GetAttributeObjectSky ()
 get the attribute object associated with the current sky object.
void GetAttributeObjectSky_ (ParaAttributeObject &output)
 used for API exportation.
bool CreateSkyBox (const char *strObjectName, const char *strMeshAssetName, float fScaleX, float fScaleY, float fScaleZ, float fHeightOffset)
 create a sky box and add it to the current list.
bool CreateSkyBox_ (const char *strObjectName, ParaAssetObject &asset, float fScaleX, float fScaleY, float fScaleZ, float fHeightOffset)
void DeleteSkyBox (const char *strObjectName)
 delete a name sky box.
void EnableLighting (bool bEnable)
 Enable both global and local lighting.
bool IsLightingEnabled ()
void SetTimeOfDaySTD (float time)
 set standard time.
float GetTimeOfDaySTD ()
 get standard time.
void SetFog (bool bRenderFog, const char *strFogColor, float fFogStart, float fFogEnd, float fFogDensity)
 set the global fog effect
bool IsVisible ()
 invisible object will not be drawn.
void SetVisible (bool bVisible)
 set the visibility of this object.
void EnableCamera (bool bEnable)
 enable or disable a given camera
bool IsCameraEnabled ()
 whether camera is enabled.
ParaObject GetObject (const char *name)
 get object by name, if there are multiple objects with the same name, the last added one is inserted.
ParaObject GetObject3 (float x, float y, float z)
 get the first object that matches the position.
ParaObject GetObject4 (float x, float y, float z, float fEpsilon)
 get the first object that matches the position within fEpsilon, which is usually 0.01f
int RemoveObject (const char *name)
 remove an object from this scene graph but do not destroy it.
int RemoveObject_ (const ParaObject &pObj)
 remove an object from this scene graph but do not destroy it.
void AddChild (const ParaObject obj)
 attach the object as its child object.
int DestroyObject (const char *name)
 destroy all objects with the given name.
void DestroyChildren ()
 destroy all children of this mini-scenegraph.
void Reset ()
 clear the entire scene graph
void SetActor (const ParaObject pActor)
 set the actor: The camera always focuses on actor, so this actor can be used to control the current camera position.
ParaObject GetActor ()
 get the current actor
ParaAssetObject GetTexture ()
 the canvas texture, which can be used as any other ordinary texture on 3D or 2D object.
void CameraZoom (float fAmount)
 Zoom the camera.
void CameraZoomSphere (float center_x, float center_y, float center_z, float raduis)
 reset the camera parameters to view the entire sphere at best (default) distance
void CameraRotate (float dx, float dy, float dz)
 rotate the camera round the object on canvas
void CameraPan (float dx, float dy)
 pan the camera
void CameraSetLootAtPos (float x, float y, float z)
 set the camera look at position
void CameraGetLootAtPos (float *x, float *y, float *z)
void CameraSetEyePosByAngle (float fRotY, float fLiftupAngle, float fCameraObjectDist)
 set the camera eye position
void CameraGetEyePosByAngle (float *fRotY, float *fLiftupAngle, float *fCameraObjectDist)
void CameraSetEyePos (float x, float y, float z)
void CameraGetEyePos (float *x, float *y, float *z)
void Draw (float fDeltaTime)
 draw the content of the scene graph to the current render target.
void SaveToFile (const char *sFileName, int nImageSize=0)
 save to file.
void SetRenderTargetSize (int nWidth, int nHeight)
 set the canvas size in pixels
void SetBackGroundColor (const char *rgba)
 set the color of the scene ground when it is not enabled.When scene is enabled, the background color is always the fog color.
void SetMaskTexture (ParaAssetObject pTexture)
 this is an optional 2D mask, which is drawn over the entire canvas after scene is rendered in to it.
void EnableActiveRendering (bool bEnable)
 if true, contents will be drawn to the current render target each frame.
bool IsActiveRenderingEnabled ()
 if true, contents will be drawn to the current render target each frame.
ParaObject MousePick (float x, float y, float fMaxDistance, const char *sFilterFunc)
 Pick scene object at the current mouse cursor position.
void ShowHeadOnDisplay (bool bShow)
 show or hide all scene's objects' head on display
bool IsHeadOnDisplayShown ()
 whether all scene's objects' head on display

Public Attributes

CMiniSceneGraph * m_pSceneGraph


Member Function Documentation

void ParaScripting::ParaMiniSceneGraph::SetName ( const char *  sName  ) 

set the object name.

this function can be used to rename this object

ParaAttributeObject ParaScripting::ParaMiniSceneGraph::GetAttributeObject (  ) 

get the attribute object associated with the global scene.

void ParaScripting::ParaMiniSceneGraph::GetAttributeObject_ ( ParaAttributeObject output  ) 

used for API exportation.

ParaAttributeObject ParaScripting::ParaMiniSceneGraph::GetAttributeObjectSky (  ) 

get the attribute object associated with the current sky object.

void ParaScripting::ParaMiniSceneGraph::GetAttributeObjectSky_ ( ParaAttributeObject output  ) 

used for API exportation.

bool ParaScripting::ParaMiniSceneGraph::CreateSkyBox ( const char *  strObjectName,
const char *  strMeshAssetName,
float  fScaleX,
float  fScaleY,
float  fScaleZ,
float  fHeightOffset 
)

create a sky box and add it to the current list.

sky box with the same name will not be recreated,but will be selected as the current sky box. It may be a sky box/dome/plane or whatever. The associated mesh will be scaled by the specified amount along x,y,z axis and then translate up or down along the y axis. in many cases, the mesh data in the mesh asset is of unit size.

Parameters:
strObjectName,: sky name
strMeshAssetName,: mesh asset name. this is not the file name.
fScaleX,: the static mesh local transform scale along the x axis
fScaleY,: the static mesh local transform scale along the y axis
fScaleZ,: the static mesh local transform scale along the z axis
fHeightOffset,: the translation along the y axis.

void ParaScripting::ParaMiniSceneGraph::DeleteSkyBox ( const char *  strObjectName  ) 

delete a name sky box.

Parameters:
strObjectName,: if this is "", all sky boxes will be deleted.

void ParaScripting::ParaMiniSceneGraph::EnableLighting ( bool  bEnable  ) 

Enable both global and local lighting.

Turn off lighting will greatly improve performance, such as on slower computers

void ParaScripting::ParaMiniSceneGraph::SetTimeOfDaySTD ( float  time  ) 

set standard time.

see SetTimeOfDay()

Parameters:
time,: always in the range [-1,1], 0 means at noon, -1 is morning. 1 is night.

float ParaScripting::ParaMiniSceneGraph::GetTimeOfDaySTD (  ) 

get standard time.

see GetTimeOfDay()

Returns:
: always in the range [-1,1], 0 means at noon, -1 is morning. 1 is night.

void ParaScripting::ParaMiniSceneGraph::SetFog ( bool  bRenderFog,
const char *  strFogColor,
float  fFogStart,
float  fFogEnd,
float  fFogDensity 
)

set the global fog effect

Parameters:
bRenderFog,: 1 to enable fog.
strFogColor,: a string of RGB value in the format "%f %f %f", such as "1.0 1.0 1.0", value must be in the range [0, 1.0].
fFogDensity,: between (0,1)
fFogStart,: unit in meters.
fFogEnd,: unit in meters.

bool ParaScripting::ParaMiniSceneGraph::IsVisible (  ) 

invisible object will not be drawn.

e.g. one can turn off the visibility of physics object.

void ParaScripting::ParaMiniSceneGraph::SetVisible ( bool  bVisible  ) 

set the visibility of this object.

The visibility will recursively affect all its child objects.

bool ParaScripting::ParaMiniSceneGraph::IsCameraEnabled (  ) 

whether camera is enabled.

it is disabled by default. it is much faster to disable camera, because it will use the main scene's render pipeline and effects. Otherwise it will be rendered after the main scene is rendered, since the camera is different. TODO: currently mini scene graph is only rendered when its camera is disabled. local camera is not supported at the moment

ParaScripting::ParaObject ParaScripting::ParaMiniSceneGraph::GetObject ( const char *  name  ) 

get object by name, if there are multiple objects with the same name, the last added one is inserted.

Note:
: This function will traverse the scene to search the object. So there might be some performance penalty.
Parameters:
name,: 

ParaObject ParaScripting::ParaMiniSceneGraph::GetObject3 ( float  x,
float  y,
float  z 
)

get the first object that matches the position.

EPSILON is 0.01f

int ParaScripting::ParaMiniSceneGraph::RemoveObject ( const char *  name  ) 

remove an object from this scene graph but do not destroy it.

this function can be used to move a node from one scene graph to another

int ParaScripting::ParaMiniSceneGraph::RemoveObject_ ( const ParaObject pObj  ) 

remove an object from this scene graph but do not destroy it.

this function can be used to move a node from one scene graph to another

void ParaScripting::ParaMiniSceneGraph::AddChild ( const ParaObject  obj  ) 

attach the object as its child object.

Parameters:
obj,: the child object to attach

int ParaScripting::ParaMiniSceneGraph::DestroyObject ( const char *  name  ) 

destroy all objects with the given name.

the current version will only destroy the first met child with the given name.

Returns:
the number of objects deleted.

void ParaScripting::ParaMiniSceneGraph::DestroyChildren (  ) 

destroy all children of this mini-scenegraph.

but still preserving other settings like camera and render target.

void ParaScripting::ParaMiniSceneGraph::SetActor ( const ParaObject  pActor  ) 

set the actor: The camera always focuses on actor, so this actor can be used to control the current camera position.

Parameters:
pActor,: it must be a valid object.

ParaScripting::ParaAssetObject ParaScripting::ParaMiniSceneGraph::GetTexture (  ) 

the canvas texture, which can be used as any other ordinary texture on 3D or 2D object.

Returns:

void ParaScripting::ParaMiniSceneGraph::CameraZoom ( float  fAmount  ) 

Zoom the camera.

Parameters:
fAmount 

void ParaScripting::ParaMiniSceneGraph::CameraZoomSphere ( float  center_x,
float  center_y,
float  center_z,
float  raduis 
)

reset the camera parameters to view the entire sphere at best (default) distance

Parameters:
center_x,: sphere center x
center_y,: sphere center y
center_z,: sphere center z
raduis,: sphere raduis

void ParaScripting::ParaMiniSceneGraph::CameraRotate ( float  dx,
float  dy,
float  dz 
)

rotate the camera round the object on canvas

Parameters:
dx 
dy relative amount in radian.
dz 

void ParaScripting::ParaMiniSceneGraph::CameraPan ( float  dx,
float  dy 
)

pan the camera

Parameters:
dx relative amount in pixels
dy relative amount in pixels

void ParaScripting::ParaMiniSceneGraph::CameraSetEyePosByAngle ( float  fRotY,
float  fLiftupAngle,
float  fCameraObjectDist 
)

set the camera eye position

Parameters:
fRotY rotation of the camera around the Y axis, in the world coordinate.
fLiftupAngle lift up angle of the camera.
fCameraObjectDist the distance from the camera eye to the object being followed.

void ParaScripting::ParaMiniSceneGraph::Draw ( float  fDeltaTime  ) 

draw the content of the scene graph to the current render target.

If EnableActiveRendering is enabled, this function will be called each render frame after the main scene graph. however, if EnableActiveRendering is disabled, one can call this function to render a single frame to the render target on demand.

void ParaScripting::ParaMiniSceneGraph::SaveToFile ( const char *  sFileName,
int  nImageSize = 0 
)

save to file.

Parameters:
sFileName a texture file path to save the file to. we support ".dds", ".jpg", ".png" files. If the file extension is not recognized, ".png" file is used.
nImageSize,: if this is zero, the original size is used. If it is dds, all mip map levels are saved.

void ParaScripting::ParaMiniSceneGraph::SetRenderTargetSize ( int  nWidth,
int  nHeight 
)

set the canvas size in pixels

Parameters:
nWidth default to 512
nHeight default to 512

void ParaScripting::ParaMiniSceneGraph::SetBackGroundColor ( const char *  rgba  ) 

set the color of the scene ground when it is not enabled.When scene is enabled, the background color is always the fog color.

Parameters:
rgba,: it can contain alpha channel, such as "255 255 255 128". If no alpha is specified like "255 255 255", alpha will be 1.0

void ParaScripting::ParaMiniSceneGraph::SetMaskTexture ( ParaAssetObject  pTexture  ) 

this is an optional 2D mask, which is drawn over the entire canvas after scene is rendered in to it.

Parameters:
pTexture 

void ParaScripting::ParaMiniSceneGraph::EnableActiveRendering ( bool  bEnable  ) 

if true, contents will be drawn to the current render target each frame.

Default value is false. where the user can call DrawToTexture() on demand.

bool ParaScripting::ParaMiniSceneGraph::IsActiveRenderingEnabled (  ) 

if true, contents will be drawn to the current render target each frame.

Default value is false. where the user can call DrawToTexture() on demand.

ParaScripting::ParaObject ParaScripting::ParaMiniSceneGraph::MousePick ( float  x,
float  y,
float  fMaxDistance,
const char *  sFilterFunc 
)

Pick scene object at the current mouse cursor position.

pick the smallest intersected object which is un-occluded by any objects. Object A is considered occluded by object B only if (1) both A and B intersect with the hit ray. (2) both A and B do not intersect with each other. (3) B is in front of A, with regard to the ray origin.

this function will ray-pick any loaded scene object(biped & mesh, but excluding the terrain) using their oriented bounding box. a filter function may be provided to further filter selected object. this function will transform all objects to near-camera coordinate system. This will remove some floating point inaccuracy near the camera position.Hence this function is most suitable for testing object near the camera eye position. This function does not rely on the physics engine to perform ray-picking.

Parameters:
x,: screen position relative to the render target.
y,: screen position relative to the render target. fMaxDistance: the longest distance from the ray origin to check for collision. If the value is 0 or negative, the view culling radius is used as the fMaxDistance.
sFnctFilter,: it can be any of the following string or a number string "mesh": mesh any mesh object in the scene. Usually for selection during scene editing. "cmesh": mesh object that is clickable (associated with scripts). Usually for game playing. "notplayer": any object in the scene except for the current player. Usually for selection during scene editing. "": any object in the scene except. Usually for selection during scene editing. "light": only pick light objects "biped": any character objects :local or global. "anyobject": any objects, including mesh and characters. but not including helper objects, such as light. "global": all global objects, such as global character and mesh. This is usually for game mode. "point": the returned object is invalid if there no collision with any physics faces. otherwise, one can use GetPosition function of the returned object to retrieve the intersection point. "actionmesh": mesh with action script. number: if it is a number, it is treated as a 32 bitwise DWORD filter code. see SetPickingFilter() for more example.
Returns:
:the scene object. if the object is invalid, it means that the ray has hit nothing.


Generated on Mon Dec 1 14:34:46 2008 for NPL Scripting Reference for ParaEngine by  doxygen 1.5.2