diff options
Diffstat (limited to 'linden/indra/newview/llfloaterimagepreview.cpp')
-rw-r--r-- | linden/indra/newview/llfloaterimagepreview.cpp | 215 |
1 files changed, 208 insertions, 7 deletions
diff --git a/linden/indra/newview/llfloaterimagepreview.cpp b/linden/indra/newview/llfloaterimagepreview.cpp index 9237380..9dfaa49 100644 --- a/linden/indra/newview/llfloaterimagepreview.cpp +++ b/linden/indra/newview/llfloaterimagepreview.cpp | |||
@@ -102,10 +102,14 @@ BOOL LLFloaterImagePreview::postBuild() | |||
102 | { | 102 | { |
103 | mAvatarPreview = new LLImagePreviewAvatar(256, 256); | 103 | mAvatarPreview = new LLImagePreviewAvatar(256, 256); |
104 | mAvatarPreview->setPreviewTarget("mPelvis", "mUpperBodyMesh0", mRawImagep, 2.f, FALSE); | 104 | mAvatarPreview->setPreviewTarget("mPelvis", "mUpperBodyMesh0", mRawImagep, 2.f, FALSE); |
105 | |||
106 | mSculptedPreview = new LLImagePreviewSculpted(256, 256); | ||
107 | mSculptedPreview->setPreviewTarget(mRawImagep, 2.0f); | ||
105 | } | 108 | } |
106 | else | 109 | else |
107 | { | 110 | { |
108 | mAvatarPreview = NULL; | 111 | mAvatarPreview = NULL; |
112 | mSculptedPreview = NULL; | ||
109 | childShow("bad_image_text"); | 113 | childShow("bad_image_text"); |
110 | childDisable("clothing_type_combo"); | 114 | childDisable("clothing_type_combo"); |
111 | childDisable("ok_btn"); | 115 | childDisable("ok_btn"); |
@@ -121,6 +125,8 @@ LLFloaterImagePreview::~LLFloaterImagePreview() | |||
121 | { | 125 | { |
122 | mRawImagep = NULL; | 126 | mRawImagep = NULL; |
123 | delete mAvatarPreview; | 127 | delete mAvatarPreview; |
128 | delete mSculptedPreview; | ||
129 | |||
124 | if (mGLName) | 130 | if (mGLName) |
125 | { | 131 | { |
126 | glDeleteTextures(1, &mGLName ); | 132 | glDeleteTextures(1, &mGLName ); |
@@ -135,7 +141,7 @@ void LLFloaterImagePreview::onPreviewTypeCommit(LLUICtrl* ctrl, void* userdata) | |||
135 | { | 141 | { |
136 | LLFloaterImagePreview *fp =(LLFloaterImagePreview *)userdata; | 142 | LLFloaterImagePreview *fp =(LLFloaterImagePreview *)userdata; |
137 | 143 | ||
138 | if (!fp->mAvatarPreview) | 144 | if (!fp->mAvatarPreview || !fp->mSculptedPreview) |
139 | { | 145 | { |
140 | return; | 146 | return; |
141 | } | 147 | } |
@@ -176,10 +182,15 @@ void LLFloaterImagePreview::onPreviewTypeCommit(LLUICtrl* ctrl, void* userdata) | |||
176 | case 8: | 182 | case 8: |
177 | fp->mAvatarPreview->setPreviewTarget("mKneeLeft", "mSkirtMesh0", fp->mRawImagep, 1.3f, FALSE); | 183 | fp->mAvatarPreview->setPreviewTarget("mKneeLeft", "mSkirtMesh0", fp->mRawImagep, 1.3f, FALSE); |
178 | break; | 184 | break; |
185 | case 9: | ||
186 | fp->mSculptedPreview->setPreviewTarget(fp->mRawImagep, 2.0f); | ||
187 | break; | ||
179 | default: | 188 | default: |
180 | break; | 189 | break; |
181 | } | 190 | } |
191 | |||
182 | fp->mAvatarPreview->refresh(); | 192 | fp->mAvatarPreview->refresh(); |
193 | fp->mSculptedPreview->refresh(); | ||
183 | } | 194 | } |
184 | 195 | ||
185 | //----------------------------------------------------------------------------- | 196 | //----------------------------------------------------------------------------- |
@@ -193,7 +204,11 @@ void LLFloaterImagePreview::draw() | |||
193 | if (mRawImagep.notNull()) | 204 | if (mRawImagep.notNull()) |
194 | { | 205 | { |
195 | LLCtrlSelectionInterface* iface = childGetSelectionInterface("clothing_type_combo"); | 206 | LLCtrlSelectionInterface* iface = childGetSelectionInterface("clothing_type_combo"); |
196 | if (iface && iface->getFirstSelectedIndex() <= 0) | 207 | U32 selected = 0; |
208 | if (iface) | ||
209 | selected = iface->getFirstSelectedIndex(); | ||
210 | |||
211 | if (selected <= 0) | ||
197 | { | 212 | { |
198 | gl_rect_2d_checkerboard(mPreviewRect); | 213 | gl_rect_2d_checkerboard(mPreviewRect); |
199 | LLGLDisable gls_alpha(GL_ALPHA_TEST); | 214 | LLGLDisable gls_alpha(GL_ALPHA_TEST); |
@@ -230,6 +245,7 @@ void LLFloaterImagePreview::draw() | |||
230 | if (mAvatarPreview) | 245 | if (mAvatarPreview) |
231 | { | 246 | { |
232 | mAvatarPreview->setTexture(mGLName); | 247 | mAvatarPreview->setTexture(mGLName); |
248 | mSculptedPreview->setTexture(mGLName); | ||
233 | } | 249 | } |
234 | } | 250 | } |
235 | 251 | ||
@@ -253,10 +269,14 @@ void LLFloaterImagePreview::draw() | |||
253 | } | 269 | } |
254 | else | 270 | else |
255 | { | 271 | { |
256 | if (mAvatarPreview) | 272 | if ((mAvatarPreview) && (mSculptedPreview)) |
257 | { | 273 | { |
258 | glColor3f(1.f, 1.f, 1.f); | 274 | glColor3f(1.f, 1.f, 1.f); |
259 | mAvatarPreview->bindTexture(); | 275 | |
276 | if (selected == 9) | ||
277 | mSculptedPreview->bindTexture(); | ||
278 | else | ||
279 | mAvatarPreview->bindTexture(); | ||
260 | 280 | ||
261 | glBegin( GL_QUADS ); | 281 | glBegin( GL_QUADS ); |
262 | { | 282 | { |
@@ -271,12 +291,16 @@ void LLFloaterImagePreview::draw() | |||
271 | } | 291 | } |
272 | glEnd(); | 292 | glEnd(); |
273 | 293 | ||
274 | mAvatarPreview->unbindTexture(); | 294 | if (selected == 9) |
295 | mSculptedPreview->unbindTexture(); | ||
296 | else | ||
297 | mAvatarPreview->unbindTexture(); | ||
275 | } | 298 | } |
276 | } | 299 | } |
277 | } | 300 | } |
278 | } | 301 | } |
279 | 302 | ||
303 | |||
280 | //----------------------------------------------------------------------------- | 304 | //----------------------------------------------------------------------------- |
281 | // loadImage() | 305 | // loadImage() |
282 | //----------------------------------------------------------------------------- | 306 | //----------------------------------------------------------------------------- |
@@ -417,6 +441,7 @@ BOOL LLFloaterImagePreview::handleHover(S32 x, S32 y, MASK mask) | |||
417 | else | 441 | else |
418 | { | 442 | { |
419 | mAvatarPreview->pan((F32)(x - mLastMouseX) * -0.005f, (F32)(y - mLastMouseY) * -0.005f); | 443 | mAvatarPreview->pan((F32)(x - mLastMouseX) * -0.005f, (F32)(y - mLastMouseY) * -0.005f); |
444 | mSculptedPreview->pan((F32)(x - mLastMouseX) * -0.005f, (F32)(y - mLastMouseY) * -0.005f); | ||
420 | } | 445 | } |
421 | } | 446 | } |
422 | else if (local_mask == MASK_ORBIT) | 447 | else if (local_mask == MASK_ORBIT) |
@@ -425,6 +450,7 @@ BOOL LLFloaterImagePreview::handleHover(S32 x, S32 y, MASK mask) | |||
425 | F32 pitch_radians = (F32)(y - mLastMouseY) * 0.02f; | 450 | F32 pitch_radians = (F32)(y - mLastMouseY) * 0.02f; |
426 | 451 | ||
427 | mAvatarPreview->rotate(yaw_radians, pitch_radians); | 452 | mAvatarPreview->rotate(yaw_radians, pitch_radians); |
453 | mSculptedPreview->rotate(yaw_radians, pitch_radians); | ||
428 | } | 454 | } |
429 | else | 455 | else |
430 | { | 456 | { |
@@ -441,6 +467,8 @@ BOOL LLFloaterImagePreview::handleHover(S32 x, S32 y, MASK mask) | |||
441 | 467 | ||
442 | mAvatarPreview->rotate(yaw_radians, 0.f); | 468 | mAvatarPreview->rotate(yaw_radians, 0.f); |
443 | mAvatarPreview->zoom(zoom_amt); | 469 | mAvatarPreview->zoom(zoom_amt); |
470 | mSculptedPreview->rotate(yaw_radians, 0.f); | ||
471 | mSculptedPreview->zoom(zoom_amt); | ||
444 | } | 472 | } |
445 | } | 473 | } |
446 | 474 | ||
@@ -486,12 +514,13 @@ BOOL LLFloaterImagePreview::handleHover(S32 x, S32 y, MASK mask) | |||
486 | else | 514 | else |
487 | { | 515 | { |
488 | mAvatarPreview->refresh(); | 516 | mAvatarPreview->refresh(); |
517 | mSculptedPreview->refresh(); | ||
489 | } | 518 | } |
490 | 519 | ||
491 | LLUI::setCursorPositionLocal(this, mLastMouseX, mLastMouseY); | 520 | LLUI::setCursorPositionLocal(this, mLastMouseX, mLastMouseY); |
492 | } | 521 | } |
493 | 522 | ||
494 | if (!mPreviewRect.pointInRect(x, y) || !mAvatarPreview) | 523 | if (!mPreviewRect.pointInRect(x, y) || !mAvatarPreview || !mSculptedPreview) |
495 | { | 524 | { |
496 | return LLFloater::handleHover(x, y, mask); | 525 | return LLFloater::handleHover(x, y, mask); |
497 | } | 526 | } |
@@ -520,6 +549,9 @@ BOOL LLFloaterImagePreview::handleScrollWheel(S32 x, S32 y, S32 clicks) | |||
520 | { | 549 | { |
521 | mAvatarPreview->zoom((F32)clicks * -0.2f); | 550 | mAvatarPreview->zoom((F32)clicks * -0.2f); |
522 | mAvatarPreview->refresh(); | 551 | mAvatarPreview->refresh(); |
552 | |||
553 | mSculptedPreview->zoom((F32)clicks * -0.2f); | ||
554 | mSculptedPreview->refresh(); | ||
523 | } | 555 | } |
524 | 556 | ||
525 | return TRUE; | 557 | return TRUE; |
@@ -560,6 +592,7 @@ LLImagePreviewAvatar::LLImagePreviewAvatar(S32 width, S32 height) : LLDynamicTex | |||
560 | mTextureName = 0; | 592 | mTextureName = 0; |
561 | } | 593 | } |
562 | 594 | ||
595 | |||
563 | LLImagePreviewAvatar::~LLImagePreviewAvatar() | 596 | LLImagePreviewAvatar::~LLImagePreviewAvatar() |
564 | { | 597 | { |
565 | mDummyAvatar->markDead(); | 598 | mDummyAvatar->markDead(); |
@@ -602,7 +635,7 @@ void LLImagePreviewAvatar::setPreviewTarget(const char* joint_name, const char* | |||
602 | //----------------------------------------------------------------------------- | 635 | //----------------------------------------------------------------------------- |
603 | // update() | 636 | // update() |
604 | //----------------------------------------------------------------------------- | 637 | //----------------------------------------------------------------------------- |
605 | BOOL LLImagePreviewAvatar::render() | 638 | BOOL LLImagePreviewAvatar::render() |
606 | { | 639 | { |
607 | mNeedsUpdate = FALSE; | 640 | mNeedsUpdate = FALSE; |
608 | LLVOAvatar* avatarp = mDummyAvatar; | 641 | LLVOAvatar* avatarp = mDummyAvatar; |
@@ -640,6 +673,7 @@ BOOL LLImagePreviewAvatar::render() | |||
640 | 673 | ||
641 | stop_glerror(); | 674 | stop_glerror(); |
642 | 675 | ||
676 | gCamera->setAspect((F32)mWidth / mHeight); | ||
643 | gCamera->setView(gCamera->getDefaultFOV() / mCameraZoom); | 677 | gCamera->setView(gCamera->getDefaultFOV() / mCameraZoom); |
644 | gCamera->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mWidth, mHeight, FALSE); | 678 | gCamera->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mWidth, mHeight, FALSE); |
645 | 679 | ||
@@ -692,3 +726,170 @@ void LLImagePreviewAvatar::pan(F32 right, F32 up) | |||
692 | mCameraOffset.mV[VY] = llclamp(mCameraOffset.mV[VY] + right * mCameraDistance / mCameraZoom, -1.f, 1.f); | 726 | mCameraOffset.mV[VY] = llclamp(mCameraOffset.mV[VY] + right * mCameraDistance / mCameraZoom, -1.f, 1.f); |
693 | mCameraOffset.mV[VZ] = llclamp(mCameraOffset.mV[VZ] + up * mCameraDistance / mCameraZoom, -1.f, 1.f); | 727 | mCameraOffset.mV[VZ] = llclamp(mCameraOffset.mV[VZ] + up * mCameraDistance / mCameraZoom, -1.f, 1.f); |
694 | } | 728 | } |
729 | |||
730 | |||
731 | //----------------------------------------------------------------------------- | ||
732 | // LLImagePreviewSculpted | ||
733 | //----------------------------------------------------------------------------- | ||
734 | |||
735 | LLImagePreviewSculpted::LLImagePreviewSculpted(S32 width, S32 height) : LLDynamicTexture(width, height, 3, ORDER_MIDDLE, FALSE) | ||
736 | { | ||
737 | mNeedsUpdate = TRUE; | ||
738 | mCameraDistance = 0.f; | ||
739 | mCameraYaw = 0.f; | ||
740 | mCameraPitch = 0.f; | ||
741 | mCameraZoom = 1.f; | ||
742 | mTextureName = 0; | ||
743 | |||
744 | LLVolumeParams volume_params; | ||
745 | volume_params.setType(LL_PCODE_PROFILE_CIRCLE, LL_PCODE_PATH_CIRCLE); | ||
746 | mVolume = new LLVolume(volume_params, (F32) MAX_LOD); | ||
747 | |||
748 | /* | ||
749 | mDummyAvatar = new LLVOAvatar(LLUUID::null, LL_PCODE_LEGACY_AVATAR, gAgent.getRegion()); | ||
750 | mDummyAvatar->createDrawable(&gPipeline); | ||
751 | mDummyAvatar->mIsDummy = TRUE; | ||
752 | mDummyAvatar->mSpecialRenderMode = 2; | ||
753 | mDummyAvatar->setPositionAgent(LLVector3::zero); | ||
754 | mDummyAvatar->slamPosition(); | ||
755 | mDummyAvatar->updateJointLODs(); | ||
756 | mDummyAvatar->updateGeometry(mDummyAvatar->mDrawable); | ||
757 | gPipeline.markVisible(mDummyAvatar->mDrawable, *gCamera); | ||
758 | mTextureName = 0; | ||
759 | */ | ||
760 | } | ||
761 | |||
762 | |||
763 | LLImagePreviewSculpted::~LLImagePreviewSculpted() | ||
764 | { | ||
765 | /* | ||
766 | mDummyAvatar->markDead(); | ||
767 | */ | ||
768 | } | ||
769 | |||
770 | |||
771 | void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance) | ||
772 | { | ||
773 | mCameraDistance = distance; | ||
774 | mCameraZoom = 1.f; | ||
775 | mCameraPitch = 0.f; | ||
776 | mCameraYaw = 0.f; | ||
777 | mCameraOffset.clearVec(); | ||
778 | |||
779 | if (imagep) | ||
780 | { | ||
781 | mVolume->sculpt(imagep->getWidth(), imagep->getHeight(), imagep->getComponents(), imagep->getData(), 0); | ||
782 | } | ||
783 | |||
784 | } | ||
785 | |||
786 | |||
787 | //----------------------------------------------------------------------------- | ||
788 | // render() | ||
789 | //----------------------------------------------------------------------------- | ||
790 | BOOL LLImagePreviewSculpted::render() | ||
791 | { | ||
792 | mNeedsUpdate = FALSE; | ||
793 | |||
794 | LLGLSUIDefault def; | ||
795 | LLGLDisable no_blend(GL_BLEND); | ||
796 | LLGLEnable cull(GL_CULL_FACE); | ||
797 | LLGLDepthTest depth(GL_TRUE); | ||
798 | |||
799 | glMatrixMode(GL_PROJECTION); | ||
800 | glPushMatrix(); | ||
801 | glLoadIdentity(); | ||
802 | glOrtho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f); | ||
803 | |||
804 | glMatrixMode(GL_MODELVIEW); | ||
805 | glPushMatrix(); | ||
806 | glLoadIdentity(); | ||
807 | |||
808 | glColor4f(0.15f, 0.2f, 0.3f, 1.f); | ||
809 | |||
810 | gl_rect_2d_simple( mWidth, mHeight ); | ||
811 | |||
812 | glMatrixMode(GL_PROJECTION); | ||
813 | glPopMatrix(); | ||
814 | |||
815 | glMatrixMode(GL_MODELVIEW); | ||
816 | glPopMatrix(); | ||
817 | |||
818 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | ||
819 | |||
820 | LLVector3 target_pos(0, 0, 0); | ||
821 | |||
822 | LLQuaternion camera_rot = LLQuaternion(mCameraPitch, LLVector3::y_axis) * | ||
823 | LLQuaternion(mCameraYaw, LLVector3::z_axis); | ||
824 | |||
825 | LLQuaternion av_rot = camera_rot; | ||
826 | gCamera->setOriginAndLookAt( | ||
827 | target_pos + ((LLVector3(mCameraDistance, 0.f, 0.f) + mCameraOffset) * av_rot), // camera | ||
828 | LLVector3::z_axis, // up | ||
829 | target_pos + (mCameraOffset * av_rot) ); // point of interest | ||
830 | |||
831 | stop_glerror(); | ||
832 | |||
833 | gCamera->setAspect((F32) mWidth / mHeight); | ||
834 | gCamera->setView(gCamera->getDefaultFOV() / mCameraZoom); | ||
835 | gCamera->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mWidth, mHeight, FALSE); | ||
836 | |||
837 | gPipeline.enableLightsAvatar(0.0); | ||
838 | |||
839 | |||
840 | glPushMatrix(); | ||
841 | glScalef(0.5, 0.5, 0.5); | ||
842 | |||
843 | glBegin(GL_TRIANGLES); | ||
844 | glColor3f(0.8f, 0.8f, 0.8f); | ||
845 | |||
846 | const LLVolumeFace &vf = mVolume->getVolumeFace(0); | ||
847 | S32 num_indices = (S32)vf.mIndices.size(); | ||
848 | for (U32 i = 0; (S32)i < num_indices; i++) | ||
849 | { | ||
850 | LLVector3 normal = vf.mVertices[vf.mIndices[i]].mNormal; | ||
851 | normal.normVec(); | ||
852 | glNormal3f(normal.mV[VX], normal.mV[VY], normal.mV[VZ]); | ||
853 | |||
854 | LLVector3 position = vf.mVertices[vf.mIndices[i]].mPosition; | ||
855 | glVertex3f(position.mV[VX], position.mV[VY], position.mV[VZ]); | ||
856 | } | ||
857 | |||
858 | glEnd(); | ||
859 | |||
860 | glPopMatrix(); | ||
861 | |||
862 | return TRUE; | ||
863 | } | ||
864 | |||
865 | //----------------------------------------------------------------------------- | ||
866 | // refresh() | ||
867 | //----------------------------------------------------------------------------- | ||
868 | void LLImagePreviewSculpted::refresh() | ||
869 | { | ||
870 | mNeedsUpdate = TRUE; | ||
871 | } | ||
872 | |||
873 | //----------------------------------------------------------------------------- | ||
874 | // rotate() | ||
875 | //----------------------------------------------------------------------------- | ||
876 | void LLImagePreviewSculpted::rotate(F32 yaw_radians, F32 pitch_radians) | ||
877 | { | ||
878 | mCameraYaw = mCameraYaw + yaw_radians; | ||
879 | |||
880 | mCameraPitch = llclamp(mCameraPitch + pitch_radians, F_PI_BY_TWO * -0.8f, F_PI_BY_TWO * 0.8f); | ||
881 | } | ||
882 | |||
883 | //----------------------------------------------------------------------------- | ||
884 | // zoom() | ||
885 | //----------------------------------------------------------------------------- | ||
886 | void LLImagePreviewSculpted::zoom(F32 zoom_amt) | ||
887 | { | ||
888 | mCameraZoom = llclamp(mCameraZoom + zoom_amt, 1.f, 10.f); | ||
889 | } | ||
890 | |||
891 | void LLImagePreviewSculpted::pan(F32 right, F32 up) | ||
892 | { | ||
893 | mCameraOffset.mV[VY] = llclamp(mCameraOffset.mV[VY] + right * mCameraDistance / mCameraZoom, -1.f, 1.f); | ||
894 | mCameraOffset.mV[VZ] = llclamp(mCameraOffset.mV[VZ] + up * mCameraDistance / mCameraZoom, -1.f, 1.f); | ||
895 | } | ||