Newer
Older
/**
* @file llpanelface.cpp
* @brief Panel in the tools floater for editing face textures, colors, etc.
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* 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.
* 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.
* 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
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
*/
#include "llviewerprecompiledheaders.h"
// file include
#include "llpanelface.h"
// library includes
#include "llcalc.h"
#include "llerror.h"
#include "llfocusmgr.h"
#include "llrect.h"
#include "llstring.h"
#include "llfontgl.h"
// project includes
Paul ProductEngine
committed
#include "llagentdata.h"
#include "llbutton.h"
#include "llcheckboxctrl.h"
#include "llcolorswatch.h"
#include "llcombobox.h"
#include "lldrawpoolbump.h"
Thickbrick Sleaford
committed
#include "llface.h"
#include "llinventoryfunctions.h"
#include "llinventorymodel.h" // gInventory
andreykproductengine
committed
#include "llinventorymodelbackgroundfetch.h"
#include "llmaterialmgr.h"
Monroe Williams
committed
#include "llmediaentry.h"
Paul ProductEngine
committed
#include "llnotificationsutil.h"
#include "llpanelobject.h" // LLPanelObject::canCopyTexture
Mnikolenko ProductEngine
committed
#include "llradiogroup.h"
#include "llresmgr.h"
#include "llselectmgr.h"
#include "llspinctrl.h"
#include "lltextbox.h"
#include "lltexturectrl.h"
#include "lltextureentry.h"
#include "lltooldraganddrop.h"
#include "lltrans.h"
#include "llviewerregion.h"
Monroe Williams
committed
#include "llvovolume.h"
#include "lluictrlfactory.h"
#include "llviewertexturelist.h"// Update sel manager as to which channel we're editing so it can reflect the correct overlay UI
//
// Constant definitions for comboboxes
// Must match the commbobox definitions in panel_tools_texture.xml
//
const S32 MATMEDIA_MATERIAL = 0; // Material
const S32 MATMEDIA_MEDIA = 1; // Media
const S32 MATTYPE_DIFFUSE = 0; // Diffuse material texture
const S32 MATTYPE_NORMAL = 1; // Normal map
const S32 MATTYPE_SPECULAR = 2; // Specular map
const S32 ALPHAMODE_MASK = 2; // Alpha masking mode
const S32 BUMPY_TEXTURE = 18; // use supplied normal map
const S32 SHINY_TEXTURE = 4; // use supplied specular map
ruslantproductengine
committed
BOOST_STATIC_ASSERT(MATTYPE_DIFFUSE == LLRender::DIFFUSE_MAP && MATTYPE_NORMAL == LLRender::NORMAL_MAP && MATTYPE_SPECULAR == LLRender::SPECULAR_MAP);
//
// "Use texture" label for normal/specular type comboboxes
// Filled in at initialization from translated strings
//
std::string USE_TEXTURE;
LLRender::eTexIndex LLPanelFace::getTextureChannelToEdit()
{
LLComboBox* combobox_matmedia = getChild<LLComboBox>("combobox matmedia");
Mnikolenko ProductEngine
committed
LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type");
LLRender::eTexIndex channel_to_edit = (combobox_matmedia && combobox_matmedia->getCurrentIndex() == MATMEDIA_MATERIAL) ?
Mnikolenko ProductEngine
committed
(radio_mat_type ? (LLRender::eTexIndex)radio_mat_type->getSelectedIndex() : LLRender::DIFFUSE_MAP) : LLRender::DIFFUSE_MAP;
channel_to_edit = (channel_to_edit == LLRender::NORMAL_MAP) ? (getCurrentNormalMap().isNull() ? LLRender::DIFFUSE_MAP : channel_to_edit) : channel_to_edit;
channel_to_edit = (channel_to_edit == LLRender::SPECULAR_MAP) ? (getCurrentSpecularMap().isNull() ? LLRender::DIFFUSE_MAP : channel_to_edit) : channel_to_edit;
return channel_to_edit;
}
Graham Madarasz
committed
// Things the UI provides...
//
LLUUID LLPanelFace::getCurrentNormalMap() { return getChild<LLTextureCtrl>("bumpytexture control")->getImageAssetID(); }
LLUUID LLPanelFace::getCurrentSpecularMap() { return getChild<LLTextureCtrl>("shinytexture control")->getImageAssetID(); }
U32 LLPanelFace::getCurrentShininess() { return getChild<LLComboBox>("combobox shininess")->getCurrentIndex(); }
U32 LLPanelFace::getCurrentBumpiness() { return getChild<LLComboBox>("combobox bumpiness")->getCurrentIndex(); }
U8 LLPanelFace::getCurrentDiffuseAlphaMode() { return (U8)getChild<LLComboBox>("combobox alphamode")->getCurrentIndex(); }
U8 LLPanelFace::getCurrentAlphaMaskCutoff() { return (U8)getChild<LLUICtrl>("maskcutoff")->getValue().asInteger(); }
U8 LLPanelFace::getCurrentEnvIntensity() { return (U8)getChild<LLUICtrl>("environment")->getValue().asInteger(); }
U8 LLPanelFace::getCurrentGlossiness() { return (U8)getChild<LLUICtrl>("glossiness")->getValue().asInteger(); }
F32 LLPanelFace::getCurrentBumpyRot() { return getChild<LLUICtrl>("bumpyRot")->getValue().asReal(); }
F32 LLPanelFace::getCurrentBumpyScaleU() { return getChild<LLUICtrl>("bumpyScaleU")->getValue().asReal(); }
F32 LLPanelFace::getCurrentBumpyScaleV() { return getChild<LLUICtrl>("bumpyScaleV")->getValue().asReal(); }
F32 LLPanelFace::getCurrentBumpyOffsetU() { return getChild<LLUICtrl>("bumpyOffsetU")->getValue().asReal(); }
F32 LLPanelFace::getCurrentBumpyOffsetV() { return getChild<LLUICtrl>("bumpyOffsetV")->getValue().asReal(); }
F32 LLPanelFace::getCurrentShinyRot() { return getChild<LLUICtrl>("shinyRot")->getValue().asReal(); }
F32 LLPanelFace::getCurrentShinyScaleU() { return getChild<LLUICtrl>("shinyScaleU")->getValue().asReal(); }
F32 LLPanelFace::getCurrentShinyScaleV() { return getChild<LLUICtrl>("shinyScaleV")->getValue().asReal(); }
F32 LLPanelFace::getCurrentShinyOffsetU() { return getChild<LLUICtrl>("shinyOffsetU")->getValue().asReal(); }
F32 LLPanelFace::getCurrentShinyOffsetV() { return getChild<LLUICtrl>("shinyOffsetV")->getValue().asReal(); }
//
// Methods
//
BOOL LLPanelFace::postBuild()
{
Monroe Williams
committed
childSetCommitCallback("combobox shininess",&LLPanelFace::onCommitShiny,this);
childSetCommitCallback("combobox bumpiness",&LLPanelFace::onCommitBump,this);
childSetCommitCallback("combobox alphamode",&LLPanelFace::onCommitAlphaMode,this);
childSetCommitCallback("TexScaleU",&LLPanelFace::onCommitTextureScaleX, this);
childSetCommitCallback("TexScaleV",&LLPanelFace::onCommitTextureScaleY, this);
childSetCommitCallback("TexRot",&LLPanelFace::onCommitTextureRot, this);
childSetCommitCallback("rptctrl",&LLPanelFace::onCommitRepeatsPerMeter, this);
Thickbrick Sleaford
committed
childSetCommitCallback("checkbox planar align",&LLPanelFace::onCommitPlanarAlign, this);
childSetCommitCallback("TexOffsetU",LLPanelFace::onCommitTextureOffsetX, this);
childSetCommitCallback("TexOffsetV",LLPanelFace::onCommitTextureOffsetY, this);
Graham Madarasz
committed
childSetCommitCallback("bumpyScaleU",&LLPanelFace::onCommitMaterialBumpyScaleX, this);
childSetCommitCallback("bumpyScaleV",&LLPanelFace::onCommitMaterialBumpyScaleY, this);
childSetCommitCallback("bumpyRot",&LLPanelFace::onCommitMaterialBumpyRot, this);
childSetCommitCallback("bumpyOffsetU",&LLPanelFace::onCommitMaterialBumpyOffsetX, this);
childSetCommitCallback("bumpyOffsetV",&LLPanelFace::onCommitMaterialBumpyOffsetY, this);
childSetCommitCallback("shinyScaleU",&LLPanelFace::onCommitMaterialShinyScaleX, this);
childSetCommitCallback("shinyScaleV",&LLPanelFace::onCommitMaterialShinyScaleY, this);
childSetCommitCallback("shinyRot",&LLPanelFace::onCommitMaterialShinyRot, this);
childSetCommitCallback("shinyOffsetU",&LLPanelFace::onCommitMaterialShinyOffsetX, this);
childSetCommitCallback("shinyOffsetV",&LLPanelFace::onCommitMaterialShinyOffsetY, this);
childSetCommitCallback("glossiness",&LLPanelFace::onCommitMaterialGloss, this);
childSetCommitCallback("environment",&LLPanelFace::onCommitMaterialEnv, this);
childSetCommitCallback("maskcutoff",&LLPanelFace::onCommitMaterialMaskCutoff, this);
Monroe Williams
committed
childSetAction("button align",&LLPanelFace::onClickAutoFix,this);
ruslantproductengine
committed
childSetAction("button align textures", &LLPanelFace::onAlignTexture, this);
Monroe Williams
committed
LLTextureCtrl* mShinyTextureCtrl;
LLTextureCtrl* mBumpyTextureCtrl;
LLColorSwatchCtrl* mShinyColorSwatch;
LLCheckBoxCtrl *mCheckFullbright;
LLTextBox* mLabelColorTransp;
LLSpinCtrl* mCtrlColorTransp; // transparency = 1 - alpha
LLSpinCtrl* mCtrlGlow;
Steven Bennetts
committed
mTextureCtrl = getChild<LLTextureCtrl>("texture control");
if(mTextureCtrl)
{
mTextureCtrl->setDefaultImageAssetID(LLUUID( gSavedSettings.getString( "DefaultObjectTexture" )));
mTextureCtrl->setCommitCallback( boost::bind(&LLPanelFace::onCommitTexture, this, _2) );
mTextureCtrl->setOnCancelCallback( boost::bind(&LLPanelFace::onCancelTexture, this, _2) );
mTextureCtrl->setOnSelectCallback( boost::bind(&LLPanelFace::onSelectTexture, this, _2) );
Monroe Williams
committed
mTextureCtrl->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2));
Paul ProductEngine
committed
mTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1));
Graham Madarasz
committed
mTextureCtrl->setOnCloseCallback( boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2) );
mTextureCtrl->setFollowsTop();
mTextureCtrl->setFollowsLeft();
Paul ProductEngine
committed
mTextureCtrl->setImmediateFilterPermMask(PERM_NONE);
mTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER);
mShinyTextureCtrl = getChild<LLTextureCtrl>("shinytexture control");
if(mShinyTextureCtrl)
{
Graham Madarasz
committed
mShinyTextureCtrl->setDefaultImageAssetID(LLUUID( gSavedSettings.getString( "DefaultObjectSpecularTexture" )));
mShinyTextureCtrl->setCommitCallback( boost::bind(&LLPanelFace::onCommitSpecularTexture, this, _2) );
mShinyTextureCtrl->setOnCancelCallback( boost::bind(&LLPanelFace::onCancelSpecularTexture, this, _2) );
mShinyTextureCtrl->setOnSelectCallback( boost::bind(&LLPanelFace::onSelectSpecularTexture, this, _2) );
Graham Madarasz
committed
mShinyTextureCtrl->setOnCloseCallback( boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2) );
mShinyTextureCtrl->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2));
mShinyTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1));
mShinyTextureCtrl->setFollowsTop();
mShinyTextureCtrl->setFollowsLeft();
mShinyTextureCtrl->setImmediateFilterPermMask(PERM_NONE);
mShinyTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER);
}
mBumpyTextureCtrl = getChild<LLTextureCtrl>("bumpytexture control");
if(mBumpyTextureCtrl)
{
Graham Madarasz
committed
mBumpyTextureCtrl->setDefaultImageAssetID(LLUUID( gSavedSettings.getString( "DefaultObjectNormalTexture" )));
mBumpyTextureCtrl->setBlankImageAssetID(LLUUID( gSavedSettings.getString( "DefaultBlankNormalTexture" )));
mBumpyTextureCtrl->setCommitCallback( boost::bind(&LLPanelFace::onCommitNormalTexture, this, _2) );
mBumpyTextureCtrl->setOnCancelCallback( boost::bind(&LLPanelFace::onCancelNormalTexture, this, _2) );
mBumpyTextureCtrl->setOnSelectCallback( boost::bind(&LLPanelFace::onSelectNormalTexture, this, _2) );
Graham Madarasz
committed
mBumpyTextureCtrl->setOnCloseCallback( boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2) );
mBumpyTextureCtrl->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2));
mBumpyTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1));
mBumpyTextureCtrl->setFollowsTop();
mBumpyTextureCtrl->setFollowsLeft();
mBumpyTextureCtrl->setImmediateFilterPermMask(PERM_NONE);
mBumpyTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER);
}
Steven Bennetts
committed
mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
mColorSwatch->setCommitCallback(boost::bind(&LLPanelFace::onCommitColor, this, _2));
mColorSwatch->setOnCancelCallback(boost::bind(&LLPanelFace::onCancelColor, this, _2));
mColorSwatch->setOnSelectCallback(boost::bind(&LLPanelFace::onSelectColor, this, _2));
mColorSwatch->setFollowsTop();
mColorSwatch->setFollowsLeft();
mColorSwatch->setCanApplyImmediately(TRUE);
}
mShinyColorSwatch = getChild<LLColorSwatchCtrl>("shinycolorswatch");
if(mShinyColorSwatch)
{
mShinyColorSwatch->setCommitCallback(boost::bind(&LLPanelFace::onCommitShinyColor, this, _2));
andreykproductengine
committed
mShinyColorSwatch->setOnCancelCallback(boost::bind(&LLPanelFace::onCancelShinyColor, this, _2));
mShinyColorSwatch->setOnSelectCallback(boost::bind(&LLPanelFace::onSelectShinyColor, this, _2));
mShinyColorSwatch->setFollowsTop();
mShinyColorSwatch->setFollowsLeft();
mShinyColorSwatch->setCanApplyImmediately(TRUE);
}
mLabelColorTransp = getChild<LLTextBox>("color trans");
if(mLabelColorTransp)
{
mLabelColorTransp->setFollowsTop();
mLabelColorTransp->setFollowsLeft();
}
mCtrlColorTransp = getChild<LLSpinCtrl>("ColorTrans");
mCtrlColorTransp->setCommitCallback(boost::bind(&LLPanelFace::onCommitAlpha, this, _2));
mCtrlColorTransp->setPrecision(0);
mCtrlColorTransp->setFollowsTop();
mCtrlColorTransp->setFollowsLeft();
}
mCheckFullbright = getChild<LLCheckBoxCtrl>("checkbox fullbright");
mCheckFullbright->setCommitCallback(LLPanelFace::onCommitFullbright, this);
mComboTexGen = getChild<LLComboBox>("combobox texgen");
mComboTexGen->setCommitCallback(LLPanelFace::onCommitTexGen, this);
mComboTexGen->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP);
}
mComboMatMedia = getChild<LLComboBox>("combobox matmedia");
if(mComboMatMedia)
{
mComboMatMedia->setCommitCallback(LLPanelFace::onCommitMaterialsMedia,this);
mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL);
}
Mnikolenko ProductEngine
committed
LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type");
if(radio_mat_type)
{
radio_mat_type->setCommitCallback(LLPanelFace::onCommitMaterialType, this);
radio_mat_type->selectNthItem(MATTYPE_DIFFUSE);
}
mCtrlGlow = getChild<LLSpinCtrl>("glow");
if(mCtrlGlow)
{
mCtrlGlow->setCommitCallback(LLPanelFace::onCommitGlow, this);
}
mBtnCopyFaces = getChild<LLButton>("copy_face_btn");
if(mBtnCopyFaces)
{
mBtnCopyFaces->setCommitCallback(boost::bind(&LLPanelFace::onCopyFaces, this));
}
mBtnPasteFaces = getChild<LLButton>("paste_face_btn");
if (mBtnPasteFaces)
{
mBtnPasteFaces->setCommitCallback(boost::bind(&LLPanelFace::onPasteFaces, this));
}
mBtnPasteMenu = getChild<LLMenuButton>("paste_face_gear_btn");
LLPanelFace::LLPanelFace()
: LLPanel(),
mIsAlpha(false),
mPasteColor(TRUE),
mPasteAlpha(TRUE),
mPasteGlow(TRUE),
mPasteDiffuse(TRUE),
mPasteNormal(TRUE),
mPasteSpecular(TRUE),
mPasteMapping(TRUE),
mPasteMedia(TRUE)
USE_TEXTURE = LLTrans::getString("use_texture");
mEnableCallbackRegistrar.add("BuildFace.PasteCheckItem", boost::bind(&LLPanelFace::pasteCheckMenuItem, this, _2));
mCommitCallbackRegistrar.add("BuildFace.PasteDoToSelected", boost::bind(&LLPanelFace::pasteDoMenuItem, this, _2));
mEnableCallbackRegistrar.add("BuildFace.PasteEnable", boost::bind(&LLPanelFace::pasteEnabletMenuItem, this, _2));
}
LLPanelFace::~LLPanelFace()
{
// Children all cleaned up by default view destructor.
}
void LLPanelFace::sendTexture()
{
Steven Bennetts
committed
LLTextureCtrl* mTextureCtrl = getChild<LLTextureCtrl>("texture control");
if(!mTextureCtrl) return;
if( !mTextureCtrl->getTentative() )
{
// we grab the item id first, because we want to do a
// permissions check in the selection manager. ARGH!
LLUUID id = mTextureCtrl->getImageItemID();
if(id.isNull())
{
id = mTextureCtrl->getImageAssetID();
}
LLSelectMgr::getInstance()->selectionSetImage(id);
Graham Madarasz
committed
void LLPanelFace::sendBump(U32 bumpiness)
Graham Madarasz
committed
{
Graham Madarasz
committed
LLTextureCtrl* bumpytexture_ctrl = getChild<LLTextureCtrl>("bumpytexture control");
if (bumpiness < BUMPY_TEXTURE)
Graham Madarasz
committed
LL_DEBUGS("Materials") << "clearing bumptexture control" << LL_ENDL;
Graham Madarasz
committed
bumpytexture_ctrl->clear();
Graham Linden
committed
bumpytexture_ctrl->setImageAssetID(LLUUID());
Graham Madarasz
committed
Graham Madarasz
committed
updateBumpyControls(bumpiness == BUMPY_TEXTURE, true);
LLUUID current_normal_map = bumpytexture_ctrl->getImageAssetID();
Graham Linden
committed
U8 bump = (U8) bumpiness & TEM_BUMP_MASK;
// Clear legacy bump to None when using an actual normal map
//
if (!current_normal_map.isNull())
bump = 0;
// Set the normal map or reset it to null as appropriate
//
Graham Madarasz
committed
LLSelectedTEMaterial::setNormalID(this, current_normal_map);
Graham Linden
committed
LLSelectMgr::getInstance()->selectionSetBumpmap( bump );
LLComboBox* mComboTexGen = getChild<LLComboBox>("combobox texgen");
if(!mComboTexGen)return;
U8 tex_gen = (U8) mComboTexGen->getCurrentIndex() << TEM_TEX_GEN_SHIFT;
LLSelectMgr::getInstance()->selectionSetTexGen( tex_gen );
Graham Madarasz
committed
void LLPanelFace::sendShiny(U32 shininess)
LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("shinytexture control");
if (shininess < SHINY_TEXTURE)
Graham Madarasz
committed
texture_ctrl->clear();
Graham Linden
committed
texture_ctrl->setImageAssetID(LLUUID());
Graham Linden
committed
LLUUID specmap = getCurrentSpecularMap();
U8 shiny = (U8) shininess & TEM_SHINY_MASK;
if (!specmap.isNull())
shiny = 0;
LLSelectedTEMaterial::setSpecularID(this, specmap);
LLSelectMgr::getInstance()->selectionSetShiny( shiny );
updateShinyControls(!specmap.isNull(), true);
LLCheckBoxCtrl* mCheckFullbright = getChild<LLCheckBoxCtrl>("checkbox fullbright");
if(!mCheckFullbright)return;
U8 fullbright = mCheckFullbright->get() ? TEM_FULLBRIGHT_MASK : 0;
LLSelectMgr::getInstance()->selectionSetFullbright( fullbright );
LLColorSwatchCtrl* mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
if(!mColorSwatch)return;
LLColor4 color = mColorSwatch->get();
LLSelectMgr::getInstance()->selectionSetColorOnly( color );
LLSpinCtrl* mCtrlColorTransp = getChild<LLSpinCtrl>("ColorTrans");
if(!mCtrlColorTransp)return;
F32 alpha = (100.f - mCtrlColorTransp->get()) / 100.f;
LLSelectMgr::getInstance()->selectionSetAlphaOnly( alpha );
void LLPanelFace::sendGlow()
{
LLSpinCtrl* mCtrlGlow = getChild<LLSpinCtrl>("glow");
llassert(mCtrlGlow);
if (mCtrlGlow)
{
F32 glow = mCtrlGlow->get();
LLSelectMgr::getInstance()->selectionSetGlow( glow );
}
}
struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor
LLPanelFaceSetTEFunctor(LLPanelFace* panel) : mPanel(panel) {}
virtual bool apply(LLViewerObject* object, S32 te)
ruslantproductengine
committed
LLRadioGroup * radio_mat_type = mPanel->getChild<LLRadioGroup>("radio_material_type");
std::string prefix;
switch (radio_mat_type->getSelectedIndex())
{
case MATTYPE_DIFFUSE:
prefix = "Tex";
break;
case MATTYPE_NORMAL:
prefix = "bumpy";
break;
case MATTYPE_SPECULAR:
prefix = "shiny";
break;
}
LLSpinCtrl * ctrlTexScaleS = mPanel->getChild<LLSpinCtrl>(prefix + "ScaleU");
LLSpinCtrl * ctrlTexScaleT = mPanel->getChild<LLSpinCtrl>(prefix + "ScaleV");
LLSpinCtrl * ctrlTexOffsetS = mPanel->getChild<LLSpinCtrl>(prefix + "OffsetU");
LLSpinCtrl * ctrlTexOffsetT = mPanel->getChild<LLSpinCtrl>(prefix + "OffsetV");
LLSpinCtrl * ctrlTexRotation = mPanel->getChild<LLSpinCtrl>(prefix + "Rot");
ruslantproductengine
committed
LLComboBox* comboTexGen = mPanel->getChild<LLComboBox>("combobox texgen");
LLCheckBoxCtrl* cb_planar_align = mPanel->getChild<LLCheckBoxCtrl>("checkbox planar align");
bool align_planar = (cb_planar_align && cb_planar_align->get());
if (ctrlTexScaleS)
valid = !ctrlTexScaleS->getTentative(); // || !checkFlipScaleS->getTentative();
ruslantproductengine
committed
if (valid || align_planar)
value = ctrlTexScaleS->get();
{
value *= 0.5f;
}
object->setTEScaleS( te, value );
ruslantproductengine
committed
if (align_planar)
{
ruslantproductengine
committed
LLPanelFace::LLSelectedTEMaterial::setNormalRepeatX(mPanel, value, te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatX(mPanel, value, te, object->getID());
ruslantproductengine
committed
}
if (ctrlTexScaleT)
valid = !ctrlTexScaleT->getTentative(); // || !checkFlipScaleT->getTentative();
ruslantproductengine
committed
if (valid || align_planar)
value = ctrlTexScaleT->get();
//if( checkFlipScaleT->get() )
//{
// value = -value;
//}
{
value *= 0.5f;
}
object->setTEScaleT( te, value );
ruslantproductengine
committed
if (align_planar)
{
ruslantproductengine
committed
LLPanelFace::LLSelectedTEMaterial::setNormalRepeatY(mPanel, value, te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatY(mPanel, value, te, object->getID());
ruslantproductengine
committed
}
if (ctrlTexOffsetS)
valid = !ctrlTexOffsetS->getTentative();
ruslantproductengine
committed
if (valid || align_planar)
value = ctrlTexOffsetS->get();
ruslantproductengine
committed
if (align_planar)
{
ruslantproductengine
committed
LLPanelFace::LLSelectedTEMaterial::setNormalOffsetX(mPanel, value, te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetX(mPanel, value, te, object->getID());
ruslantproductengine
committed
}
if (ctrlTexOffsetT)
valid = !ctrlTexOffsetT->getTentative();
ruslantproductengine
committed
if (valid || align_planar)
value = ctrlTexOffsetT->get();
ruslantproductengine
committed
if (align_planar)
{
ruslantproductengine
committed
LLPanelFace::LLSelectedTEMaterial::setNormalOffsetY(mPanel, value, te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetY(mPanel, value, te, object->getID());
ruslantproductengine
committed
}
if (ctrlTexRotation)
valid = !ctrlTexRotation->getTentative();
ruslantproductengine
committed
if (valid || align_planar)
value = ctrlTexRotation->get() * DEG_TO_RAD;
ruslantproductengine
committed
if (align_planar)
{
ruslantproductengine
committed
LLPanelFace::LLSelectedTEMaterial::setNormalRotation(mPanel, value, te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setSpecularRotation(mPanel, value, te, object->getID());
ruslantproductengine
committed
}
return true;
private:
LLPanelFace* mPanel;
};
Thickbrick Sleaford
committed
// Functor that aligns a face to mCenterFace
struct LLPanelFaceSetAlignedTEFunctor : public LLSelectedTEFunctor
{
LLPanelFaceSetAlignedTEFunctor(LLPanelFace* panel, LLFace* center_face) :
mPanel(panel),
mCenterFace(center_face) {}
virtual bool apply(LLViewerObject* object, S32 te)
{
LLFace* facep = object->mDrawable->getFace(te);
if (!facep)
{
return true;
}
David Parks
committed
if (facep->getViewerObject()->getVolume()->getNumVolumeFaces() <= te)
{
return true;
}
Thickbrick Sleaford
committed
bool set_aligned = true;
if (facep == mCenterFace)
{
set_aligned = false;
}
if (set_aligned)
{
LLVector2 uv_offset, uv_scale;
F32 uv_rot;
set_aligned = facep->calcAlignedPlanarTE(mCenterFace, &uv_offset, &uv_scale, &uv_rot);
if (set_aligned)
{
object->setTEOffset(te, uv_offset.mV[VX], uv_offset.mV[VY]);
ruslantproductengine
committed
object->setTEScale(te, uv_scale.mV[VX], uv_scale.mV[VY]);
Thickbrick Sleaford
committed
object->setTERotation(te, uv_rot);
ruslantproductengine
committed
LLPanelFace::LLSelectedTEMaterial::setNormalRotation(mPanel, uv_rot, te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setSpecularRotation(mPanel, uv_rot, te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setNormalOffsetX(mPanel, uv_offset.mV[VX], te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setNormalOffsetY(mPanel, uv_offset.mV[VY], te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setNormalRepeatX(mPanel, uv_scale.mV[VX], te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setNormalRepeatY(mPanel, uv_scale.mV[VY], te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetX(mPanel, uv_offset.mV[VX], te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetY(mPanel, uv_offset.mV[VY], te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatX(mPanel, uv_scale.mV[VX], te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatY(mPanel, uv_scale.mV[VY], te, object->getID());
Thickbrick Sleaford
committed
}
}
if (!set_aligned)
{
LLPanelFaceSetTEFunctor setfunc(mPanel);
setfunc.apply(object, te);
}
return true;
}
private:
LLPanelFace* mPanel;
LLFace* mCenterFace;
};
ruslantproductengine
committed
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
struct LLPanelFaceSetAlignedConcreteTEFunctor : public LLSelectedTEFunctor
{
LLPanelFaceSetAlignedConcreteTEFunctor(LLPanelFace* panel, LLFace* center_face, LLRender::eTexIndex map) :
mPanel(panel),
mChefFace(center_face),
mMap(map)
{}
virtual bool apply(LLViewerObject* object, S32 te)
{
LLFace* facep = object->mDrawable->getFace(te);
if (!facep)
{
return true;
}
if (facep->getViewerObject()->getVolume()->getNumVolumeFaces() <= te)
{
return true;
}
if (mChefFace != facep)
{
LLVector2 uv_offset, uv_scale;
F32 uv_rot;
if (facep->calcAlignedPlanarTE(mChefFace, &uv_offset, &uv_scale, &uv_rot, mMap))
{
switch (mMap)
{
case LLRender::DIFFUSE_MAP:
object->setTEOffset(te, uv_offset.mV[VX], uv_offset.mV[VY]);
object->setTEScale(te, uv_scale.mV[VX], uv_scale.mV[VY]);
object->setTERotation(te, uv_rot);
break;
case LLRender::NORMAL_MAP:
LLPanelFace::LLSelectedTEMaterial::setNormalRotation(mPanel, uv_rot, te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setNormalOffsetX(mPanel, uv_offset.mV[VX], te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setNormalOffsetY(mPanel, uv_offset.mV[VY], te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setNormalRepeatX(mPanel, uv_scale.mV[VX], te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setNormalRepeatY(mPanel, uv_scale.mV[VY], te, object->getID());
break;
case LLRender::SPECULAR_MAP:
LLPanelFace::LLSelectedTEMaterial::setSpecularRotation(mPanel, uv_rot, te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetX(mPanel, uv_offset.mV[VX], te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setSpecularOffsetY(mPanel, uv_offset.mV[VY], te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatX(mPanel, uv_scale.mV[VX], te, object->getID());
LLPanelFace::LLSelectedTEMaterial::setSpecularRepeatY(mPanel, uv_scale.mV[VY], te, object->getID());
break;
default: /*make compiler happy*/
break;
}
}
}
return true;
}
private:
LLPanelFace* mPanel;
LLFace* mChefFace;
LLRender::eTexIndex mMap;
};
Thickbrick Sleaford
committed
// Functor that tests if a face is aligned to mCenterFace
struct LLPanelFaceGetIsAlignedTEFunctor : public LLSelectedTEFunctor
{
LLPanelFaceGetIsAlignedTEFunctor(LLFace* center_face) :
mCenterFace(center_face) {}
virtual bool apply(LLViewerObject* object, S32 te)
{
LLFace* facep = object->mDrawable->getFace(te);
if (!facep)
{
return false;
}
David Parks
committed
if (facep->getViewerObject()->getVolume()->getNumVolumeFaces() <= te)
{ //volume face does not exist, can't be aligned
return false;
}
Thickbrick Sleaford
committed
if (facep == mCenterFace)
{
return true;
}
LLVector2 aligned_st_offset, aligned_st_scale;
F32 aligned_st_rot;
if ( facep->calcAlignedPlanarTE(mCenterFace, &aligned_st_offset, &aligned_st_scale, &aligned_st_rot) )
{
const LLTextureEntry* tep = facep->getTextureEntry();
LLVector2 st_offset, st_scale;
tep->getOffset(&st_offset.mV[VX], &st_offset.mV[VY]);
tep->getScale(&st_scale.mV[VX], &st_scale.mV[VY]);
F32 st_rot = tep->getRotation();
bool eq_offset_x = is_approx_equal_fraction(st_offset.mV[VX], aligned_st_offset.mV[VX], 12);
bool eq_offset_y = is_approx_equal_fraction(st_offset.mV[VY], aligned_st_offset.mV[VY], 12);
bool eq_scale_x = is_approx_equal_fraction(st_scale.mV[VX], aligned_st_scale.mV[VX], 12);
bool eq_scale_y = is_approx_equal_fraction(st_scale.mV[VY], aligned_st_scale.mV[VY], 12);
bool eq_rot = is_approx_equal_fraction(st_rot, aligned_st_rot, 6);
Thickbrick Sleaford
committed
// needs a fuzzy comparison, because of fp errors
if (eq_offset_x &&
eq_offset_y &&
eq_scale_x &&
eq_scale_y &&
eq_rot)
Thickbrick Sleaford
committed
{
return true;
}
}
return false;
}
private:
LLFace* mCenterFace;
};
struct LLPanelFaceSendFunctor : public LLSelectedObjectFunctor
{
virtual bool apply(LLViewerObject* object)
return true;
};
void LLPanelFace::sendTextureInfo()
{
Thickbrick Sleaford
committed
if ((bool)childGetValue("checkbox planar align").asBoolean())
{
Graham Madarasz
committed
LLFace* last_face = NULL;
bool identical_face =false;
LLSelectedTE::getFace(last_face, identical_face);
Thickbrick Sleaford
committed
LLPanelFaceSetAlignedTEFunctor setfunc(this, last_face);
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc);
}
else
{
LLPanelFaceSetTEFunctor setfunc(this);
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc);
}
LLPanelFaceSendFunctor sendfunc;
LLSelectMgr::getInstance()->getSelection()->applyToObjects(&sendfunc);
ruslantproductengine
committed
void LLPanelFace::alignTestureLayer()
{
LLFace* last_face = NULL;
bool identical_face = false;
LLSelectedTE::getFace(last_face, identical_face);
LLRadioGroup * radio_mat_type = getChild<LLRadioGroup>("radio_material_type");
LLPanelFaceSetAlignedConcreteTEFunctor setfunc(this, last_face, static_cast<LLRender::eTexIndex>(radio_mat_type->getSelectedIndex()));
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc);
}
{
updateUI();
}
andreykproductengine
committed
void LLPanelFace::updateUI(bool force_set_values /*false*/)
{ //set state of UI to match state of texture entry(ies) (calls setEnabled, setValue, etc, but NOT setVisible)
LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject();
&& objectp->getPCode() == LL_PCODE_VOLUME
&& objectp->permModify())
Todd Stinson
committed
BOOL editable = objectp->permModify() && !objectp->isPermanentEnforced();
// only turn on auto-adjust button if there is a media renderer and the media is loaded
getChildView("button align")->setEnabled(editable);
LLComboBox* combobox_matmedia = getChild<LLComboBox>("combobox matmedia");
if (combobox_matmedia)
{
if (combobox_matmedia->getCurrentIndex() < MATMEDIA_MATERIAL)
{
combobox_matmedia->selectNthItem(MATMEDIA_MATERIAL);
}
}
else
{
LL_WARNS() << "failed getChild for 'combobox matmedia'" << LL_ENDL;
}
getChildView("combobox matmedia")->setEnabled(editable);
Mnikolenko ProductEngine
committed
LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type");
if(radio_mat_type)
{
Mnikolenko ProductEngine
committed
if (radio_mat_type->getSelectedIndex() < MATTYPE_DIFFUSE)
{
radio_mat_type->selectNthItem(MATTYPE_DIFFUSE);
}
}
else
{
Mnikolenko ProductEngine
committed
LL_WARNS("Materials") << "failed getChild for 'radio_material_type'" << LL_ENDL;
}
Mnikolenko ProductEngine
committed
getChildView("radio_material_type")->setEnabled(editable);
getChildView("checkbox_sync_settings")->setEnabled(editable);
childSetValue("checkbox_sync_settings", gSavedSettings.getBOOL("SyncMaterialSettings"));
updateVisibility();
Graham Madarasz
committed
bool identical = true; // true because it is anded below
bool identical_diffuse = false;
bool identical_norm = false;
bool identical_spec = false;
LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("texture control");
LLTextureCtrl* shinytexture_ctrl = getChild<LLTextureCtrl>("shinytexture control");
LLTextureCtrl* bumpytexture_ctrl = getChild<LLTextureCtrl>("bumpytexture control");
David Parks
committed
LLUUID id;
LLUUID normmap_id;
LLUUID specmap_id;
// Color swatch
{
getChildView("color label")->setEnabled(editable);
}
LLColorSwatchCtrl* mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
Graham Madarasz
committed
LLColor4 color = LLColor4::white;
bool identical_color = false;
if(mColorSwatch)
andreykproductengine
committed
{
Graham Madarasz
committed
LLSelectedTE::getColor(color, identical_color);
andreykproductengine
committed
LLColor4 prev_color = mColorSwatch->get();
Graham Madarasz
committed
mColorSwatch->setOriginal(color);
andreykproductengine
committed
mColorSwatch->set(color, force_set_values || (prev_color != color) || !editable);
mColorSwatch->setValid(editable);
mColorSwatch->setEnabled( editable );
mColorSwatch->setCanApplyImmediately( editable );
}
// Color transparency
Graham Madarasz
committed
getChildView("color trans")->setEnabled(editable);
F32 transparency = (1.f - color.mV[VALPHA]) * 100.f;
Graham Madarasz
committed
getChild<LLUICtrl>("ColorTrans")->setValue(editable ? transparency : 0);
getChildView("ColorTrans")->setEnabled(editable);
Graham Madarasz
committed
// Specular map
Graham Madarasz
committed
LLSelectedTEMaterial::getSpecularID(specmap_id, identical_spec);
Graham Madarasz
committed
U8 shiny = 0;
Graham Madarasz
committed
bool identical_shiny = false;
Graham Madarasz
committed
// Shiny
Graham Madarasz
committed
LLSelectedTE::getShiny(shiny, identical_shiny);
identical = identical && identical_shiny;
Graham Madarasz
committed
Graham Madarasz
committed
shiny = specmap_id.isNull() ? shiny : SHINY_TEXTURE;
Graham Madarasz
committed
LLCtrlSelectionInterface* combobox_shininess = childGetSelectionInterface("combobox shininess");
if (combobox_shininess)
{
Graham Madarasz
committed
combobox_shininess->selectNthItem((S32)shiny);
}
Graham Madarasz
committed
Graham Madarasz
committed
getChildView("label shininess")->setEnabled(editable);
getChildView("combobox shininess")->setEnabled(editable);
Graham Madarasz
committed
Graham Madarasz
committed
getChildView("label glossiness")->setEnabled(editable);
getChildView("glossiness")->setEnabled(editable);
Graham Madarasz
committed
Graham Madarasz
committed
getChildView("label environment")->setEnabled(editable);
getChildView("environment")->setEnabled(editable);
getChildView("label shinycolor")->setEnabled(editable);
Rick Pasetto
committed
Graham Madarasz
committed
getChild<LLUICtrl>("combobox shininess")->setTentative(!identical_spec);
getChild<LLUICtrl>("glossiness")->setTentative(!identical_spec);
getChild<LLUICtrl>("environment")->setTentative(!identical_spec);
getChild<LLUICtrl>("shinycolorswatch")->setTentative(!identical_spec);
Rick Pasetto
committed
Graham Madarasz
committed
LLColorSwatchCtrl* mShinyColorSwatch = getChild<LLColorSwatchCtrl>("shinycolorswatch");
if(mShinyColorSwatch)
Rick Pasetto
committed
{
Graham Madarasz
committed
mShinyColorSwatch->setValid(editable);
mShinyColorSwatch->setEnabled( editable );
mShinyColorSwatch->setCanApplyImmediately( editable );
}
U8 bumpy = 0;
// Bumpy
Rick Pasetto
committed
{
Graham Madarasz
committed
bool identical_bumpy = false;
LLSelectedTE::getBumpmap(bumpy,identical_bumpy);
Graham Madarasz
committed
Graham Madarasz
committed
LLUUID norm_map_id = getCurrentNormalMap();
Graham Madarasz
committed
LLCtrlSelectionInterface* combobox_bumpiness = childGetSelectionInterface("combobox bumpiness");
Graham Linden
committed
bumpy = norm_map_id.isNull() ? bumpy : BUMPY_TEXTURE;
Graham Madarasz
committed
if (combobox_bumpiness)
Rick Pasetto
committed
{
Graham Linden
committed
combobox_bumpiness->selectNthItem((S32)bumpy);
Rick Pasetto
committed
}
Graham Madarasz
committed
else
Rick Pasetto
committed
{
LL_WARNS() << "failed childGetSelectionInterface for 'combobox bumpiness'" << LL_ENDL;
Rick Pasetto
committed
}
Graham Linden
committed
Graham Madarasz
committed
getChildView("combobox bumpiness")->setEnabled(editable);
Graham Madarasz
committed
getChild<LLUICtrl>("combobox bumpiness")->setTentative(!identical_bumpy);
Graham Madarasz
committed
getChildView("label bumpiness")->setEnabled(editable);
Rick Pasetto
committed
}
Graham Madarasz
committed
Graham Madarasz
committed
LLSelectedTE::getTexId(id,identical_diffuse);
Melinda Green
committed
David Parks
committed
// Normal map
Graham Madarasz
committed
LLSelectedTEMaterial::getNormalID(normmap_id, identical_norm);
Graham Madarasz
committed
mIsAlpha = FALSE;
Graham Madarasz
committed
LLGLenum image_format = GL_RGB;
Graham Madarasz
committed
bool identical_image_format = false;
LLSelectedTE::getImageFormat(image_format, identical_image_format);
Graham Madarasz (Graham Linden)
committed
Graham Madarasz
committed
mIsAlpha = FALSE;
switch (image_format)
{
case GL_RGBA:
case GL_ALPHA:
{
mIsAlpha = TRUE;
}