#include <seg_remanence_shape.h>
Inheritance diagram for NL3D::CSegRemanenceShape:

NB this doesn't support material with animated texture matrix (texture matrix is used internally)
Nevrax France
Definition at line 65 of file seg_remanence_shape.h.
Public Member Functions | |
| virtual bool | clip (const std::vector< CPlane > &pyramid, const CMatrix &worldMatrix) |
| virtual void | getAABBox (NLMISC::CAABBox &bbox) const |
| from IShape | |
| CMaterialBase * | getAnimatedMaterial () const |
| Get animated material or NULL if none. | |
| virtual std::string | getClassName ()=0 |
| NLMISC::CVector | getCorner (uint corner) const |
| float | getDistMax () const |
| const CMaterial & | getMaterial () const |
| Get material. | |
| uint32 | getNumCorners () const |
| uint32 | getNumSlices () const |
| const sint & | getRefCount () const |
| float | getRollupRatio () const |
| float | getSliceTime () const |
| bool | getTextureShifting () const |
| Test whether there is texture shifting at the start of the animation. | |
| virtual void | profileSceneRender (CRenderTrav *rdrTrav, CTransformShape *trans, bool opaquePass) |
| void | setAnimatedMaterial (const std::string &name) |
| Force animated material. This can be called only once. | |
| void | setBBox (const NLMISC::CAABBox &bbox) |
| void | setCorner (uint corner, const NLMISC::CVector &value) |
| void | setDistMax (float distMax) |
| void | setMaterial (const CMaterial &mat) |
| void | setNumCorners (uint numCorners) |
| void | setNumSlices (uint32 numSlices) |
| void | setRollupRatio (float ratio) |
| void | setSliceTime (float sliceTime) |
| void | setTextureShifting (bool on=true) |
| CSegRemanenceShape (const CSegRemanenceShape &other) | |
| CSegRemanenceShape () | |
| NLMISC_DECLARE_CLASS (CSegRemanenceShape) | |
| CSegRemanenceShape & | operator= (const CSegRemanenceShape &other) |
| virtual void | serial (NLMISC::IStream &f) throw (NLMISC::EStream) |
| ~CSegRemanenceShape () | |
access default tracks. | |
| CTrackDefaultVector * | getDefaultPos () |
| CTrackDefaultQuat * | getDefaultRotQuat () |
| CTrackDefaultVector * | getDefaultScale () |
Data Fields | |
| sint | crefs |
| CPtrInfo * | pinfo |
Static Public Attributes | |
| CPtrInfo | NullPtrInfo |
Protected Member Functions | |
from IShape | |
| virtual CTransformShape * | createInstance (CScene &scene) |
| virtual void | flushTextures (IDriver &driver, uint selectedTexture) |
| virtual float | getNumTriangles (float distance) |
| virtual void | render (IDriver *drv, CTransformShape *trans, bool opaquePass) |
Protected Attributes | |
| float | _DistMax |
| Default to -1. | |
Private Types | |
| typedef std::vector< CVector > | TCornerVect |
Private Member Functions | |
| void | copyFromOther (const CSegRemanenceShape &other) |
| void | setupMaterial () |
| void | setupVBnPB () |
Private Attributes | |
| CMaterialBase * | _AnimatedMat |
| NLMISC::CAABBoxExt | _BBox |
| For clipping. | |
| TCornerVect | _Corners |
| CTrackDefaultVector | _DefaultPos |
| CTrackDefaultQuat | _DefaultRotQuat |
| CTrackDefaultVector | _DefaultScale |
| bool | _GeomTouched |
| CMaterial | _Mat |
| bool | _MatTouched |
| uint32 | _NumSlices |
| CPrimitiveBlock | _PB |
| float | _RollUpRatio |
| float | _SliceTime |
| bool | _TextureShifting |
| CVertexBuffer | _VB |
Friends | |
| struct | CPtrInfo |
|
|
Definition at line 165 of file seg_remanence_shape.h. |
|
|
default ctor : a seg from (0, 0, 0) to (0, 0, 1) A default bbox is set (from (-3, -3, -3) to (3, 3, 3)) Definition at line 41 of file seg_remanence_shape.cpp. References NLMISC::CAABBoxExt::setCenter(), NLMISC::CAABBoxExt::setHalfSize(), and setNumCorners().
00041 : _GeomTouched(true), 00042 _MatTouched(true), 00043 _TextureShifting(true), 00044 _NumSlices(8), 00045 _SliceTime(0.05f), 00046 _RollUpRatio(1.f), 00047 _AnimatedMat(NULL) 00048 { 00049 _BBox.setCenter(NLMISC::CVector::Null); 00050 _BBox.setHalfSize(NLMISC::CVector(3, 3, 3)); 00051 setNumCorners(2); 00052 } |
|
|
Definition at line 282 of file seg_remanence_shape.cpp. References _AnimatedMat.
00283 {
00284 delete _AnimatedMat;
00285 }
|
|
|
Definition at line 265 of file seg_remanence_shape.cpp. References copyFromOther().
00265 : IShape(other), _AnimatedMat(NULL) 00266 { 00267 copyFromOther(other); 00268 } |
|
||||||||||||
|
clip this shape with a pyramid. the pyramid is given in world space.The world matrix of the object is given.
Reimplemented from NL3D::IShape. Definition at line 312 of file seg_remanence_shape.cpp. References NLMISC::CBSphere::applyTransform(), NLMISC::CBSphere::Center, NLMISC::CAABBoxExt::getCenter(), NLMISC::CAABBoxExt::getRadius(), NLMISC::CBSphere::Radius, and sint.
00313 {
00314 // Speed Clip: clip just the sphere.
00315 NLMISC::CBSphere localSphere(_BBox.getCenter(), _BBox.getRadius());
00316 NLMISC::CBSphere worldSphere;
00317
00318 // transform the sphere in WorldMatrix (with nearly good scale info).
00319 localSphere.applyTransform(worldMatrix, worldSphere);
00320
00321 // if out of only plane, entirely out.
00322 for(sint i=0;i<(sint)pyramid.size();i++)
00323 {
00324 // We are sure that pyramid has normalized plane normals.
00325 // if SpherMax OUT return false.
00326 float d= pyramid[i]*worldSphere.Center;
00327 if(d>worldSphere.Radius)
00328 return false;
00329 }
00330 return true;
00331 }
|
|
|
Definition at line 288 of file seg_remanence_shape.cpp. References _AnimatedMat, _BBox, _Corners, _GeomTouched, _Mat, _MatTouched, _NumSlices, _PB, _RollUpRatio, _SliceTime, _TextureShifting, and _VB. Referenced by CSegRemanenceShape(), and operator=().
00289 {
00290 if (&other == this) return;
00291 CMaterialBase *otherAnimatedMat = other._AnimatedMat != NULL ? new CMaterialBase(*other._AnimatedMat)
00292 : NULL;
00293 delete _AnimatedMat;
00294 _AnimatedMat = otherAnimatedMat;
00295
00296 _GeomTouched = other._GeomTouched;
00297 _MatTouched = other._MatTouched;
00298 _TextureShifting = other._TextureShifting;
00299 _NumSlices = other._NumSlices;
00300 _SliceTime = other._SliceTime;
00301 _Corners = other._Corners;
00302 _Mat = other._Mat;
00303 _VB = other._VB;
00304 _PB = other._PB;
00305 _BBox = other._BBox;
00306 _RollUpRatio = other._RollUpRatio;
00307 }
|
|
|
create an instance of this shape. The instance may be a CTransformShape, or a specialized version of it. The default behavior is to createModel() a CTransformShape, and just assign to it the Shape.
Reimplemented from NL3D::IShape. Definition at line 150 of file seg_remanence_shape.cpp. References _AnimatedMat, NL3D::CAnimatedValueQuat, NL3D::CAnimatedValueVector, NL3D::CScene::createModel(), NL3D::CTrackDefaultBlendable< CQuat >::getValue(), NL3D::CTrackDefaultBlendable< CVector >::getValue(), NL3D::CSegRemanence::setAnimatedMaterial(), NL3D::CTransform::setLoadBalancingGroup(), NL3D::CAnimatedMaterial::setMaterial(), NL3D::CSegRemanence::setSliceTime(), NL3D::CSegRemanence::setupFromShape(), and NL3D::CTransformShape::Shape.
00151 {
00152 CSegRemanence *sr = NLMISC::safe_cast<CSegRemanence *>(scene.createModel(NL3D::SegRemanenceShapeId) );
00153 sr->Shape = this;
00154 CAnimatedMaterial *aniMat = NULL;
00155 if (_AnimatedMat)
00156 {
00157 aniMat = new CAnimatedMaterial(_AnimatedMat);
00158 aniMat->setMaterial(&_Mat);
00159 }
00160 sr->setAnimatedMaterial(aniMat);
00161 sr->setupFromShape();
00162 // SegRemanence are added to the "Fx" Load Balancing Group.
00163 sr->setLoadBalancingGroup("Fx");
00164
00165 sr->ITransformable::setPos( ((CAnimatedValueVector&)_DefaultPos.getValue()).Value );
00166 sr->ITransformable::setRotQuat( ((CAnimatedValueQuat&)_DefaultRotQuat.getValue()).Value );
00167 sr->ITransformable::setScale( ((CAnimatedValueVector&)_DefaultScale.getValue()).Value );
00168
00169 sr->setSliceTime(_SliceTime);
00170
00171 return sr;
00172 }
|
|
||||||||||||
|
flush textures used by this shape. Implements NL3D::IShape. Definition at line 144 of file seg_remanence_shape.cpp. References NL3D::CMaterial::flushTextures(), and uint.
00145 {
00146 _Mat.flushTextures(driver, selectedTexture);
00147 }
|
|
|
from IShape
Reimplemented from NL3D::IShape. Definition at line 127 of file seg_remanence_shape.h. References NLMISC::CAABBoxExt::getAABBox().
|
|
|
Get animated material or NULL if none.
Definition at line 132 of file seg_remanence_shape.h. References _AnimatedMat.
00132 { return _AnimatedMat; }
|
|
|
Implemented in NLAIAGENT::CNumericIndex, NLAIC::IPointerGestion, NLAIC::CIdentType, and CAutomataDesc. Referenced by NLMISC::CClassRegistry::checkObject(), and NL3D::GetTextureSize(). |
|
|
Definition at line 109 of file seg_remanence_shape.cpp. References _Corners, nlassert, and uint. Referenced by NL3D::CSegRemanence::samplePos().
|
|
|
Definition at line 148 of file seg_remanence_shape.h. Referenced by NL3D::CSegRemanence::getDefaultTrack().
00148 {return &_DefaultPos;}
|
|
|
Definition at line 149 of file seg_remanence_shape.h. Referenced by NL3D::CSegRemanence::getDefaultTrack().
00149 {return &_DefaultRotQuat;}
|
|
|
Definition at line 150 of file seg_remanence_shape.h. Referenced by NL3D::CSegRemanence::getDefaultTrack().
00150 {return &_DefaultScale;}
|
|
|
return the DistMax where the shape is no more displayed. Default is to return -1, meaning DistMax = infinite. Definition at line 112 of file shape.h.
00112 {return _DistMax;}
|
|
|
Get material.
Definition at line 90 of file seg_remanence_shape.h. Referenced by NL3D::CSegRemanence::updateOpacityFromShape().
00090 { return _Mat; }
|
|
|
Definition at line 108 of file seg_remanence_shape.h. References _Corners, and uint32. Referenced by NL3D::CSegRemanence::setupFromShape().
00108 { return _Corners.size(); }
|
|
|
Definition at line 97 of file seg_remanence_shape.h. References _NumSlices, and uint32. Referenced by NL3D::CSegRemanence::render(), and NL3D::CSegRemanence::setupFromShape().
00097 { return _NumSlices; }
|
|
|
get an approximation of the number of triangles this instance will render for a fixed distance. return 0 if do not support degradation. Implements NL3D::IShape. Definition at line 176 of file seg_remanence_shape.cpp. References _NumSlices.
00177 {
00178 return (float) (_NumSlices * 2);
00179 }
|
|
|
Definition at line 70 of file smart_ptr.h. References NLMISC::CRefCount::crefs, and sint.
00071 {
00072 return crefs;
00073 }
|
|
|
Definition at line 141 of file seg_remanence_shape.h. References _RollUpRatio. Referenced by NL3D::CSegRemanence::render().
00141 { return _RollUpRatio; }
|
|
|
Definition at line 99 of file seg_remanence_shape.h.
00099 { return _SliceTime; }
|
|
|
Test whether there is texture shifting at the start of the animation.
Definition at line 124 of file seg_remanence_shape.h. References _TextureShifting. Referenced by NL3D::CSegRemanence::restart().
00124 { return _TextureShifting; }
|
|
|
|
|
|
Definition at line 271 of file seg_remanence_shape.cpp. References copyFromOther().
00272 {
00273 if (&other != this)
00274 {
00275 copyFromOther(other);
00276 (IShape &) *this = (IShape &) other; // copy base part
00277 }
00278 return *this;
00279 }
|
|
||||||||||||||||
|
Profiling. Called in RenderPass if Current Frame profiled. No-Op by default Informations must be added in rdrTrav->Scene Reimplemented in NL3D::CMesh, NL3D::CMeshMRM, NL3D::CMeshMRMSkinned, and NL3D::CMeshMultiLod. Definition at line 123 of file shape.h.
00123 {}
|
|
||||||||||||||||
|
render() this shape in a driver, with the specified TransformShape information. CTransfromShape call this method in the render traversal. if opaquePass render the opaque materials else render the transparent materials. Implements NL3D::IShape. Definition at line 125 of file seg_remanence_shape.cpp. References _PB, NL3D::CMaterial::getBlend(), NL3D::CSegRemanence::isStarted(), NL3D::CSegRemanence::render(), setupMaterial(), and setupVBnPB().
00126 {
00127 if ((!opaquePass && _Mat.getBlend())
00128 || (opaquePass && !_Mat.getBlend())
00129 )
00130 {
00131 CSegRemanence *sr = NLMISC::safe_cast<CSegRemanence *>(trans);
00132 #ifndef DEBUG_SEG_REMANENCE_DISPLAY
00133 if (!sr->isStarted()) return;
00134 #endif
00135 setupVBnPB();
00136 setupMaterial();
00137 //
00138 sr->render(drv, _VB, _PB, _Mat);
00139 }
00140 }
|
|
|
Implements NLMISC::IStreamable. Definition at line 55 of file seg_remanence_shape.cpp. References sint.
00056 {
00057 // version 2 : added default tracks
00058 // version 1 : rollup ratio
00059 // version 0 : base version
00060
00061 sint ver = f.serialVersion(2);
00062 f.serial(_NumSlices);
00063 f.serial(_SliceTime);
00064 f.serialCont(_Corners);
00065 f.serial(_Mat);
00066 f.serial(_BBox);
00067 f.serial(_TextureShifting);
00068 f.serialPtr(_AnimatedMat);
00069 if (f.isReading())
00070 {
00071 _GeomTouched = true;
00072 _MatTouched = true;
00073 }
00074 if (ver >= 1)
00075 {
00076 f.serial(_RollUpRatio);
00077 }
00078 if (ver >= 2)
00079 {
00080 f.serial(_DefaultPos);
00081 f.serial(_DefaultRotQuat);
00082 f.serial(_DefaultScale);
00083 }
00084 }
|
|
|
Force animated material. This can be called only once.
Definition at line 254 of file seg_remanence_shape.cpp. References _AnimatedMat, NL3D::CMaterialBase::Name, and nlassert.
00255 {
00256 nlassert(!name.empty());
00257 nlassert(_AnimatedMat == NULL);
00258 _AnimatedMat = new CMaterialBase;
00259 _AnimatedMat->Name = name;
00260 }
|
|
|
Set this shape bounding box NB: ideally the bbox should be computed per model, but practically, a fixed bbox suffice. Definition at line 216 of file seg_remanence_shape.cpp.
00217 {
00218 _BBox = bbox;
00219 }
|
|
||||||||||||
|
Definition at line 94 of file seg_remanence_shape.cpp. References _Corners, nlassert, uint, and value.
|
|
|
setup the DistMax where the shape is no more displayed. Take effect only for the next created instances. setting <0 means -1 and so means DistMax = infinite. Definition at line 66 of file shape.cpp. Referenced by NL3D::CFlareShape::CFlareShape().
|
|
|
Set material. A double sided material is forced Definition at line 222 of file seg_remanence_shape.cpp. References _MatTouched.
00223 {
00224 _Mat = mat;
00225 _MatTouched = true;
00226 }
|
|
|
Set the number of corners. By default it is 2 so you get a segment NB this invalidate previous calls to setCorner NB numCorners must be >= 2 Definition at line 116 of file seg_remanence_shape.cpp. References _Corners, _GeomTouched, nlassert, and uint. Referenced by CSegRemanenceShape().
00117 {
00118 nlassert(numCorners >= 2);
00119 _Corners.resize(numCorners);
00120 std::fill(_Corners.begin(), _Corners.end(), NLMISC::CVector::Null);
00121 _GeomTouched = true;
00122 }
|
|
|
Set the number of slices used to draw the remanence Should be >= 2 Definition at line 101 of file seg_remanence_shape.cpp. References _GeomTouched, _NumSlices, nlassert, and uint32.
00102 {
00103 nlassert(numSlices >= 2);
00104 _NumSlices = numSlices;
00105 _GeomTouched = true;
00106 }
|
|
|
When stop() is called, the fx doesn't disappear, it must rollup (a texture shifting is performed). This set the speed of rollup. 1 means it takes sliceTime * numSlice to unroll 0.5 means it takes 2 * sliceTime * numSlice to unroll and so on NB ratio must be > 0 Definition at line 236 of file seg_remanence_shape.cpp. References _RollUpRatio, and nlassert.
00237 {
00238 nlassert(ratio > 0);
00239 _RollUpRatio = ratio;
00240 }
|
|
|
Definition at line 87 of file seg_remanence_shape.cpp. References nlassert.
00088 {
00089 nlassert(sliceTime > 0);
00090 _SliceTime = sliceTime;
00091 }
|
|
|
Enable texture shifting on the u coordinates at the start of the animation, so that the texture will 'unroll' until it is completly visible NB this apply on all texture stages, and clamps the U coordinates. NB the default is on Definition at line 229 of file seg_remanence_shape.cpp. References _MatTouched, and _TextureShifting.
00230 {
00231 _TextureShifting = on;
00232 _MatTouched = true;
00233 }
|
|
|
Definition at line 243 of file seg_remanence_shape.cpp. References _MatTouched, NL3D::CMaterial::enableUserTexMat(), NL3D::CMaterial::getTexture(), NL3D::CMaterial::setDoubleSided(), NL3D::CMaterial::setLighting(), and NL3D::ITexture::setWrapS(). Referenced by render().
00244 {
00245 if (!_MatTouched) return;
00246 _Mat.enableUserTexMat(0);
00247 if (_Mat.getTexture(0)) _Mat.getTexture(0)->setWrapS(ITexture::Clamp);
00248 _Mat.setDoubleSided(true);
00249 _Mat.setLighting(false); // lighting not supported (the vb has no normals anyway..)
00250 _MatTouched = false;
00251 }
|
|
|
Definition at line 183 of file seg_remanence_shape.cpp. References _Corners, _GeomTouched, _NumSlices, _PB, NL3D::CPrimitiveBlock::setNumTri(), NL3D::CVertexBuffer::setNumVertices(), NL3D::CVertexBuffer::setTexCoord(), NL3D::CPrimitiveBlock::setTri(), NL3D::CVertexBuffer::setVertexFormat(), and uint. Referenced by render().
00184 {
00185 if (!_GeomTouched) return;
00186
00187 uint numCorners = _Corners.size();
00188 _VB.setVertexFormat(CVertexBuffer::PositionFlag | CVertexBuffer::TexCoord0Flag);
00189 _VB.setNumVertices(numCorners * (_NumSlices + 1));
00190 uint k, l;
00191
00192 // set tex coords
00193 for(l = 0; l < numCorners; ++l)
00194 {
00195 for(k = 0; k <= _NumSlices; ++k)
00196 {
00197
00198 _VB.setTexCoord((_NumSlices + 1) * l + k, 0, (float) k / _NumSlices, (float) l / (numCorners - 1));
00199 }
00200 }
00201 // create primitive block
00202 _PB.setNumTri(2 * (numCorners - 1) * _NumSlices);
00203 //
00204 for(l = 0; l < numCorners - 1; ++l)
00205 {
00206 for(k = 0; k < _NumSlices; ++k)
00207 {
00208 _PB.setTri(2 * (l * _NumSlices + k), (_NumSlices + 1) * l + k, (_NumSlices + 1) * (l + 1) + k + 1, (_NumSlices + 1) * (l + 1) + k);
00209 _PB.setTri(2 * (l * _NumSlices + k) + 1, (_NumSlices + 1) * l + k, (_NumSlices + 1) * l + k + 1, (_NumSlices + 1) * (l + 1) + k + 1);
00210 }
00211 }
00212 _GeomTouched = false;
00213 }
|
|
||||||||||||
|
return !NULL if this shape can support MeshBlock rendering for a special instance. NB: Mesh Block render cannot occurs if the Mesh is Skinned/MeshMorphed. NB: Mesh Block render can occurs only in Opaque pass NB: Mesh block render can occurs only for CMeshBase meshes.
Reimplemented in NL3D::CMesh, NL3D::CMeshMRM, NL3D::CMeshMRMSkinned, and NL3D::CMeshMultiLod. Definition at line 158 of file shape.h.
00158 {return NULL;}
|
|
|
tells if the shape wants LocalAttenuation for RealTime lighting. Default is false Reimplemented in NL3D::CMeshBase. Definition at line 142 of file shape.h.
00142 {return false;}
|
|
|
Definition at line 67 of file smart_ptr.h. |
|
|
Definition at line 181 of file seg_remanence_shape.h. Referenced by copyFromOther(), createInstance(), getAnimatedMaterial(), setAnimatedMaterial(), and ~CSegRemanenceShape(). |
|
|
For clipping.
Definition at line 180 of file seg_remanence_shape.h. Referenced by copyFromOther(). |
|
|
Definition at line 174 of file seg_remanence_shape.h. Referenced by copyFromOther(), getCorner(), getNumCorners(), setCorner(), setNumCorners(), and setupVBnPB(). |
|
|
Definition at line 183 of file seg_remanence_shape.h. |
|
|
Definition at line 184 of file seg_remanence_shape.h. |
|
|
Definition at line 185 of file seg_remanence_shape.h. |
|
|
Default to -1.
|
|
|
Definition at line 167 of file seg_remanence_shape.h. Referenced by copyFromOther(), setNumCorners(), setNumSlices(), and setupVBnPB(). |
|
|
Definition at line 176 of file seg_remanence_shape.h. Referenced by copyFromOther(). |
|
|
Definition at line 168 of file seg_remanence_shape.h. Referenced by copyFromOther(), setMaterial(), setTextureShifting(), and setupMaterial(). |
|
|
Definition at line 171 of file seg_remanence_shape.h. Referenced by copyFromOther(), getNumSlices(), getNumTriangles(), setNumSlices(), and setupVBnPB(). |
|
|
Definition at line 178 of file seg_remanence_shape.h. Referenced by copyFromOther(), render(), and setupVBnPB(). |
|
|
Definition at line 173 of file seg_remanence_shape.h. Referenced by copyFromOther(), getRollupRatio(), and setRollupRatio(). |
|
|
Definition at line 172 of file seg_remanence_shape.h. Referenced by copyFromOther(). |
|
|
Definition at line 169 of file seg_remanence_shape.h. Referenced by copyFromOther(), getTextureShifting(), and setTextureShifting(). |
|
|
Definition at line 177 of file seg_remanence_shape.h. Referenced by copyFromOther(). |
|
|
Definition at line 79 of file smart_ptr.h. Referenced by NLMISC::CRefCount::CRefCount(), NLMISC::CRefCount::getRefCount(), and NLMISC::CRefCount::~CRefCount(). |
|
|
Referenced by NLMISC::CRefCount::CRefCount(). |
|
|
Definition at line 80 of file smart_ptr.h. Referenced by NLMISC::CRefCount::CRefCount(), and NLMISC::CRefCount::~CRefCount(). |
1.3.6