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

ParaObject class: it is used to control game scene objects from scripts. More...

#include <ParaScriptingScene.h>

Public Member Functions

 ParaObject (CBaseObject *pObj)
 
CBaseObjectget () const
 
const char * GetType ()
 get the Runtime class information of the object. More...
 
int GetMyType () const
 get paraengine defined object type name. More...
 
int GetID ()
 the ID of the object. More...
 
bool IsValid () const
 check if the object is valid
 
bool IsAttached () const
 whether the object has been attached to the scene. More...
 
ParaAssetObject GetPrimaryAsset ()
 get the main asset object associated with this object. More...
 
void GetPrimaryAsset_ (ParaAssetObject *pOut)
 this function shall never be called from the scripting interface. More...
 
ParaParamBlock GetEffectParamBlock ()
 get the parameter block of the effect (shader) associated with this object. More...
 
bool IsPersistent ()
 whether the object is persistent in the world. More...
 
void SetPersistent (bool bPersistent)
 
bool SaveToDB ()
 save the current character to database according to the persistent property. More...
 
bool equals (const ParaObject obj) const
 return true, if this object is the same as the given object.
 
const char * ToString () const
 convert the object to object creation string. More...
 
const char * ToString1 (const char *sMethod) const
 convert the object to string. More...
 
ParaAttributeObject GetAttributeObject ()
 get the attribute object associated with an object. More...
 
void GetAttributeObject_ (ParaAttributeObject &output)
 for API exportation
 
void CheckLoadPhysics ()
 when this function is called, it ensures that the physics object around this object is properly loaded. More...
 
void LoadPhysics ()
 only load physics of this object if it has not loaded. More...
 
object GetField (const char *sFieldname, const object &output)
 get field by name. More...
 
void SetField (const char *sFieldname, const object &input)
 set field by name e.g. More...
 
void CallField (const char *sFieldname)
 call field by name. More...
 
object GetDynamicField (const char *sFieldname, const object &output)
 get field by name. More...
 
void SetDynamicField (const char *sFieldname, const object &input)
 set field by name e.g. More...
 
ParaObject GetObject (const char *name)
 get object by name, if there are multiple objects with the same name, the last added one is inserted. More...
 
bool IsStanding ()
 whether the object has 0 speed. More...
 
bool IsVisible ()
 invisible object will not be drawn. More...
 
void SetVisible (bool bVisible)
 set the visibility of this object. More...
 
bool CheckAttribute (DWORD attribute)
 whether an object attribute is enabled. More...
 
void SetAttribute (DWORD dwAtt, bool bTurnOn)
 enable or disable a given attribute. More...
 
void SetPosition (double x, double y, double z)
 set world position. More...
 
void GetPosition (double *x, double *y, double *z)
 get the world position of the object. More...
 
void GetViewCenter (double *x, double *y, double *z)
 get the world position of the center of the view object. More...
 
void OffsetPosition (float dx, float dy, float dz)
 offset the current object position by (dx,dy,dz) More...
 
void SetFacing (float fFacing)
 set object facing around the Y axis. More...
 
float GetFacing ()
 get object facing around the Y axis
 
void Rotate (float x, float y, float z)
 Rotate the object.This only takes effects on objects having 3D orientation, such as static mesh and physics mesh. More...
 
void Scale (float s)
 set the scale of the object. More...
 
void SetScaling (float s)
 
float GetScale ()
 set the scale of the object. More...
 
void SetScale (float s)
 set scale More...
 
object GetRotation (const object &quat)
 this usually applies only to mesh object. More...
 
void SetRotation (const object &quat)
 set the rotation as quaternion. More...
 
void Reset ()
 reset the object to its default settings. More...
 
void SetPhysicsGroup (int nGroup)
 set the physics group ID to which this object belongs to default to 0, must be smaller than 32. More...
 
int GetPhysicsGroup ()
 Get the physics group ID to which this object belongs to default to 0, must be smaller than 32. More...
 
void SetSelectGroupIndex (int nGroupIndex)
 set the selection group index. More...
 
int GetSelectGroupIndex ()
 get the selection group index. More...
 
void SetDensity (float fDensity)
 body density. More...
 
float GetDensity ()
 get body density
 
float GetPhysicsRadius ()
 the biped is modeled as a cylinder or sphere during rough physics calculation. More...
 
void SetPhysicsRadius (float fR)
 the biped is modeled as a cylinder or sphere during rough physics calculation. More...
 
float GetPhysicsHeight ()
 the biped is modeled as a cylinder or sphere during rough physics calculation. More...
 
void SetPhysicsHeight (float fHeight)
 the biped is modeled as a cylinder or sphere during rough physics calculation. More...
 
string GetName () const
 get the object name
 
const char * GetName_ () const
 for .NET API use only.not thread safe. More...
 
void SetName (const char *sName)
 set the object name More...
 
void SnapToTerrainSurface (int bUseNorm)
 snap to terrain surface. More...
 
bool IsCharacter () const
 
bool IsOPC () const
 
ParaCharacter ToCharacter ()
 return the ParaCharacter object, if this object is a biped typed scene object. More...
 
IGameObjectToGameObject ()
 convert to game object. More...
 
void AddEvent (const char *strEvent, int nEventType, bool bIsUnique)
 add events to object to control the object, please refer to HLE for object event specifications. More...
 
void AddChild (const ParaObject obj)
 attach the object as its child object. More...
 
void EnablePhysics (bool bEnable)
 if this is a physics mesh object, this function will turn on or off the physics of the object. More...
 
bool IsPhysicsEnabled ()
 whether this is a physics mesh object
 
float DistanceTo (ParaObject obj)
 get the distance with another object
 
float DistanceToSq (ParaObject obj)
 get the distance square with another object
 
float DistanceToPlayerSq ()
 get the distance square with the current player object
 
float DistanceToCameraSq ()
 get the distance square with the camera object
 
object GetViewBox (const object &output)
 get the view box. More...
 
bool HasAttachmentPoint (int nAttachmentID)
 return whether this model has a given attachment point More...
 
void GetAttachmentPosition (int nAttachmentID, float *x, float *y, float *z)
 return this object's attachment point e.g. More...
 
void SetHomeZone (const char *sHomeZone)
 set the home zone of this object if any. More...
 
const char * GetHomeZone ()
 get the home zone of this object if any. More...
 
void SetHeadOnText (const char *sText, int nIndex)
 set the text to be displayed on head on display
 
const char * GetHeadOnText (int nIndex)
 Get the text to be displayed on head on display.
 
void SetHeadOnUITemplateName (const char *sUIName, int nIndex)
 set which UI control the head on display will be used as a template for drawing the text it can be a single CGUIText Object or it can be a container with a direct children called "text" if this is "" or empty, the default UI template will be used. More...
 
const char * GetHeadOnUITemplateName (int nIndex)
 get which UI control the head on display will be used as a template for drawing the text it can be a single CGUIText Object or it can be a container with a direct children called "text" if this is "" or empty, the default UI template will be used. More...
 
void SetHeadOnTextColor (const char *color, int nIndex)
 set the text to be displayed on head on display More...
 
void SetHeadOnOffest (float x, float y, float z, int nIndex)
 set the offset where head on display should be rendered relative to the origin or head of the host 3d object
 
void GetHeadOnOffset (int nIndex, float *x, float *y, float *z)
 Get the offset where head on display should be rendered relative to the origin or head of the host 3d object.
 
void ShowHeadOnDisplay (bool bShow, int nIndex)
 show or hide object's head on display
 
bool IsHeadOnDisplayShown (int nIndex)
 whether the object head on display shall be visible
 
bool HasHeadOnDisplay (int nIndex)
 whether the object contains head on display
 
int GetXRefScriptCount ()
 get the number of the script X reference instances
 
const char * GetXRefScript (int nIndex)
 return xref script file path by index
 
void GetXRefScriptPosition (int nIndex, float *x, float *y, float *z)
 get the 3D position in world space of the script object's origin
 
void GetXRefScriptScaling (int nIndex, float *x, float *y, float *z)
 get the scaling of the object in both x,y,z directions
 
float GetXRefScriptFacing (int nIndex)
 get the facing of the object in xz plane
 
const char * GetXRefScriptLocalMatrix (int nIndex)
 get the local transform of the script object. More...
 
bool IsSentient ()
 whether the biped is sentient or not
 
float GetSentientRadius ()
 get the sentient radius. More...
 
float GetPerceptiveRadius ()
 get the perceptive radius. More...
 
void SetPerceptiveRadius (float fNewRaduis)
 Set the perceptive radius. More...
 
int GetNumOfPerceivedObject ()
 return the total number of perceived objects. More...
 
ParaObject GetPerceivedObject (int nIndex)
 get the perceived object by index. More...
 
bool IsAlwaysSentient ()
 whether the object is always sentient. More...
 
void SetAlwaysSentient (bool bAlways)
 set whether sentient. More...
 
void MakeSentient (bool bSentient)
 set the object to sentient. More...
 
void UpdateTileContainer ()
 update the tile container according to the current position of the game object. More...
 
void MakeGlobal (bool bGlobal)
 make the biped global if it is not and vice versa. More...
 
bool IsGlobal ()
 whether the object is global or not. More...
 
void SetGroupID (int nGroup)
 set the group ID to which this object belongs to. More...
 
void SetSentientField (DWORD dwFieldOrGroup, bool bIsGroup)
 set the sentient field. More...
 
bool IsSentientWith (const ParaObject &pObj)
 return true if the current object is sentient to the specified object. More...
 
void SetMovableRegion (float center_x, float center_y, float center_z, float extent_x, float extent_y, float extent_z)
 Set the region within which the object can move. More...
 
void GetMovableRegion (float *center_x, float *center_y, float *center_z, float *extent_x, float *extent_y, float *extent_z)
 get the region within which the object can move. More...
 
void SetAnimation (int nAnimID)
 Set the current animation id. More...
 
int GetAnimation ()
 get the scaling. More...
 
string GetOnEnterSentientArea () const
 when other game objects of a different type entered the sentient area of this object. More...
 
void SetOnEnterSentientArea (const char *script)
 
string GetOnLeaveSentientArea () const
 when no other game objects of different type is in the sentient area of this object. More...
 
void SetOnLeaveSentientArea (const char *script)
 
string GetOnClick () const
 when the player clicked on this object. More...
 
void SetOnClick (const char *script)
 
void On_Click (DWORD nMouseKey, DWORD dwParam1, DWORD dwParam2)
 activate the OnClick
 
string GetOnPerceived () const
 when other game objects of a different type entered the perceptive area of this object. More...
 
void SetOnPerceived (const char *script)
 
string GetOnFrameMove () const
 called every frame move when this character is sentient. More...
 
void SetOnFrameMove (const char *script)
 
string GetOnNetSend () const
 during the execution of this object, it may send various network commands to the server or client. More...
 
void SetOnNetSend (const char *script)
 
string GetOnNetReceive () const
 when the network module receives packages from the network and it is about a certain game object. More...
 
void SetOnNetReceive (const char *script)
 
int GetEffectHandle ()
 Get the current shader handle used to render the object. More...
 
void SetEffectHandle (int nHandle)
 Set the shader handle used to render the object. More...
 
int AddReference (const ParaObject &maker, int nTag)
 add a new reference. More...
 
int DeleteReference (const ParaObject &ref)
 delete a reference. More...
 
int DeleteAllRefs ()
 Deletes all references of this object. More...
 
int GetRefObjNum ()
 get the total number of references
 
ParaObject GetRefObject (int nIndex)
 get the referenced object at the given index
 
ParaAssetObject GetTexture ()
 get primary texture object
 
int GetNumReplaceableTextures ()
 get the total number of replaceable textures, which is the largest replaceable texture ID. More...
 
ParaAssetObject GetDefaultReplaceableTexture (int ReplaceableTextureID)
 get the default replaceable texture by its ID. More...
 
ParaAssetObject GetReplaceableTexture (int ReplaceableTextureID)
 get the current replaceable texture by its ID. More...
 
bool SetReplaceableTexture (int ReplaceableTextureID, ParaAssetObject pTextureEntity)
 set the replaceable texture at the given index with a new texture. More...
 

Public Attributes

CBaseObject::WeakPtr_type m_pObj
 

Detailed Description

ParaObject class: it is used to control game scene objects from scripts.

Class Properties

Member Function Documentation

§ AddChild()

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

attach the object as its child object.

Parameters
objthe child object to attach

§ AddEvent()

void ParaScripting::ParaObject::AddEvent ( const char *  strEvent,
int  nEventType,
bool  bIsUnique 
)

add events to object to control the object, please refer to HLE for object event specifications.

Generally, one can use event to tell a biped to walk to a new position play a certain animation, speak some words, follow another biped, attack, etc.

Parameters
strEventcurrently a biped object accepts the following events. A list of events (more will be coming in future release):
  • "stop"
    Stop the biped
  • "walk x y"
    Walk to (x,y) using the default animation
  • "colr r, g, b"
    Set model color[0, 1]
    e.g. colr 1.0 0 0 = to set red color
  • "anim string | number"
    Play animation
  • "asai type parameters"
    Assign AI module of type type to the biped. Old modules are discarded Currently only support creature type AI module, with one parameter which can be ranged or melee unit.
    type:
    AIModuleCreatures=1, // respawning creatures that may be neural,or aggressive. They will not attack bipeds of any type, but may attack any team bipeds.
    AIModuleTeam=2, // Player Controllable biped AI module. it recognize creatures and members in other teams by their IDs.
    "asai 1 1" Assign creature AI with ranged unit attribute
    "asai 1 0" Assign creature AI with melee unit attribute
  • "ClearAll"
    Clear all tasks that this biped is assigned.
  • "task taskType parameters"
    Assign task to the AImodule associated with the biped.
    taskType:
    Currently taskType should be string, not their number
    • DieAndReborn = 0,
    • WanderNearby = 1,
    • Evade=2, "task Evade name"
      name: which biped to evade
      e.g. "task Evade enemy1"
    • Follow=3, "task Follow name"
      name: which biped to follow
      e.g. "task Follow LiXizhi"
    • Movie=4, "task Movie string"
      string: list of key, no spaces in the str are allowed. Format is given below
      [<const char* anim, float x, float y, float z, float facing, float duration>]+
      If y=0, then the height of the position is ignored. Duration is in seconds.
      e.g. "task Movie <attack-1,50,0,60,0,10><Die-1,50,0,60,0,0>"
nEventTypedefault to 0
bIsUniqueis it unique by string

§ AddReference()

int ParaScripting::ParaObject::AddReference ( const ParaObject maker,
int  nTag 
)

add a new reference.

Parameters
maker
Returns

§ CallField()

void ParaScripting::ParaObject::CallField ( const char *  sFieldname)

call field by name.

This function is only valid when The field type is void. It simply calls the function associated with the field name.

§ CheckAttribute()

bool ParaScripting::ParaObject::CheckAttribute ( DWORD  attribute)

whether an object attribute is enabled.

Parameters
attributeobject volume bit fields enum OBJECT_ATTRIBUTE { / two solid objects with sensor volume will cause environment simulator to / to generate sensor/collision event when they come in to contact. OBJ_VOLUMN_SENSOR = 1, / all child objects are in this object's volume OBJ_VOLUMN_CONTAINER = 0x1<<1, / solid objects(like biped) can be placed on its volume, provided / it's not already occupied by any solid objects from its children / when we solve two solid object collision, this is the field we check first. OBJ_VOLUMN_FREESPACE = 0x1<<2, / whether the object is isolated from its siblings. An isolated object / can overlap in physical space with all its siblings regardless of their solidity. / multiple scenes or terrains can be declared as ISOLATED object. Note, the object / is not isolated from its parent, though. OBJ_VOLUMN_ISOLATED = 0x1<<3, / the object has a perceptive radius that may be larger than the object's / collision radius. Currently only biped object might has this volume type OBJ_VOLUMN_PERCEPTIVE_RADIUS = 0x1<<4, / objects with this VIP volume type will trigger the plot of the scene in its view-culling radius. OBJ_VOLUMN_VIP = 0x1<<5, / Object invisible, the object is not drawn.but its physics may load. added by lxz 2006.3.5 OBJ_VOLUMN_INVISIBLE = 0x1<<6, / mask of the above bits. this field is never used externally. VOLUMN_MASK = 0x7f, / whether lights have effects on this object. MESH_USE_LIGHT = 0x1<<7, / whether to rotate the object around Y axis to let the object always facing the camera. MESH_BILLBOARDED= 0x1<<8, / whether it is a shadow receiver. MESH_SHADOW_RECEIVER= 0x1<<9, / whether it is a vegetation. MESH_VEGETATION= 0x1<<10, };
Returns
true if enabled

§ CheckLoadPhysics()

void ParaScripting::ParaObject::CheckLoadPhysics ( )

when this function is called, it ensures that the physics object around this object is properly loaded.

It increases the hit count of these physics objects by 1. The garbage collector in the physics world may use the hit count to move out unused static physics object from the physics scene (Novodex). This function might be called for the current player, each active mobile object in the scene and the camera eye position. vCenter: the center of the object in world coordinates fRadius: the radius of the object within which all physics object must be active.

§ DeleteAllRefs()

int ParaScripting::ParaObject::DeleteAllRefs ( )

Deletes all references of this object.

§ DeleteReference()

int ParaScripting::ParaObject::DeleteReference ( const ParaObject ref)

delete a reference.

Parameters
ref
Returns
return REF_FAIL if reference not found. otherwise REF_SUCCEED

§ EnablePhysics()

void ParaScripting::ParaObject::EnablePhysics ( bool  bEnable)

if this is a physics mesh object, this function will turn on or off the physics of the object.

§ GetAnimation()

int ParaScripting::ParaObject::GetAnimation ( )

get the scaling.

§ GetAttachmentPosition()

void ParaScripting::ParaObject::GetAttachmentPosition ( int  nAttachmentID,
float *  x,
float *  y,
float *  z 
)

return this object's attachment point e.g.

local x,y,z = obj:GetAttachmentPosition(0);

Parameters
nAttachmentIDsee ATTACHMENT_ID. default to 0, which is general mount point. ATT_ID_MOUNT1-9(20-28) is another mount points
Returns
x,y,z: in world coordinates

§ GetAttributeObject()

ParaAttributeObject ParaScripting::ParaObject::GetAttributeObject ( )

get the attribute object associated with an object.

§ GetDefaultReplaceableTexture()

ParaAssetObject ParaScripting::ParaObject::GetDefaultReplaceableTexture ( int  ReplaceableTextureID)

get the default replaceable texture by its ID.

The default replaceable texture is the main texture exported from the 3dsmax exporter.

Note
: This function will cause the mesh entity to be initialized.
Parameters
ReplaceableTextureIDusually [0-32) generally speaking, replaceable ID 0 is used for general purpose replaceable texture, ID 1 is for user defined. ID 2 is for custom skins.
Returns
this may return NULL, if replaceable texture is not set before or ID is invalid.

§ GetDynamicField()

luabind::object ParaScripting::ParaObject::GetDynamicField ( const char *  sFieldname,
const object output 
)

get field by name.

e.g. suppose att is the attribute object. local bGloble = att:GetField("URL", nil); local facing = att:GetField("Title", "default one");

Parameters
sFieldnamefield name
outputdefault value. if field type is vectorN, output is a table with N items.
Returns
: return the field result. If field not found, output will be returned. if field type is vectorN, return a table with N items.Please note table index start from 1

§ GetEffectHandle()

int ParaScripting::ParaObject::GetEffectHandle ( )

Get the current shader handle used to render the object.

See also
TechniqueHandle

§ GetEffectParamBlock()

ParaScripting::ParaParamBlock ParaScripting::ParaObject::GetEffectParamBlock ( )

get the parameter block of the effect (shader) associated with this object.

§ GetField()

luabind::object ParaScripting::ParaObject::GetField ( const char *  sFieldname,
const object output 
)

get field by name.

e.g. suppose att is the attribute object. local bGloble = att:GetField("global", true); local facing = att:GetField("facing", 0); local pos = att:GetField("position", {0,0,0}); pos[1] = pos[1]+100;pos[2] = 0;pos[3] = 10;

Parameters
sFieldnamefield name
outputdefault value. if field type is vectorN, output is a table with N items.
Returns
: return the field result. If field not found, output will be returned. if field type is vectorN, return a table with N items.Please note table index start from 1

§ GetHeadOnUITemplateName()

const char * ParaScripting::ParaObject::GetHeadOnUITemplateName ( int  nIndex)

get which UI control the head on display will be used as a template for drawing the text it can be a single CGUIText Object or it can be a container with a direct children called "text" if this is "" or empty, the default UI template will be used.

The default UI template is an invisible CGUIText control called "_HeadOnDisplayText_" By default, "_HeadOnDisplayText_" uses horizontal text alignment and system font.

Returns
: it returns NULL if no UI head on display.

§ GetHomeZone()

const char * ParaScripting::ParaObject::GetHomeZone ( )

get the home zone of this object if any.

it may return NULL or "", if zone is not visible.

§ GetID()

int ParaScripting::ParaObject::GetID ( )

the ID of the object.

The ID of the object is only generated when the first time this function is called. One can then easily get the object, by calling ParaScene.GetObject(nID). When an object is released, its ID is not longer used. Please note that we can ParaScene.GetObject(nID) even if the object is never attached before. Please note that the ID is neither unique outside the world, nor persistent in the same world.

Returns
: return 0 if object is invalid.

§ GetMovableRegion()

void ParaScripting::ParaObject::GetMovableRegion ( float *  center_x,
float *  center_y,
float *  center_z,
float *  extent_x,
float *  extent_y,
float *  extent_z 
)

get the region within which the object can move.

. This function takes no parameters. input are not input, but pure output. In the script, we can call it as below cx,cy,cz,ex,ey,ez = biped:GetMovableRegion(); – get the biped's position please note, y is the absolute position in world coordinate

See also
SetMovableRegion()

§ GetMyType()

int ParaScripting::ParaObject::GetMyType ( ) const

get paraengine defined object type name.

TODO: This function is not implemented

§ GetName_()

const char * ParaScripting::ParaObject::GetName_ ( ) const

for .NET API use only.not thread safe.

§ GetNumOfPerceivedObject()

int ParaScripting::ParaObject::GetNumOfPerceivedObject ( )

return the total number of perceived objects.

§ GetNumReplaceableTextures()

int ParaScripting::ParaObject::GetNumReplaceableTextures ( )

get the total number of replaceable textures, which is the largest replaceable texture ID.

but it does not mean that all ID contains valid replaceable textures. This function can be used to quickly decide whether the model contains replaceable textures. Generally we allow 32 replaceable textures per model.

Note
: This function will cause the mesh entity to be initialized.
Returns
0 may be returned if no replaceable texture is used by the model.

§ GetObject()

ParaScripting::ParaObject ParaScripting::ParaObject::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

§ GetOnClick()

string ParaScripting::ParaObject::GetOnClick ( ) const

when the player clicked on this object.

This function will be automatically called by the environment simulator.

§ GetOnEnterSentientArea()

string ParaScripting::ParaObject::GetOnEnterSentientArea ( ) const

when other game objects of a different type entered the sentient area of this object.

This function will be automatically called by the environment simulator.

§ GetOnFrameMove()

string ParaScripting::ParaObject::GetOnFrameMove ( ) const

called every frame move when this character is sentient.

This is most likely used by active AI controllers, such as movie controller.

§ GetOnLeaveSentientArea()

string ParaScripting::ParaObject::GetOnLeaveSentientArea ( ) const

when no other game objects of different type is in the sentient area of this object.

This function will be automatically called by the environment simulator.

§ GetOnNetReceive()

string ParaScripting::ParaObject::GetOnNetReceive ( ) const

when the network module receives packages from the network and it is about a certain game object.

Then this function will be automatically called. In this function, the game object may read the network packages and act accordingly.

§ GetOnNetSend()

string ParaScripting::ParaObject::GetOnNetSend ( ) const

during the execution of this object, it may send various network commands to the server or client.

the network module will decide when to group these commands and send them over the network in one package. this function will be called when such network package is being prepared.

§ GetOnPerceived()

string ParaScripting::ParaObject::GetOnPerceived ( ) const

when other game objects of a different type entered the perceptive area of this object.

This function will be automatically called by the environment simulator.

§ GetPerceivedObject()

ParaObject ParaScripting::ParaObject::GetPerceivedObject ( int  nIndex)

get the perceived object by index.

This function may return NULL.

§ GetPerceptiveRadius()

float ParaScripting::ParaObject::GetPerceptiveRadius ( )

get the perceptive radius.

§ GetPhysicsGroup()

int ParaScripting::ParaObject::GetPhysicsGroup ( )

Get the physics group ID to which this object belongs to default to 0, must be smaller than 32.

please see groups Mask used to filter shape objects. See #NxShape::setGroup

  • group 0 means physics object that will block the camera and player, such as building walls, big tree trunks, etc.
  • group 1 means physics object that will block the player, but not the camera, such as small stones, thin posts, trees, etc.

§ GetPhysicsHeight()

float ParaScripting::ParaObject::GetPhysicsHeight ( )

the biped is modeled as a cylinder or sphere during rough physics calculation.

this function returns the height of the cylinder or sphere. this value will also restrict the biped's vertical movement. if there is no head attachment, the GetPhysicsHeight is used for character head on text position instead. If PhysicsHeight is never set, it is always 4*PhysicsRadius. However, if it is set, its value are maintained.

§ GetPhysicsRadius()

float ParaScripting::ParaObject::GetPhysicsRadius ( )

the biped is modeled as a cylinder or sphere during rough physics calculation.

this function returns the radius of the cylinder or sphere.

§ GetPosition()

void ParaScripting::ParaObject::GetPosition ( double *  x,
double *  y,
double *  z 
)

get the world position of the object.

This function takes no parameters. x,y,z are not input, but pure output. In the script, we can call it as below x,y,z = biped:GetPosition(); – get the biped's position in Luabind, it is defined as .def("GetPosition", &ParaObject::GetPosition, pure_out_value(_2) + pure_out_value(_3) + pure_out_value(_4)) please note, y is the absolute position in world coordinate

See also
SetPosition(double x, double y, double z)

§ GetPrimaryAsset()

ParaAssetObject ParaScripting::ParaObject::GetPrimaryAsset ( )

get the main asset object associated with this object.

the object may be invalid.

§ GetPrimaryAsset_()

void ParaScripting::ParaObject::GetPrimaryAsset_ ( ParaAssetObject pOut)

this function shall never be called from the scripting interface.

this is solely for exporting API. and should not be used from the scripting interface.

§ GetReplaceableTexture()

ParaAssetObject ParaScripting::ParaObject::GetReplaceableTexture ( int  ReplaceableTextureID)

get the current replaceable texture by its ID.

if no replaceable textures is set before, this will return the same result as GetNumReplaceableTextures().

Note
: This function will cause the mesh entity to be initialized.
Parameters
ReplaceableTextureIDusually [0-32) generally speaking, replaceable ID 0 is used for general purpose replaceable texture, ID 1 is for user defined. ID 2 is for custom skins.
Returns
this may return NULL, if replaceable texture is not set before or ID is invalid.

§ GetRotation()

object ParaScripting::ParaObject::GetRotation ( const object quat)

this usually applies only to mesh object.

get the rotation as quaternion. e.g. local mat3x3 = obj:GetRotation({});

Returns
the rotational matrix is of the following format: {x,y,z,w,}

§ GetScale()

float ParaScripting::ParaObject::GetScale ( )

set the scale of the object.

This function takes effects on both character object and mesh object. Note: this function is safe to call for all kind of objects except the physics mesh object. for physics mesh object, one must call ParaScene.Attach() immediately after this function. for more information, please see SetPostion();

Parameters
sthis is the absolute scale on the original mesh model. Scaling applied to all axis.1.0 means original size.

§ GetSelectGroupIndex()

int ParaScripting::ParaObject::GetSelectGroupIndex ( )

get the selection group index.

if -1, it means that it was not selected.

§ GetSentientRadius()

float ParaScripting::ParaObject::GetSentientRadius ( )

get the sentient radius.

usually this is much larger than the perceptive radius.

§ GetType()

const char * ParaScripting::ParaObject::GetType ( )

get the Runtime class information of the object.

§ GetViewBox()

object ParaScripting::ParaObject::GetViewBox ( const object output)

get the view box.

e.g. local box = obj:GetViewBox({}); log(box.pos_x..box.pos_y..box.pos_z); return a table containing the following field:{pos_x, pos_y,pos_z,obb_x,obb_y,obb_z,} pos_x, pos_y,pos_z: is the point at the bottom center of the box. obb_x,obb_y,obb_z: is the size of the box.

§ GetViewCenter()

void ParaScripting::ParaObject::GetViewCenter ( double *  x,
double *  y,
double *  z 
)

get the world position of the center of the view object.

This function takes no parameters. x,y,z are not input, but pure output. In the script, we can call it as below x,y,z = biped:GetViewCenter(); – get the biped's center

§ GetXRefScriptLocalMatrix()

const char * ParaScripting::ParaObject::GetXRefScriptLocalMatrix ( int  nIndex)

get the local transform of the script object.

It contains scale and rotation only the string returned by this function must be used at once and should not be saved. This function is also not thread-safe.

Returns
: "11,12,13, 21,22,23, 31,32,33,41,42,43" ,where 41,42,43 are always 0. It may return NULL, if the local matrix does not exist.

§ HasAttachmentPoint()

bool ParaScripting::ParaObject::HasAttachmentPoint ( int  nAttachmentID)

return whether this model has a given attachment point

Parameters
nAttachmentIDsee ATTACHMENT_ID. default to 0, which is general mount point. ATT_ID_MOUNT1-9(20-28) is another mount points

§ IsAlwaysSentient()

bool ParaScripting::ParaObject::IsAlwaysSentient ( )

whether the object is always sentient.

The current player is always sentient

§ IsAttached()

bool ParaScripting::ParaObject::IsAttached ( ) const

whether the object has been attached to the scene.

§ IsCharacter()

bool ParaScripting::ParaObject::IsCharacter ( ) const
Returns
return true if object is a character(biped) object

§ IsGlobal()

bool ParaScripting::ParaObject::IsGlobal ( )

whether the object is global or not.

§ IsOPC()

bool ParaScripting::ParaObject::IsOPC ( ) const
Returns
return true if object is a network player

§ IsPersistent()

bool ParaScripting::ParaObject::IsPersistent ( )

whether the object is persistent in the world.

If an object is persistent, it will be saved to the world's database. if it is not persistent it will not be saved when the world closes. Player, OPC, some temporary movie actors may by non-persistent; whereas NPC are usually persistent to the world that it belongs.

§ IsSentientWith()

bool ParaScripting::ParaObject::IsSentientWith ( const ParaObject pObj)

return true if the current object is sentient to the specified object.

If the object is always sentient, this function will always return true.

§ IsStanding()

bool ParaScripting::ParaObject::IsStanding ( )

whether the object has 0 speed.

§ IsVisible()

bool ParaScripting::ParaObject::IsVisible ( )

invisible object will not be drawn.

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

§ LoadPhysics()

void ParaScripting::ParaObject::LoadPhysics ( )

only load physics of this object if it has not loaded.

§ MakeGlobal()

void ParaScripting::ParaObject::MakeGlobal ( bool  bGlobal)

make the biped global if it is not and vice versa.

§ MakeSentient()

void ParaScripting::ParaObject::MakeSentient ( bool  bSentient)

set the object to sentient.

Parameters
bSentienttrue to make sentient. if the object's sentient count is larger than 0, this function has no effect false, to remove the object from the sentient list.

§ OffsetPosition()

void ParaScripting::ParaObject::OffsetPosition ( float  dx,
float  dy,
float  dz 
)

offset the current object position by (dx,dy,dz)

See also
SetPosition(float x, float y, float z) for precautions of using this function

§ Reset()

void ParaScripting::ParaObject::Reset ( )

reset the object to its default settings.

§ Rotate()

void ParaScripting::ParaObject::Rotate ( float  x,
float  y,
float  z 
)

Rotate the object.This only takes effects on objects having 3D orientation, such as static mesh and physics mesh.

The orientation is computed in the following way: first rotate around x axis, then around y, finally z axis. Note: this function is safe to call for all kind of objects except the physics mesh object. for physics mesh object, one must call ParaScene.Attach() immediately after this function. for more information, please see SetPostion();

Parameters
xrotation around the x axis.
yrotation around the y axis.
zrotation around the z axis.
See also
: SetPostion();

§ SaveToDB()

bool ParaScripting::ParaObject::SaveToDB ( )

save the current character to database according to the persistent property.

if the object is persistent, the action is to update or insert the character to db if the object is non-persistent, the action is to delete it from the database.

§ Scale()

void ParaScripting::ParaObject::Scale ( float  s)

set the scale of the object.

This function takes effects on both character object and mesh object. Note: this function is safe to call for all kind of objects except the physics mesh object. for physics mesh object, one must call ParaScene.Attach() immediately after this function. for more information, please see SetPostion();

Parameters
sThis is a relative scale to its current size. Scaling applied to all axis.1.0 means original size.
See also
: SetPostion();

§ SetAlwaysSentient()

void ParaScripting::ParaObject::SetAlwaysSentient ( bool  bAlways)

set whether sentient.

§ SetAnimation()

void ParaScripting::ParaObject::SetAnimation ( int  nAnimID)

Set the current animation id.

Parameters
nAnimID0 is default standing animation. 4 is walking, 5 is running. more information, please see AnimationID

§ SetAttribute()

void ParaScripting::ParaObject::SetAttribute ( DWORD  dwAtt,
bool  bTurnOn 
)

enable or disable a given attribute.

Below are some attributes. For more information please see BaseObject.h

/ two solid objects with sensor volume will cause environment simulator to / to generate sensor/collision event when they come in to contact. OBJ_VOLUMN_SENSOR = 1, / all child objects are in this object's volume OBJ_VOLUMN_CONTAINER = 0x1<<1, / solid objects(like biped) can be placed on its volume, provided / it's not already occupied by any solid objects from its children / when we solve two solid object collision, this is the field we check first. OBJ_VOLUMN_FREESPACE = 0x1<<2, / whether the object is isolated from its siblings. An isolated object / can overlap in physical space with all its siblings regardless of their solidity. / multiple scenes or terrains can be declared as ISOLATED object. Note, the object / is not isolated from its parent, though. OBJ_VOLUMN_ISOLATED = 0x1<<3, / the object has a perceptive radius that may be larger than the object's / collision radius. Currently only biped object might has this volume type OBJ_VOLUMN_PERCEPTIVE_RADIUS = 0x1<<4, / objects with this VIP volume type will trigger the plot of the scene in its view-culling radius. OBJ_VOLUMN_VIP = 0x1<<5, / Object invisible, the object is not drawn.but its physics may load. added by lxz 2006.3.5 OBJ_VOLUMN_INVISIBLE = 0x1<<6,

Parameters
dwAtt
bTurnOntrue to turn on, false to turn off.

§ SetDensity()

void ParaScripting::ParaObject::SetDensity ( float  fDensity)

body density.

The water density is always 1.0 in the game engine. So if it is above 1.0, it will sink in water; otherwise it will float on water surface. So if it is below 0.5, it will fly or glind in air falling down with little gravity; otherwise it will fall down with full gravity. A density of 0 or negative, means that the character can fly. The default value is 1.2. the following are some examples

  • character: body density: 1.2
  • car: body density: 2.0 mount target
  • ship: body density: 0.8 mount target
  • plane: body density: 0.4 mount target
    Parameters
    fDensity

§ SetDynamicField()

void ParaScripting::ParaObject::SetDynamicField ( const char *  sFieldname,
const object input 
)

set field by name e.g.

suppose att is the attribute object. att:SetDynamicField("URL", 3.14); att:SetDynamicField("Title", {100,0,0});

Parameters
sFieldnamefield name
inputinput value. can be value or string type

§ SetEffectHandle()

void ParaScripting::ParaObject::SetEffectHandle ( int  nHandle)

Set the shader handle used to render the object.

Please note, object will be immediately rendered using the newly assigned shader in the next frame. shade handle in the range [0,2048] is reserved for ParaEngine's internal usage. CAUTION: setting a shader whose input is incompatible with the object's internal data presentation will cause the application to close.

Parameters
nHandle
See also
TechniqueHandle

§ SetFacing()

void ParaScripting::ParaObject::SetFacing ( float  fFacing)

set object facing around the Y axis.

this function is safe to call for all kind of objects except the physics mesh object. for physics mesh object, one must call ParaScene.Attach() immediately after this function. for more information, please see SetPostion();

See also
: SetPostion();

§ SetField()

void ParaScripting::ParaObject::SetField ( const char *  sFieldname,
const object input 
)

set field by name e.g.

suppose att is the attribute object. att:SetField("facing", 3.14); att:SetField("position", {100,0,0});

Parameters
sFieldnamefield name
inputinput value. if field type is vectorN, input is a table with N items.

§ SetGroupID()

void ParaScripting::ParaObject::SetGroupID ( int  nGroup)

set the group ID to which this object belongs to.

In order to be detected by other game object. Object needs to be in group 0 to 31. default value is 0

§ SetHeadOnTextColor()

void ParaScripting::ParaObject::SetHeadOnTextColor ( const char *  color,
int  nIndex 
)

set the text to be displayed on head on display

Parameters
color"r g b" or "r g b a", such as "0 255 0", "0 255 0 255"

§ SetHeadOnUITemplateName()

void ParaScripting::ParaObject::SetHeadOnUITemplateName ( const char *  sUIName,
int  nIndex 
)

set which UI control the head on display will be used as a template for drawing the text it can be a single CGUIText Object or it can be a container with a direct children called "text" if this is "" or empty, the default UI template will be used.

The default UI template is an invisible CGUIText control called "_HeadOnDisplayText_" By default, "_HeadOnDisplayText_" uses horizontal text alignment and system font.

§ SetHomeZone()

void ParaScripting::ParaObject::SetHomeZone ( const char *  sHomeZone)

set the home zone of this object if any.

it may return NULL, if zone is not visible.

Parameters
sHomeZoneif this is NULL, it will remove the zone.

§ SetMovableRegion()

void ParaScripting::ParaObject::SetMovableRegion ( float  center_x,
float  center_y,
float  center_z,
float  extent_x,
float  extent_y,
float  extent_z 
)

Set the region within which the object can move.

This function is not fully implemented on a per object basis.

Note
: currently it sets the global movable region of the character.

§ SetName()

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

set the object name

Remarks
: currently, renaming an object after attaching it to the scene is dangerous, because when people use the ParaScene.GetObject(), it may return a renamed and deleted object. The good practice is that never change an object's name when it is attached to the scene.
: In version 0.9 or above, renaming an object will detach the object from the scene and then reattach it to the scene using the new name; so it works fine when changing object name after attachment.
: this function will not take effect, if the object can not be renamed, such as due to another global object with the same name.
Parameters
sNamenew name of the object

§ SetPerceptiveRadius()

void ParaScripting::ParaObject::SetPerceptiveRadius ( float  fNewRaduis)

Set the perceptive radius.

§ SetPersistent()

void ParaScripting::ParaObject::SetPersistent ( bool  bPersistent)
See also
IsPersistent()

§ SetPhysicsGroup()

void ParaScripting::ParaObject::SetPhysicsGroup ( int  nGroup)

set the physics group ID to which this object belongs to default to 0, must be smaller than 32.

please see groups Mask used to filter shape objects. See #NxShape::setGroup

  • group 0 means physics object that will block the camera and player, such as building walls, big tree trunks, etc.
  • group 1 means physics object that will block the player, but not the camera, such as small stones, thin posts, trees, etc.

§ SetPhysicsHeight()

void ParaScripting::ParaObject::SetPhysicsHeight ( float  fHeight)

the biped is modeled as a cylinder or sphere during rough physics calculation.

this function set the height of the cylinder or sphere. this value will also restrict the biped's vertical movement. if there is no head attachment, the GetPhysicsHeight is used for character head on text position instead. If PhysicsHeight is never set, it is always 4*PhysicsRadius. However, if it is set, its value are maintained.

§ SetPhysicsRadius()

void ParaScripting::ParaObject::SetPhysicsRadius ( float  fR)

the biped is modeled as a cylinder or sphere during rough physics calculation.

this function set the radius of the cylinder or sphere.

§ SetPosition()

void ParaScripting::ParaObject::SetPosition ( double  x,
double  y,
double  z 
)

set world position.

Please note, for static object, it may make the quad tree terrain in which the object is located invalid. it may also make the physics engine panic.In such cases, one should call ParaScene.Attach() after chancing the position or rotation of a static mesh or physics object. If any of the following rule matches, the function is safe to use.

  • Use this function for global biped if (x,y,z) changes.
  • Use this function for all objects if it has not been attached to the global terrain
  • Use this function for static mesh, with (0,y,0) only.i.e. only changing height.
  • Never use this function for physics object, unless you are building the world. If you do use it it with physics or static mesh object, make sure that you follow the following rules: – create the physics object and save it in a global variable called physicsObj. physicsObj = ParaScene.Attach(physicsObj); – attach the physics object to the scene – modification of the position, orientation, scaling of the object occurred. local x,y,z = physicsObj:GetPosition(); physicsObj:SetPosition(x+2,y,z); – immediately call Attach again with physicsObj, so that the physical scene will be updated and the object be re-inserted properly in to the scene. physicsObj = ParaScene.Attach(physicsObj);
    Parameters
    xglobal x
    yglobal y
    zglobal z

since the object has moved, we may need to update its location in the scene graph we only do this for static object.

§ SetReplaceableTexture()

bool ParaScripting::ParaObject::SetReplaceableTexture ( int  ReplaceableTextureID,
ParaAssetObject  pTextureEntity 
)

set the replaceable texture at the given index with a new texture.

this function will succeed regardless whether the mesh is initialized. Hence it can be used at loading time. because default instance of the mesh may use different replaceable texture set.

Parameters
ReplaceableTextureIDusually [0-32) generally speaking, replaceable ID 0 is used for general purpose replaceable texture, ID 1 is for user defined. ID 2 is for custom skins.
pTextureEntityThe reference account of the texture entity will be automatically increased by one.
Returns
true if succeed. if ReplaceableTextureID exceed the total number of replaceable textures, this function will return false.

§ SetRotation()

void ParaScripting::ParaObject::SetRotation ( const object quat)

set the rotation as quaternion.

Parameters
sRotthe rotational matrix is of the following format: {x,y,z,w,}

§ SetScale()

void ParaScripting::ParaObject::SetScale ( float  s)

set scale

See also
GetScale();
Parameters
s

§ SetSelectGroupIndex()

void ParaScripting::ParaObject::SetSelectGroupIndex ( int  nGroupIndex)

set the selection group index.

if -1, it means that it was not selected. this function is equivalent to calling ParaSelection.AddObject(obj, nGroupID);

Parameters
nGroupIndexselection group index.

§ SetSentientField()

void ParaScripting::ParaObject::SetSentientField ( DWORD  dwFieldOrGroup,
bool  bIsGroup 
)

set the sentient field.

A bit field of sentient object. from lower bit to higher bits, it matches to the 0-31 groups.

See also
SetGroupID() if this is 0x0000, it will detect no objects. If this is 0xffff, it will detects all objects in any of the 32 groups. if this is 0x0001, it will only detect group 0.
Parameters
dwFieldOrGroupthis is either treated as field or group,depending on the bIsGroup parameter.
bIsGroupif this is true, dwFieldOrGroup is treated as a group number of which will object will detect. if this is false, dwFieldOrGroup is treated as a bitwise field of which will object will detect.

§ SetVisible()

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

set the visibility of this object.

The visibility will recursively affect all its child objects.

§ SnapToTerrainSurface()

void ParaScripting::ParaObject::SnapToTerrainSurface ( int  bUseNorm)

snap to terrain surface.

Such as landscape trees, stones, etc. set bUseNorm to 1, if you want the norm to be aligned.

§ ToCharacter()

ParaCharacter ParaScripting::ParaObject::ToCharacter ( )

return the ParaCharacter object, if this object is a biped typed scene object.

the ParaCharacter interface offers more specific functions to control the behavior and appearance of the character object.

See also
ParaCharacter

§ ToGameObject()

IGameObject * ParaScripting::ParaObject::ToGameObject ( )

convert to game object.

This function may return NULL.

§ ToString()

const char * ParaScripting::ParaObject::ToString ( ) const

convert the object to object creation string.

Returns
: "" if not valid

§ ToString1()

const char * ParaScripting::ParaObject::ToString1 ( const char *  sMethod) const

convert the object to string.

Parameters
sMethodit can be one of the following strings "create": generate script to create the object "update": generate script to update the object, useful for updating static physics object "delete": generate script to delete the object "loader": generate script to create the object in managed loader
Returns
: "" if not valid

§ UpdateTileContainer()

void ParaScripting::ParaObject::UpdateTileContainer ( )

update the tile container according to the current position of the game object.

This function is automatically called when a global object is attached.


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