blender_anki_additions.patch 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp
  2. index 76b5114..6b87128 100644
  3. --- a/source/blender/collada/EffectExporter.cpp
  4. +++ b/source/blender/collada/EffectExporter.cpp
  5. @@ -47,7 +47,9 @@ extern "C" {
  6. #include "BKE_customdata.h"
  7. #include "BKE_mesh.h"
  8. #include "BKE_material.h"
  9. + #include "BKE_idprop.h"
  10. }
  11. +#include <sstream>
  12. // OB_MESH is assumed
  13. static std::string getActiveUVLayerName(Object *ob)
  14. @@ -170,6 +172,26 @@ void EffectsExporter::writeTextures(COLLADASW::EffectProfile &ep,
  15. texture.setChildElementName("bump");
  16. ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture));
  17. }
  18. + // AnKi: Add some textures
  19. + if (t->mapto & MAP_HAR) {
  20. + COLLADASW::Texture texture(key);
  21. + texture.setTexcoord(uvname);
  22. + texture.setSampler(*sampler);
  23. + texture.setProfileName("blender");
  24. + texture.setChildElementName("roughness");
  25. + ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture));
  26. + }
  27. + if (t->mapto & MAP_DISPLACE) {
  28. + COLLADASW::Texture texture(key);
  29. + texture.setTexcoord(uvname);
  30. + texture.setSampler(*sampler);
  31. + texture.setProfileName("blender");
  32. + texture.setChildElementName("height");
  33. + ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture));
  34. + }
  35. + if ((t->mapto & MAP_COLMIR) || (t->mapto & MAP_RAYMIRR)) {
  36. + ep.setReflective(createTexture(ima, uvname, sampler));
  37. + }
  38. }
  39. void EffectsExporter::operator()(Material *ma, Object *ob)
  40. @@ -398,6 +420,67 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
  41. }
  42. }
  43. + // AnKi: Export extra properties
  44. + static const char *property_names[] = {
  45. + "diffuse_texture_detail",
  46. + "normal_texture_detail",
  47. + "material_override",
  48. + "metallic",
  49. + "roughness",
  50. + NULL};
  51. + IDProperty *rprop = ma->id.properties;
  52. + while (rprop) {
  53. + if (rprop->type == IDP_GROUP) {
  54. + // Search properties
  55. + const char **iter = property_names;
  56. + while (*iter != NULL) {
  57. + const char *prop_name = *iter;
  58. + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name);
  59. +
  60. + if (prop) {
  61. + const char *value = NULL;
  62. + float valuef = 0.0;
  63. + bool ok = true;
  64. +
  65. + if(prop->type == IDP_STRING) {
  66. + value = IDP_String(prop);
  67. + }
  68. + else if (prop->type == IDP_FLOAT) {
  69. + valuef = IDP_Float(prop);
  70. + }
  71. + else if (prop->type == IDP_DOUBLE) {
  72. + valuef = IDP_Double(prop);
  73. + }
  74. + else if (prop->type == IDP_INT) {
  75. + valuef = IDP_Int(prop);
  76. + }
  77. + else {
  78. + printf("Property value type cannot be handled\n");
  79. + ok = false;
  80. + }
  81. +
  82. + if (ok)
  83. + {
  84. + if (value) {
  85. + printf("Found %s property \"%s\"\n", prop_name, value);
  86. + ep.addExtraTechniqueParameter("blender", prop_name, COLLADASW::String(value));
  87. + }
  88. + else {
  89. + printf("Found %s property %f\n", prop_name, valuef);
  90. + std::stringstream ss;
  91. + ss << valuef;
  92. + ep.addExtraTechniqueParameter("blender", prop_name, COLLADASW::String(ss.str()));
  93. + }
  94. + }
  95. + } // end found
  96. +
  97. + ++iter;
  98. + } // end iterate property_names
  99. + } // end group
  100. +
  101. + rprop = rprop->next;
  102. + }
  103. +
  104. // performs the actual writing
  105. ep.addProfileElements();
  106. bool twoSided = false;
  107. diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp
  108. index 7c7c57f..b02ba47 100644
  109. --- a/source/blender/collada/GeometryExporter.cpp
  110. +++ b/source/blender/collada/GeometryExporter.cpp
  111. @@ -47,6 +47,7 @@ extern "C" {
  112. #include "BKE_customdata.h"
  113. #include "BKE_material.h"
  114. #include "BKE_mesh.h"
  115. + #include "BKE_idprop.h"
  116. }
  117. #include "collada_internal.h"
  118. @@ -143,13 +144,133 @@ void GeometryExporter::operator()(Object *ob)
  119. createPolylist(0, has_uvs, has_color, ob, me, geom_id, norind);
  120. }
  121. }
  122. -
  123. +
  124. + // AnKi: Export mesh properties
  125. + {
  126. + static const char *property_names[] = {
  127. + "particles",
  128. + "collision",
  129. + "sector",
  130. + "portal",
  131. + "lod1",
  132. + "skip",
  133. + "reflection_probe",
  134. + "reflection_proxy",
  135. + "occluder",
  136. + "collision_mesh",
  137. + "decal_diffuse_atlas",
  138. + "decal_diffuse_sub_texture",
  139. + "decal_diffuse_factor",
  140. + "decal_normal_roughness_atlas",
  141. + "decal_normal_roughness_sub_texture",
  142. + "decal_normal_roughness_factor",
  143. + NULL};
  144. +
  145. + ID *mesh_id = (ID*)ob->data;
  146. + IDProperty *rprop = mesh_id->properties;
  147. + while (rprop) {
  148. + if (rprop->type == IDP_GROUP) {
  149. + const char **iter = property_names;
  150. + while (*iter != NULL) {
  151. + const char *prop_name = *iter;
  152. + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name);
  153. +
  154. + if (prop) {
  155. + const char *value = NULL;
  156. + float valuef = 0.0;
  157. + bool ok = true;
  158. +
  159. + if(prop->type == IDP_STRING) {
  160. + value = IDP_String(prop);
  161. + }
  162. + else if (prop->type == IDP_FLOAT) {
  163. + valuef = IDP_Float(prop);
  164. + }
  165. + else if (prop->type == IDP_DOUBLE) {
  166. + valuef = IDP_Double(prop);
  167. + }
  168. + else if (prop->type == IDP_INT) {
  169. + valuef = IDP_Int(prop);
  170. + }
  171. + else {
  172. + printf("Property value type cannot be handled\n");
  173. + ok = false;
  174. + }
  175. +
  176. + if (ok) {
  177. + if (value) {
  178. + printf("Found %s property \"%s\"\n", prop_name, value);
  179. +
  180. + std::string str = std::string("<") + prop_name + ">" + value + "</" + prop_name + ">";
  181. + mSW->appendTextBlock(str.c_str());
  182. + }
  183. + else {
  184. + printf("Found %s property \"%f\"\n", prop_name, valuef);
  185. +
  186. + std::stringstream ss;
  187. + ss << "<" << prop_name << ">" << valuef << "</" << prop_name << ">";
  188. + mSW->appendTextBlock(ss.str().c_str());
  189. + }
  190. + }
  191. + } // end found
  192. +
  193. + ++iter;
  194. + } // end iterate property_names
  195. + } // end group
  196. +
  197. + rprop = rprop->next;
  198. + }
  199. + }
  200. +
  201. closeMesh();
  202. if (me->flag & ME_TWOSIDED) {
  203. mSW->appendTextBlock("<extra><technique profile=\"MAYA\"><double_sided>1</double_sided></technique></extra>");
  204. }
  205. + // AnKi: Export object properties
  206. + {
  207. + static const char *property_names[] = {
  208. + "add some",
  209. + NULL};
  210. + IDProperty *rprop = ob->id.properties;
  211. + while (rprop) {
  212. + if (rprop->type == IDP_GROUP) {
  213. + // Search properties
  214. + const char **iter = property_names;
  215. + while (*iter != NULL) {
  216. + const char *prop_name = *iter;
  217. + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name);
  218. +
  219. + if (prop) {
  220. + const char *value = NULL;
  221. +
  222. + if(prop->type == IDP_STRING) {
  223. + value = IDP_String(prop);
  224. + }
  225. + else {
  226. + printf("Property's value is not string\n");
  227. + }
  228. +
  229. + if (value) {
  230. + printf("Found %s property \"%s\"\n", prop_name, value);
  231. +
  232. + std::string str = std::string("<") + prop_name + ">" + value + "</" + prop_name + ">";
  233. + mSW->appendTextBlock(str.c_str());
  234. + }
  235. + else {
  236. + printf("Value error in %s property\n", prop_name);
  237. + }
  238. + } // end found
  239. +
  240. + ++iter;
  241. + } // end iterate property_names
  242. + } // end group
  243. +
  244. + rprop = rprop->next;
  245. + }
  246. + }
  247. +
  248. closeGeometry();
  249. if (this->export_settings->include_shapekeys) {
  250. diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp
  251. index ff50abf..205f687 100644
  252. --- a/source/blender/collada/LightExporter.cpp
  253. +++ b/source/blender/collada/LightExporter.cpp
  254. @@ -31,6 +31,9 @@
  255. #include "COLLADASWLight.h"
  256. #include "BLI_math.h"
  257. +extern "C" {
  258. +#include "BKE_idprop.h"
  259. +}
  260. #include "LightExporter.h"
  261. #include "collada_internal.h"
  262. @@ -107,6 +110,7 @@ void LightsExporter::operator()(Object *ob)
  263. cla.setLinearAttenuation(linatt);
  264. cla.setQuadraticAttenuation(quadatt);
  265. exportBlenderProfile(cla, la);
  266. + cla.addExtraTechniqueParameter("FCOLLADA", "outer_cone", RAD2DEGF(la->spotsize)); // AnKi: Add cone angle
  267. addLight(cla);
  268. }
  269. // lamp
  270. @@ -190,6 +194,49 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la)
  271. cla.addExtraTechniqueParameter("blender", "skyblendfac", la->skyblendfac);
  272. cla.addExtraTechniqueParameter("blender", "sky_exposure", la->sky_exposure);
  273. cla.addExtraTechniqueParameter("blender", "sky_colorspace", la->sky_colorspace);
  274. -
  275. +
  276. + // AnKi: Export properties
  277. + static const char *property_names[] = {
  278. + "lens_flare",
  279. + "lens_flare_first_sprite_size",
  280. + "lens_flare_color",
  281. + "specular_color",
  282. + "shadow",
  283. + "light_event_intensity",
  284. + "light_event_frequency",
  285. + NULL};
  286. + IDProperty *rprop = la->id.properties;
  287. + while (rprop) {
  288. + if (rprop->type == IDP_GROUP) {
  289. + // Search properties
  290. + const char **iter = property_names;
  291. + while (*iter != NULL) {
  292. + const char *prop_name = *iter;
  293. + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name);
  294. +
  295. + if (prop) {
  296. + const char *value = NULL;
  297. +
  298. + if(prop->type == IDP_STRING) {
  299. + value = IDP_String(prop);
  300. + }
  301. +
  302. + if (value) {
  303. + printf("Found %s property \"%s\"\n", prop_name, value);
  304. +
  305. + cla.addExtraTechniqueParameter("blender", prop_name, COLLADASW::String(value));
  306. + }
  307. + else {
  308. + printf("Value error in %s property\n", prop_name);
  309. + }
  310. + } // end found
  311. +
  312. + ++iter;
  313. + } // end iterate property_names
  314. + } // end group
  315. +
  316. + rprop = rprop->next;
  317. + }
  318. +
  319. return true;
  320. }
  321. diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
  322. index 30cd6dd..17563dd 100644
  323. --- a/source/blender/collada/SceneExporter.cpp
  324. +++ b/source/blender/collada/SceneExporter.cpp
  325. @@ -28,6 +28,7 @@ extern "C" {
  326. #include "BLI_utildefines.h"
  327. #include "BKE_object.h"
  328. #include "BLI_listbase.h"
  329. + #include "BKE_group.h"
  330. }
  331. #include "SceneExporter.h"
  332. @@ -234,6 +235,14 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
  333. }
  334. }
  335. + // AnKi: Export group
  336. + Group *group = BKE_group_object_find(NULL, ob);
  337. + if (group) {
  338. + colladaNode.addExtraTechniqueParameter("blender", "group", COLLADASW::String(group->id.name));
  339. + } else {
  340. + colladaNode.addExtraTechniqueParameter("blender", "group", COLLADASW::String("none"));
  341. + }
  342. +
  343. for (std::list<Object *>::iterator i = child_objects.begin(); i != child_objects.end(); ++i) {
  344. if (bc_is_marked(*i)) {
  345. bc_remove_mark(*i);