00001
00032 #ifndef LL_LLVOVOLUME_H
00033 #define LL_LLVOVOLUME_H
00034
00035 #include "llviewerobject.h"
00036 #include "llspatialpartition.h"
00037 #include "llviewerimage.h"
00038 #include "llframetimer.h"
00039 #include "llapr.h"
00040 #include <map>
00041
00042 class LLViewerTextureAnim;
00043 class LLDrawPool;
00044 class LLSelectNode;
00045
00046 enum LLVolumeInterfaceType
00047 {
00048 INTERFACE_FLEXIBLE = 1,
00049 };
00050
00051
00052 class LLVolumeInterface
00053 {
00054 public:
00055 virtual ~LLVolumeInterface() { }
00056 virtual LLVolumeInterfaceType getInterfaceType() const = 0;
00057 virtual BOOL doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) = 0;
00058 virtual BOOL doUpdateGeometry(LLDrawable *drawable) = 0;
00059 virtual LLVector3 getPivotPosition() const = 0;
00060 virtual void onSetVolume(const LLVolumeParams &volume_params, const S32 detail) = 0;
00061 virtual void onSetScale(const LLVector3 &scale, BOOL damped) = 0;
00062 virtual void onParameterChanged(U16 param_type, LLNetworkData *data, BOOL in_use, bool local_origin) = 0;
00063 virtual void onShift(const LLVector3 &shift_vector) = 0;
00064 virtual bool isVolumeUnique() const = 0;
00065 virtual bool isVolumeGlobal() const = 0;
00066 virtual bool isActive() const = 0;
00067 virtual const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const = 0;
00068 virtual void updateRelativeXform() = 0;
00069 virtual U32 getID() const = 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 F32 getIndividualRadius() { return mRadius; }
00109 S32 getLOD() const { return mLOD; }
00110 const LLVector3 getPivotPositionAgent() const;
00111 const LLMatrix4& getRelativeXform() const { return mRelativeXform; }
00112 const LLMatrix3& getRelativeXformInvTrans() const { return mRelativeXformInvTrans; }
00113 const LLMatrix4 getRenderMatrix() const;
00114
00115 BOOL lineSegmentIntersect(const LLVector3& start, LLVector3& end) const;
00116 LLVector3 agentPositionToVolume(const LLVector3& pos) const;
00117 LLVector3 agentDirectionToVolume(const LLVector3& dir) const;
00118 LLVector3 volumePositionToAgent(const LLVector3& dir) const;
00119
00120
00121 BOOL getVolumeChanged() const { return mVolumeChanged; }
00122 F32 getTextureVirtualSize(LLFace* face);
00123 F32 getRadius() const { return mVObjRadius; };
00124 const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const;
00125
00126 void markForUpdate(BOOL priority) { LLViewerObject::markForUpdate(priority); mVolumeChanged = TRUE; }
00127
00128 void onShift(const LLVector3 &shift_vector);
00129
00130 void parameterChanged(U16 param_type, bool local_origin);
00131 void parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_use, bool local_origin);
00132
00133 U32 processUpdateMessage(LLMessageSystem *mesgsys,
00134 void **user_data,
00135 U32 block_num, const EObjectUpdateType update_type,
00136 LLDataPacker *dp);
00137
00138 void setSelected(BOOL sel);
00139 BOOL setDrawableParent(LLDrawable* parentp);
00140
00141 void setScale(const LLVector3 &scale, BOOL damped);
00142
00143 void setTEImage(const U8 te, LLViewerImage *imagep);
00144 S32 setTETexture(const U8 te, const LLUUID &uuid);
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 setTEScale(const U8 te, const F32 s, const F32 t);
00151 S32 setTEScaleS(const U8 te, const F32 s);
00152 S32 setTEScaleT(const U8 te, const F32 t);
00153 S32 setTETexGen(const U8 te, const U8 texgen);
00154 BOOL setMaterial(const U8 material);
00155
00156 void setTexture(const S32 face);
00157
00158 BOOL setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume = false);
00159 void sculpt();
00160 void updateRelativeXform();
00161 BOOL updateGeometry(LLDrawable *drawable);
00162 void updateFaceSize(S32 idx);
00163 BOOL updateLOD();
00164 void updateRadius();
00165 void updateTextures(LLAgent &agent);
00166 void updateTextures();
00167
00168 void updateFaceFlags();
00169 void regenFaces();
00170 BOOL genBBoxes(BOOL force_global);
00171 virtual void updateSpatialExtents(LLVector3& min, LLVector3& max);
00172 virtual F32 getBinRadius();
00173 virtual void writeCAL3D(apr_file_t* fp,
00174 std::string& path,
00175 std::string& file_base,
00176 S32 joint_num,
00177 LLVector3& pos,
00178 LLQuaternion& rot,
00179 S32& material_index,
00180 S32& texture_index,
00181 std::multimap<LLUUID, LLMaterialExportInfo*>& material_map);
00182
00183
00184 virtual U32 getPartitionType() const;
00185
00186
00187 void setIsLight(BOOL is_light);
00188 void setLightColor(const LLColor3& color);
00189 void setLightIntensity(F32 intensity);
00190 void setLightRadius(F32 radius);
00191 void setLightFalloff(F32 falloff);
00192 void setLightCutoff(F32 cutoff);
00193 BOOL getIsLight() const;
00194 LLColor3 getLightBaseColor() const;
00195 LLColor3 getLightColor() const;
00196 F32 getLightIntensity() const;
00197 F32 getLightRadius() const;
00198 F32 getLightFalloff() const;
00199 F32 getLightCutoff() const;
00200 F32 getLightDistance(const LLVector3& pos) const;
00201
00202
00203 U32 getVolumeInterfaceID() const;
00204 virtual BOOL isFlexible() const;
00205 virtual BOOL isSculpted() const;
00206 BOOL isVolumeGlobal() const;
00207 BOOL canBeFlexible() const;
00208 BOOL setIsFlexible(BOOL is_flexible);
00209
00210
00211 F32 calcLightAtPoint(const LLVector3& pos, const LLVector3& norm, LLColor4& result);
00212 BOOL updateLighting(BOOL do_lighting);
00213
00214 protected:
00215 S32 computeLODDetail(F32 distance, F32 radius);
00216 BOOL calcLOD();
00217 LLFace* addFace(S32 face_index);
00218 void updateTEData();
00219
00220 public:
00221 LLViewerTextureAnim *mTextureAnimp;
00222 U8 mTexAnimMode;
00223 protected:
00224 friend class LLDrawable;
00225
00226 BOOL mFaceMappingChanged;
00227 BOOL mGlobalVolume;
00228 BOOL mInited;
00229 LLFrameTimer mTextureUpdateTimer;
00230 S32 mLOD;
00231 BOOL mLODChanged;
00232 BOOL mSculptChanged;
00233 F32 mRadius;
00234 LLMatrix4 mRelativeXform;
00235 LLMatrix3 mRelativeXformInvTrans;
00236 BOOL mVolumeChanged;
00237 F32 mVObjRadius;
00238 LLVolumeInterface *mVolumeImpl;
00239 LLPointer<LLViewerImage> mSculptTexture;
00240
00241
00242 public:
00243 static F32 sLODSlopDistanceFactor;
00244 static F32 sLODFactor;
00245 static F32 sDistanceFactor;
00246
00247 protected:
00248 static S32 sNumLODChanges;
00249
00250 friend class LLVolumeImplFlexible;
00251 };
00252
00253 #endif // LL_LLVOVOLUME_H