My Project
Public Member Functions | List of all members
ParaEngine::IViewClippingObject Class Reference

Pure interface for CBaseObject (3D scene object) It defines basic shapes and collision detection. More...

#include <IViewClippingObject.h>

Inheritance diagram for ParaEngine::IViewClippingObject:
ParaEngine::IRefObject ParaEngine::IAttributeFields ParaEngine::IObject ParaEngine::CRefCounted ParaEngine::CBaseObject ParaEngine::CViewCullingObject ParaEngine::C3DCanvas ParaEngine::CContainerObject ParaEngine::CDynamicObject ParaEngine::CGeosetObject ParaEngine::CManagedLoader ParaEngine::CRenderTarget ParaEngine::CSceneObject ParaEngine::CSphereObject ParaEngine::CTileObject ParaEngine::CWeatherEffect ParaEngine::CZoneNode ParaEngine::WeatherParticleSpawner

Public Member Functions

virtual ObjectShape GetObjectShape ()
 get the object shape
 
virtual void SetObjectShape (ObjectShape shape)
 set the object shape
 
virtual void SetBoundingBox (float fOBB_X, float fOBB_Y, float fOBB_Z, float fFacing)
 Set the object shape to box and bounding box parameters if fFacing is 0, it is a axis aligned bounding box (AABB). More...
 
virtual void GetBoundingBox (float *fOBB_X, float *fOBB_Y, float *fOBB_Z, float *fFacing)
 
virtual void SetBoundRect (float fWidth, float fHeight, float fFacing)
 Set the object shape to rect (a plane) and rect parameters if fFacing is 0, it is a axis aligned bounding box (AABB). More...
 
virtual void GetBoundRect (float *fWidth, float *fHeight, float *fFacing)
 
virtual void SetRadius (float fRadius)
 Set the object shape to Sphere and sphere parameters. More...
 
virtual float GetRadius ()
 
virtual void GetVertices (Vector3 *pVertices, int *nNumber)
 get all the vertices which can represent the object's shape. More...
 
virtual void GetRenderVertices (Vector3 *pVertices, int *nNumber)
 same as GetVertices(). More...
 
virtual void GetVerticesWithOrigin (const Vector3 *vOrigin, Vector3 *pVertices, int *nNumber)
 
virtual DVector3 GetPosition ()
 get object position in the world space. More...
 
virtual void SetPosition (const DVector3 &v)
 set the object position. More...
 
virtual 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...
 
virtual void SetRotation (const Quaternion &quat)
 set rotation using a quaternion. More...
 
virtual void GetRotation (Quaternion *quat)
 get rotation using a quaternion
 
virtual void SetScaling (float s)
 set the scale of the object. More...
 
virtual float GetScaling ()
 get the scaling. More...
 
virtual Vector3 GetRenderOffset ()
 get the offset(translation) of the object used for rendering. More...
 
virtual DVector3 GetObjectCenter ()
 get the center of the object in world space
 
virtual void SetObjectCenter (const DVector3 &v)
 set the center of the object in world space
 
virtual void GetFacing3D (Vector3 *pV)
 get object facing: only for object that has a facing property like biped, not bound facing
 
float GetFacing ()
 same as GetYaw and SetYaw get object facing: only for object that has a facing property like biped, not bound facing The object is facing the positive x axis, if facing is 0.
 
void SetFacing (float fFacing)
 
virtual float GetYaw ()
 get object Yaw: is facing the positive x axis, if yaw is 0.
 
virtual void SetYaw (float fFacing)
 
virtual float GetPitch ()
 get object pitch: is facing the positive x axis, if yaw is 0.
 
virtual void SetPitch (float fFacing)
 
virtual float GetRoll ()
 get object roll: is facing the positive x axis, if yaw is 0.
 
virtual void SetRoll (float fFacing)
 
virtual float GetHeight ()
 get object height y axis: only for object that has a Height property, usually is height of the bounding box
 
virtual void SetHeight (float fHeight)
 
virtual float GetWidth ()
 get object width: x axis
 
virtual void SetWidth (float fWidth)
 
virtual float GetDepth ()
 get object depth: z axis
 
virtual void SetDepth (float fDepth)
 
virtual Vector3 GetNormal ()
 
virtual void SetNormal (const Vector3 &pNorm)
 
virtual void GetOBB (CShapeOBB *obb)
 get the oriented bounding box in world space. More...
 
virtual void GetAABB (CShapeAABB *aabb)
 
virtual void SetAABB (const Vector3 *vMin, const Vector3 *vMax)
 Set local AABB information. More...
 
virtual Vector3 GetLocalAABBCenter ()
 
virtual void SetTransform (Matrix4 *pLocalTransform, const DVector3 &pGlobalPos, float *pRotation)
 Set a local transform matrix, a global position and a facing value, according to which the object will be transformed on demand, so that the transformed object can be used for efficient object-level view culling in ParaEngine. More...
 
virtual void SetTransform (Matrix4 *pWorldTransform)
 
virtual Matrix4GetRenderMatrix (Matrix4 &out, int nRenderNumber=0)
 return the world matrix of the object for rendering More...
 
virtual Matrix4GetWorldTransform (Matrix4 &pOut, int nRenderNumber=0)
 get world transform
 
virtual bool TestCollisionSphere (const Vector3 *pvCenter, float radius, BYTE nMethod=1)
 – collision detection More...
 
virtual bool TestCollisionSphere (CBaseCamera *pCamera, float fFarPlaneDistance)
 assume that the object is a sphere, it will return false if the sphere is completely out of the 6 frustum planes of the camera More...
 
virtual bool TestShadowSweptSphere (CBaseCamera *pCamera, const Vector3 *pvDirection)
 assume that the object is a sphere, it will return false if the swept sphere along the given direction is completely out of the 6 frustum planes of the camera this function is usually used to test whether we need to render this object as shadow caster, where pvDirection is the current sun direction.
 
virtual bool TestCollision (CBaseCamera *pCamera)
 check if the object's original shape can be seen via a camera. More...
 
virtual bool TestCollisionObject (IViewClippingObject *pObj)
 desc: test if the object collide with this object in the world view. More...
 
virtual bool TestCollisionRay (const Vector3 &vPickRayOrig, const Vector3 &vPickRayDir, float *fDistance)
 Desc: Check the ray intersection with the object input:vPickRayOrig,vPickRayDir: mouse ray params output: fDistance: the distance between the eye and the intersection point. More...
 
virtual float GetSphereCollisionDepth (Vector3 *pvCenter, float radius, bool bSolveDepth=false)
 desc: this is similar to TestCollisionSphere, but does more than that. More...
 
virtual float GetObjectCollisionDepth (IViewClippingObject *pObj)
 desc: test if the circle in the y=0 plane collide with this object in the world view Note: radius can be zero. More...
 
virtual float GetObjectToPointDistance (const Vector3 *pPoint)
 get the distance from the object's surface to a given point. More...
 
virtual void DrawBoundingBox (SceneState *sceneState, DWORD color)
 debugging only: draw bounding box
 
virtual void DrawOcclusionObject (SceneState *sceneState)
 draw the occlusion object More...
 
virtual void DebugDraw (IBatchedElementDraw *pDebugDraw)
 this function is called whenever debugging drawing is enabled. More...
 
- Public Member Functions inherited from ParaEngine::IRefObject
virtual const std::string & GetIdentifier ()
 get the name or identifier. More...
 
virtual void SetIdentifier (const std::string &sID)
 
int GetNameW (std::u16string &out)
 gets the unicode name
 
const std::string & GetName ()
 alias name for GetIdentifier
 
IRefObjectGetRefObjectByName (const char *sName)
 
RefListItemGetRefObjectByTag (int nTag)
 get the first reference object by its tag
 
bool HasReferences ()
 
RefResult AddReference (IRefObject *maker, int nTag=0)
 add a new reference. More...
 
RefResult DeleteReference (IRefObject *ref)
 delete a reference. More...
 
RefResult DeleteAllRefs ()
 Deletes all references of this object. More...
 
int DeleteAllRefsByTag (int nTag=0)
 Deletes all references whose tag is nTag of this object. More...
 
RefListGetRefList ()
 get the ref list
 
int GetRefObjNum ()
 get the total number of references
 
RefListItemGetRefObject (int nIndex)
 get the referenced object at the given index. More...
 
virtual void OnRefAdded (IRefObject *rm, int nTag=0)
 This is called after another object added this object to its reference list. More...
 
virtual void OnRefDeleted (IRefObject *rm)
 This is called after another object deleted this object from its reference list. More...
 
- Public Member Functions inherited from ParaEngine::IAttributeFields
virtual int GetAttributeClassID ()
 attribute class ID should be identical, unless one knows how overriding rules work. More...
 
virtual const char * GetAttributeClassName ()
 a static string, describing the attribute class object's name
 
virtual const char * GetAttributeClassDescription ()
 a static string, describing the attribute class object
 
virtual int InstallFields (CAttributeClass *pClass, bool bOverride)
 this class should be implemented if one wants to add new attribute. More...
 
virtual int GetChildAttributeColumnCount ()
 we support multi-dimensional child object. More...
 
virtual int GetChildAttributeObjectCount (int nColumnIndex=0)
 get the number of child objects (row count) in the given column. More...
 
virtual IAttributeFieldsGetChildAttributeObject (int nRowIndex, int nColumnIndex=0)
 
virtual IAttributeFieldsGetChildAttributeObject (const std::string &sName)
 get attribute by child object. More...
 
 ATTRIBUTE_METHOD1 (IAttributeFields, GetName_s, const char **)
 
 ATTRIBUTE_METHOD1 (IAttributeFields, SetName_s, const char *)
 
 ATTRIBUTE_METHOD (IAttributeFields, PrintObject_s)
 
 ATTRIBUTE_METHOD (IAttributeFields, AddRef_s)
 
 ATTRIBUTE_METHOD1 (IAttributeFields, GetRefCount_s, int *)
 
 ATTRIBUTE_METHOD1 (IAttributeFields, SetTime_s, int)
 
 ATTRIBUTE_METHOD1 (IAttributeFields, GetTime_s, int *)
 
 ATTRIBUTE_METHOD (IAttributeFields, Release_s)
 
virtual bool IsModified ()
 whether some of the fields are modified.It is up to the implementation class to provide this functionality if necessary. More...
 
virtual void SetModified (bool bModified)
 set whether any field has been modified. More...
 
virtual bool ValidateFields ()
 validate all fields and return true if validation passed. More...
 
virtual string GetValidationMessage ()
 get the recent validation message due to the most recent call to ValidateFields()
 
virtual bool ResetField (int nFieldID)
 Reset the field to its initial or default value. More...
 
virtual bool InvokeEditor (int nFieldID, const std::string &sParameters)
 Invoke an (external) editor for a given field. More...
 
virtual bool AddChildAttributeObject (IAttributeFields *pChild, int nRowIndex=-1, int nColumnIndex=0)
 add child object. More...
 
virtual void * QueryObjectByName (const std::string &sObjectType)
 convert to object of a given type. More...
 
virtual void * QueryObject (int nObjectType)
 convert to object of a given type. More...
 
virtual int GetTime ()
 get the current local time in case it is animated in milli seconds frames. More...
 
virtual void SetTime (int nTime)
 
virtual CDynamicAttributeFieldGetDynamicField (const std::string &sName)
 Get a dynamic field with a given name. More...
 
virtual CDynamicAttributeFieldGetDynamicField (int nIndex)
 Get a dynamic field with a given index. More...
 
virtual const char * GetDynamicFieldNameByIndex (int nIndex)
 get field name by index
 
virtual int GetDynamicFieldCount ()
 how many dynamic field this object currently have. More...
 
virtual int SetDynamicField (const std::string &sName, const CVariable &value)
 set a dynamic field with a given name. More...
 
virtual int AddDynamicField (const std::string &sName, ATTRIBUTE_FIELDTYPE dwType)
 add dynamic field and return field index
 
virtual void RemoveAllDynamicFields ()
 remove all dynamic fields
 
virtual int SaveDynamicFieldsToString (std::string &output)
 save only text dynamic fields to fieldname = value text strings. More...
 
virtual int LoadDynamicFieldsFromString (const std::string &input)
 load only text dynamic fields from string More...
 
CAttributeClassGetAttributeClass ()
 get the main attribute class object. More...
 
void PrintObject ()
 print the content of this object to a text file at temp/doc/[ClassName].txt. More...
 
- Public Member Functions inherited from ParaEngine::IObject
virtual void Clone (IObject *obj) const
 Clone the object's contains to a pointer. More...
 
virtual IObjectClone () const
 Clone the object's contains and return a pointer to the newly created object. More...
 
virtual bool Equals (const IObject *obj) const
 Compare the object with another object. More...
 
virtual const ITypeGetType () const
 
virtual std::string ToString () const
 
WeakPtr_typeGetWeakReference ()
 get weak reference object. More...
 
virtual int ProcessObjectEvent (const ObjectEvent &event)
 this function is only used to backward compatibility of ParaObject:AddEvent() function. More...
 
- Public Member Functions inherited from ParaEngine::CRefCounted
void addref () const
 add reference count of the object. More...
 
bool delref () const
 decrease reference count of the object. More...
 
int GetRefCount () const
 get the reference count
 
virtual int Release ()
 
CRefCountedAddToAutoReleasePool ()
 addref and releases the ownership sometime soon automatically (usually at the end of the current frame). More...
 

Additional Inherited Members

- Public Types inherited from ParaEngine::IAttributeFields
typedef ParaEngine::weak_ptr< IObject, IAttributeFieldsWeakPtr_type
 
- Public Types inherited from ParaEngine::IObject
typedef ParaEngine::weak_ptr< IObjectWeakPtr_type
 
- Static Public Member Functions inherited from ParaEngine::IAttributeFields
static HRESULT GetAttributeClassID_s (IAttributeFields *cls, int *p1)
 
static HRESULT GetAttributeClassName_s (IAttributeFields *cls, const char **p1)
 
static bool OpenWithDefaultEditor (const char *sFilename, bool bWaitOnReturn=false)
 Open a given file with the default registered editor in the game engine. More...
 
- Protected Member Functions inherited from ParaEngine::IAttributeFields
virtual CAttributeClassCreateAttributeClass ()
 initialize fields
 
virtual CDynamicAttributesSetGetDynamicAttributes (bool bCreateIfNotExist=false)
 
- Protected Attributes inherited from ParaEngine::IRefObject
RefList m_references
 This is the list of active references that refer to us.
 
std::string m_sIdentifer
 unit name used in the scripting language
 
- Protected Attributes inherited from ParaEngine::IObject
WeakPtr_type m_weak_reference
 
- Protected Attributes inherited from ParaEngine::CRefCounted
int m_refcount
 

Detailed Description

Pure interface for CBaseObject (3D scene object) It defines basic shapes and collision detection.

Member Function Documentation

§ DebugDraw()

void IViewClippingObject::DebugDraw ( IBatchedElementDraw pDebugDraw)
virtual

this function is called whenever debugging drawing is enabled.

§ DrawOcclusionObject()

void IViewClippingObject::DrawOcclusionObject ( SceneState sceneState)
virtual

draw the occlusion object

the occlusion object is defined in CBaseObject.

However, I may use more simplified model to draw the object. Currently I used the line primitive of the bounding box. Maybe Point primitive is enough(I tested it. it is not working well with point primitive even with fixed screen point size set.)

§ GetBoundingBox()

void ParaEngine::IViewClippingObject::GetBoundingBox ( float *  fOBB_X,
float *  fOBB_Y,
float *  fOBB_Z,
float *  fFacing 
)
virtual

§ GetBoundRect()

void ParaEngine::IViewClippingObject::GetBoundRect ( float *  fWidth,
float *  fHeight,
float *  fFacing 
)
virtual

§ GetOBB()

void IViewClippingObject::GetOBB ( CShapeOBB obb)
virtual

get the oriented bounding box in world space.

One may need to shift by the rendering origin if used on that purposes.

Parameters
obb[out]

Reimplemented in ParaEngine::CBipedObject, ParaEngine::CTileObject, and ParaEngine::CViewCullingObject.

§ GetObjectCollisionDepth()

FLOAT IViewClippingObject::GetObjectCollisionDepth ( IViewClippingObject pObj)
virtual

desc: test if the circle in the y=0 plane collide with this object in the world view Note: radius can be zero.

We assume that test is done in the y=0 plane only

§ GetObjectToPointDistance()

float IViewClippingObject::GetObjectToPointDistance ( const Vector3 pPoint)
virtual

get the distance from the object's surface to a given point.

the object is always treated as a sphere. If the point is not inside the object, a positive value is always returned. otherwise, a negative value will be returned.

§ GetPosition()

DVector3 IViewClippingObject::GetPosition ( )
virtual

get object position in the world space.

The position of an object is the bottom center of the object. most scene object will return the position using the following rules project the center of the shape to the bottom plane of the shape, the projection point at the bottom is returned as the object's world position. so it is different from the center of the object.

See also
GetObjectCenter(Vector3 *pV)

this is perhaps only for root scene

Reimplemented in ParaEngine::CBaseObject, ParaEngine::CSkyMesh, ParaEngine::CSphereObject, ParaEngine::CViewCullingObject, ParaEngine::CZoneNode, and ParaEngine::CTileObject.

§ GetRadius()

virtual float ParaEngine::IViewClippingObject::GetRadius ( )
inlinevirtual

§ GetRenderMatrix()

Matrix4 * ParaEngine::IViewClippingObject::GetRenderMatrix ( Matrix4 out,
int  nRenderNumber = 0 
)
virtual

return the world matrix of the object for rendering

Parameters
outthe output.
nRenderNumberif it is bigger than current calculated render number, the value will be recalculated. If 0, it will not recalculate
Returns
: same as out. or NULL if not exists.

set facing and rotate local matrix round y axis

Reimplemented in ParaEngine::CBipedObject, ParaEngine::CMeshPhysicsObject, ParaEngine::CMeshObject, ParaEngine::CLightObject, ParaEngine::BMaxObject, and ParaEngine::CadModelNode.

§ GetRenderOffset()

Vector3 IViewClippingObject::GetRenderOffset ( )
virtual

get the offset(translation) of the object used for rendering.

the rendering offset will translate the object from the world coordinate system to the scene's rendering coordinate system.This will make the components of world transform matrix consistent.(i.e. of the same magnitude.) hence it will correct floating point calculation imprecisions, due to large object coordinates, such as (20000.01). Notes: both the render function and the camera will use the render offset, instead of GetPosition() to get the position of the render object. This function will internally call the virtual function GetPosition().

Returns
: the offset returned.
See also
: GetRenderOrigin().

§ GetRenderVertices()

void IViewClippingObject::GetRenderVertices ( Vector3 pVertices,
int *  nNumber 
)
virtual

same as GetVertices().

Except that the vertices returned are for rendering, not for physics.

Reimplemented in ParaEngine::CViewCullingObject.

§ GetScaling()

float ParaEngine::IViewClippingObject::GetScaling ( )
virtual

§ GetSphereCollisionDepth()

FLOAT IViewClippingObject::GetSphereCollisionDepth ( Vector3 pvCenter,
float  radius,
bool  bSolveDepth = false 
)
virtual

desc: this is similar to TestCollisionSphere, but does more than that.

a depth value is returned test if the object collide with this object in the world view. Currently the pObj is regarded as a spherical/circular object. mostly it's a biped object. And this object can have shape of any type.

pvCenter[in/out]: bSolveDepth: true, the pvCenter will be changed to align to the nearest edge, if the original depth value is greater than 0. after alignment the value will be 0.

return the depth of collision, the large this value, the deeper the two object run into each other if this value is smaller than or equal to 0, then no collision is detected

§ GetVertices()

void IViewClippingObject::GetVertices ( Vector3 pVertices,
int *  nNumber 
)
virtual

get all the vertices which can represent the object's shape.

This is used for view clipping. for sphere shaped object: 8 vertices of a axis aligned bounding box of the sphere is returned for box shaped object: The eight points of the bounding box is returned. for rect shaped object: The 4 points of the bounding box is returned. for circle shaped object: The 4 points of the bounding box of the circle is returned. pVertices: out parameter for storing the vertices, must be at least Vector3[8] nNumber: out parameter storing the number of vertices returned

Reimplemented in ParaEngine::CPortalNode.

§ Rotate()

void IViewClippingObject::Rotate ( float  x,
float  y,
float  z 
)
virtual

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.

Parameters
xrotation around the x axis.
yrotation around the y axis.
zrotation around the z axis.

Reimplemented in ParaEngine::CBipedObject, ParaEngine::CMeshPhysicsObject, ParaEngine::C3DCanvas, ParaEngine::CLightObject, ParaEngine::CCanvasCamera, ParaEngine::CMeshObject, and ParaEngine::CadModelNode.

§ SetAABB()

void ParaEngine::IViewClippingObject::SetAABB ( const Vector3 vMin,
const Vector3 vMax 
)
virtual

Set local AABB information.

It is possibly attained from a mesh entity.

Reimplemented in ParaEngine::CTileObject, and ParaEngine::CViewCullingObject.

§ SetBoundingBox()

void ParaEngine::IViewClippingObject::SetBoundingBox ( float  fOBB_X,
float  fOBB_Y,
float  fOBB_Z,
float  fFacing 
)
virtual

Set the object shape to box and bounding box parameters if fFacing is 0, it is a axis aligned bounding box (AABB).

The bounding sphere is set to radius of bounding box's the smallest spherical container

Parameters
fOBB_Xobject bounding box.x
fOBB_Yobject bounding box.y
fOBB_Zobject bounding box.z
fFacingrotation of the bounding box around the y axis.

Reimplemented in ParaEngine::CBaseObject, ParaEngine::CMeshPhysicsObject, and ParaEngine::CTileObject.

§ SetBoundRect()

virtual void ParaEngine::IViewClippingObject::SetBoundRect ( float  fWidth,
float  fHeight,
float  fFacing 
)
inlinevirtual

Set the object shape to rect (a plane) and rect parameters if fFacing is 0, it is a axis aligned bounding box (AABB).

Parameters
fWidthplane width or x
fHeightplane height or y.
fFacingrotation of the plane around the y axis.

Reimplemented in ParaEngine::CBaseObject, ParaEngine::CMeshPhysicsObject, and ParaEngine::CTileObject.

§ SetPosition()

void IViewClippingObject::SetPosition ( const DVector3 v)
virtual

§ SetRadius()

virtual void ParaEngine::IViewClippingObject::SetRadius ( float  fRadius)
inlinevirtual

Set the object shape to Sphere and sphere parameters.

Parameters
fRadiusradius

Reimplemented in ParaEngine::CBaseObject, ParaEngine::CMeshPhysicsObject, ParaEngine::CSphereObject, ParaEngine::CTileObject, and ParaEngine::CViewCullingObject.

§ SetRotation()

void IViewClippingObject::SetRotation ( const Quaternion quat)
virtual

set rotation using a quaternion.

Reimplemented in ParaEngine::CMeshPhysicsObject, ParaEngine::CMeshObject, and ParaEngine::CadModelNode.

§ SetScaling()

void ParaEngine::IViewClippingObject::SetScaling ( float  s)
virtual

set the scale of the object.

This function takes effects on both character object and mesh object.

Parameters
sscaling applied to all axis.1.0 means original size.

Reimplemented in ParaEngine::CBipedObject, ParaEngine::CMeshPhysicsObject, ParaEngine::CLightObject, ParaEngine::BMaxObject, ParaEngine::CMeshObject, ParaEngine::CadModelNode, and ParaEngine::CVoxelMesh.

§ SetTransform()

void ParaEngine::IViewClippingObject::SetTransform ( Matrix4 pLocalTransform,
const DVector3 pGlobalPos,
float *  pRotation 
)
virtual

Set a local transform matrix, a global position and a facing value, according to which the object will be transformed on demand, so that the transformed object can be used for efficient object-level view culling in ParaEngine.

Please note, that the input pointers must be valid until the ClearTransform is called

Reimplemented in ParaEngine::CViewCullingObject.

§ TestCollision()

bool IViewClippingObject::TestCollision ( CBaseCamera pCamera)
virtual

check if the object's original shape can be seen via a camera.

it will return false if the object is completely out of the 6 frustum planes of the camera

Reimplemented in ParaEngine::CBlockDynamicObject, ParaEngine::CZoneNode, and ParaEngine::CPortalNode.

§ TestCollisionObject()

bool IViewClippingObject::TestCollisionObject ( IViewClippingObject pObj)
virtual

desc: test if the object collide with this object in the world view.

Currently the pObj is regarded as a spherical/circular object. mostly it's a biped object. And this object can have shape of any type.

§ TestCollisionRay()

bool IViewClippingObject::TestCollisionRay ( const Vector3 vPickRayOrig,
const Vector3 vPickRayDir_,
float *  fDistance 
)
virtual

Desc: Check the ray intersection with the object input:vPickRayOrig,vPickRayDir: mouse ray params output: fDistance: the distance between the eye and the intersection point.

this is only set when it's intersection in the first place return: true if they collide. note: TODO: currently the caller should always be the biped class

Let:a = Dx2 + Dy2 + Dz2; (for normalized rays, a=1) b = 2[ Dx(x0 每cx) + Dy(y0 每cy) + Dz(z0 每cz)] c = (x0 每cx)2 +(y0 每cy)2 +(z0 每cz)2-r2 Then: t = (-b ㊣ sqrt(b2 每 4ac))/2a if (b2 每 4ac) < 0, the ray does not intersect the sphere; if (b2 每 4ac) = 0, the ray grazes the sphere; if (b2 每 4ac) > 0, the ray enters and passes through the sphere, exiting on the other side. Use the smallest positive t to find the closest visible ray/sphere intersection point x(t), y(t), z(t),

§ TestCollisionSphere() [1/2]

bool IViewClippingObject::TestCollisionSphere ( const Vector3 pvCenter,
float  radius,
BYTE  nMethod = 1 
)
virtual

– collision detection

test if the sphere collides with this object in the world coordinate. this function is called by the game engine for object level clipping. The more accurate method will be slower. We assume that the view culling object is a box transformed from the AABB with the temporary transform information.

Parameters
pvCentercenter of the sphere to test against
radiusthe radius of the sphere. It can be zero.
nMethodwhether this object will be treated as a 2D cylinder, a 3D sphere or the original shape.
  • nMethod=0: The object is treated as its original shape.This may be slow.
  • nMethod=1: both the incoming sphere and the object are treated as 2D circles. This is the fastest method, and is useful for rough object-level culling, even for 3D scenes;
  • nMethod=2: both the incoming sphere and the object are treated as 3D sphere. This is a all very method, and is useful for rough object-level culling for 3D scenes;
  • nMethod=3: reserved
  • nMethod=0: The object is treated as its original shape.This may be slow.
  • nMethod=1: both the incoming sphere and the object are treated as 2D circles. This is the fastest method, and is useful for rough object-level culling, even for 3D scenes;
  • nMethod=2: both the incoming sphere and the object are treated as 3D sphere. This is a all very method, and is useful for rough object-level culling for 3D scenes;
  • nMethod=3:

only test in the y=0 plane

we will first do a sphere based rough test

Parameters
nMethod= 1

§ TestCollisionSphere() [2/2]

bool IViewClippingObject::TestCollisionSphere ( CBaseCamera pCamera,
float  fFarPlaneDistance 
)
virtual

assume that the object is a sphere, it will return false if the sphere is completely out of the 6 frustum planes of the camera

Parameters
fFarPlaneDistancethis value will replace the far plane.

Reimplemented in ParaEngine::CZoneNode, and ParaEngine::CPortalNode.


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