void LLControlGroup::setVector3(const LLString& name, const LLVector3 &val) { LLControlBase* control = getControl(name); if (control && control->isType(TYPE_VEC3)) { control->set(val.getValue()); } else { CONTROL_ERRS << "Invalid control " << name << llendl; } }
void LLControlGroup::setVector3(const std::string& name, const LLVector3 &val) { LLControlVariable* control = getControl(name); if (control && control->isType(TYPE_VEC3)) { control->set(val.getValue()); if(mChangeCallback) mChangeCallback(name,llformat("<%f,%f,%f>",val.mV[VX],val.mV[VY],val.mV[VZ])); } else { CONTROL_ERRS << "Invalid control " << name << llendl; } }
LLSD lggBeamMapFloater::getMyDataSerialized() { LLSD out; LLRect r = getChild<LLPanel>("beamshape_draw")->getRect(); for(int i =0; i<(int)dots.size();i++) { LLSD point; lggPoint t = dots[i]; LLVector3 vec = LLVector3((F32)0.0,(F32)t.x,(F32)t.y); vec -= LLVector3((F32)0.0,(F32)r.getCenterX(),r.getCenterY()); point["offset"]= vec.getValue(); point["color"] = t.c.getValue(); out[i]=point; } return out; }
//static void LLFloaterSettingsDebug::onCommitSettings(LLUICtrl* ctrl, void* user_data) { LLFloaterSettingsDebug* floaterp = (LLFloaterSettingsDebug*)user_data; LLComboBox* settings_combo = floaterp->getChild<LLComboBox>("settings_combo"); LLControlVariable* controlp = (LLControlVariable*)settings_combo->getCurrentUserdata(); LLVector3 vector; LLVector3d vectord; LLRect rect; LLColor4 col4; LLColor3 col3; LLColor4U col4U; LLColor4 color_with_alpha; switch(controlp->type()) { case TYPE_U32: controlp->set(floaterp->childGetValue("val_spinner_1")); break; case TYPE_S32: controlp->set(floaterp->childGetValue("val_spinner_1")); break; case TYPE_F32: controlp->set(LLSD(floaterp->childGetValue("val_spinner_1").asReal())); break; case TYPE_BOOLEAN: controlp->set(floaterp->childGetValue("boolean_combo")); break; case TYPE_STRING: controlp->set(LLSD(floaterp->childGetValue("val_text").asString())); break; case TYPE_VEC3: vector.mV[VX] = (F32)floaterp->childGetValue("val_spinner_1").asReal(); vector.mV[VY] = (F32)floaterp->childGetValue("val_spinner_2").asReal(); vector.mV[VZ] = (F32)floaterp->childGetValue("val_spinner_3").asReal(); controlp->set(vector.getValue()); break; case TYPE_VEC3D: vectord.mdV[VX] = floaterp->childGetValue("val_spinner_1").asReal(); vectord.mdV[VY] = floaterp->childGetValue("val_spinner_2").asReal(); vectord.mdV[VZ] = floaterp->childGetValue("val_spinner_3").asReal(); controlp->set(vectord.getValue()); break; case TYPE_RECT: rect.mLeft = floaterp->childGetValue("val_spinner_1").asInteger(); rect.mRight = floaterp->childGetValue("val_spinner_2").asInteger(); rect.mBottom = floaterp->childGetValue("val_spinner_3").asInteger(); rect.mTop = floaterp->childGetValue("val_spinner_4").asInteger(); controlp->set(rect.getValue()); break; case TYPE_COL4: col3.setValue(floaterp->childGetValue("color_swatch")); col4 = LLColor4(col3, (F32)floaterp->childGetValue("val_spinner_4").asReal()); controlp->set(col4.getValue()); break; case TYPE_COL3: controlp->set(floaterp->childGetValue("color_swatch")); //col3.mV[VRED] = (F32)floaterp->childGetValue("val_spinner_1").asC(); //col3.mV[VGREEN] = (F32)floaterp->childGetValue("val_spinner_2").asReal(); //col3.mV[VBLUE] = (F32)floaterp->childGetValue("val_spinner_3").asReal(); //controlp->set(col3.getValue()); break; case TYPE_COL4U: col3.setValue(floaterp->childGetValue("color_swatch")); col4U.setVecScaleClamp(col3); col4U.mV[VALPHA] = floaterp->childGetValue("val_spinner_4").asInteger(); controlp->set(col4U.getValue()); break; default: break; } }
// Returns number of controls loaded, so 0 if failure U32 LLControlGroup::loadFromFile(const LLString& filename, BOOL require_declaration, eControlType declare_as) { LLString name; LLXmlTree xml_controls; if (!xml_controls.parseFile(filename)) { llwarns << "Unable to open control file " << filename << llendl; return 0; } LLXmlTreeNode* rootp = xml_controls.getRoot(); if (!rootp || !rootp->hasAttribute("version")) { llwarns << "No valid settings header found in control file " << filename << llendl; return 0; } U32 item = 0; U32 validitems = 0; S32 version; rootp->getAttributeS32("version", version); // Check file version if (version != CURRENT_VERSION) { llinfos << filename << " does not appear to be a version " << CURRENT_VERSION << " controls file" << llendl; return 0; } LLXmlTreeNode* child_nodep = rootp->getFirstChild(); while(child_nodep) { name = child_nodep->getName(); BOOL declared = controlExists(name); if (require_declaration && !declared) { // Declaration required, but this name not declared. // Complain about non-empty names. if (!name.empty()) { //read in to end of line llwarns << "LLControlGroup::loadFromFile() : Trying to set \"" << name << "\", setting doesn't exist." << llendl; } child_nodep = rootp->getNextChild(); continue; } // Got an item. Load it up. item++; // If not declared, assume it's a string if (!declared) { switch(declare_as) { case TYPE_COL4: declareColor4(name, LLColor4::white, "", NO_PERSIST); break; case TYPE_COL4U: declareColor4U(name, LLColor4U::white, "", NO_PERSIST); break; case TYPE_STRING: default: declareString(name, LLString::null, "", NO_PERSIST); break; } } // Control name has been declared in code. LLControlBase *control = getControl(name); llassert(control); mLoadedSettings.insert(name); switch(control->mType) { case TYPE_F32: { F32 initial = 0.f; child_nodep->getAttributeF32("value", initial); control->set(initial); validitems++; } break; case TYPE_S32: { S32 initial = 0; child_nodep->getAttributeS32("value", initial); control->set(initial); validitems++; } break; case TYPE_U32: { U32 initial = 0; child_nodep->getAttributeU32("value", initial); control->set((LLSD::Integer) initial); validitems++; } break; case TYPE_BOOLEAN: { BOOL initial = FALSE; child_nodep->getAttributeBOOL("value", initial); control->set(initial); validitems++; } break; case TYPE_STRING: { LLString string; child_nodep->getAttributeString("value", string); if (string == LLString::null) { string = ""; } control->set(string); validitems++; } break; case TYPE_VEC3: { LLVector3 vector; child_nodep->getAttributeVector3("value", vector); control->set(vector.getValue()); validitems++; } break; case TYPE_VEC3D: { LLVector3d vector; child_nodep->getAttributeVector3d("value", vector); control->set(vector.getValue()); validitems++; } break; case TYPE_RECT: { //RN: hack to support reading rectangles from a string LLString rect_string; child_nodep->getAttributeString("value", rect_string); std::istringstream istream(rect_string); S32 left, bottom, width, height; istream >> left >> bottom >> width >> height; LLRect rect; rect.setOriginAndSize(left, bottom, width, height); control->set(rect.getValue()); validitems++; } break; case TYPE_COL4U: { LLColor4U color; child_nodep->getAttributeColor4U("value", color); control->set(color.getValue()); validitems++; } break; case TYPE_COL4: { LLColor4 color; child_nodep->getAttributeColor4("value", color); control->set(color.getValue()); validitems++; } break; case TYPE_COL3: { LLVector3 color; child_nodep->getAttributeVector3("value", color); control->set(LLColor3(color.mV).getValue()); validitems++; } break; } child_nodep = rootp->getNextChild(); } return validitems; }
BOOL LLControlGroup::declareVec3(const LLString& name, const LLVector3 &initial_val, const LLString& comment, BOOL persist) { return declareControl(name, TYPE_VEC3, initial_val.getValue(), comment, persist); }
template <> eControlType get_control_type<LLVector3>(const LLVector3& in, LLSD& out) { out = in.getValue(); return TYPE_VEC3; }
template <> LLSD convert_to_llsd<LLVector3>(const LLVector3& in) { return in.getValue(); }
LLSD LLModel::Decomposition::asLLSD() const { LLSD ret; if (mBaseHull.empty() && mHull.empty()) { //nothing to write return ret; } //write decomposition block // ["physics_convex"]["HullList"] -- list of 8 bit integers, each entry represents a hull with specified number of points // ["physics_convex"]["Position"] -- list of 16-bit integers to be decoded to given domain, encoded 3D points // ["physics_convex"]["BoundingVerts"] -- list of 16-bit integers to be decoded to given domain, encoded 3D points representing a single hull approximation of given shape //get minimum and maximum LLVector3 min; if (mHull.empty()) { min = mBaseHull[0]; } else { min = mHull[0][0]; } LLVector3 max = min; LLSD::Binary hulls(mHull.size()); U32 total = 0; for (U32 i = 0; i < mHull.size(); ++i) { U32 size = mHull[i].size(); total += size; hulls[i] = (U8) (size); for (U32 j = 0; j < mHull[i].size(); ++j) { update_min_max(min, max, mHull[i][j]); } } for (U32 i = 0; i < mBaseHull.size(); ++i) { update_min_max(min, max, mBaseHull[i]); } ret["Min"] = min.getValue(); ret["Max"] = max.getValue(); LLVector3 range = max-min; if (!hulls.empty()) { ret["HullList"] = hulls; } if (total > 0) { LLSD::Binary p(total*3*2); U32 vert_idx = 0; for (U32 i = 0; i < mHull.size(); ++i) { std::set<U64> valid; llassert(!mHull[i].empty()); for (U32 j = 0; j < mHull[i].size(); ++j) { U64 test = 0; const F32* src = mHull[i][j].mV; for (U32 k = 0; k < 3; k++) { //convert to 16-bit normalized across domain U16 val = (U16) (((src[k]-min.mV[k])/range.mV[k])*65535); if(valid.size() < 3) { switch (k) { case 0: test = test | (U64) val; break; case 1: test = test | ((U64) val << 16); break; case 2: test = test | ((U64) val << 32); break; }; valid.insert(test); } U8* buff = (U8*) &val; //write to binary buffer p[vert_idx++] = buff[0]; p[vert_idx++] = buff[1]; //makes sure we haven't run off the end of the array llassert(vert_idx <= p.size()); } } //must have at least 3 unique points llassert(valid.size() > 2); } ret["Positions"] = p; } //llassert(!mBaseHull.empty()); if (!mBaseHull.empty()) { LLSD::Binary p(mBaseHull.size()*3*2); U32 vert_idx = 0; for (U32 j = 0; j < mBaseHull.size(); ++j) { const F32* v = mBaseHull[j].mV; for (U32 k = 0; k < 3; k++) { //convert to 16-bit normalized across domain U16 val = (U16) (((v[k]-min.mV[k])/range.mV[k])*65535); U8* buff = (U8*) &val; //write to binary buffer p[vert_idx++] = buff[0]; p[vert_idx++] = buff[1]; if (vert_idx > p.size()) { LL_ERRS() << "Index out of bounds" << LL_ENDL; } } } ret["BoundingVerts"] = p; } return ret; }
void LLFloaterSettingsDebug::onCommitSettings() { if (!mCurrentControlVariable) return; LLVector3 vector; LLVector3d vectord; LLRect rect; LLColor4 col4; LLColor3 col3; LLColor4U col4U; LLColor4 color_with_alpha; switch(mCurrentControlVariable->type()) { case TYPE_U32: mCurrentControlVariable->set(getChild<LLUICtrl>("val_spinner_1")->getValue()); break; case TYPE_S32: mCurrentControlVariable->set(getChild<LLUICtrl>("val_spinner_1")->getValue()); break; case TYPE_F32: mCurrentControlVariable->set(LLSD(getChild<LLUICtrl>("val_spinner_1")->getValue().asReal())); break; case TYPE_BOOLEAN: mCurrentControlVariable->set(getChild<LLUICtrl>("boolean_combo")->getValue()); break; case TYPE_STRING: mCurrentControlVariable->set(LLSD(getChild<LLUICtrl>("val_text")->getValue().asString())); break; case TYPE_VEC3: vector.mV[VX] = (F32)getChild<LLUICtrl>("val_spinner_1")->getValue().asReal(); vector.mV[VY] = (F32)getChild<LLUICtrl>("val_spinner_2")->getValue().asReal(); vector.mV[VZ] = (F32)getChild<LLUICtrl>("val_spinner_3")->getValue().asReal(); mCurrentControlVariable->set(vector.getValue()); break; case TYPE_VEC3D: vectord.mdV[VX] = getChild<LLUICtrl>("val_spinner_1")->getValue().asReal(); vectord.mdV[VY] = getChild<LLUICtrl>("val_spinner_2")->getValue().asReal(); vectord.mdV[VZ] = getChild<LLUICtrl>("val_spinner_3")->getValue().asReal(); mCurrentControlVariable->set(vectord.getValue()); break; case TYPE_RECT: rect.mLeft = getChild<LLUICtrl>("val_spinner_1")->getValue().asInteger(); rect.mRight = getChild<LLUICtrl>("val_spinner_2")->getValue().asInteger(); rect.mBottom = getChild<LLUICtrl>("val_spinner_3")->getValue().asInteger(); rect.mTop = getChild<LLUICtrl>("val_spinner_4")->getValue().asInteger(); mCurrentControlVariable->set(rect.getValue()); break; case TYPE_COL4: col3.setValue(getChild<LLUICtrl>("val_color_swatch")->getValue()); col4 = LLColor4(col3, (F32)getChild<LLUICtrl>("val_spinner_4")->getValue().asReal()); mCurrentControlVariable->set(col4.getValue()); break; case TYPE_COL3: mCurrentControlVariable->set(getChild<LLUICtrl>("val_color_swatch")->getValue()); //col3.mV[VRED] = (F32)getChild<LLUICtrl>("val_spinner_1")->getValue().asC(); //col3.mV[VGREEN] = (F32)getChild<LLUICtrl>("val_spinner_2")->getValue().asReal(); //col3.mV[VBLUE] = (F32)getChild<LLUICtrl>("val_spinner_3")->getValue().asReal(); //mCurrentControlVariable->set(col3.getValue()); break; case TYPE_COL4U: col3.setValue(getChild<LLUICtrl>("val_color_swatch")->getValue()); col4U.setVecScaleClamp(col3); col4U.mV[VALPHA] = getChild<LLUICtrl>("val_spinner_4")->getValue().asInteger(); mCurrentControlVariable->set(col4U.getValue()); break; default: break; } }
BOOL LLControlGroup::declareVec3(const std::string& name, const LLVector3 &initial_val, const std::string& comment, BOOL persist) { return declareControl(name, TYPE_VEC3, initial_val.getValue(), comment, SANITY_TYPE_NONE, LLSD(), std::string(""), persist); }