00001
00032 #ifndef LL_LLVOVOLUME_H
00033 #define LL_LLVOVOLUME_H
00034
00035 #include "llviewerobject.h"
00036 #include "llviewerimage.h"
00037 #include "llframetimer.h"
00038 #include "llapr.h"
00039 #include <map>
00040
00041 class LLViewerTextureAnim;
00042 class LLDrawPool;
00043 class LLSelectNode;
00044
00045 enum LLVolumeInterfaceType
00046 {
00047 INTERFACE_FLEXIBLE = 1,
00048 };
00049
00050
00051 class LLVolumeInterface
00052 {
00053 public:
00054 virtual ~LLVolumeInterface() { }
00055 virtual LLVolumeInterfaceType getInterfaceType() const = 0;
00056 virtual BOOL doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) = 0;
00057 virtual BOOL doUpdateGeometry(LLDrawable *drawable) = 0;
00058 virtual LLVector3 getPivotPosition() const = 0;
00059 virtual void onSetVolume(const LLVolumeParams &volume_params, const S32 detail) = 0;
00060 virtual void onSetScale(const LLVector3 &scale, BOOL damped) = 0;
00061 virtual void onParameterChanged(U16 param_type, LLNetworkData *data, BOOL in_use, bool local_origin) = 0;
00062 virtual void onShift(const LLVector3 &shift_vector) = 0;
00063 virtual bool isVolumeUnique() const = 0;
00064 virtual bool isVolumeGlobal() const = 0;
00065 virtual bool isActive() const = 0;
00066 virtual const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const = 0;
00067 virtual void updateRelativeXform() = 0;
00068 virtual U32 getID() const = 0;
00069 virtual void preRebuild() = 0;
00070 };
00071
00072
00073 class LLVOVolume : public LLViewerObject
00074 {
00075 protected:
00076 virtual ~LLVOVolume();
00077
00078 public:
00079 static void initClass();
00080 static void preUpdateGeom();
00081
00082 enum
00083 {
00084 VERTEX_DATA_MASK = (1 << LLVertexBuffer::TYPE_VERTEX) |
00085 (1 << LLVertexBuffer::TYPE_NORMAL) |
00086 (1 << LLVertexBuffer::TYPE_TEXCOORD) |
00087 (1 << LLVertexBuffer::TYPE_TEXCOORD2) |
00088 (1 << LLVertexBuffer::TYPE_COLOR)
00089 };
00090
00091 public:
00092 LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
00093
00094 LLDrawable* createDrawable(LLPipeline *pipeline);
00095
00096 void deleteFaces();
00097
00098 void animateTextures();
00099 BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
00100
00101 BOOL isActive() const;
00102 BOOL isAttachment() const;
00103 BOOL isRootEdit() const;
00104 BOOL isHUDAttachment() const;
00105
00106 void generateSilhouette(LLSelectNode* nodep, const LLVector3& view_point);
00107 void setParent(LLViewerObject* parent);
00108 S32 getLOD() const { return mLOD; }
00109 const LLVector3 getPivotPositionAgent() const;
00110 const LLMatrix4& getRelativeXform() const { return mRelativeXform; }
00111 const LLMatrix3& getRelativeXformInvTrans() const { return mRelativeXformInvTrans; }
00112 const LLMatrix4 getRenderMatrix() const;
00113
00114 BOOL lineSegmentIntersect(const LLVector3& start, LLVector3& end) const;
00115 LLVector3 agentPositionToVolume(const LLVector3& pos) const;
00116 LLVector3 agentDirectionToVolume(const LLVector3& dir) const;
00117 LLVector3 volumePositionToAgent(const LLVector3& dir) const;
00118
00119
00120 BOOL getVolumeChanged() const { return mVolumeChanged; }
00121 F32 getTextureVirtualSize(LLFace* face);
00122 F32 getRadius() const { return mVObjRadius; };
00123 const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const;
00124
00125 void markForUpdate(BOOL priority) { LLViewerObject::markForUpdate(priority); mVolumeChanged = TRUE; }
00126
00127 void onShift(const LLVector3 &shift_vector);
00128
00129 void parameterChanged(U16 param_type, bool local_origin);
00130 void parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_use, bool local_origin);
00131
00132 U32 processUpdateMessage(LLMessageSystem *mesgsys,
00133 void **user_data,
00134 U32 block_num, const EObjectUpdateType update_type,
00135 LLDataPacker *dp);
00136
00137 void setSelected(BOOL sel);
00138 BOOL setDrawableParent(LLDrawable* parentp);
00139
00140 void setScale(const LLVector3 &scale, BOOL damped);
00141
00142 void setTEImage(const U8 te, LLViewerImage *imagep);
00143 S32 setTETexture(const U8 te, const LLUUID &uuid);
00144 S32 setTEColor(const U8 te, const LLColor3 &color);
00145 S32 setTEColor(const U8 te, const LLColor4 &color);
00146 S32 setTEBumpmap(const U8 te, const U8 bump);
00147 S32 setTEShiny(const U8 te, const U8 shiny);
00148 S32 setTEFullbright(const U8 te, const U8 fullbright);
00149 S32 setTEMediaFlags(const U8 te, const U8 media_flags);
00150 S32 setTEGlow(const U8 te, const F32 glow);
00151 S32 setTEScale(const U8 te, const F32 s, const F32 t);
00152 S32 setTEScaleS(const U8 te, const F32 s);
00153 S32 setTEScaleT(const U8 te, const F32 t);
00154 S32 setTETexGen(const U8 te, const U8 texgen);
00155 BOOL setMaterial(const U8 material);
00156
00157 void setTexture(const S32 face);
00158
00159 BOOL setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume = false);
00160 void sculpt();
00161 void updateRelativeXform();
00162 BOOL updateGeometry(LLDrawable *drawable);
00163 void updateFaceSize(S32 idx);
00164 BOOL updateLOD();
00165 void updateRadius();
00166 void updateTextures(LLAgent &agent);
00167 void updateTextures();
00168
00169 void updateFaceFlags();
00170 void regenFaces();
00171 BOOL genBBoxes(BOOL force_global);
00172 void preRebuild();
00173 virtual void updateSpatialExtents(LLVector3& min, LLVector3& max);
00174 virtual F32 getBinRadius();
00175
00176 virtual U32 getPartitionType() const;
00177
00178
00179 void setIsLight(BOOL is_light);
00180 void setLightColor(const LLColor3& color);
00181 void setLightIntensity(F32 intensity);
00182 void setLightRadius(F32 radius);
00183 void setLightFalloff(F32 falloff);
00184 void setLightCutoff(F32 cutoff);
00185 BOOL getIsLight() const;
00186 LLColor3 getLightBaseColor() const;
00187 LLColor3 getLightColor() const;
00188 F32 getLightIntensity() const;
00189 F32 getLightRadius() const;
00190 F32 getLightFalloff() const;
00191 F32 getLightCutoff() const;
00192
00193
00194 U32 getVolumeInterfaceID() const;
00195 virtual BOOL isFlexible() const;
00196 virtual BOOL isSculpted() const;
00197 BOOL isVolumeGlobal() const;
00198 BOOL canBeFlexible() const;
00199 BOOL setIsFlexible(BOOL is_flexible);
00200
00201 protected:
00202 S32 computeLODDetail(F32 distance, F32 radius);
00203 BOOL calcLOD();
00204 LLFace* addFace(S32 face_index);
00205 void updateTEData();
00206
00207 public:
00208 LLViewerTextureAnim *mTextureAnimp;
00209 U8 mTexAnimMode;
00210 private:
00211 friend class LLDrawable;
00212
00213 BOOL mFaceMappingChanged;
00214 LLFrameTimer mTextureUpdateTimer;
00215 S32 mLOD;
00216 BOOL mLODChanged;
00217 BOOL mSculptChanged;
00218 LLMatrix4 mRelativeXform;
00219 LLMatrix3 mRelativeXformInvTrans;
00220 BOOL mVolumeChanged;
00221 F32 mVObjRadius;
00222 LLVolumeInterface *mVolumeImpl;
00223 LLPointer<LLViewerImage> mSculptTexture;
00224
00225
00226 public:
00227 static F32 sLODSlopDistanceFactor;
00228 static F32 sLODFactor;
00229 static F32 sDistanceFactor;
00230
00231 protected:
00232 static S32 sNumLODChanges;
00233
00234 friend class LLVolumeImplFlexible;
00235 };
00236
00237 #endif // LL_LLVOVOLUME_H