/usr/include/crystalspace-2.0/cstool/meshobjtmpl.h is in libcrystalspace-dev 2.0+dfsg-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | /*
Copyright (C) 2003 by Martin Geisse <mgeisse@gmx.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CS_MESHOBJTMPL_H__
#define __CS_MESHOBJTMPL_H__
/**\file
* Base implementation of iMeshObject.
*/
#include "csextern.h"
#include "csgeom/box.h"
#include "cstool/objmodel.h"
#include "csutil/flags.h"
#include "csutil/refarr.h"
#include "csutil/scf_implementation.h"
#include "ivideo/graph3d.h"
#include "imesh/object.h"
#include "iutil/comp.h"
struct iEngine;
struct iMaterialWrapper;
//Deprecate these when possible!
/// Declare a simple mesh factory class
#define CS_DECLARE_SIMPLE_MESH_FACTORY(name,meshclass) \
class name : public csMeshFactory { \
public: \
name (iEngine *e, iObjectRegistry* reg, iMeshObjectType* type) \
: csMeshFactory (e, reg, type) {} \
virtual csPtr<iMeshObject> NewInstance () \
{ return new meshclass (Engine, this); } \
virtual csPtr<iMeshObjectFactory> Clone () { return 0; } \
};
/// Declare a simple mesh type plugin
#define CS_DECLARE_SIMPLE_MESH_PLUGIN(name,factclass) \
class name : public csMeshType { \
public: \
name (iBase *p) : csMeshType (p) {} \
virtual csPtr<iMeshObjectFactory> NewFactory () \
{ return new factclass (Engine, object_reg, this); } \
};
/**
* This is an abstract implementation of iMeshObject. It can be used to
* write custom mesh object implementations more easily. Currently it
* supports the following common functions of mesh objects:
* - Implementation of iMeshObject
* - Implementation of iObjectModel
* - Storing a "visible callback"
* - Storing a logical parent
* - Storing object model properties
* - Default implementation of most methods
*/
class CS_CRYSTALSPACE_EXPORT csMeshObject :
public scfImplementationExt1<csMeshObject, csObjectModel, iMeshObject>
{
protected:
/// the drawing callback
csRef<iMeshObjectDrawCallback> VisCallback;
/// logical parent (usually the wrapper object from the engine)
iMeshWrapper *LogParent;
/// pointer to the engine if available.
iEngine *Engine;
/// Tell the engine that this object wants to be deleted
void WantToDie ();
/// Flags.
csFlags flags;
/// The bounding box.
csBox3 boundingbox;
public:
/// Constructor
csMeshObject (iEngine *engine);
/// Destructor
virtual ~csMeshObject ();
/**
* See imesh/object.h for specification. There is no default
* implementation for this method.
*/
virtual iMeshObjectFactory* GetFactory () const = 0;
/**
* See imesh/object.h for specification. The default implementation
* does nothing and returns 0.
*/
virtual csPtr<iMeshObject> Clone () { return 0; }
/**
* See imesh/object.h for specification.
*/
virtual csFlags& GetFlags () { return flags; }
/**
* See imesh/object.h for specification. The default implementation
* does nothing and always returns 0.
*/
virtual CS::Graphics::RenderMesh** GetRenderMeshes (int& num, iRenderView*, iMovable*,
uint32)
{
num = 0;
return 0;
}
/**
* See imesh/object.h for specification. This function is handled
* completely in csMeshObject. The actual implementation just has
* to use the VisCallback variable to perform the callback.
*/
virtual void SetVisibleCallback (iMeshObjectDrawCallback* cb);
/**
* See imesh/object.h for specification. This function is handled
* completely in csMeshObject.
*/
virtual iMeshObjectDrawCallback* GetVisibleCallback () const;
/**
* See imesh/object.h for specification. The default implementation
* does nothing.
*/
virtual void NextFrame (csTicks current_time,const csVector3& pos,
uint currentFrame);
/**
* See imesh/object.h for specification. The default implementation
* does nothing.
*/
virtual void HardTransform (const csReversibleTransform& t);
/**
* See imesh/object.h for specification. The default implementation
* returns false.
*/
virtual bool SupportsHardTransform () const;
/**
* See imesh/object.h for specification. The default implementation
* will always return a miss.
*/
virtual bool HitBeamOutline (const csVector3& start,
const csVector3& end, csVector3& isect, float* pr);
/**
* See imesh/object.h for specification. The default implementation
* will always return a miss.
*/
virtual bool HitBeamObject (const csVector3& start, const csVector3& end,
csVector3& isect, float* pr, int* polygon_idx = 0,
iMaterialWrapper** = 0);
/**
* See imesh/object.h for specification. This function is handled
* completely in csMeshObject.
*/
virtual void SetMeshWrapper (iMeshWrapper* logparent);
/**
* See imesh/object.h for specification. This function is handled
* completely in csMeshObject.
*/
virtual iMeshWrapper* GetMeshWrapper () const;
/**
* See imesh/object.h for specification.
*/
virtual iObjectModel* GetObjectModel () { return this; }
/**
* See imesh/object.h for specification. The default implementation
* does not support a base color.
*/
virtual bool SetColor (const csColor& color);
/**
* See imesh/object.h for specification. The default implementation
* does not support a base color.
*/
virtual bool GetColor (csColor& color) const;
/**
* See imesh/object.h for specification. The default implementation
* does not support a material.
*/
virtual bool SetMaterialWrapper (iMaterialWrapper* material);
/**
* See imesh/object.h for specification. The default implementation
* does not support a material.
*/
virtual iMaterialWrapper* GetMaterialWrapper () const;
/// Set mix mode. Default implementation doesn't do anything.
virtual void SetMixMode (uint) { }
/// Get mix mode.
virtual uint GetMixMode () const { return CS_FX_COPY; }
/**
* see imesh/object.h for specification. The default implementation
* does nothing.
*/
virtual void PositionChild (iMeshObject* /*child*/,csTicks /*current_time*/) { }
/**
* see imesh/object.h for specification. The default implementation
* does nothing.
*/
virtual void BuildDecal(const csVector3* pos, float decalRadius,
iDecalBuilder* decalBuilder)
{
}
/**
* See imesh/objmodel.h for specification. The default implementation
* returns an infinite bounding box.
*/
virtual const csBox3& GetObjectBoundingBox ();
/**
* See imesh/objmodel.h for specification. Overrides the
* default bounding box.
*/
virtual void SetObjectBoundingBox (const csBox3& bbox);
/**
* See imesh/objmodel.h for specification. The default implementation
* returns an infinite radius.
*/
virtual void GetRadius (float& radius, csVector3& center);
/**
* See imesh/objmodel.h for specification. The default implementation
* returns 0.
*/
virtual iTerraFormer* GetTerraFormerColldet () { return 0; }
virtual iTerrainSystem* GetTerrainColldet () { return 0; }
};
/**
* This is the abstract implementation of iMeshObjectFactory. Like
* csMeshObject, it stores a pointer to the "logical parent".
*/
class CS_CRYSTALSPACE_EXPORT csMeshFactory :
public scfImplementation1<csMeshFactory, iMeshObjectFactory>
{
protected:
/// Logical parent (usually the wrapper object from the engine)
iMeshFactoryWrapper *LogParent;
/// Pointer to the MeshObjectType
iMeshObjectType* mesh_type;
/// Pointer to the engine if available.
iEngine *Engine;
/// Object registry.
iObjectRegistry* object_reg;
/// Flags.
csFlags flags;
public:
/// Constructor
csMeshFactory (iEngine *engine, iObjectRegistry* object_reg,
iMeshObjectType* parent);
/// Get the object registry.
iObjectRegistry* GetObjectRegistry () { return object_reg; }
/// destructor
virtual ~csMeshFactory ();
/**
* See imesh/object.h for specification.
*/
virtual csFlags& GetFlags () { return flags; }
/**
* See imesh/object.h for specification. There is no default
* implementation for this method.
*/
virtual csPtr<iMeshObject> NewInstance () = 0;
/**
* See imesh/object.h for specification. The default implementation
* does nothing.
*/
virtual void HardTransform (const csReversibleTransform& t);
/**
* See imesh/object.h for specification. The default implementation
* returns false.
*/
virtual bool SupportsHardTransform () const;
/**
* See imesh/object.h for specification. This function is handled
* completely in csMeshObject.
*/
virtual void SetMeshFactoryWrapper (iMeshFactoryWrapper* logparent);
/**
* See imesh/object.h for specification. This function is handled
* completely in csMeshObject.
*/
virtual iMeshFactoryWrapper* GetMeshFactoryWrapper () const;
/**
* Get the ObjectType for this mesh factory.
*/
virtual iMeshObjectType* GetMeshObjectType () const;
/**
* See imesh/object.h for specification.
*/
virtual iObjectModel* GetObjectModel () { return 0; }
virtual bool SetMaterialWrapper (iMaterialWrapper*) { return false; }
virtual iMaterialWrapper* GetMaterialWrapper () const { return 0; }
virtual void SetMixMode (uint) { }
virtual uint GetMixMode () const { return 0; }
};
/**
* This is the abstract implementation of iMeshObjectType.
*/
class CS_CRYSTALSPACE_EXPORT csMeshType :
public scfImplementation2<csMeshType, iMeshObjectType, iComponent>
{
protected:
/// pointer to the engine if available.
iEngine *Engine;
/// Object registry.
iObjectRegistry* object_reg;
public:
/// constructor
csMeshType (iBase *p);
/// destructor
virtual ~csMeshType ();
/**
* Initialize this plugin.
*/
bool Initialize (iObjectRegistry* reg);
/**
* See imesh/object.h for specification. There is no default
* implementation for this method.
*/
virtual csPtr<iMeshObjectFactory> NewFactory () = 0;
};
#endif // __CS_MESHOBJTMPL_H__
|