diff options
Diffstat (limited to 'indra/appearance_utility')
18 files changed, 1774 insertions, 0 deletions
diff --git a/indra/appearance_utility/CMakeLists.txt b/indra/appearance_utility/CMakeLists.txt new file mode 100644 index 0000000000..92898fa48b --- /dev/null +++ b/indra/appearance_utility/CMakeLists.txt @@ -0,0 +1,66 @@ +# -*- cmake -*- + +project(appearance_utility) + +include(00-Common) +include(LLAppearance) +include(LLCharacter) +include(LLCommon) +include(LLImage) +include(LLInventory) +include(LLMath) +include(LLRender) +include(LLVFS) +include(LLXML) +include(Linking) +include(GooglePerfTools) + +include_directories( + ${LLCOMMON_INCLUDE_DIRS} + ${LLVFS_INCLUDE_DIRS} + ${LLXML_INCLUDE_DIRS} + ${LLCHARACTER_INCLUDE_DIRS} + ${LLIMAGE_INCLUDE_DIRS} + ${LLMATH_INCLUDE_DIRS} + ${LLINVENTORY_INCLUDE_DIRS} + ${LLRENDER_INCLUDE_DIRS} + ${LLAPPEARANCE_INCLUDE_DIRS} + ) + +set(appearance_utility_SOURCE_FILES + appearance_utility.cpp + llappappearanceutility.cpp + llbakingavatar.cpp + llbakingjoint.cpp + llbakingjointmesh.cpp + llbakingshadermgr.cpp + llbakingtexlayer.cpp + llprocessparams.cpp + ) + +set(appearance_utility_HEADER_FILES + CMakeLists.txt + llappappearanceutility.h + llbakingavatar.h + llbakingjoint.h + llbakingjointmesh.h + llbakingprocess.h + llbakingshadermgr.h + llbakingtexlayer.h + llprocessparams.h + ) + +set_source_files_properties(${appearance_utility_HEADER_FILES} + PROPERTIES HEADER_FILES_ONLY TRUE) + +list(APPEND appearance_utility_SOURCE_FILES ${appearance_utility_HEADER_FILES}) + +add_executable(appearance-utility-bin ${appearance_utility_SOURCE_FILES}) + +target_link_libraries(appearance-utility-bin + ${LLAPPEARANCE_LIBRARIES} + ${TCMALLOC_LIBRARIES} + ) + +add_custom_target(appearance-utility-bin-target ALL + DEPENDS appearance-utility-bin) diff --git a/indra/appearance_utility/appearance_utility.cpp b/indra/appearance_utility/appearance_utility.cpp new file mode 100644 index 0000000000..098c3550de --- /dev/null +++ b/indra/appearance_utility/appearance_utility.cpp @@ -0,0 +1,66 @@ +/** + * @file appearance_utility.cpp + * @author Don Kjer <don@lindenlab.com>, Nyx Linden + * @brief Utility for processing avatar appearance without a full viewer implementation. + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + +// linden includes +#include "linden_common.h" +#include "llapr.h" + +// project includes +#include "llappappearanceutility.h" + +int main(int argc, char** argv) +{ + // Create an application instance. + ll_init_apr(); + LLAppAppearanceUtility* app = new LLAppAppearanceUtility(argc, argv); + + // Assume success, unless exception is thrown. + EResult rv = RV_SUCCESS; + try + { + // Process command line and initialize system. + if (app->init()) + { + // Run process. + app->mainLoop(); + } + } + catch (LLAppException& e) + { + // Deal with errors. + rv = e.getStatusCode(); + } + + // Clean up application instance. + app->cleanup(); + delete app; + ll_cleanup_apr(); + + return (int) rv; +} + + diff --git a/indra/appearance_utility/llappappearanceutility.cpp b/indra/appearance_utility/llappappearanceutility.cpp new file mode 100644 index 0000000000..66e59e1b89 --- /dev/null +++ b/indra/appearance_utility/llappappearanceutility.cpp @@ -0,0 +1,445 @@ +/** + * @file llappappearanceutility.cpp + * @brief Implementation of LLAppAppearanceUtility class. + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + +#include <iostream> +#include <sstream> +#include <string> + +// linden includes +#include "linden_common.h" + +#include "llapr.h" +#include "llerrorcontrol.h" +#include "llsd.h" +#include "llsdserialize.h" +#include "llsdutil.h" + +// appearance includes +#include "llavatarappearance.h" +#include "llwearabletype.h" + +// project includes +#include "llappappearanceutility.h" +#include "llbakingprocess.h" +#include "llprocessparams.h" + +const std::string NOTHING_EXTRA(""); + +//////////////////////////////////////////// +// LLAppException +//////////////////////////////////////////// + +static const std::string MESSAGE_RV_UNKNOWN("Unknown error."); +static const std::string MESSAGE_RV_ARGUMENTS +("Invalid arguments: "); +static const std::string MESSAGE_RV_UNABLE_OPEN("Unable to open file: "); +static const std::string MESSAGE_RV_UNABLE_TO_PARSE("Unable to parse input LLSD."); +static const std::string MESSAGE_DUPLICATE_MODES = "Cannot specify more than one process mode."; + + +LLAppException::LLAppException(EResult status_code, const std::string& extra) : + mStatusCode(status_code) +{ + switch(status_code) + { + case RV_UNKNOWN_ERROR: + printErrorLLSD("unknown", MESSAGE_RV_UNKNOWN); + case RV_BAD_ARGUMENTS: + printErrorLLSD("arguments", MESSAGE_RV_ARGUMENTS + extra); + break; + case RV_UNABLE_OPEN: + printErrorLLSD("file", MESSAGE_RV_UNABLE_OPEN + extra); + break; + case RV_UNABLE_TO_PARSE: + printErrorLLSD("input", MESSAGE_RV_UNABLE_TO_PARSE); + break; + default: + printErrorLLSD("arguments", "Unknown exception."); + break; + } +} + +void LLAppException::printErrorLLSD(const std::string& key, const std::string& message) +{ + LLSD error_llsd; + error_llsd["success"] = false; + error_llsd["error"]["key"] = key; + error_llsd["error"]["message"] = message; + + std::cerr << LLSDOStreamer<LLSDXMLFormatter>(error_llsd); +} + + + +//////////////////////////////////////////// +// LLAppAppearanceUtility +//////////////////////////////////////////// + +///////// Option Parsing ///////// + +// Simple usage command. +class LLProcessUsage : public LLBakingProcess +{ +public: + LLProcessUsage(LLAppAppearanceUtility* app) : + LLBakingProcess(app) {} + /*virtual*/ void process(LLSD& input, std::ostream& output) + { + mApp->usage(output); + } +}; + + +static const apr_getopt_option_t APPEARANCE_UTILITY_OPTIONS[] = +{ + {"params", 'p', 0, "Generate appearance parameters for an agent."}, + {"output", 'o', 1, "The output file to write to. Default is stdout"}, + {"agent-id", 'a', 1, "The agent-id of the user."}, + //{"grid", 'g', 1, "The grid."}, + {"help", 'h', 0, "Print the help message."}, + {0, 0, 0, 0} +}; + +void LLAppAppearanceUtility::usage(std::ostream& ostr) +{ + ostr << "Utilities for processing agent appearance data." + << std::endl << std::endl + << "Usage:" << std::endl + << "\t" << mAppName << " [options] filename" << std::endl << std::endl + << "Will read from stdin if filename is set to '-'." << std::endl << std::endl + << "Options:" << std::endl; + const apr_getopt_option_t* option = &APPEARANCE_UTILITY_OPTIONS[0]; + while(option->name) + { + ostr << "\t--" << option->name << "\t\t" + << option->description << std::endl; + ++option; + } + ostr << std::endl << "Return Values:" << std::endl + << "\t0\t\tSuccess." << std::endl + << "\t1\t\tUnknown error." << std::endl + << "\t2\t\tBad arguments." << std::endl + << "\t3\t\tUnable to open file. Possibly wrong filename" + << " or bad permissions." << std::endl + << "\t4\t\tUnable to parse input LLSD." << std::endl + << std::endl + << "Output:" << std::endl + << "If a non-zero status code is returned, additional error information" + << " will be returned on stderr." << std::endl + << "* This will be in the form of an LLSD document." << std::endl + << "* Check ['error']['message'] to get a human readable message." << std::endl + << "If a zero status code is returned, processed output will be written" + << " to the file specified by --out (or stdout, if not specified)." << std::endl + << std::endl + << std::endl; +} + + +/////// LLApp Interface //////// + +LLAppAppearanceUtility::LLAppAppearanceUtility(int argc, char** argv) : + LLApp(), + mArgc(argc), + mArgv(argv), + mProcess(NULL), + mInput(NULL), + mOutput(NULL), + mAppName(argv[0]) +{ +} + +// virtual +LLAppAppearanceUtility::~LLAppAppearanceUtility() +{ +} + +void LLAppAppearanceUtility::verifyNoProcess() +{ + if (mProcess) + { + std::cerr << "Invalid arguments. " << MESSAGE_DUPLICATE_MODES << std::endl; + usage(std::cerr); + throw LLAppException(RV_BAD_ARGUMENTS, MESSAGE_DUPLICATE_MODES); + } +} + +void LLAppAppearanceUtility::parseArguments() +{ + ////// BEGIN OPTION PARSING ////// + // Check for '-' as last option, since apr doesn't seem to like that. + if (std::string(mArgv[mArgc-1]) == "-") + { + mInputFilename.assign("-"); + mArgc--; + } + + apr_status_t apr_err; + const char* opt_arg = NULL; + int opt_id = 0; + apr_getopt_t* os = NULL; + if(APR_SUCCESS != apr_getopt_init(&os, gAPRPoolp, mArgc, mArgv)) + { + std::cerr << "Unable to initialize apr" << std::endl; + throw LLAppException(RV_UNKNOWN_ERROR); + } + + //std::string grid; + while(true) + { + apr_err = apr_getopt_long(os, APPEARANCE_UTILITY_OPTIONS, &opt_id, &opt_arg); + if(APR_STATUS_IS_EOF(apr_err)) break; + if(apr_err) + { + char buf[MAX_STRING]; /* Flawfinder: ignore */ + std::cerr << "Error parsing options: " + << apr_strerror(apr_err, buf, MAX_STRING) << std::endl; + usage(std::cerr); + throw LLAppException(RV_BAD_ARGUMENTS, buf); + } + switch (opt_id) + { + case 'h': + verifyNoProcess(); + mProcess = new LLProcessUsage(this); + break; + case 'p': + verifyNoProcess(); + mProcess = new LLProcessParams(this); + break; + case 'o': + mOutputFilename.assign(opt_arg); + break; + case 'a': + mAgentID.set(opt_arg); + if (mAgentID.isNull()) + { + const char* INVALID_AGENT_ID="agent-id must be a valid uuid."; + std::cerr << "Invalid arguments. " << INVALID_AGENT_ID << std::endl; + usage(std::cerr); + throw LLAppException(RV_BAD_ARGUMENTS, INVALID_AGENT_ID); + } + break; + //case 'g': + // grid = opt_arg; + // break; + default: + usage(std::cerr); + throw LLAppException(RV_BAD_ARGUMENTS, "Unknown option."); + } + } + + if ("-" != mInputFilename) + { + bool valid_input_filename = false; + // Try to grab the input filename. + if (os->argv && os->argv[os->ind]) + { + mInputFilename.assign(os->argv[os->ind]); + if (! mInputFilename.empty() ) + { + valid_input_filename = true; + } + } + if (!valid_input_filename) + { + const char* INVALID_FILENAME="Must specify input file."; + std::cerr << "Invalid arguments. " << INVALID_FILENAME << std::endl; + usage(std::cerr); + throw LLAppException(RV_BAD_ARGUMENTS, INVALID_FILENAME); + } + } + + ////// END OPTION PARSING ////// +} + +void LLAppAppearanceUtility::validateArguments() +{ + ///// BEGIN ARGUMENT VALIDATION ///// + + // Make sure we have a command specified. + if (!mProcess) + { + const char* INVALID_MODE="No process mode specified."; + std::cerr << "Invalid arguments. " << INVALID_MODE + << std::endl; + usage(std::cerr); + throw LLAppException(RV_BAD_ARGUMENTS, INVALID_MODE); + } + + ///// END ARGUMENT VALIDATION ///// +} + +void LLAppAppearanceUtility::initializeIO() +{ + ///// BEGIN OPEN INPUT FILE //// + + if ( "-" == mInputFilename ) + { + // Read unformated data from stdin in to memory. + std::stringstream* data = new std::stringstream(); + const S32 BUFFER_SIZE = BUFSIZ; + char buffer[BUFFER_SIZE]; + while (true) + { + std::cin.read(buffer, BUFFER_SIZE); + // Check if anything out of the ordinary happened. + if (!std::cin) + { + // See if something 'really bad' happened, or if we just + // used up all of our buffer. + if (std::cin.bad()) + { + std::cerr << "Problem reading standard input." << std::endl; + delete data; + throw (RV_UNKNOWN_ERROR); + } + else + { + // Output normally. + data->write(buffer, std::cin.gcount()); + if (std::cin.eof()) break; + + // Clear this problem. We have handled it. + std::cin.clear(); + } + } + else + { + data->write(buffer, std::cin.gcount()); + if (std::cin.eof()) break; + } + } + mInput = data; + } + else + { + // Make sure we can open the input file. + std::ifstream* input_file = new std::ifstream(); + input_file->open( mInputFilename.c_str(), std::fstream::in ); + if ( input_file->fail()) + { + std::cerr << "Couldn't open input file '" << mInputFilename << "'." << std::endl; + delete input_file; + throw LLAppException(RV_UNABLE_OPEN, mInputFilename); + } + mInput = input_file; + } + ///// END OPEN INPUT FILE //// + + ///// BEGIN OPEN OUTPUT FILE //// + + if ("" == mOutputFilename) + { + mOutput = &std::cout; + } + else + { + // Make sure we can open the output file. + std::fstream* output_file = new std::fstream(); + output_file->open( mOutputFilename.c_str(), std::fstream::out ); + if ( output_file->fail() ) + { + std::cerr << "Couldn't open output file '" << mOutputFilename << "'." << std::endl; + delete output_file; + throw LLAppException(RV_UNABLE_OPEN, mOutputFilename); + } + mOutput = output_file; + } + ///// END OPEN OUTPUT FILE //// + + ///// BEGIN INPUT PARSING //// + LLSDSerialize::fromXML( mInputData, *mInput ); + if (mInputData.isUndefined()) + { + throw LLAppException(RV_UNABLE_TO_PARSE); + } + ///// END INPUT PARSING //// +} + +class LLPassthroughTranslationBridge : public LLTranslationBridge +{ +public: + virtual std::string getString(const std::string &xml_desc) + { + // Just pass back the input string. + return xml_desc; + } +}; + + +bool LLAppAppearanceUtility::init() +{ + parseArguments(); + + bool log_to_stderr = true; + LLError::initForApplication("", log_to_stderr); + // *TODO: Add debug mode(s). Skip this in debug mode. + LLError::setDefaultLevel(LLError::LEVEL_WARN); + + validateArguments(); + initializeIO(); + + // Initialize classes. + LLWearableType::initClass(new LLPassthroughTranslationBridge()); + + // *TODO: Create a texture bridge? + LLAvatarAppearance::initClass(); + + return true; +} + +bool LLAppAppearanceUtility::cleanup() +{ + LLAvatarAppearance::cleanupClass(); + LLWearableType::cleanupClass(); + + if (mProcess) + { + delete mProcess; + mProcess = NULL; + } + if ("-" != mInputFilename && mInput) + { + static_cast<std::ifstream*>(mInput)->close(); + } + if ("" != mOutputFilename && mOutput) + { + static_cast<std::ofstream*>(mOutput)->close(); + delete mOutput; + mOutput = NULL; + } + delete mInput; + mInput = NULL; + return true; +} + +bool LLAppAppearanceUtility::mainLoop() +{ + // This isn't really a loop, for this application. We just execute the requested command. + mProcess->process(mInputData, *mOutput); + return true; +} + diff --git a/indra/appearance_utility/llappappearanceutility.h b/indra/appearance_utility/llappappearanceutility.h new file mode 100644 index 0000000000..2a5b8232eb --- /dev/null +++ b/indra/appearance_utility/llappappearanceutility.h @@ -0,0 +1,97 @@ +/** + * @file llappappearanceutility.h + * @brief Declaration of LLAppAppearanceUtility class. + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + +#ifndef LL_LLAPPAPPEARANCEUTILITY_H +#define LL_LLAPPAPPEARANCEUTILITY_H + +#include <exception> + +#include "llapp.h" + +enum EResult +{ + RV_SUCCESS = 0, + RV_UNKNOWN_ERROR, + RV_BAD_ARGUMENTS, + RV_UNABLE_OPEN, + RV_UNABLE_TO_PARSE, +}; + +extern const std::string NOTHING_EXTRA; + +class LLAppAppearanceUtility; +class LLBakingProcess; + +// Translate error status into error messages. +class LLAppException : public std::exception +{ +public: + LLAppException(EResult status_code, const std::string& extra = NOTHING_EXTRA); + EResult getStatusCode() { return mStatusCode; } + +private: + void printErrorLLSD(const std::string& key, const std::string& message); + EResult mStatusCode; +}; + + +class LLAppAppearanceUtility : public LLApp +{ +public: + LLAppAppearanceUtility(int argc, char** argv); + virtual ~LLAppAppearanceUtility(); + + // LLApp interface. + /*virtual*/ bool init(); + /*virtual*/ bool cleanup(); + /*virtual*/ bool mainLoop(); + +private: + // Option parsing. + void verifyNoProcess(); + void parseArguments(); + void validateArguments(); + void initializeIO(); +public: + void usage(std::ostream& ostr); + + +private: + int mArgc; + char** mArgv; + LLBakingProcess* mProcess; + std::istream* mInput; + std::ostream* mOutput; + std::string mAppName; + std::string mInputFilename; + std::string mOutputFilename; + LLUUID mAgentID; + LLSD mInputData; +}; + + +#endif /* LL_LLAPPAPPEARANCEUTILITY_H */ + diff --git a/indra/appearance_utility/llbakingavatar.cpp b/indra/appearance_utility/llbakingavatar.cpp new file mode 100644 index 0000000000..0424e8134b --- /dev/null +++ b/indra/appearance_utility/llbakingavatar.cpp @@ -0,0 +1,159 @@ +/** + * @File llbakingavatar.cpp + * @brief Implementation of LLBakingAvatar class which is a derivation of LLAvatarAppearance + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + +// linden includes +#include "linden_common.h" +#include "v3dmath.h" + +// project includes +#include "llbakingavatar.h" +#include "llbakingjoint.h" +#include "llbakingjointmesh.h" +#include "llbakingtexlayer.h" + +LLBakingAvatar::LLBakingAvatar(LLWearableData* wearable_data) : + LLAvatarAppearance(wearable_data) +{ +} + +// virtual +LLBakingAvatar::~LLBakingAvatar() +{ +} + +//----------------------------------------------------------------------------- +// Implemented methods +//----------------------------------------------------------------------------- + +LLAvatarJoint* LLBakingAvatar::createAvatarJoint() +{ + return new LLBakingJoint(); +} + +LLAvatarJoint* LLBakingAvatar::createAvatarJoint(S32 joint_num) +{ + return new LLBakingJoint(joint_num); +} + +LLAvatarJointMesh* LLBakingAvatar::createAvatarJointMesh() +{ + return new LLBakingJointMesh(); +} + +LLTexLayerSet* LLBakingAvatar::createTexLayerSet() +{ + return new LLBakingTexLayerSet(this); +} + +//----------------------------------------------------------------------------- +// (Ignored) Non-implemented methods. +//----------------------------------------------------------------------------- + +void LLBakingAvatar::bodySizeChanged() {} +void LLBakingAvatar::applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components, + LLAvatarAppearanceDefines::EBakedTextureIndex index) {} +void LLBakingAvatar::invalidateComposite(LLTexLayerSet* layerset, BOOL upload_result) {} +void LLBakingAvatar::updateMeshTextures() {} +void LLBakingAvatar::dirtyMesh() {} +void LLBakingAvatar::dirtyMesh(S32 priority) {} +void LLBakingAvatar::onGlobalColorChanged(const LLTexGlobalColor* global_color, BOOL upload_bake) {} + +BOOL LLBakingAvatar::isTextureDefined(LLAvatarAppearanceDefines::ETextureIndex type, U32 index) const +{ + return TRUE; +} + + +//----------------------------------------------------------------------------- +// (LLERR) Non-implemented methods. +//----------------------------------------------------------------------------- + +LLVector3 LLBakingAvatar::getCharacterPosition() +{ + LL_ERRS("AppearanceUtility") << "Not implemented." << LL_ENDL; + return LLVector3::zero; +} + +LLQuaternion LLBakingAvatar::getCharacterRotation() +{ + LL_ERRS("AppearanceUtility") << "Not implemented." << LL_ENDL; + return LLQuaternion::DEFAULT; +} + +LLVector3 LLBakingAvatar::getCharacterVelocity() +{ + LL_ERRS("AppearanceUtility") << "Not implemented." << LL_ENDL; + return LLVector3::zero; +} + +LLVector3 LLBakingAvatar::getCharacterAngularVelocity() +{ + LL_ERRS("AppearanceUtility") << "Not implemented." << LL_ENDL; + return LLVector3::zero; +} + +const LLUUID& LLBakingAvatar::getID() const +{ + LL_ERRS("AppearanceUtility") << "Not implemented." << LL_ENDL; + return LLUUID::null; +} + +void LLBakingAvatar::addDebugText(const std::string& text) +{ + LL_ERRS("AppearanceUtility") << "Not implemented." << LL_ENDL; +} + +F32 LLBakingAvatar::getTimeDilation() +{ + LL_ERRS("AppearanceUtility") << "Not implemented." << LL_ENDL; + return 0.0f; +} + +void LLBakingAvatar::getGround(const LLVector3 &inPos, LLVector3 &outPos, LLVector3 &outNorm) +{ + LL_ERRS("AppearanceUtility") << "Not implemented." << LL_ENDL; +} + +F32 LLBakingAvatar::getPixelArea() const +{ + LL_ERRS("AppearanceUtility") << "Not implemented." << LL_ENDL; + return 0.0f; +} + +LLVector3d LLBakingAvatar::getPosGlobalFromAgent(const LLVector3 &position) +{ + LL_ERRS("AppearanceUtility") << "Not implemented." << LL_ENDL; + return LLVector3d::zero; +} + +LLVector3 LLBakingAvatar::getPosAgentFromGlobal(const LLVector3d &position) +{ + LL_ERRS("AppearanceUtility") << "Not implemented." << LL_ENDL; + return LLVector3::zero; +} + + + diff --git a/indra/appearance_utility/llbakingavatar.h b/indra/appearance_utility/llbakingavatar.h new file mode 100644 index 0000000000..7f20d31674 --- /dev/null +++ b/indra/appearance_utility/llbakingavatar.h @@ -0,0 +1,125 @@ +/** + * @file llbakingavatar.h + * @brief Declaration of LLBakingAvatar class which is a derivation of LLAvatarAppearance + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + +#ifndef LL_LLBAKINGAVATAR_H +#define LL_LLBAKINGAVATAR_H + +#include "llavatarappearance.h" + +class LLBakingAvatar : public LLAvatarAppearance +{ + LOG_CLASS(LLBakingAvatar); + +/******************************************************************************** + ** ** + ** INITIALIZATION + **/ +public: + void* operator new(size_t size) + { + return ll_aligned_malloc_16(size); + } + + void operator delete(void* ptr) + { + ll_aligned_free_16(ptr); + } + + LLBakingAvatar(LLWearableData* wearable_data); + virtual ~LLBakingAvatar(); + + static void initClass(); // initializes static members + +/** Initialization + ** ** + *******************************************************************************/ + +/******************************************************************************** + ** ** + ** INHERITED + **/ + + //-------------------------------------------------------------------- + // LLCharacter interface + //-------------------------------------------------------------------- +public: + /*virtual*/ LLVector3 getCharacterPosition(); + /*virtual*/ LLQuaternion getCharacterRotation(); + /*virtual*/ LLVector3 getCharacterVelocity(); + /*virtual*/ LLVector3 getCharacterAngularVelocity(); + + /*virtual*/ const LLUUID& getID() const; + /*virtual*/ void addDebugText(const std::string& text); + /*virtual*/ F32 getTimeDilation(); + /*virtual*/ void getGround(const LLVector3 &inPos, LLVector3 &outPos, LLVector3 &outNorm); + /*virtual*/ F32 getPixelArea() const; + /*virtual*/ LLVector3d getPosGlobalFromAgent(const LLVector3 &position); + /*virtual*/ LLVector3 getPosAgentFromGlobal(const LLVector3d &position); + + //-------------------------------------------------------------------- + // LLAvatarAppearance interface + //-------------------------------------------------------------------- +public: + /*virtual*/ void bodySizeChanged(); + /*virtual*/ void applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components, + LLAvatarAppearanceDefines::EBakedTextureIndex index); + /*virtual*/ void invalidateComposite(LLTexLayerSet* layerset, BOOL upload_result); + /*virtual*/ void updateMeshTextures(); + /*virtual*/ void dirtyMesh(); // Dirty the avatar mesh + /*virtual*/ void onGlobalColorChanged(const LLTexGlobalColor* global_color, BOOL upload_bake); + /*virtual*/ BOOL isTextureDefined(LLAvatarAppearanceDefines::ETextureIndex type, U32 index = 0) const; +private: + /*virtual*/ void dirtyMesh(S32 priority); // Dirty the avatar mesh, with priority + + // LLAvatarAppearance instance factories: +protected: + /*virtual*/ LLAvatarJoint* createAvatarJoint(); + /*virtual*/ LLAvatarJoint* createAvatarJoint(S32 joint_num); + /*virtual*/ LLAvatarJointMesh* createAvatarJointMesh(); + /*virtual*/ LLTexLayerSet* createTexLayerSet(); + + +/** Inherited + ** ** + *******************************************************************************/ + +/******************************************************************************** + ** ** + ** STATE + **/ +public: + /*virtual*/ bool isSelf() const { return true; } + /*virtual*/ BOOL isValid() const { return TRUE; } + /*virtual*/ BOOL isUsingBakedTextures() const { return TRUE; } + +/** State + ** ** + *******************************************************************************/ + +}; + +#endif /* LL_LLBAKINGAVATAR_H */ + diff --git a/indra/appearance_utility/llbakingjoint.cpp b/indra/appearance_utility/llbakingjoint.cpp new file mode 100644 index 0000000000..96f7b686b2 --- /dev/null +++ b/indra/appearance_utility/llbakingjoint.cpp @@ -0,0 +1,54 @@ +/** + * @file llbakingjoint.cpp + * @brief Implementation of LLBakingJoint class + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + + +#include "linden_common.h" + +#include "llbakingjoint.h" + + +LLBakingJoint::LLBakingJoint() : + LLAvatarJoint() +{ +} + +LLBakingJoint::LLBakingJoint(S32 joint_num) : + LLAvatarJoint(joint_num) +{ +} + +// virtual +LLBakingJoint::~LLBakingJoint() +{ +} + +// virtual +U32 LLBakingJoint::render( F32 pixelArea, BOOL first_pass, BOOL is_dummy) +{ + llerrs << "LLBakingJoint::render() should never be called!" << llendl; + return 0; +} + diff --git a/indra/appearance_utility/llbakingjoint.h b/indra/appearance_utility/llbakingjoint.h new file mode 100644 index 0000000000..5247eb7510 --- /dev/null +++ b/indra/appearance_utility/llbakingjoint.h @@ -0,0 +1,44 @@ +/** + * @file llbakingjoint.h + * @brief Implementation of LLBakingJoint class + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + +#ifndef LL_LLBAKINGJOINT_H +#define LL_LLBAKINGJOINT_H + +#include "llavatarjoint.h" + +class LLBakingJoint : public virtual LLAvatarJoint +{ +public: + LLBakingJoint(); + LLBakingJoint(S32 joint_num); + virtual ~LLBakingJoint(); + + // LLViewerJoint interface + virtual U32 render( F32 pixelArea, BOOL first_pass = TRUE, BOOL is_dummy = FALSE ); +}; + +#endif /* LL_LLBAKINGJOINT_H */ + diff --git a/indra/appearance_utility/llbakingjointmesh.cpp b/indra/appearance_utility/llbakingjointmesh.cpp new file mode 100644 index 0000000000..877317deb8 --- /dev/null +++ b/indra/appearance_utility/llbakingjointmesh.cpp @@ -0,0 +1,43 @@ +/** + * @file llbakingjointmesh.cpp + * @brief Implementation of LLBakingJointMesh class + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + + +#include "linden_common.h" + +#include "llbakingjointmesh.h" + + +LLBakingJointMesh::LLBakingJointMesh() : + LLAvatarJointMesh() +{ +} + +// virtual +LLBakingJointMesh::~LLBakingJointMesh() +{ +} + + diff --git a/indra/appearance_utility/llbakingjointmesh.h b/indra/appearance_utility/llbakingjointmesh.h new file mode 100644 index 0000000000..6252f6cee3 --- /dev/null +++ b/indra/appearance_utility/llbakingjointmesh.h @@ -0,0 +1,43 @@ +/** + * @file llbakingjoint.h + * @brief Implementation of LLBakingJointMesh class + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + +#ifndef LL_LLBAKINGJOINTMESH_H +#define LL_LLBAKINGJOINTMESH_H + +#include "llavatarjointmesh.h" +#include "llbakingjoint.h" + +class LLBakingJointMesh : public LLAvatarJointMesh, public LLBakingJoint +{ +public: + LLBakingJointMesh(); + LLBakingJointMesh(S32 joint_num); + virtual ~LLBakingJointMesh(); + +}; + +#endif /* LL_LLBAKINGJOINTMESH_H */ + diff --git a/indra/appearance_utility/llbakingprocess.h b/indra/appearance_utility/llbakingprocess.h new file mode 100644 index 0000000000..a32eae6443 --- /dev/null +++ b/indra/appearance_utility/llbakingprocess.h @@ -0,0 +1,55 @@ +/** + * @file llbakingprocess.h + * @brief Declaration of LLBakingProcess interface. + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + +#ifndef LL_LLBAKINGPROCESS_H +#define LL_LLBAKINGPROCESS_H + +#include <ostream> + +class LLAppAppearanceUtility; +class LLSD; + +// Simple wrapper for various process modes. +class LLBakingProcess +{ +private: + // Hide default constructor. + LLBakingProcess() {} +public: + LLBakingProcess(LLAppAppearanceUtility* app) : + mApp(app) {} + virtual ~LLBakingProcess() {} + + //virtual std::string getProcessName() const = 0; + virtual void process(LLSD& input, std::ostream& output) = 0; + +protected: + LLAppAppearanceUtility* mApp; +}; + + +#endif /* LL_LLBAKINGPROCESS_H */ + diff --git a/indra/appearance_utility/llbakingshadermgr.cpp b/indra/appearance_utility/llbakingshadermgr.cpp new file mode 100644 index 0000000000..a858fc760f --- /dev/null +++ b/indra/appearance_utility/llbakingshadermgr.cpp @@ -0,0 +1,226 @@ + +/** + * @file LLBakingShaderMgr.cpp + * @brief Viewer shader manager implementation. + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * 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 + * $/LicenseInfo$ + */ + + +#include "linden_common.h" + +#include "llbakingshadermgr.h" + +#include "lldir.h" +#include "llfile.h" +#include "llrender.h" +#include "llvertexbuffer.h" + +#if LL_DARWIN +#include "OpenGL/OpenGL.h" +#endif + +#ifdef LL_RELEASE_FOR_DOWNLOAD +#define UNIFORM_ERRS LL_WARNS_ONCE("Shader") +#else +#define UNIFORM_ERRS LL_ERRS("Shader") +#endif + +// Lots of STL stuff in here, using namespace std to keep things more readable +using std::vector; +using std::pair; +using std::make_pair; +using std::string; + +BOOL LLBakingShaderMgr::sInitialized = FALSE; +bool LLBakingShaderMgr::sSkipReload = false; + +//utility shaders +LLGLSLShader gAlphaMaskProgram; + + +LLBakingShaderMgr::LLBakingShaderMgr() : + mVertexShaderLevel(SHADER_COUNT, 0), + mMaxAvatarShaderLevel(0) +{ +} + +LLBakingShaderMgr::~LLBakingShaderMgr() +{ + mVertexShaderLevel.clear(); + mShaderList.clear(); +} + +// static +LLBakingShaderMgr * LLBakingShaderMgr::instance() +{ + if(NULL == sInstance) + { + sInstance = new LLBakingShaderMgr(); + } + + return static_cast<LLBakingShaderMgr*>(sInstance); +} + +void LLBakingShaderMgr::initAttribsAndUniforms(void) +{ + if (mReservedAttribs.empty()) + { + LLShaderMgr::initAttribsAndUniforms(); + } +} + + +//============================================================================ +// Set Levels + +S32 LLBakingShaderMgr::getVertexShaderLevel(S32 type) +{ + return mVertexShaderLevel[type]; +} + +//============================================================================ +// Shader Management + +void LLBakingShaderMgr::setShaders() +{ + //setShaders might be called redundantly by gSavedSettings, so return on reentrance + static bool reentrance = false; + + if (!sInitialized || reentrance || sSkipReload) + { + return; + } + + LLGLSLShader::sIndexedTextureChannels = llmax(gGLManager.mNumTextureImageUnits, 1); + + //NEVER use more than 16 texture channels (work around for prevalent driver bug) + LLGLSLShader::sIndexedTextureChannels = llmin(LLGLSLShader::sIndexedTextureChannels, 16); + + if (gGLManager.mGLSLVersionMajor < 1 || + (gGLManager.mGLSLVersionMajor == 1 && gGLManager.mGLSLVersionMinor <= 20)) + { //NEVER use indexed texture rendering when GLSL version is 1.20 or earlier + LLGLSLShader::sIndexedTextureChannels = 1; + } + + reentrance = true; + + //setup preprocessor definitions + LLShaderMgr::instance()->mDefinitions["NUM_TEX_UNITS"] = llformat("%d", gGLManager.mNumTextureImageUnits); + + // Make sure the compiled shader map is cleared before we recompile shaders. + mShaderObjects.clear(); + + initAttribsAndUniforms(); + + // Shaders + LL_INFOS("ShaderLoading") << "\n~~~~~~~~~~~~~~~~~~\n Loading Shaders:\n~~~~~~~~~~~~~~~~~~" << LL_ENDL; + LL_INFOS("ShaderLoading") << llformat("Using GLSL %d.%d", gGLManager.mGLSLVersionMajor, gGLManager.mGLSLVersionMinor) << llendl; + + for (S32 i = 0; i < SHADER_COUNT; i++) + { + mVertexShaderLevel[i] = 0; + } + mMaxAvatarShaderLevel = 0; + + LLGLSLShader::sNoFixedFunction = false; + LLVertexBuffer::unbind(); + if (gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 10) + { + //using shaders, disable fixed function + LLGLSLShader::sNoFixedFunction = true; + + //gPipeline.mVertexShadersEnabled = TRUE; + //gPipeline.mVertexShadersLoaded = 1; + + loadShadersInterface(); + } + else + { + LLGLSLShader::sNoFixedFunction = false; + //gPipeline.mVertexShadersEnabled = FALSE; + //gPipeline.mVertexShadersLoaded = 0; + mVertexShaderLevel[SHADER_LIGHTING] = 0; + mVertexShaderLevel[SHADER_INTERFACE] = 0; + mVertexShaderLevel[SHADER_ENVIRONMENT] = 0; + mVertexShaderLevel[SHADER_WATER] = 0; + mVertexShaderLevel[SHADER_OBJECT] = 0; + mVertexShaderLevel[SHADER_EFFECT] = 0; + mVertexShaderLevel[SHADER_WINDLIGHT] = 0; + mVertexShaderLevel[SHADER_AVATAR] = 0; + } + + //gPipeline.createGLBuffers(); + + reentrance = false; +} + +void LLBakingShaderMgr::unloadShaders() +{ + gAlphaMaskProgram.unload(); + + mVertexShaderLevel[SHADER_INTERFACE] = 0; + + //gPipeline.mVertexShadersLoaded = 0; +} + +BOOL LLBakingShaderMgr::loadShadersInterface() +{ + BOOL success = TRUE; + + if (success) + { + gAlphaMaskProgram.mName = "Alpha Mask Shader"; + gAlphaMaskProgram.mShaderFiles.clear(); + gAlphaMaskProgram.mShaderFiles.push_back(make_pair("interface/alphamaskV.glsl", GL_VERTEX_SHADER_ARB)); + gAlphaMaskProgram.mShaderFiles.push_back(make_pair("interface/alphamaskF.glsl", GL_FRAGMENT_SHADER_ARB)); + gAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gAlphaMaskProgram.createShader(NULL, NULL); + } + + if( !success ) + { + mVertexShaderLevel[SHADER_INTERFACE] = 0; + return FALSE; + } + + return TRUE; +} + +std::string LLBakingShaderMgr::getShaderDirPrefix(void) +{ + return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "shaders/class"); +} + +void LLBakingShaderMgr::updateShaderUniforms(LLGLSLShader * shader) +{ +} + +LLBakingShaderMgr::shader_iter LLBakingShaderMgr::beginShaders() const +{ + return mShaderList.begin(); +} + +LLBakingShaderMgr::shader_iter LLBakingShaderMgr::endShaders() const +{ + return mShaderList.end(); +} diff --git a/indra/appearance_utility/llbakingshadermgr.h b/indra/appearance_utility/llbakingshadermgr.h new file mode 100644 index 0000000000..88d43ab769 --- /dev/null +++ b/indra/appearance_utility/llbakingshadermgr.h @@ -0,0 +1,137 @@ +/** + * @file llbakingshadermgr.h + * @brief Texture Baking Shader Manager + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + +#ifndef LL_BAKING_SHADER_MGR_H +#define LL_BAKING_SHADER_MGR_H + +#include "llshadermgr.h" + +class LLBakingShaderMgr: public LLShaderMgr +{ +public: + static BOOL sInitialized; + static bool sSkipReload; + + LLBakingShaderMgr(); + /* virtual */ ~LLBakingShaderMgr(); + + // singleton pattern implementation + static LLBakingShaderMgr * instance(); + + void initAttribsAndUniforms(void); + void setShaders(); + void unloadShaders(); + S32 getVertexShaderLevel(S32 type); + BOOL loadShadersInterface(); + + std::vector<S32> mVertexShaderLevel; + S32 mMaxAvatarShaderLevel; + + enum EShaderClass + { + SHADER_LIGHTING, + SHADER_OBJECT, + SHADER_AVATAR, + SHADER_ENVIRONMENT, + SHADER_INTERFACE, + SHADER_EFFECT, + SHADER_WINDLIGHT, + SHADER_WATER, + SHADER_DEFERRED, + SHADER_TRANSFORM, + SHADER_COUNT + }; + + // simple model of forward iterator + // http://www.sgi.com/tech/stl/ForwardIterator.html + class shader_iter + { + private: + friend bool operator == (shader_iter const & a, shader_iter const & b); + friend bool operator != (shader_iter const & a, shader_iter const & b); + + typedef std::vector<LLGLSLShader *>::const_iterator base_iter_t; + public: + shader_iter() + { + } + + shader_iter(base_iter_t iter) : mIter(iter) + { + } + + LLGLSLShader & operator * () const + { + return **mIter; + } + + LLGLSLShader * operator -> () const + { + return *mIter; + } + + shader_iter & operator++ () + { + ++mIter; + return *this; + } + + shader_iter operator++ (int) + { + return mIter++; + } + + private: + base_iter_t mIter; + }; + + shader_iter beginShaders() const; + shader_iter endShaders() const; + + /* virtual */ std::string getShaderDirPrefix(void); + + /* virtual */ void updateShaderUniforms(LLGLSLShader * shader); + +private: + + // the list of shaders we need to propagate parameters to. + std::vector<LLGLSLShader *> mShaderList; + +}; //LLBakingShaderMgr + +inline bool operator == (LLBakingShaderMgr::shader_iter const & a, LLBakingShaderMgr::shader_iter const & b) +{ + return a.mIter == b.mIter; +} + +inline bool operator != (LLBakingShaderMgr::shader_iter const & a, LLBakingShaderMgr::shader_iter const & b) +{ + return a.mIter != b.mIter; +} + +extern LLVector4 gShinyOrigin; + +#endif // LL_BAKING_SHADER_MGR_H diff --git a/indra/appearance_utility/llbakingtexlayer.cpp b/indra/appearance_utility/llbakingtexlayer.cpp new file mode 100644 index 0000000000..38fbd7c557 --- /dev/null +++ b/indra/appearance_utility/llbakingtexlayer.cpp @@ -0,0 +1,51 @@ +/** + * @file llbakingtexlayer.cpp + * @brief Implementation of LLBakingTexLayer class + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llbakingtexlayer.h" + +LLBakingTexLayerSet::LLBakingTexLayerSet(LLAvatarAppearance* const appearance) : + LLTexLayerSet(appearance) +{ +} + +// virtual +LLBakingTexLayerSet::~LLBakingTexLayerSet() +{ +} + +// Ignored. +void LLBakingTexLayerSet::requestUpdate() +{ +} + +void LLBakingTexLayerSet::createComposite() +{ + llerrs << "TODO: Create a composite." << llendl; +} + + diff --git a/indra/appearance_utility/llbakingtexlayer.h b/indra/appearance_utility/llbakingtexlayer.h new file mode 100644 index 0000000000..2ed9863d4a --- /dev/null +++ b/indra/appearance_utility/llbakingtexlayer.h @@ -0,0 +1,43 @@ +/** + * @file llbakingtexlayer.h + * @brief Declaration of LLBakingTexLayerSet. + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + +#ifndef LL_LLBAKINGTEXLAYER_H +#define LL_LLBAKINGTEXLAYER_H + +#include "lltexlayer.h" + +class LLBakingTexLayerSet : public LLTexLayerSet +{ +public: + LLBakingTexLayerSet(LLAvatarAppearance* const appearance); + virtual ~LLBakingTexLayerSet(); + + /*virtual*/void requestUpdate(); + /*virtual*/void createComposite(); +}; + +#endif /* LL_LLBAKINGTEXLAYER_H */ + diff --git a/indra/appearance_utility/llprocessparams.cpp b/indra/appearance_utility/llprocessparams.cpp new file mode 100644 index 0000000000..723bae0dd6 --- /dev/null +++ b/indra/appearance_utility/llprocessparams.cpp @@ -0,0 +1,53 @@ +/** + * @file llprocessparams.cpp + * @brief Implementation of LLProcessParams class. + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + +// linden includes +#include "linden_common.h" + +#include "llsd.h" +#include "llsdserialize.h" +#include "llsdutil.h" + +// appearance includes +#include "llwearabledata.h" + +// project includes +#include "llappappearanceutility.h" +#include "llbakingavatar.h" +#include "llprocessparams.h" + +void LLProcessParams::process(LLSD& input, std::ostream& output) +{ + LLWearableData wearable_data; + LLBakingAvatar avatar(&wearable_data); + avatar.initInstance(); + + LLSD result; + result["success"] = true; + result["input"] = input; + output << LLSDOStreamer<LLSDXMLFormatter>(result); +} + diff --git a/indra/appearance_utility/llprocessparams.h b/indra/appearance_utility/llprocessparams.h new file mode 100644 index 0000000000..d1e64cb4f0 --- /dev/null +++ b/indra/appearance_utility/llprocessparams.h @@ -0,0 +1,42 @@ +/** + * @file llprocessparams.h + * @brief Declaration of LLProcessParams class. + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + * $/LicenseInfo$ + */ + +#ifndef LL_LLPROCESSPARAMS_H +#define LL_LLPROCESSPARAMS_H + +#include "llbakingprocess.h" + +class LLProcessParams : public LLBakingProcess +{ +public: + LLProcessParams(LLAppAppearanceUtility* app) : + LLBakingProcess(app) {} + + /*virtual*/ void process(LLSD& intput, std::ostream& output); +}; + +#endif /* LL_LLPROCESSPARAMS_H */ + diff --git a/indra/appearance_utility/wrapper.sh b/indra/appearance_utility/wrapper.sh new file mode 100755 index 0000000000..87d2179a13 --- /dev/null +++ b/indra/appearance_utility/wrapper.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Simple wrapper for secondlife utilities. + +## - Avoids an often-buggy X feature that doesn't really benefit us anyway. +export SDL_VIDEO_X11_DGAMOUSE=0 + +## - Works around a problem with misconfigured 64-bit systems not finding GL +export LIBGL_DRIVERS_PATH="${LIBGL_DRIVERS_PATH}":/usr/lib64/dri:/usr/lib32/dri:/usr/lib/dri + +## - The 'scim' GTK IM module widely crashes the viewer. Avoid it. +if [ "$GTK_IM_MODULE" = "scim" ]; then + export GTK_IM_MODULE=xim +fi + +EXECUTABLE="$(basename "$0")-bin" +SCRIPTSRC="$(readlink -f "$0" || echo "$0")" +RUN_PATH="$(dirname "${SCRIPTSRC}" || echo .)" +cd "${RUN_PATH}" + +export LD_LIBRARY_PATH="$PWD/lib:${LD_LIBRARY_PATH}" + +# Run the program. +"./$EXECUTABLE" "$@" +exit $? |