Collada export, now with more awesome
* Added support for exporting textures * Added support for applying texture parameters * Added support for merging faces with same textures * Added support for skipping transparent faces
This commit is contained in:
@@ -17513,6 +17513,77 @@ This should be as low as possible, but too low may break functionality</string>
|
||||
<key>Value</key>
|
||||
<real>1280.0</real>
|
||||
</map>
|
||||
<key>ColladaExportFloaterRect</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Collada floater position</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Rect</string>
|
||||
<key>Value</key>
|
||||
<array>
|
||||
<integer>0</integer>
|
||||
<integer>0</integer>
|
||||
<integer>0</integer>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
</map>
|
||||
<key>DAEExportConsolidateMaterials</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Combine faces with same texture</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>1</integer>
|
||||
</map>
|
||||
<key>DAEExportSkipTransparent</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Skip exporting faces with default transparent texture or full transparent</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>1</integer>
|
||||
</map>
|
||||
<key>DAEExportTextures</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Export textures when exporting Collada</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
<key>DAEExportTextureParams</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Apply texture params suchs as repeats to the exported UV map</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>1</integer>
|
||||
</map>
|
||||
<key>DAEExportTexturesType</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Image file format to use when exporting Collada</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>S32</string>
|
||||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
</map>
|
||||
</llsd>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,48 +1,110 @@
|
||||
/**
|
||||
* @file daeexport.h
|
||||
* @brief A system which allows saving in-world objects to Collada .DAE files for offline texturizing/shading.
|
||||
* @authors Latif Khalifa
|
||||
*
|
||||
* $LicenseInfo:firstyear=2013&license=LGPLV2.1$
|
||||
* Copyright (C) 2013 Latif Khalifa
|
||||
*
|
||||
* 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; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
* @file daeexport.h
|
||||
* @brief A system which allows saving in-world objects to Collada .DAE files for offline texturizing/shading.
|
||||
* @authors Latif Khalifa
|
||||
*
|
||||
* $LicenseInfo:firstyear=2013&license=LGPLV2.1$
|
||||
* Copyright (C) 2013 Latif Khalifa
|
||||
*
|
||||
* 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; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef DAEEXPORT_H_
|
||||
#define DAEEXPORT_H_
|
||||
|
||||
#include <dom/domElements.h>
|
||||
#include "lltextureentry.h"
|
||||
|
||||
class LLViewerObject;
|
||||
|
||||
class DAESaver
|
||||
{
|
||||
typedef std::vector<std::pair<LLViewerObject*,std::string> > obj_info_t;
|
||||
|
||||
public:
|
||||
class MaterialInfo
|
||||
{
|
||||
public:
|
||||
LLUUID textureID;
|
||||
LLColor4 color;
|
||||
std::string name;
|
||||
|
||||
bool matches(LLTextureEntry* te)
|
||||
{
|
||||
return (textureID == te->getID()) && (color == te->getColor());
|
||||
}
|
||||
|
||||
bool operator== (const MaterialInfo& rhs)
|
||||
{
|
||||
return (textureID == rhs.textureID) && (color == rhs.color) && (name == rhs.name);
|
||||
}
|
||||
|
||||
bool operator!= (const MaterialInfo& rhs)
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
MaterialInfo()
|
||||
{
|
||||
}
|
||||
|
||||
MaterialInfo(const MaterialInfo& rhs)
|
||||
{
|
||||
textureID = rhs.textureID;
|
||||
color = rhs.color;
|
||||
name = rhs.name;
|
||||
}
|
||||
|
||||
MaterialInfo& operator= (const MaterialInfo& rhs)
|
||||
{
|
||||
textureID = rhs.textureID;
|
||||
color = rhs.color;
|
||||
name = rhs.name;
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
typedef std::vector<std::pair<LLViewerObject*,std::string> > obj_info_t;
|
||||
typedef std::vector<LLUUID> id_list_t;
|
||||
typedef std::vector<std::string> string_list_t;
|
||||
typedef std::vector<S32> int_list_t;
|
||||
typedef std::vector<MaterialInfo> material_list_t;
|
||||
|
||||
material_list_t mAllMaterials;
|
||||
id_list_t mTextures;
|
||||
string_list_t mTextureNames;
|
||||
obj_info_t mObjects;
|
||||
LLVector3 mOffset;
|
||||
std::string mImageFormat;
|
||||
S32 mTotalNumMaterials;
|
||||
|
||||
DAESaver();
|
||||
void Add(const LLViewerObject* prim, const std::string name);
|
||||
void updateTextureInfo();
|
||||
void add(const LLViewerObject* prim, const std::string name);
|
||||
bool saveDAE(std::string filename);
|
||||
|
||||
private:
|
||||
void transformTexCoord(S32 num_vert, LLVector2* coord, LLVector3* positions, LLVector3* normals, LLTextureEntry* te, LLVector3 scale);
|
||||
void addSource(daeElement* mesh, const char* src_id, std::string params, const std::vector<F32> &vals);
|
||||
void addPolygons(daeElement* mesh, const char* geomID, const char* materialID, LLViewerObject* obj, int face_to_include);
|
||||
void addPolygons(daeElement* mesh, const char* geomID, const char* materialID, LLViewerObject* obj, int_list_t* faces_to_include);
|
||||
bool skipFace(LLTextureEntry *te);
|
||||
MaterialInfo getMaterial(LLTextureEntry* te);
|
||||
void getMaterials(LLViewerObject* obj, material_list_t* ret);
|
||||
void getFacesWithMaterial(LLViewerObject* obj, MaterialInfo& mat, int_list_t* ret);
|
||||
void generateEffects(daeElement *effects);
|
||||
void generateImagesSection(daeElement* images);
|
||||
};
|
||||
|
||||
#endif // DAEEXPORT_H_
|
||||
|
||||
@@ -2891,24 +2891,18 @@ class LLObjectEnableExport : public view_listener_t
|
||||
{
|
||||
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
|
||||
{
|
||||
LLPermissions perms;
|
||||
bool new_value = LLSelectMgr::getInstance()->selectGetPermissions(perms) && perms.isOwned(); // At least one object, accumulated permissions of all objects.
|
||||
ExportPolicy export_policy = LFSimFeatureHandler::instance().exportPolicy();
|
||||
if (new_value && !(export_policy == ep_export_bit && (perms.getMaskEveryone() & PERM_EXPORT))) // No need to call allowExportBy if PERM_EXPORT is set on (all) root objects.
|
||||
bool can_export_any = false;
|
||||
LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
|
||||
for (LLObjectSelection::iterator node = selection->begin(); node != selection->end(); ++node)
|
||||
{
|
||||
bool can_export_any = false;
|
||||
LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
|
||||
for (LLObjectSelection::iterator node = selection->begin(); node != selection->end(); ++node)
|
||||
if ((*node)->mPermissions->allowExportBy(gAgent.getID(), export_policy))
|
||||
{
|
||||
if ((*node)->mPermissions->allowExportBy(gAgent.getID(), export_policy))
|
||||
{
|
||||
can_export_any = true;
|
||||
break;
|
||||
}
|
||||
can_export_any = true;
|
||||
break;
|
||||
}
|
||||
new_value = can_export_any;
|
||||
}
|
||||
gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
|
||||
gMenuHolder->findControl(userdata["control"].asString())->setValue(can_export_any);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
36
indra/newview/skins/default/xui/en-us/floater_dae_export.xml
Normal file
36
indra/newview/skins/default/xui/en-us/floater_dae_export.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||||
<floater name="Collada Export" title="Collada Export" width="600" height="260" can_close="true" can_minimize="true">
|
||||
<string name="texture_progress">Collada Export: Saving textures ([COUNT] remaining)</string>
|
||||
<text name="file name" follows="bottom|left" left="10" bottom="-48" height="20">File Name:</text>
|
||||
<line_editor name="file name editor" follows="bottom|left" left_delta="60" bottom_delta="4" width="360" height="20"/>
|
||||
<button name="browse button" label="Browse" follows="bottom|left" left_delta="363" bottom_delta="0" width="80" height="20">
|
||||
<button.commit_callback function="ColladaExport.FilePicker"/>
|
||||
</button>
|
||||
<button name="export button" label="Export" follows="bottom|left" left_delta="83" bottom_delta="0" width="80" height="20">
|
||||
<button.commit_callback function="ColladaExport.Export"/>
|
||||
</button>
|
||||
<panel border="true" left="10" bottom_delta="-88" height="80" width="200" follows="bottom|left" name="object info panel">
|
||||
<text name="Object info" bottom="-20" height="20" left="5">Object Info</text>
|
||||
<text name="Object Name" bottom_delta="-20" height="20" left="10">Name: [NAME]</text>
|
||||
<text name="Exportable Prims" bottom_delta="-20" height="20" left="10">Exportable Prims: [COUNT]/[TOTAL]</text>
|
||||
<text name="Exportable Textures" bottom_delta="-20" height="20">Exportable Textures: [COUNT]/[TOTAL]</text>
|
||||
</panel>
|
||||
<panel border="true" bottom_delta="-120" height="115" width="200" follows="bottom|left" name="options panel">
|
||||
<text name="Object info" bottom="-20" height="20" left="5">Options</text>
|
||||
<check_box name="texture export check" label="Export Textures" height="20" bottom_delta="-20" left="10" control_name="DAEExportTextures">
|
||||
<check_box.commit_callback function="ColladaExport.TextureExport"/>
|
||||
</check_box>
|
||||
<combo_box name="texture type combo" bottom_delta="0" left_delta="120" height="20" width="60" control_name="DAEExportTexturesType">
|
||||
<combo_item name="tga" value="0">TGA</combo_item>
|
||||
<combo_item name="png" value="1">PNG</combo_item>
|
||||
<combo_item name="j2c" value="2">J2C</combo_item>
|
||||
<combo_item name="bmp" value="3">BMP</combo_item>
|
||||
<combo_item name="jpg" value="4">JPG</combo_item>
|
||||
<combo_box.commit_callback function="ColladaExport.TextureTypeCombo" />
|
||||
</combo_box>
|
||||
<check_box name="consolidate check" label="Consolidate faces" tool_tip="Export faces that have the same texture as one" bottom_delta="-20" left="10" height="20" control_name="DAEExportConsolidateMaterials"/>
|
||||
<check_box name="skip transparent check" label="Skip transparent textures" bottom_delta="-20" height="20" control_name="DAEExportSkipTransparent"/>
|
||||
<check_box name="texture params check" label="Apply texture params" bottom_delta="-20" height="20" control_name="DAEExportTextureParams"/>
|
||||
</panel>
|
||||
<scroll_container name="textures container" follows="all" bottom="-252" left_delta="205" width="380" height="200"/>
|
||||
</floater>
|
||||
Reference in New Issue
Block a user