diff options
Diffstat (limited to 'indra/newview/llfloatermodelpreview.h')
-rw-r--r-- | indra/newview/llfloatermodelpreview.h | 278 |
1 files changed, 148 insertions, 130 deletions
diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h index 1f9de2e2b9..05106644dc 100644 --- a/indra/newview/llfloatermodelpreview.h +++ b/indra/newview/llfloatermodelpreview.h @@ -2,30 +2,25 @@ * @file llfloatermodelpreview.h * @brief LLFloaterModelPreview class definition * - * $LicenseInfo:firstyear=2004&license=viewergpl$ - * - * Copyright (c) 2004-2007, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2004&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlife.com/developers/opensource/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at http://secondlife.com/developers/opensource/flossexception + * 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 + * Lesser General Public License for more details. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -40,7 +35,6 @@ #include "llmodel.h" #include "llthread.h" -#if LL_MESH_ENABLED class LLComboBox; class LLJoint; class LLViewerJointMesh; @@ -52,14 +46,8 @@ class LLFloaterModelPreview; class daeElement; class domProfile_COMMON; class domInstance_geometry; - -class LLPhysicsDecompFloater : public LLFloater -{ -public: - - LLPhysicsDecompFloater(LLSD& key); - ~LLPhysicsDecompFloater(); -}; +class domNode; +class domTranslate; class LLModelLoader : public LLThread { @@ -93,6 +81,11 @@ public: scene mScene; + typedef std::queue<LLPointer<LLModel> > model_queue; + + //queue of models that need a physics rep + model_queue mPhysicsQ; + LLModelLoader(std::string filename, S32 lod, LLModelPreview* preview); virtual void run(); @@ -102,11 +95,118 @@ public: LLImportMaterial profileToMaterial(domProfile_COMMON* material); std::string getElementLabel(daeElement *element); LLColor4 getDaeColor(daeElement* element); + + daeElement* getChildFromElement( daeElement* pElement, std::string const & name ); + + bool isNodeAJoint( domNode* pNode ); + void processJointNode( domNode* pNode, std::map<std::string,LLMatrix4>& jointTransforms ); + void extractTranslation( domTranslate* pTranslate, LLMatrix4& transform ); + void extractTranslationViaElement( daeElement* pTranslateElement, LLMatrix4& transform ); + //map of avatar joints as named in COLLADA assets to internal joint names std::map<std::string, std::string> mJointMap; }; +class LLFloaterModelPreview : public LLFloater +{ +public: + + class DecompRequest : public LLPhysicsDecomp::Request + { + public: + S32 mContinue; + LLPointer<LLModel> mModel; + + DecompRequest(const std::string& stage, LLModel* mdl); + virtual S32 statusCallback(const char* status, S32 p1, S32 p2); + virtual void completed(); + + }; + static LLFloaterModelPreview* sInstance; + + LLFloaterModelPreview(const LLSD& key); + virtual ~LLFloaterModelPreview(); + + virtual BOOL postBuild(); + + BOOL handleMouseDown(S32 x, S32 y, MASK mask); + BOOL handleMouseUp(S32 x, S32 y, MASK mask); + BOOL handleHover(S32 x, S32 y, MASK mask); + BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); + + static void onMouseCaptureLostModelPreview(LLMouseHandler*); + static void setUploadAmount(S32 amount) { sUploadAmount = amount; } + + static void onBrowseLOD(void* data); + + static void onUpload(void* data); + + static void onConsolidate(void* data); + static void onClearMaterials(void* data); + static void onModelDecompositionComplete(LLModel* model, std::vector<LLPointer<LLVertexBuffer> >& physics_mesh); + + static void refresh(LLUICtrl* ctrl, void* data); + + void updateResourceCost(); + + void loadModel(S32 lod); + +protected: + friend class LLModelPreview; + friend class LLMeshFilePicker; + friend class LLPhysicsDecomp; + + static void onImportScaleCommit(LLUICtrl*, void*); + static void onUploadJointsCommit(LLUICtrl*,void*); + static void onUploadSkinCommit(LLUICtrl*,void*); + + static void onPreviewLODCommit(LLUICtrl*,void*); + + static void onTriangleLimitCommit(LLUICtrl*,void*); + + static void onGenerateNormalsCommit(LLUICtrl*,void*); + + static void onAutoFillCommit(LLUICtrl*,void*); + static void onShowEdgesCommit(LLUICtrl*,void*); + + static void onExplodeCommit(LLUICtrl*, void*); + + static void onPhysicsParamCommit(LLUICtrl* ctrl, void* userdata); + static void onPhysicsStageExecute(LLUICtrl* ctrl, void* userdata); + static void onPhysicsStageCancel(LLUICtrl* ctrl, void* userdata); + + static void onPhysicsBrowse(LLUICtrl* ctrl, void* userdata); + static void onPhysicsUseLOD(LLUICtrl* ctrl, void* userdata); + static void onPhysicsOptimize(LLUICtrl* ctrl, void* userdata); + static void onPhysicsDecomposeBack(LLUICtrl* ctrl, void* userdata); + static void onPhysicsSimplifyBack(LLUICtrl* ctrl, void* userdata); + + + + void draw(); + + static void setLimit(S32 lod, void* userdata); + void setLimit(S32 lod, S32 limit); + + void initDecompControls(); + + LLModelPreview* mModelPreview; + + LLPhysicsDecomp::decomp_params mDecompParams; + + S32 mLastMouseX; + S32 mLastMouseY; + LLRect mPreviewRect; + U32 mGLName; + BOOL mLoading; + static S32 sUploadAmount; + + LLPointer<DecompRequest> mCurRequest; + + +}; + class LLModelPreview : public LLViewerDynamicTexture, public LLMutex { public: @@ -114,37 +214,45 @@ class LLModelPreview : public LLViewerDynamicTexture, public LLMutex LLModelPreview(S32 width, S32 height, LLFloaterModelPreview* fmp); virtual ~LLModelPreview(); + void resetPreviewTarget(); void setPreviewTarget(F32 distance); void setTexture(U32 name) { mTextureName = name; } + void setPhysicsFromLOD(S32 lod); BOOL render(); - void genBuffers(S32 lod); + void update(); + void genBuffers(S32 lod, bool skinned); + void clearBuffers(); void refresh(); void rotate(F32 yaw_radians, F32 pitch_radians); void zoom(F32 zoom_amt); void pan(F32 right, F32 up); virtual BOOL needsRender() { return mNeedsUpdate; } void setPreviewLOD(S32 lod); + void clearModel(S32 lod); void loadModel(std::string filename, S32 lod); void loadModelCallback(S32 lod); void genLODs(S32 which_lod = -1); - void smoothNormals(); + void generateNormals(); void consolidate(); - void scrubMaterials(); + void clearMaterials(); U32 calcResourceCost(); void rebuildUploadData(); void clearIncompatible(S32 lod); void updateStatusMessages(); + bool containsRiggedAsset( void ); static void textureLoadedCallback( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata ); protected: friend class LLFloaterModelPreview; + friend class LLFloaterModelPreview::DecompRequest; friend class LLPhysicsDecomp; LLFloaterModelPreview* mFMP; BOOL mNeedsUpdate; + bool mDirty; U32 mTextureName; F32 mCameraDistance; F32 mCameraYaw; @@ -155,9 +263,9 @@ class LLModelPreview : public LLViewerDynamicTexture, public LLMutex LLVector3 mPreviewScale; S32 mPreviewLOD; U32 mResourceCost; - S32 mLODMode[LLModel::NUM_LODS]; S32 mLimit[LLModel::NUM_LODS]; - + std::string mLODFile[LLModel::NUM_LODS]; + LLModelLoader* mModelLoader; @@ -167,109 +275,19 @@ class LLModelPreview : public LLViewerDynamicTexture, public LLMutex LLModelLoader::model_list mModel[LLModel::NUM_LODS]; LLModelLoader::model_list mBaseModel; - std::map<LLModel*, U32> mGroup; - std::map<LLModel*, U32> mObject; - std::map<LLModel*, std::vector<U32> > mPatch; + std::map<LLPointer<LLModel>, U32> mGroup; + std::map<LLPointer<LLModel>, U32> mObject; + std::map<LLPointer<LLModel>, std::vector<U32> > mPatch; + std::map<LLPointer<LLModel>, F32> mPercentage; - std::map<LLModel*, F32> mPercentage; - std::map<LLModel*, std::vector<LLPointer<LLVertexBuffer> > > mPhysicsMesh; + std::map<LLPointer<LLModel>, std::vector<LLPointer<LLVertexBuffer> > > mPhysicsMesh; LLMeshUploadThread::instance_list mUploadData; std::set<LLPointer<LLViewerFetchedTexture> > mTextureSet; //map of vertex buffers to models (one vertex buffer in vector per face in model - std::map<LLModel*, std::vector<LLPointer<LLVertexBuffer> > > mVertexBuffer[6]; -}; - -class LLFloaterModelPreview : public LLFloater -{ -public: - static LLFloaterModelPreview* sInstance; - - LLFloaterModelPreview(const LLSD& key); - virtual ~LLFloaterModelPreview(); - - virtual BOOL postBuild(); - - BOOL handleMouseDown(S32 x, S32 y, MASK mask); - BOOL handleMouseUp(S32 x, S32 y, MASK mask); - BOOL handleHover(S32 x, S32 y, MASK mask); - BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); - - static void onMouseCaptureLostModelPreview(LLMouseHandler*); - static void setUploadAmount(S32 amount) { sUploadAmount = amount; } - - static void onBrowseHighLOD(void* data); - static void onBrowseMediumLOD(void* data); - static void onBrowseLowLOD(void* data); - static void onBrowseLowestLOD(void* data); - - static void onUpload(void* data); - - static void onConsolidate(void* data); - static void onScrubMaterials(void* data); - static void onDecompose(void* data); - static void onModelDecompositionComplete(LLModel* model, std::vector<LLPointer<LLVertexBuffer> >& physics_mesh); - - static void refresh(LLUICtrl* ctrl, void* data); - - void updateResourceCost(); - - void loadModel(S32 lod); - -protected: - friend class LLModelPreview; - friend class LLMeshFilePicker; - friend class LLPhysicsDecomp; - friend class LLPhysicsDecompFloater; - - static void onPreviewLODCommit(LLUICtrl*,void*); - - static void onHighLODCommit(LLUICtrl*,void*); - static void onMediumLODCommit(LLUICtrl*,void*); - static void onLowLODCommit(LLUICtrl*,void*); - static void onLowestLODCommit(LLUICtrl*,void*); - static void onPhysicsLODCommit(LLUICtrl*,void*); - - static void onHighLimitCommit(LLUICtrl*,void*); - static void onMediumLimitCommit(LLUICtrl*,void*); - static void onLowLimitCommit(LLUICtrl*,void*); - static void onLowestLimitCommit(LLUICtrl*,void*); - static void onPhysicsLimitCommit(LLUICtrl*,void*); - - static void onSmoothNormalsCommit(LLUICtrl*,void*); - - static void onAutoFillCommit(LLUICtrl*,void*); - static void onShowEdgesCommit(LLUICtrl*,void*); - - static void onExplodeCommit(LLUICtrl*, void*); - - static void onPhysicsParamCommit(LLUICtrl* ctrl, void* userdata); - static void onPhysicsStageExecute(LLUICtrl* ctrl, void* userdata); - static void onPhysicsStageCancel(LLUICtrl* ctrl, void* userdata); - static void onClosePhysicsFloater(LLUICtrl* ctrl, void* userdata); - - void draw(); - static void setLODMode(S32 lod, void* userdata); - void setLODMode(S32 lod, S32 which_mode); - - static void setLimit(S32 lod, void* userdata); - void setLimit(S32 lod, S32 limit); - - void showDecompFloater(); - - LLModelPreview* mModelPreview; - - LLFloater* mDecompFloater; - - S32 mLastMouseX; - S32 mLastMouseY; - LLRect mPreviewRect; - U32 mGLName; - BOOL mLoading; - static S32 sUploadAmount; + std::map<LLModel*, std::vector<LLPointer<LLVertexBuffer> > > mVertexBuffer[LLModel::NUM_LODS+1]; }; -#endif #endif // LL_LLFLOATERMODELPREVIEW_H |