Exposed light projection textures in object edit panel.

This commit is contained in:
Shyotl
2011-06-04 15:09:37 -05:00
parent fef7ce9f76
commit 278cfbdb67
3 changed files with 183 additions and 11 deletions

View File

@@ -73,9 +73,11 @@
#include "llvovolume.h"
#include "llworld.h"
#include "pipeline.h"
#include "llviewershadermgr.h"
#include "lldrawpool.h"
#include "lluictrlfactory.h"
#include "lltexturectrl.h"
// "Features" Tab
@@ -111,12 +113,28 @@ BOOL LLPanelVolume::postBuild()
LightColorSwatch->setOnSelectCallback(onLightSelectColor);
childSetCommitCallback("colorswatch",onCommitLight,this);
}
LLTextureCtrl* LightTexPicker = getChild<LLTextureCtrl>("light texture control");
if (LightTexPicker)
{
LightTexPicker->setOnCancelCallback(onLightCancelTexture);
LightTexPicker->setOnSelectCallback(onLightSelectTexture);
childSetCommitCallback("light texture control", onCommitLight, this);
}
childSetCommitCallback("Light Intensity",onCommitLight,this);
childSetValidate("Light Intensity",precommitValidate);
childSetCommitCallback("Light Radius",onCommitLight,this);
childSetValidate("Light Radius",precommitValidate);
childSetCommitCallback("Light Falloff",onCommitLight,this);
childSetValidate("Light Falloff",precommitValidate);
childSetCommitCallback("Light FOV", onCommitLight, this);
childSetValidate("Light FOV", precommitValidate);
childSetCommitCallback("Light Focus", onCommitLight, this);
childSetValidate("Light Focus", precommitValidate);
childSetCommitCallback("Light Ambiance", onCommitLight, this);
childSetValidate("Light Ambiance", precommitValidate);
}
// Start with everyone disabled
@@ -221,14 +239,32 @@ void LLPanelVolume::getState( )
LightColorSwatch->setValid( TRUE );
LightColorSwatch->set(volobjp->getLightBaseColor());
}
childSetEnabled("label texture",true);
LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control");
if (LightTextureCtrl)
{
LightTextureCtrl->setEnabled(TRUE);
LightTextureCtrl->setValid(TRUE);
LightTextureCtrl->setImageAssetID(volobjp->getLightTextureID());
}
childSetEnabled("Light Intensity",true);
childSetEnabled("Light Radius",true);
childSetEnabled("Light Falloff",true);
childSetEnabled("Light FOV",true);
childSetEnabled("Light Focus",true);
childSetEnabled("Light Ambiance",true);
childSetValue("Light Intensity",volobjp->getLightIntensity());
childSetValue("Light Radius",volobjp->getLightRadius());
childSetValue("Light Falloff",volobjp->getLightFalloff());
LLVector3 params = volobjp->getSpotLightParams();
childSetValue("Light FOV",params.mV[0]);
childSetValue("Light Focus",params.mV[1]);
childSetValue("Light Ambiance",params.mV[2]);
mLightSavedColor = volobjp->getLightColor();
}
else
@@ -244,9 +280,20 @@ void LLPanelVolume::getState( )
LightColorSwatch->setEnabled( FALSE );
LightColorSwatch->setValid( FALSE );
}
childSetEnabled("label texture",false);
LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control");
if (LightTextureCtrl)
{
LightTextureCtrl->setEnabled(FALSE);
LightTextureCtrl->setValid(FALSE);
}
childSetEnabled("Light Intensity",false);
childSetEnabled("Light Radius",false);
childSetEnabled("Light Falloff",false);
childSetEnabled("Light FOV",false);
childSetEnabled("Light Focus",false);
childSetEnabled("Light Ambiance",false);
}
// Flexible properties
@@ -336,6 +383,14 @@ void LLPanelVolume::refresh()
{
mRootObject = NULL;
}
BOOL visible = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_DEFERRED) > 0 ? TRUE : FALSE;
childSetVisible("label texture", visible);
childSetVisible("Light FOV", visible);
childSetVisible("Light Focus", visible);
childSetVisible("Light Ambiance", visible);
childSetVisible("light texture control", visible);
}
@@ -355,13 +410,20 @@ void LLPanelVolume::clearCtrls()
childSetVisible("edit_object",false);
childSetEnabled("Light Checkbox Ctrl",false);
childSetEnabled("label color",false);
childSetEnabled("label color",false);
LLColorSwatchCtrl* LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
if(LightColorSwatch)
{
LightColorSwatch->setEnabled( FALSE );
LightColorSwatch->setValid( FALSE );
}
childSetEnabled("label texture",false);
LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control");
if(LightTextureCtrl)
{
LightTextureCtrl->setEnabled( FALSE );
LightTextureCtrl->setValid( FALSE );
}
childSetEnabled("Light Intensity",false);
childSetEnabled("Light Radius",false);
childSetEnabled("Light Falloff",false);
@@ -438,6 +500,16 @@ void LLPanelVolume::onLightCancelColor(LLUICtrl* ctrl, void* userdata)
onLightSelectColor(NULL, userdata);
}
void LLPanelVolume::onLightCancelTexture(LLUICtrl* ctrl, void* userdata)
{
LLPanelVolume* self = (LLPanelVolume*) userdata;
LLTextureCtrl* LightTextureCtrl = self->getChild<LLTextureCtrl>("light texture control");
if (LightTextureCtrl)
{
LightTextureCtrl->setImageAssetID(self->mLightSavedTexture);
}
}
void LLPanelVolume::onLightSelectColor(LLUICtrl* ctrl, void* userdata)
{
LLPanelVolume* self = (LLPanelVolume*) userdata;
@@ -459,6 +531,25 @@ void LLPanelVolume::onLightSelectColor(LLUICtrl* ctrl, void* userdata)
}
}
void LLPanelVolume::onLightSelectTexture(LLUICtrl* ctrl, void* userdata)
{
LLPanelVolume* self = (LLPanelVolume*) userdata;
LLVOVolume *volobjp = (LLVOVolume*)self->mObject.get();
if (!volobjp || (volobjp->getPCode() != LL_PCODE_VOLUME))
{
return;
}
LLTextureCtrl* LightTextureCtrl = self->getChild<LLTextureCtrl>("light texture control");
if(LightTextureCtrl)
{
LLUUID id = LightTextureCtrl->getImageAssetID();
volobjp->setLightTextureID(id);
self->mLightSavedTexture = id;
}
}
// static
void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata )
{
@@ -474,12 +565,45 @@ void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata )
volobjp->setLightIntensity((F32)self->childGetValue("Light Intensity").asReal());
volobjp->setLightRadius((F32)self->childGetValue("Light Radius").asReal());
volobjp->setLightFalloff((F32)self->childGetValue("Light Falloff").asReal());
LLColorSwatchCtrl* LightColorSwatch = self->getChild<LLColorSwatchCtrl>("colorswatch");
if(LightColorSwatch)
{
LLColor4 clr = LightColorSwatch->get();
volobjp->setLightColor(LLColor3(clr));
}
LLTextureCtrl* LightTextureCtrl = self->getChild<LLTextureCtrl>("light texture control");
if(LightTextureCtrl)
{
LLUUID id = LightTextureCtrl->getImageAssetID();
if (id.notNull())
{
if (!volobjp->isLightSpotlight())
{ //this commit is making this a spot light, set UI to default params
volobjp->setLightTextureID(id);
LLVector3 spot_params = volobjp->getSpotLightParams();
self->getChild<LLUICtrl>("Light FOV")->setValue(spot_params.mV[0]);
self->getChild<LLUICtrl>("Light Focus")->setValue(spot_params.mV[1]);
self->getChild<LLUICtrl>("Light Ambiance")->setValue(spot_params.mV[2]);
}
else
{ //modifying existing params
LLVector3 spot_params;
spot_params.mV[0] = (F32) self->getChild<LLUICtrl>("Light FOV")->getValue().asReal();
spot_params.mV[1] = (F32) self->getChild<LLUICtrl>("Light Focus")->getValue().asReal();
spot_params.mV[2] = (F32) self->getChild<LLUICtrl>("Light Ambiance")->getValue().asReal();
volobjp->setSpotLightParams(spot_params);
}
}
else if (volobjp->isLightSpotlight())
{ //no longer a spot light
volobjp->setLightTextureID(id);
//self->getChildView("Light FOV")->setEnabled(FALSE);
//self->getChildView("Light Focus")->setEnabled(FALSE);
//self->getChildView("Light Ambiance")->setEnabled(FALSE);
}
}
}
// static

View File

@@ -74,6 +74,8 @@ public:
static void onLightCancelColor(LLUICtrl* ctrl, void* userdata);
static void onLightSelectColor(LLUICtrl* ctrl, void* userdata);
static void onLightCancelTexture(LLUICtrl* ctrl, void* userdata);
static void onLightSelectTexture(LLUICtrl* ctrl, void* userdata);
protected:
void getState();
@@ -99,6 +101,7 @@ protected:
*/
LLColor4 mLightSavedColor;
LLUUID mLightSavedTexture;
LLPointer<LLViewerObject> mObject;
LLPointer<LLViewerObject> mRootObject;
};

View File

@@ -1068,22 +1068,67 @@
mouse_opaque="true" name="label color" v_pad="0" width="58">
Color
</text>
<text bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
bottom_delta="0" drop_shadow_visible="true" follows="left|top"
font="SansSerifSmall" h_pad="0" halign="left" height="10" left_delta="114"
mouse_opaque="true" name="label texture" v_pad="0" width="58">
Texture
</text>
<color_swatch border_color="0.45098, 0.517647, 0.607843, 1" bottom_delta="-28"
left="55"
can_apply_immediately="true" color="0.5, 0.5, 0.5, 1" follows="left|top"
height="48" label="" left_delta="67" mouse_opaque="true" name="colorswatch"
height="48" label="" mouse_opaque="true" name="colorswatch"
tool_tip="Click to open Color Picker" width="32" />
<texture_picker
allow_no_texture="true"
bottom_delta="-1"
can_apply_immediately="true"
default_image_name="Default"
follows="left|top"
height="48"
label=""
left_delta="124"
mouse_opaque="true"
name="light texture control"
tool_tip="Click to choose a projection image (only has effect with deferred rendering enabled)"
width="32" />
<spinner bottom_delta="-4" decimal_digits="5" follows="left|top" height="16"
increment="0.1" initial_val="0.5" label="Intensity" label_width="65"
left="10" max_val="1" min_val="0" mouse_opaque="true"
name="Light Intensity" width="128" />
left="10"
increment="0.1" initial_val="0.5" label="Intensity" label_width="45"
max_val="1" min_val="0" mouse_opaque="true"
name="Light Intensity"
width="108" />
<spinner bottom_delta="0" decimal_digits="3" follows="left|top" height="16"
left_delta="114"
increment="0.1" initial_val="0.5" label="FOV" label_width="55"
max_val="3" min_val="0" mouse_opaque="true"
name="Light FOV"
width="118" />
<spinner bottom_delta="-20" decimal_digits="5" follows="left|top" height="16"
increment="0.1" initial_val="5" label="Radius" label_width="65"
left_delta="0" max_val="20" min_val="0" mouse_opaque="true"
name="Light Radius" width="128" />
left="10"
increment="0.1" initial_val="5" label="Radius" label_width="45"
max_val="20" min_val="0" mouse_opaque="true"
name="Light Radius"
width="108" />
<spinner bottom_delta="0" decimal_digits="3" follows="left|top" height="16"
left_delta="114"
increment="0.5" initial_val="0.5" label="Focus" label_width="55"
max_val="20" min_val="-20" mouse_opaque="true"
name="Light Focus"
width="118" />
<spinner bottom_delta="-20" decimal_digits="5" follows="left|top" height="16"
increment="0.25" initial_val="1" label="Falloff" label_width="65"
left_delta="0" max_val="2" min_val="0" mouse_opaque="true"
name="Light Falloff" width="128" />
left="10"
increment="0.25" initial_val="1" label="Falloff" label_width="45"
max_val="2" min_val="0" mouse_opaque="true"
name="Light Falloff"
width="108" />
<spinner bottom_delta="0" decimal_digits="3" follows="left|top" height="16"
left_delta="114"
increment="0.05" initial_val="1" label="Ambiance" label_width="55"
max_val="1" min_val="0" mouse_opaque="true"
name="Light Ambiance"
width="118" />
</panel>
<!-- Texture sub-tab -->