2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2010-10-07 00:24:42 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Jan Diederich, Tod Liverseed,
|
|
|
|
* Nathan Letwory
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:30:35 +00:00
|
|
|
/** \file blender/collada/EffectExporter.cpp
|
|
|
|
* \ingroup collada
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-10-07 00:24:42 +00:00
|
|
|
#include <map>
|
2012-06-22 16:16:58 +00:00
|
|
|
#include <set>
|
2010-10-07 00:24:42 +00:00
|
|
|
|
|
|
|
#include "COLLADASWEffectProfile.h"
|
2016-07-15 16:12:39 +02:00
|
|
|
#include "COLLADAFWColorOrTexture.h"
|
2010-10-07 00:24:42 +00:00
|
|
|
|
|
|
|
#include "EffectExporter.h"
|
2012-06-12 21:25:29 +00:00
|
|
|
#include "DocumentExporter.h"
|
2010-10-07 00:24:42 +00:00
|
|
|
#include "MaterialExporter.h"
|
|
|
|
|
|
|
|
#include "collada_internal.h"
|
|
|
|
#include "collada_utils.h"
|
|
|
|
|
2012-08-12 17:13:07 +00:00
|
|
|
extern "C" {
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_texture_types.h"
|
|
|
|
#include "DNA_world_types.h"
|
|
|
|
|
|
|
|
#include "BKE_customdata.h"
|
|
|
|
#include "BKE_mesh.h"
|
|
|
|
#include "BKE_material.h"
|
|
|
|
}
|
|
|
|
|
2010-10-07 00:24:42 +00:00
|
|
|
// OB_MESH is assumed
|
|
|
|
static std::string getActiveUVLayerName(Object *ob)
|
|
|
|
{
|
2012-06-12 22:05:33 +00:00
|
|
|
Mesh *me = (Mesh *)ob->data;
|
2010-10-07 00:24:42 +00:00
|
|
|
|
|
|
|
int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
|
|
|
|
if (num_layers)
|
|
|
|
return std::string(bc_CustomData_get_active_layer_name(&me->fdata, CD_MTFACE));
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2012-06-12 22:05:33 +00:00
|
|
|
EffectsExporter::EffectsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryEffects(sw), export_settings(export_settings) {
|
|
|
|
}
|
2011-03-18 14:06:13 +00:00
|
|
|
|
|
|
|
bool EffectsExporter::hasEffects(Scene *sce)
|
|
|
|
{
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
BaseLegacy *base = (BaseLegacy *)sce->base.first;
|
2011-03-18 14:06:13 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
while (base) {
|
2012-06-12 22:05:33 +00:00
|
|
|
Object *ob = base->object;
|
2011-03-18 14:06:13 +00:00
|
|
|
int a;
|
2012-04-28 06:31:57 +00:00
|
|
|
for (a = 0; a < ob->totcol; a++) {
|
2012-06-12 22:05:33 +00:00
|
|
|
Material *ma = give_current_material(ob, a + 1);
|
2011-03-18 14:06:13 +00:00
|
|
|
|
|
|
|
// no material, but check all of the slots
|
|
|
|
if (!ma) continue;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2012-06-12 22:05:33 +00:00
|
|
|
base = base->next;
|
2011-03-18 14:06:13 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-07 18:23:30 +00:00
|
|
|
void EffectsExporter::exportEffects(Scene *sce)
|
2010-10-07 00:24:42 +00:00
|
|
|
{
|
2012-03-24 07:52:14 +00:00
|
|
|
if (hasEffects(sce)) {
|
2011-09-12 13:20:24 +00:00
|
|
|
this->scene = sce;
|
2011-03-18 14:06:13 +00:00
|
|
|
openLibrary();
|
|
|
|
MaterialFunctor mf;
|
2012-06-12 21:25:29 +00:00
|
|
|
mf.forEachMaterialInExportSet<EffectsExporter>(sce, *this, this->export_settings->export_set);
|
2010-10-07 00:24:42 +00:00
|
|
|
|
2011-03-18 14:06:13 +00:00
|
|
|
closeLibrary();
|
|
|
|
}
|
2010-10-07 00:24:42 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 15:28:56 +00:00
|
|
|
void EffectsExporter::writeBlinn(COLLADASW::EffectProfile &ep, Material *ma)
|
|
|
|
{
|
|
|
|
COLLADASW::ColorOrTexture cot;
|
|
|
|
ep.setShaderType(COLLADASW::EffectProfile::BLINN);
|
|
|
|
// shininess
|
2012-04-29 15:47:02 +00:00
|
|
|
ep.setShininess(ma->har, false, "shininess");
|
2011-03-22 15:28:56 +00:00
|
|
|
// specular
|
|
|
|
cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
|
2012-06-12 22:05:33 +00:00
|
|
|
ep.setSpecular(cot, false, "specular");
|
2011-03-22 15:28:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsExporter::writeLambert(COLLADASW::EffectProfile &ep, Material *ma)
|
|
|
|
{
|
|
|
|
COLLADASW::ColorOrTexture cot;
|
|
|
|
ep.setShaderType(COLLADASW::EffectProfile::LAMBERT);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsExporter::writePhong(COLLADASW::EffectProfile &ep, Material *ma)
|
|
|
|
{
|
|
|
|
COLLADASW::ColorOrTexture cot;
|
|
|
|
ep.setShaderType(COLLADASW::EffectProfile::PHONG);
|
|
|
|
// shininess
|
2012-06-12 22:05:33 +00:00
|
|
|
ep.setShininess(ma->har, false, "shininess");
|
2011-03-22 15:28:56 +00:00
|
|
|
// specular
|
|
|
|
cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
|
2012-06-12 22:05:33 +00:00
|
|
|
ep.setSpecular(cot, false, "specular");
|
2011-03-22 15:28:56 +00:00
|
|
|
}
|
|
|
|
|
2012-06-22 16:16:58 +00:00
|
|
|
void EffectsExporter::writeTextures(COLLADASW::EffectProfile &ep,
|
|
|
|
std::string &key,
|
|
|
|
COLLADASW::Sampler *sampler,
|
|
|
|
MTex *t, Image *ima,
|
|
|
|
std::string &uvname ) {
|
|
|
|
|
|
|
|
// Image not set for texture
|
|
|
|
if (!ima) return;
|
|
|
|
|
|
|
|
// color
|
2015-02-04 19:06:55 +01:00
|
|
|
if (t->mapto & MAP_COL) {
|
2012-06-22 16:16:58 +00:00
|
|
|
ep.setDiffuse(createTexture(ima, uvname, sampler), false, "diffuse");
|
|
|
|
}
|
|
|
|
// ambient
|
|
|
|
if (t->mapto & MAP_AMB) {
|
|
|
|
ep.setAmbient(createTexture(ima, uvname, sampler), false, "ambient");
|
|
|
|
}
|
|
|
|
// specular
|
2015-02-04 19:06:55 +01:00
|
|
|
if (t->mapto & (MAP_SPEC | MAP_COLSPEC)) {
|
2012-06-22 16:16:58 +00:00
|
|
|
ep.setSpecular(createTexture(ima, uvname, sampler), false, "specular");
|
|
|
|
}
|
|
|
|
// emission
|
|
|
|
if (t->mapto & MAP_EMIT) {
|
|
|
|
ep.setEmission(createTexture(ima, uvname, sampler), false, "emission");
|
|
|
|
}
|
|
|
|
// reflective
|
|
|
|
if (t->mapto & MAP_REF) {
|
|
|
|
ep.setReflective(createTexture(ima, uvname, sampler));
|
|
|
|
}
|
|
|
|
// alpha
|
|
|
|
if (t->mapto & MAP_ALPHA) {
|
|
|
|
ep.setTransparent(createTexture(ima, uvname, sampler));
|
|
|
|
}
|
|
|
|
// extension:
|
|
|
|
// Normal map --> Must be stored with <extra> tag as different technique,
|
|
|
|
// since COLLADA doesn't support normal maps, even in current COLLADA 1.5.
|
|
|
|
if (t->mapto & MAP_NORM) {
|
|
|
|
COLLADASW::Texture texture(key);
|
|
|
|
texture.setTexcoord(uvname);
|
|
|
|
texture.setSampler(*sampler);
|
|
|
|
// technique FCOLLADA, with the <bump> tag, is most likely the best understood,
|
|
|
|
// most widespread de-facto standard.
|
|
|
|
texture.setProfileName("FCOLLADA");
|
|
|
|
texture.setChildElementName("bump");
|
|
|
|
ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 00:24:42 +00:00
|
|
|
void EffectsExporter::operator()(Material *ma, Object *ob)
|
|
|
|
{
|
|
|
|
// create a list of indices to textures of type TEX_IMAGE
|
|
|
|
std::vector<int> tex_indices;
|
2012-07-08 21:37:59 +00:00
|
|
|
if (this->export_settings->include_material_textures)
|
2012-06-23 22:03:31 +00:00
|
|
|
createTextureIndices(ma, tex_indices);
|
2010-10-07 00:24:42 +00:00
|
|
|
|
|
|
|
openEffect(translate_id(id_name(ma)) + "-effect");
|
2015-03-05 19:33:59 +01:00
|
|
|
|
2010-10-07 00:24:42 +00:00
|
|
|
COLLADASW::EffectProfile ep(mSW);
|
|
|
|
ep.setProfileType(COLLADASW::EffectProfile::COMMON);
|
|
|
|
ep.openProfile();
|
2015-03-05 19:33:59 +01:00
|
|
|
// set shader type - one of three blinn, phong or lambert
|
|
|
|
if (ma->spec > 0.0f) {
|
|
|
|
if (ma->spec_shader == MA_SPEC_BLINN) {
|
|
|
|
writeBlinn(ep, ma);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// \todo figure out handling of all spec+diff shader combos blender has, for now write phong
|
|
|
|
// for now set phong in case spec shader is not blinn
|
|
|
|
writePhong(ep, ma);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-03-05 19:33:59 +01:00
|
|
|
if (ma->diff_shader == MA_DIFF_LAMBERT) {
|
|
|
|
writeLambert(ep, ma);
|
2011-03-22 22:00:26 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-03-05 19:33:59 +01:00
|
|
|
// \todo figure out handling of all spec+diff shader combos blender has, for now write phong
|
|
|
|
writePhong(ep, ma);
|
2011-03-22 22:00:26 +00:00
|
|
|
}
|
2010-10-07 00:24:42 +00:00
|
|
|
}
|
2015-03-05 19:33:59 +01:00
|
|
|
|
2010-10-07 00:24:42 +00:00
|
|
|
// index of refraction
|
|
|
|
if (ma->mode & MA_RAYTRANSP) {
|
2012-04-29 15:47:02 +00:00
|
|
|
ep.setIndexOfRefraction(ma->ang, false, "index_of_refraction");
|
2010-10-07 00:24:42 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-04-29 15:47:02 +00:00
|
|
|
ep.setIndexOfRefraction(1.0f, false, "index_of_refraction");
|
2010-10-07 00:24:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
COLLADASW::ColorOrTexture cot;
|
|
|
|
|
|
|
|
// transparency
|
|
|
|
if (ma->mode & MA_TRANSP) {
|
2015-03-05 19:33:59 +01:00
|
|
|
// Tod: because we are in A_ONE mode transparency is calculated like this:
|
2016-07-15 16:12:39 +02:00
|
|
|
cot = getcol(1.0f, 1.0f, 1.0f, ma->alpha);
|
|
|
|
ep.setTransparent(cot);
|
|
|
|
ep.setOpaque(COLLADASW::EffectProfile::A_ONE);
|
2010-10-07 00:24:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// emission
|
2015-03-05 19:33:59 +01:00
|
|
|
cot = getcol(ma->emit, ma->emit, ma->emit, 1.0f);
|
2012-04-29 15:47:02 +00:00
|
|
|
ep.setEmission(cot, false, "emission");
|
2010-10-07 00:24:42 +00:00
|
|
|
|
|
|
|
// diffuse multiplied by diffuse intensity
|
2015-03-05 19:33:59 +01:00
|
|
|
cot = getcol(ma->r * ma->ref, ma->g * ma->ref, ma->b * ma->ref, 1.0f);
|
|
|
|
ep.setDiffuse(cot, false, "diffuse");
|
2010-10-07 00:24:42 +00:00
|
|
|
|
|
|
|
// ambient
|
2011-09-12 13:20:24 +00:00
|
|
|
/* ma->ambX is calculated only on render, so lets do it here manually and not rely on ma->ambX. */
|
2015-03-05 19:33:59 +01:00
|
|
|
if (this->scene->world)
|
|
|
|
cot = getcol(this->scene->world->ambr * ma->amb, this->scene->world->ambg * ma->amb, this->scene->world->ambb * ma->amb, 1.0f);
|
|
|
|
else
|
2011-09-12 13:59:23 +00:00
|
|
|
cot = getcol(ma->amb, ma->amb, ma->amb, 1.0f);
|
|
|
|
|
2015-03-05 19:33:59 +01:00
|
|
|
ep.setAmbient(cot, false, "ambient");
|
2010-10-07 00:24:42 +00:00
|
|
|
|
|
|
|
// reflective, reflectivity
|
|
|
|
if (ma->mode & MA_RAYMIRROR) {
|
|
|
|
cot = getcol(ma->mirr, ma->mirg, ma->mirb, 1.0f);
|
|
|
|
ep.setReflective(cot);
|
|
|
|
ep.setReflectivity(ma->ray_mirror);
|
|
|
|
}
|
|
|
|
// else {
|
2012-06-12 22:05:33 +00:00
|
|
|
// cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
|
|
|
|
// ep.setReflective(cot);
|
|
|
|
// ep.setReflectivity(ma->spec);
|
2010-10-07 00:24:42 +00:00
|
|
|
// }
|
|
|
|
|
|
|
|
// specular
|
|
|
|
if (ep.getShaderType() != COLLADASW::EffectProfile::LAMBERT) {
|
2015-03-05 19:33:59 +01:00
|
|
|
cot = getcol(ma->specr * ma->spec, ma->specg * ma->spec, ma->specb * ma->spec, 1.0f);
|
|
|
|
ep.setSpecular(cot, false, "specular");
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2010-10-07 00:24:42 +00:00
|
|
|
|
|
|
|
// XXX make this more readable if possible
|
|
|
|
|
|
|
|
// create <sampler> and <surface> for each image
|
|
|
|
COLLADASW::Sampler samplers[MAX_MTEX];
|
|
|
|
//COLLADASW::Surface surfaces[MAX_MTEX];
|
|
|
|
//void *samp_surf[MAX_MTEX][2];
|
2015-02-04 19:06:55 +01:00
|
|
|
void *samp_surf[MAX_MTEX];
|
2010-10-07 00:24:42 +00:00
|
|
|
|
|
|
|
// image to index to samp_surf map
|
|
|
|
// samp_surf[index] stores 2 pointers, sampler and surface
|
|
|
|
std::map<std::string, int> im_samp_map;
|
|
|
|
|
|
|
|
unsigned int a, b;
|
|
|
|
for (a = 0, b = 0; a < tex_indices.size(); a++) {
|
|
|
|
MTex *t = ma->mtex[tex_indices[a]];
|
|
|
|
Image *ima = t->tex->ima;
|
|
|
|
|
|
|
|
// Image not set for texture
|
2012-03-24 07:52:14 +00:00
|
|
|
if (!ima) continue;
|
2010-10-07 00:24:42 +00:00
|
|
|
|
|
|
|
std::string key(id_name(ima));
|
|
|
|
key = translate_id(key);
|
|
|
|
|
|
|
|
// create only one <sampler>/<surface> pair for each unique image
|
|
|
|
if (im_samp_map.find(key) == im_samp_map.end()) {
|
|
|
|
// //<newparam> <surface> <init_from>
|
|
|
|
// COLLADASW::Surface surface(COLLADASW::Surface::SURFACE_TYPE_2D,
|
2012-06-12 22:05:33 +00:00
|
|
|
// key + COLLADASW::Surface::SURFACE_SID_SUFFIX);
|
2010-10-07 00:24:42 +00:00
|
|
|
// COLLADASW::SurfaceInitOption sio(COLLADASW::SurfaceInitOption::INIT_FROM);
|
|
|
|
// sio.setImageReference(key);
|
|
|
|
// surface.setInitOption(sio);
|
|
|
|
|
|
|
|
// COLLADASW::NewParamSurface surface(mSW);
|
|
|
|
// surface->setParamType(COLLADASW::CSW_SURFACE_TYPE_2D);
|
|
|
|
|
|
|
|
//<newparam> <sampler> <source>
|
|
|
|
COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D,
|
2012-06-12 22:05:33 +00:00
|
|
|
key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
|
|
|
|
key + COLLADASW::Sampler::SURFACE_SID_SUFFIX);
|
2010-10-07 00:24:42 +00:00
|
|
|
sampler.setImageId(key);
|
|
|
|
// copy values to arrays since they will live longer
|
|
|
|
samplers[a] = sampler;
|
|
|
|
//surfaces[a] = surface;
|
|
|
|
|
|
|
|
// store pointers so they can be used later when we create <texture>s
|
2015-02-04 19:06:55 +01:00
|
|
|
samp_surf[b] = &samplers[a];
|
2010-10-07 00:24:42 +00:00
|
|
|
//samp_surf[b][1] = &surfaces[a];
|
|
|
|
|
|
|
|
im_samp_map[key] = b;
|
|
|
|
b++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// used as fallback when MTex->uvname is "" (this is pretty common)
|
|
|
|
// it is indeed the correct value to use in that case
|
|
|
|
std::string active_uv(getActiveUVLayerName(ob));
|
|
|
|
|
|
|
|
// write textures
|
|
|
|
// XXX very slow
|
|
|
|
for (a = 0; a < tex_indices.size(); a++) {
|
|
|
|
MTex *t = ma->mtex[tex_indices[a]];
|
|
|
|
Image *ima = t->tex->ima;
|
|
|
|
|
2014-06-28 21:51:04 +02:00
|
|
|
if (!ima) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-10-07 00:24:42 +00:00
|
|
|
std::string key(id_name(ima));
|
|
|
|
key = translate_id(key);
|
|
|
|
int i = im_samp_map[key];
|
|
|
|
std::string uvname = strlen(t->uvname) ? t->uvname : active_uv;
|
2015-02-04 19:06:55 +01:00
|
|
|
COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)samp_surf[i];
|
2012-06-22 16:16:58 +00:00
|
|
|
writeTextures(ep, key, sampler, t, ima, uvname);
|
|
|
|
}
|
2010-10-07 00:24:42 +00:00
|
|
|
|
|
|
|
// performs the actual writing
|
|
|
|
ep.addProfileElements();
|
|
|
|
bool twoSided = false;
|
|
|
|
if (ob->type == OB_MESH && ob->data) {
|
2012-06-12 22:05:33 +00:00
|
|
|
Mesh *me = (Mesh *)ob->data;
|
2010-10-07 00:24:42 +00:00
|
|
|
if (me->flag & ME_TWOSIDED)
|
|
|
|
twoSided = true;
|
|
|
|
}
|
|
|
|
if (twoSided)
|
2011-03-23 00:03:52 +00:00
|
|
|
ep.addExtraTechniqueParameter("GOOGLEEARTH", "double_sided", 1);
|
2010-10-07 00:24:42 +00:00
|
|
|
ep.addExtraTechniques(mSW);
|
|
|
|
|
|
|
|
ep.closeProfile();
|
|
|
|
if (twoSided)
|
|
|
|
mSW->appendTextBlock("<extra><technique profile=\"MAX3D\"><double_sided>1</double_sided></technique></extra>");
|
2012-10-21 05:46:41 +00:00
|
|
|
closeEffect();
|
2010-10-07 00:24:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
COLLADASW::ColorOrTexture EffectsExporter::createTexture(Image *ima,
|
2012-06-12 22:05:33 +00:00
|
|
|
std::string& uv_layer_name,
|
|
|
|
COLLADASW::Sampler *sampler
|
|
|
|
/*COLLADASW::Surface *surface*/)
|
2010-10-07 00:24:42 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
COLLADASW::Texture texture(translate_id(id_name(ima)));
|
|
|
|
texture.setTexcoord(uv_layer_name);
|
|
|
|
//texture.setSurface(*surface);
|
|
|
|
texture.setSampler(*sampler);
|
|
|
|
|
|
|
|
COLLADASW::ColorOrTexture cot(texture);
|
|
|
|
return cot;
|
|
|
|
}
|
|
|
|
|
|
|
|
COLLADASW::ColorOrTexture EffectsExporter::getcol(float r, float g, float b, float a)
|
|
|
|
{
|
2012-04-29 15:47:02 +00:00
|
|
|
COLLADASW::Color color(r, g, b, a);
|
2010-10-07 00:24:42 +00:00
|
|
|
COLLADASW::ColorOrTexture cot(color);
|
|
|
|
return cot;
|
|
|
|
}
|
|
|
|
|
|
|
|
//returns the array of mtex indices which have image
|
|
|
|
//need this for exporting textures
|
|
|
|
void EffectsExporter::createTextureIndices(Material *ma, std::vector<int> &indices)
|
|
|
|
{
|
|
|
|
indices.clear();
|
|
|
|
|
|
|
|
for (int a = 0; a < MAX_MTEX; a++) {
|
|
|
|
if (ma->mtex[a] &&
|
2012-03-28 05:03:24 +00:00
|
|
|
ma->mtex[a]->tex &&
|
|
|
|
ma->mtex[a]->tex->type == TEX_IMAGE &&
|
|
|
|
ma->mtex[a]->texco == TEXCO_UV)
|
|
|
|
{
|
2010-10-07 00:24:42 +00:00
|
|
|
indices.push_back(a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|