blender_anki_additions.patch 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp
  2. index 13dc1ed..77d6a6e 100644
  3. --- a/source/blender/collada/EffectExporter.cpp
  4. +++ b/source/blender/collada/EffectExporter.cpp
  5. @@ -46,7 +46,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. @@ -169,6 +171,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. @@ -397,6 +419,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..00c909d 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,127 @@ 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. + NULL};
  138. +
  139. + ID *mesh_id = (ID*)ob->data;
  140. + IDProperty *rprop = mesh_id->properties;
  141. + while (rprop) {
  142. + if (rprop->type == IDP_GROUP) {
  143. + const char **iter = property_names;
  144. + while (*iter != NULL) {
  145. + const char *prop_name = *iter;
  146. + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name);
  147. +
  148. + if (prop) {
  149. + const char *value = NULL;
  150. + float valuef = 0.0;
  151. + bool ok = true;
  152. +
  153. + if(prop->type == IDP_STRING) {
  154. + value = IDP_String(prop);
  155. + }
  156. + else if (prop->type == IDP_FLOAT) {
  157. + valuef = IDP_Float(prop);
  158. + }
  159. + else if (prop->type == IDP_DOUBLE) {
  160. + valuef = IDP_Double(prop);
  161. + }
  162. + else if (prop->type == IDP_INT) {
  163. + valuef = IDP_Int(prop);
  164. + }
  165. + else {
  166. + printf("Property value type cannot be handled\n");
  167. + ok = false;
  168. + }
  169. +
  170. + if (ok) {
  171. + if (value) {
  172. + printf("Found %s property \"%s\"\n", prop_name, value);
  173. +
  174. + std::string str = std::string("<") + prop_name + ">" + value + "</" + prop_name + ">";
  175. + mSW->appendTextBlock(str.c_str());
  176. + }
  177. + else {
  178. + printf("Found %s property \"%f\"\n", prop_name, valuef);
  179. +
  180. + std::stringstream ss;
  181. + ss << "<" << prop_name << ">" << valuef << "</" << prop_name << ">";
  182. + mSW->appendTextBlock(ss.str().c_str());
  183. + }
  184. + }
  185. + } // end found
  186. +
  187. + ++iter;
  188. + } // end iterate property_names
  189. + } // end group
  190. +
  191. + rprop = rprop->next;
  192. + }
  193. + }
  194. +
  195. closeMesh();
  196. if (me->flag & ME_TWOSIDED) {
  197. mSW->appendTextBlock("<extra><technique profile=\"MAYA\"><double_sided>1</double_sided></technique></extra>");
  198. }
  199. + // AnKi: Export object properties
  200. + {
  201. + static const char *property_names[] = {
  202. + "add some",
  203. + NULL};
  204. + IDProperty *rprop = ob->id.properties;
  205. + while (rprop) {
  206. + if (rprop->type == IDP_GROUP) {
  207. + // Search properties
  208. + const char **iter = property_names;
  209. + while (*iter != NULL) {
  210. + const char *prop_name = *iter;
  211. + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name);
  212. +
  213. + if (prop) {
  214. + const char *value = NULL;
  215. +
  216. + if(prop->type == IDP_STRING) {
  217. + value = IDP_String(prop);
  218. + }
  219. + else {
  220. + printf("Property's value is not string\n");
  221. + }
  222. +
  223. + if (value) {
  224. + printf("Found %s property \"%s\"\n", prop_name, value);
  225. +
  226. + std::string str = std::string("<") + prop_name + ">" + value + "</" + prop_name + ">";
  227. + mSW->appendTextBlock(str.c_str());
  228. + }
  229. + else {
  230. + printf("Value error in %s property\n", prop_name);
  231. + }
  232. + } // end found
  233. +
  234. + ++iter;
  235. + } // end iterate property_names
  236. + } // end group
  237. +
  238. + rprop = rprop->next;
  239. + }
  240. + }
  241. +
  242. closeGeometry();
  243. if (this->export_settings->include_shapekeys) {
  244. diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp
  245. index ff50abf..205f687 100644
  246. --- a/source/blender/collada/LightExporter.cpp
  247. +++ b/source/blender/collada/LightExporter.cpp
  248. @@ -31,6 +31,9 @@
  249. #include "COLLADASWLight.h"
  250. #include "BLI_math.h"
  251. +extern "C" {
  252. +#include "BKE_idprop.h"
  253. +}
  254. #include "LightExporter.h"
  255. #include "collada_internal.h"
  256. @@ -107,6 +110,7 @@ void LightsExporter::operator()(Object *ob)
  257. cla.setLinearAttenuation(linatt);
  258. cla.setQuadraticAttenuation(quadatt);
  259. exportBlenderProfile(cla, la);
  260. + cla.addExtraTechniqueParameter("FCOLLADA", "outer_cone", RAD2DEGF(la->spotsize)); // AnKi: Add cone angle
  261. addLight(cla);
  262. }
  263. // lamp
  264. @@ -190,6 +194,49 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la)
  265. cla.addExtraTechniqueParameter("blender", "skyblendfac", la->skyblendfac);
  266. cla.addExtraTechniqueParameter("blender", "sky_exposure", la->sky_exposure);
  267. cla.addExtraTechniqueParameter("blender", "sky_colorspace", la->sky_colorspace);
  268. -
  269. +
  270. + // AnKi: Export properties
  271. + static const char *property_names[] = {
  272. + "lens_flare",
  273. + "lens_flare_first_sprite_size",
  274. + "lens_flare_color",
  275. + "specular_color",
  276. + "shadow",
  277. + "light_event_intensity",
  278. + "light_event_frequency",
  279. + NULL};
  280. + IDProperty *rprop = la->id.properties;
  281. + while (rprop) {
  282. + if (rprop->type == IDP_GROUP) {
  283. + // Search properties
  284. + const char **iter = property_names;
  285. + while (*iter != NULL) {
  286. + const char *prop_name = *iter;
  287. + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name);
  288. +
  289. + if (prop) {
  290. + const char *value = NULL;
  291. +
  292. + if(prop->type == IDP_STRING) {
  293. + value = IDP_String(prop);
  294. + }
  295. +
  296. + if (value) {
  297. + printf("Found %s property \"%s\"\n", prop_name, value);
  298. +
  299. + cla.addExtraTechniqueParameter("blender", prop_name, COLLADASW::String(value));
  300. + }
  301. + else {
  302. + printf("Value error in %s property\n", prop_name);
  303. + }
  304. + } // end found
  305. +
  306. + ++iter;
  307. + } // end iterate property_names
  308. + } // end group
  309. +
  310. + rprop = rprop->next;
  311. + }
  312. +
  313. return true;
  314. }
  315. diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
  316. index 30cd6dd..17563dd 100644
  317. --- a/source/blender/collada/SceneExporter.cpp
  318. +++ b/source/blender/collada/SceneExporter.cpp
  319. @@ -28,6 +28,7 @@ extern "C" {
  320. #include "BLI_utildefines.h"
  321. #include "BKE_object.h"
  322. #include "BLI_listbase.h"
  323. + #include "BKE_group.h"
  324. }
  325. #include "SceneExporter.h"
  326. @@ -234,6 +235,14 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
  327. }
  328. }
  329. + // AnKi: Export group
  330. + Group *group = BKE_group_object_find(NULL, ob);
  331. + if (group) {
  332. + colladaNode.addExtraTechniqueParameter("blender", "group", COLLADASW::String(group->id.name));
  333. + } else {
  334. + colladaNode.addExtraTechniqueParameter("blender", "group", COLLADASW::String("none"));
  335. + }
  336. +
  337. for (std::list<Object *>::iterator i = child_objects.begin(); i != child_objects.end(); ++i) {
  338. if (bc_is_marked(*i)) {
  339. bc_remove_mark(*i);