My Project
Public Member Functions | Public Attributes | List of all members
ParaScripting::ParaMiniSceneGraph Class Reference

ParaMiniSceneGraph class: More...

#include <ParaScriptingScene.h>

Public Member Functions

 ParaMiniSceneGraph (CMiniSceneGraph *pGraph)
 
const char * GetName ()
 get name
 
void SetName (const char *sName)
 set the object name. More...
 
bool IsValid () const
 check if the object is valid
 
ParaAttributeObject GetAttributeObject ()
 get the attribute object associated with the global scene. More...
 
ParaAttributeObject GetAttributeObject1 (const char *name)
 get the attribute object associated with the global scene. More...
 
void GetAttributeObject_ (ParaAttributeObject &output)
 used for API exportation. More...
 
ParaAttributeObject GetAttributeObjectCamera ()
 get the attribute object associated with the current camera object. More...
 
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. More...
 
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. More...
 
void EnableLighting (bool bEnable)
 Enable both global and local lighting. More...
 
bool IsLightingEnabled ()
 
void SetTimeOfDaySTD (float time)
 set standard time. More...
 
float GetTimeOfDaySTD ()
 get standard time. More...
 
void SetFog (bool bRenderFog, const char *strFogColor, float fFogStart, float fFogEnd, float fFogDensity)
 set the global fog effect More...
 
bool IsVisible ()
 invisible object will not be drawn. More...
 
void SetVisible (bool bVisible)
 set the visibility of this object. More...
 
void EnableCamera (bool bEnable)
 enable or disable a given camera
 
bool IsCameraEnabled ()
 whether camera is enabled. More...
 
ParaObject GetObject (const char *name)
 update the camera parameter by providing the lookat and eye position More...
 
ParaObject GetObject3 (float x, float y, float z)
 get the first object that matches the position. More...
 
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. More...
 
int RemoveObject_ (const ParaObject &pObj)
 remove an object from this scene graph but do not destroy it. More...
 
void AddChild (const ParaObject obj)
 attach the object as its child object. More...
 
int DestroyObject (const char *name)
 destroy all objects with the given name. More...
 
int DestroyObject_ (const ParaObject &pObj)
 delete an object from this scene graph but do not destroy it.This function will search the scene recursively this function can be used to move a node from one scene graph to another Note: this is like calling RemoveObject(pObj) and then delete the object. More...
 
void DestroyChildren ()
 destroy all children of this mini-scenegraph. More...
 
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. More...
 
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. More...
 
void CameraZoom (float fAmount)
 Zoom the camera. More...
 
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 More...
 
void CameraRotate (float dx, float dy, float dz)
 rotate the camera round the object on canvas More...
 
void CameraPan (float dx, float dy)
 pan the camera More...
 
void CameraSetLookAtPos (float x, float y, float z)
 set the camera look at position
 
void CameraGetLookAtPos (float *x, float *y, float *z)
 
void CameraSetEyePosByAngle (float fRotY, float fLiftupAngle, float fCameraObjectDist)
 set the camera eye position More...
 
void CameraGetEyePosByAngle (float *fRotY, float *fLiftupAngle, float *fCameraObjectDist)
 
void CameraSetEyePos (double x, double y, double z)
 
void CameraGetEyePos (double *x, double *y, double *z)
 
void Draw (float fDeltaTime)
 draw the content of the scene graph to the current render target. More...
 
void SaveToFile (const char *sFileName, int nImageSize=0)
 save to file. More...
 
void SaveToFileEx (const char *sFileName, int width=0, int height=0, DWORD dwFormat=3, UINT MipLevels=0, int srcLeft=0, int srcTop=0, int srcWidth=0, int srcHeight=0)
 
void SetRenderTargetSize (int nWidth, int nHeight)
 set the canvas size in pixels More...
 
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. More...
 
void SetMaskTexture (ParaAssetObject pTexture)
 this is an optional 2D mask, which is drawn over the entire canvas after scene is rendered in to it. More...
 
void EnableActiveRendering (bool bEnable)
 if true, contents will be drawn to the current render target each frame. More...
 
bool IsActiveRenderingEnabled ()
 if true, contents will be drawn to the current render target each frame. More...
 
ParaObject MousePick (float x, float y, float fMaxDistance, const char *sFilterFunc)
 Pick scene object at the current mouse cursor position. More...
 
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::WeakPtr_type m_pSceneGraph
 

Detailed Description

ParaMiniSceneGraph class:

Member Function Documentation

§ AddChild()

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

attach the object as its child object.

Parameters
objthe child object to attach

§ CameraPan()

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

pan the camera

Parameters
dxrelative amount in pixels
dyrelative amount in pixels

§ CameraRotate()

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

rotate the camera round the object on canvas

Parameters
dx
dyrelative amount in radian.
dz

§ CameraSetEyePosByAngle()

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

set the camera eye position

Parameters
fRotYrotation of the camera around the Y axis, in the world coordinate.
fLiftupAnglelift up angle of the camera.
fCameraObjectDistthe distance from the camera eye to the object being followed.

§ CameraZoom()

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

Zoom the camera.

Parameters
fAmount

§ CameraZoomSphere()

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_xsphere center x
center_ysphere center y
center_zsphere center z
raduissphere raduis

§ CreateSkyBox()

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
strObjectNamesky name
strMeshAssetNamemesh asset name. this is not the file name.
fScaleXthe static mesh local transform scale along the x axis
fScaleYthe static mesh local transform scale along the y axis
fScaleZthe static mesh local transform scale along the z axis
fHeightOffsetthe translation along the y axis.

§ DeleteSkyBox()

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

delete a name sky box.

Parameters
strObjectNameif this is "", all sky boxes will be deleted.

§ DestroyChildren()

void ParaScripting::ParaMiniSceneGraph::DestroyChildren ( )

destroy all children of this mini-scenegraph.

but still preserving other settings like camera and render target.

§ DestroyObject()

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.

§ DestroyObject_()

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

delete an object from this scene graph but do not destroy it.This function will search the scene recursively this function can be used to move a node from one scene graph to another Note: this is like calling RemoveObject(pObj) and then delete the object.

Parameters
pObjobject to delete.

§ Draw()

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.

§ EnableActiveRendering()

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.

§ EnableLighting()

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

Enable both global and local lighting.

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

§ GetAttributeObject()

ParaAttributeObject ParaScripting::ParaMiniSceneGraph::GetAttributeObject ( )

get the attribute object associated with the global scene.

§ GetAttributeObject1()

ParaScripting::ParaAttributeObject ParaScripting::ParaMiniSceneGraph::GetAttributeObject1 ( const char *  name)

get the attribute object associated with the global scene.

Parameters
name"" for global scene, "sky" for sky, "camera" for camera, "sun" for sun.

§ GetAttributeObject_()

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

used for API exportation.

§ GetAttributeObjectCamera()

ParaScripting::ParaAttributeObject ParaScripting::ParaMiniSceneGraph::GetAttributeObjectCamera ( )

get the attribute object associated with the current camera object.

§ GetObject()

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

update the camera parameter by providing the lookat and eye position

get the camera parameter of the lookat and eye position in scripting interface all inputs are outputs. 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

§ GetObject3()

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

get the first object that matches the position.

EPSILON is 0.01f

§ GetTexture()

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

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

Returns

§ GetTimeOfDaySTD()

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.

§ IsActiveRenderingEnabled()

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.

§ IsCameraEnabled()

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

§ IsVisible()

bool ParaScripting::ParaMiniSceneGraph::IsVisible ( )

invisible object will not be drawn.

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

§ MousePick()

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
xscreen position relative to the render target.
yscreen 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.
sFnctFilterit 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. "terrain": pick a point on the global terrain only. "walkpoint": pick a point on the global terrain or any physical object with camera obstruction attribute set to true. "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.

§ RemoveObject()

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

§ RemoveObject_()

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

§ SaveToFile()

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

save to file.

Parameters
sFileNamea 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.
nImageSizeif this is zero, the original size is used. If it is dds, all mip map levels are saved.

§ SetActor()

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
pActorit must be a valid object.

§ SetBackGroundColor()

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
rgbait can contain alpha channel, such as "255 255 255 128". If no alpha is specified like "255 255 255", alpha will be 1.0

§ SetFog()

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

set the global fog effect

Parameters
bRenderFog1 to enable fog.
strFogColora 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].
fFogDensitybetween (0,1)
fFogStartunit in meters.
fFogEndunit in meters.

§ SetMaskTexture()

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

§ SetName()

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

set the object name.

this function can be used to rename this object

§ SetRenderTargetSize()

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

set the canvas size in pixels

Parameters
nWidthdefault to 512
nHeightdefault to 512

§ SetTimeOfDaySTD()

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

set standard time.

see SetTimeOfDay()

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

§ SetVisible()

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

set the visibility of this object.

The visibility will recursively affect all its child objects.


The documentation for this class was generated from the following files: