#include <thing.h>
Inheritance diagram for csThing:
Public Methods | |
csThing (iBase *parent) | |
Create an empty thing. | |
virtual | ~csThing () |
Destructor. | |
int | AddVertex (const csVector3 &v) |
Just add a new vertex to the thing. | |
int | AddVertex (float x, float y, float z) |
Just add a new vertex to the thing. | |
int | AddVertexSmart (const csVector3 &v) |
Add a vertex but first check if there is already a vertex close to the wanted position. More... | |
int | AddVertexSmart (float x, float y, float z) |
Add a vertex but first check if there is already a vertex close to the wanted position. More... | |
void | CompressVertices () |
Compress the vertex table so that all nearly identical vertices are compressed. More... | |
void | RemoveUnusedVertices () |
Optimize the vertex table so that all unused vertices are deleted. More... | |
const csVector3& | Vobj (int idx) const |
Return the object space vector for the vertex. | |
const csVector3& | Vwor (int idx) const |
Return the world space vector for the vertex. More... | |
const csVector3& | Vcam (int idx) const |
Return the camera space vector for the vertex. More... | |
int | GetVertexCount () |
Return the number of vertices. | |
void | AddPolygon (csPolygonInt *spoly) |
Add a polygon to this thing. | |
csPolygon3D* | NewPolygon (csMaterialWrapper *material) |
Create a new polygon in this thing and add it. | |
int | GetPolygonCount () |
Get the number of polygons in this thing. | |
csPolygonInt* | GetPolygonInt (int idx) |
Get a csPolygonInt with the index. | |
csPolygon3D* | GetPolygon3D (int idx) |
Get the specified polygon from this set. | |
csPolygon3D* | GetPolygon3D (const char *name) |
Get the named polygon from this set. | |
csPolygonArray& | GetPolygonArray () |
Get the entire array of polygons. | |
unsigned long | GetNewPolygonID () |
Get a new polygon ID. More... | |
void | AddCurve (csCurve *curve) |
Add a curve to this thing. | |
int | GetCurveCount () |
Get the number of curves in this thing. | |
csCurve* | GetCurve (int idx) |
Get the specified curve from this set. | |
iCurve* | CreateCurve (iCurveTemplate *tmpl) |
Create a curve from a template. | |
csCurve* | GetCurve (char *name) |
Get the named curve from this set. | |
int | GetCurveVertexCount () |
Get the number of curve vertices. | |
csVector3& | CurveVertex (int i) |
Get the specified curve vertex. | |
csVector3* | GetCurveVertices () |
Get the curve vertices. | |
csVector2& | CurveTexel (int i) |
Get the specified curve texture coordinate (texel). | |
int | AddCurveVertex (const csVector3 &v, const csVector2 &t) |
Add a curve vertex and return the index of the vertex. | |
float | GetCurvesScale () |
Get the curve scale. | |
void | SetCurvesScale (float f) |
Set the curve scale. | |
const csVector3& | GetCurvesCenter () |
Get the curves center. | |
void | SetCurvesCenter (csVector3 &v) |
Set the curves center. | |
void | Prepare () |
Prepare all polygons for use. More... | |
void | Merge (csThing *other) |
Merge the given Thing into this one. More... | |
void | MergeTemplate (iThingState *tpl, iMaterialWrapper *default_material=NULL, csVector3 *shift=NULL, csMatrix3 *transform=NULL) |
Add polygons and vertices from the specified thing (seen as template). | |
void | ReplaceMaterials (iMaterialList *matList, const char *prefix) |
Replace the materials in this thing with new materials that are prefixed by some name. More... | |
void | SetTemplate (csThing *t) |
Set parent template. | |
csThing* | GetTemplate () const |
Query parent template. | |
void | CreateBoundingBox () |
Create an oriented bounding box (currently not oriented yet@@) for this polygon set. More... | |
csThingBBox* | GetBoundingBox () |
Get the oriented bounding box created by CreateBoundingBox(). | |
void | GetTransformedBoundingBox (const csReversibleTransform &trans, csBox3 &cbox) |
Get bounding box given some transformation. | |
float | GetScreenBoundingBox (float fov, float sx, float sy, const csReversibleTransform &trans, csBox2 &sbox, csBox3 &cbox) |
Get bounding box in screen space. | |
void | GetBoundingBox (csBox3 &box) |
Get the bounding box in object space for this polygon set. More... | |
void | GetBoundingBox (iMovable *movable, csBox3 &box) |
Get the bounding box for this object given some transformation (movable). | |
void | GetRadius (csVector3 &rad, csVector3 ¢) |
Get the radius in object space for this polygon set. | |
void | AddPortalPolygon (csPolygon3D *poly) |
Add a polygon to the list of polygons having a portal. More... | |
void | RemovePortalPolygon (csPolygon3D *poly) |
Remove a polygon from the list of polygons having a portal. | |
csPolygonTree* | GetStaticTree () |
Get the static polygon tree. | |
void | BuildStaticTree (const char *name, int mode=BSP_MINIMIZE_SPLITS) |
Call this function to generate a polygon tree for this csThing. More... | |
void | RegisterVisObject (iVisibilityObject *visobj) |
Register a visibility object with this culler. | |
void | UnregisterVisObject (iVisibilityObject *visobj) |
Unregister a visibility object with this culler. | |
bool | VisTest (iRenderView *irview) |
Do the visibility test from a given viewpoint. More... | |
void | RegisterShadowReceiver (iShadowReceiver *receiver) |
Register a shadow receiver. | |
void | UnregisterShadowReceiver (iShadowReceiver *receiver) |
Unregister a shadow receiver. | |
void | CastShadows (iFrustumView *fview) |
Start casting shadows from a given point in space. | |
bool | DrawTest (iRenderView *rview, iMovable *movable) |
Test if this thing is visible or not. | |
bool | Draw (iRenderView *rview, iMovable *movable, csZBufMode zMode) |
Draw this thing given a view and transformation. | |
bool | DrawCurves (iRenderView *rview, iMovable *movable, csZBufMode zMode) |
Draw all curves in this thing given a view and transformation. | |
bool | DrawFoggy (iRenderView *rview, iMovable *movable) |
Draw this thing as a fog volume (only when fog is enabled for this thing). | |
void | InitializeDefault () |
Init the lightmaps for all polygons in this thing. | |
bool | ReadFromCache (int id) |
Read the lightmaps from the cache. | |
bool | WriteToCache (int id) |
Cache the lightmaps for all polygons in this thing. | |
void | PrepareLighting () |
Prepare the lightmaps for all polys so that they are suitable for the 3D rasterizer. | |
csPolygon3D* | IntersectSphere (csVector3 ¢er, float radius, float *pr=NULL) |
Intersects object-space sphere with polygons of this set. More... | |
csPolygon3D* | IntersectSegment (const csVector3 &start, const csVector3 &end, csVector3 &isect, float *pr=NULL, bool only_portals=false) |
Intersect object-space segment with polygons of this set. More... | |
csPolygon3D* | IntersectSegmentFull (const csVector3 &start, const csVector3 &end, csVector3 &isect, float *pr=NULL, csMeshWrapper **p_mesh=NULL) |
Intersect object-space segment with polygons of this set. More... | |
void | RealCheckFrustum (iFrustumView *lview, iMovable *movable) |
Check frustum visibility on this thing. | |
void | CheckFrustum (iFrustumView *lview, iMovable *movable) |
Check frustum visibility on this thing. More... | |
void | AppendShadows (iMovable *movable, iShadowBlockList *shadows, csVector3 &origin) |
Return a list of shadow frustums which extend from this thing. More... | |
void | UpdateTransformation (const csTransform &c, long cam_cameranr) |
Transform to the given camera if needed. More... | |
void | WorUpdate () |
Make sure the world vertices are up-to-date. | |
void | HardTransform (const csReversibleTransform &t) |
Do a hard transform of the object vertices. More... | |
csVector3* | GetCameraVertices (const csTransform &c, long cam_cameranr) |
Get the array of camera vertices. | |
void | SetMovingOption (int opt) |
Control how this thing will be moved. | |
int | GetMovingOption () |
Get the moving option. | |
void | SetConvex (bool c) |
Set convexity flag of this thing. More... | |
int | GetCenter () |
If this thing is convex you can use getCenter to get the index of the vertex holding the center of this thing. More... | |
bool | HasFog () |
Return true if this has fog. | |
csFog& | GetFog () |
Return fog structure. | |
void | SetFog (float density, const csColor &color) |
Conveniance function to set fog to some setting. | |
void | DisableFog () |
Disable fog. | |
SCF_DECLARE_IBASE_EXT (csObject) | |
Public Attributes | |
csFlags | flags |
Set of flags. | |
int | draw_busy |
How many times are we busy drawing this thing (recursive). More... | |
csThing::ThingState | scfiThingState |
csThing::LightingInfo | scfiLightingInfo |
csThing::PolyMesh | scfiPolygonMesh |
csThing::VisCull | scfiVisibilityCuller |
csThing::MeshObject | scfiMeshObject |
csThing::MeshObjectFactory | scfiMeshObjectFactory |
Static Public Attributes | |
long | current_light_frame_number |
Current light frame number. More... | |
Friends | |
class | ThingState |
class | LightingInfo |
class | PolyMesh |
class | VisCull |
class | MeshObject |
class | MeshObjectFactory |
A thing can be used for the outside of a sector or else to augment the sector with features that are difficult to describe with convex sectors alone.
Every polygon in the set has a visible and an invisible face; if the vertices of the polygon are ordered clockwise then the polygon is visible. Using this feature it is possible to define two kinds of things: in one kind the polygons are oriented such that they are visible from within the hull. In other words, the polygons form a sort of container or room where the camera can be located. This kind of thing can be used for the outside walls of a sector. In another kind the polygons are oriented such that they are visible from the outside.
Things can also be used for volumetric fog. In that case the Thing must be convex.
If you add a static tree (octree/BSP trees) to a thing it can be used as a visibility culler (i.e. it implements iVisibilityCuller).
|
Add a polygon to the list of polygons having a portal. This function is called by a csPolygon3D in this thing whenever it gets a portal. |
|
Add a vertex but first check if there is already a vertex close to the wanted position. In that case don't add a new vertex but return the index of the old one. Note that this function is not very efficient. If you plan to add a lot of vertices you should just use AddVertex() and call CompressVertices() later. |
|
Add a vertex but first check if there is already a vertex close to the wanted position. In that case don't add a new vertex but return the index of the old one. Note that this function is not very efficient. If you plan to add a lot of vertices you should just use AddVertex() and call CompressVertices() later. |
|
Return a list of shadow frustums which extend from this thing. The origin is the position of the light. Note that this function uses camera space coordinates and thus assumes that this thing is transformed to the origin of the light. |
|
Call this function to generate a polygon tree for this csThing. This might make drawing more efficient because this thing can then be drawn using Z-fill instead of Z-buffer. Also the c-buffer requires a tree of this kind. |
|
Check frustum visibility on this thing. First initialize the 2D culler cube. |
|
Compress the vertex table so that all nearly identical vertices are compressed. The polygons in the set are automatically adapted. This function can be called at any time in the creation of the object and it can be called multiple time but it normally only makes sense to call this function after you have finished adding all polygons and all vertices. Note that calling this function will make the camera vertex array invalid. |
|
Create an oriented bounding box (currently not oriented yet@@) for this polygon set. This function will add the vertices for the bounding box to the set itself so that they will get translated together with the other vertices. The indices of the vertices are added to the csThingBBox structure which is returned here. Note that this creation is done in object space. The newly added vertices will not have been translated to world/camera space yet.
|
|
Get the bounding box in object space for this polygon set. This is calculated based on the oriented bounding box. |
|
If this thing is convex you can use getCenter to get the index of the vertex holding the center of this thing. This center is calculated by 'setConvex(true)'. |
|
Get a new polygon ID. This is used by the polygon constructor. |
|
Do a hard transform of the object vertices. This transformation and the original coordinates are not remembered but the object space coordinates are directly computed (world space coordinates are set to the object space coordinates by this routine). |
|
Intersect object-space segment with polygons of this set. Return polygon it intersects with (or NULL) and the intersection point in object coordinates.
If 'pr' != NULL it will also return a value between 0 and 1 indicating where on the 'start'-'end' vector the intersection happened.
If only_portals == true then only portals are checked. |
|
Intersect object-space segment with polygons of this set. Return polygon it intersects with (or NULL) and the intersection point in object coordinates.
If 'pr' != NULL it will also return a value between 0 and 1 indicating where on the 'start'-'end' vector the intersection happened.
This version is similar to IntersectSegment() but it will also test polygons of all objects which are registered to the visibility culler of this thing (if there is any). It also returns the mesh wrapper that was hit. If this is NULL then this mesh was hit. |
|
Intersects object-space sphere with polygons of this set. Return polygon it hits with (or NULL) and the intersection point in object coordinates. It will also return the polygon with the closest hit (the most nearby polygon). If 'pr' != NULL it will also return the distance where the intersection happened. |
|
Merge the given Thing into this one. The other polygons and curves are removed from the other thing so that it is ready to be removed. Warning! All Things are merged in world space coordinates and not in object space as one could expect! |
|
Prepare all polygons for use. This function MUST be called AFTER the texture manager has been prepared. This function is normally called by csEngine::Prepare() so you only need to worry about this function when you add sectors or things later. |
|
Optimize the vertex table so that all unused vertices are deleted. Note that calling this function will make the camera vertex array invalid. |
|
Replace the materials in this thing with new materials that are prefixed by some name. For example, if a polygon in this thing uses a material 'blabla' and the prefix is 'pref' then the new material that will be used is called 'pref_blabla'. If that material cannot be found then the original material will be used. |
|
Set convexity flag of this thing. You should call this instead of SetFlags (CS_ENTITY_CONVEX, CS_ENTITY_CONVEX) because this function does some extra calculations. |
|
Transform to the given camera if needed. This function will use the camera number to avoid unneeded transformation. |
|
Return the camera space vector for the vertex. Make sure you recently called UpdateTransformation(). Otherwise it is possible that this coordinate will not be valid. |
|
Do the visibility test from a given viewpoint. This will first clear the visible flag on all registered objects and then it will mark all visible objects. |
|
Return the world space vector for the vertex. Make sure you recently called WorUpdate(). Otherwise it is possible that this coordinate will not be valid. |
|
Current light frame number. This is used for seeing if gouraud shading should be recalculated for this thing. If there is a mismatch between the frame number of this set and the global number then the gouraud shading is not up-to-date. |
|
How many times are we busy drawing this thing (recursive). This is an important variable as it indicates to 'new_transformation' which set of camera vertices it should use. |