blender_anki_additions.patch 9.9 KB

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