Blender  V2.93
cycles_xml.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2013 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <stdio.h>
18 
19 #include <algorithm>
20 #include <iterator>
21 #include <sstream>
22 
23 #include "graph/node_xml.h"
24 
25 #include "render/background.h"
26 #include "render/camera.h"
27 #include "render/film.h"
28 #include "render/graph.h"
29 #include "render/integrator.h"
30 #include "render/light.h"
31 #include "render/mesh.h"
32 #include "render/nodes.h"
33 #include "render/object.h"
34 #include "render/osl.h"
35 #include "render/scene.h"
36 #include "render/shader.h"
37 
38 #include "subd/subd_patch.h"
39 #include "subd/subd_split.h"
40 
41 #include "util/util_foreach.h"
42 #include "util/util_path.h"
43 #include "util/util_projection.h"
44 #include "util/util_transform.h"
45 #include "util/util_xml.h"
46 
47 #include "app/cycles_xml.h"
48 
50 
51 /* XML reading state */
52 
53 struct XMLReadState : public XMLReader {
54  Scene *scene; /* scene pointer */
55  Transform tfm; /* current transform state */
56  bool smooth; /* smooth normal state */
57  Shader *shader; /* current shader */
58  string base; /* base path to current file*/
59  float dicing_rate; /* current dicing rate */
60 
62  {
64  }
65 };
66 
67 /* Attribute Reading */
68 
69 static bool xml_read_int(int *value, xml_node node, const char *name)
70 {
71  xml_attribute attr = node.attribute(name);
72 
73  if (attr) {
74  *value = atoi(attr.value());
75  return true;
76  }
77 
78  return false;
79 }
80 
81 static bool xml_read_int_array(vector<int> &value, xml_node node, const char *name)
82 {
83  xml_attribute attr = node.attribute(name);
84 
85  if (attr) {
86  vector<string> tokens;
87  string_split(tokens, attr.value());
88 
89  foreach (const string &token, tokens)
90  value.push_back(atoi(token.c_str()));
91 
92  return true;
93  }
94 
95  return false;
96 }
97 
98 static bool xml_read_float(float *value, xml_node node, const char *name)
99 {
100  xml_attribute attr = node.attribute(name);
101 
102  if (attr) {
103  *value = (float)atof(attr.value());
104  return true;
105  }
106 
107  return false;
108 }
109 
110 static bool xml_read_float_array(vector<float> &value, xml_node node, const char *name)
111 {
112  xml_attribute attr = node.attribute(name);
113 
114  if (attr) {
115  vector<string> tokens;
116  string_split(tokens, attr.value());
117 
118  foreach (const string &token, tokens)
119  value.push_back((float)atof(token.c_str()));
120 
121  return true;
122  }
123 
124  return false;
125 }
126 
127 static bool xml_read_float3(float3 *value, xml_node node, const char *name)
128 {
130 
131  if (xml_read_float_array(array, node, name) && array.size() == 3) {
132  *value = make_float3(array[0], array[1], array[2]);
133  return true;
134  }
135 
136  return false;
137 }
138 
139 static bool xml_read_float3_array(vector<float3> &value, xml_node node, const char *name)
140 {
142 
143  if (xml_read_float_array(array, node, name)) {
144  for (size_t i = 0; i < array.size(); i += 3)
145  value.push_back(make_float3(array[i + 0], array[i + 1], array[i + 2]));
146 
147  return true;
148  }
149 
150  return false;
151 }
152 
153 static bool xml_read_float4(float4 *value, xml_node node, const char *name)
154 {
156 
157  if (xml_read_float_array(array, node, name) && array.size() == 4) {
158  *value = make_float4(array[0], array[1], array[2], array[3]);
159  return true;
160  }
161 
162  return false;
163 }
164 
165 static bool xml_read_string(string *str, xml_node node, const char *name)
166 {
167  xml_attribute attr = node.attribute(name);
168 
169  if (attr) {
170  *str = attr.value();
171  return true;
172  }
173 
174  return false;
175 }
176 
177 static bool xml_equal_string(xml_node node, const char *name, const char *value)
178 {
179  xml_attribute attr = node.attribute(name);
180 
181  if (attr)
182  return string_iequals(attr.value(), value);
183 
184  return false;
185 }
186 
187 /* Camera */
188 
189 static void xml_read_camera(XMLReadState &state, xml_node node)
190 {
191  Camera *cam = state.scene->camera;
192 
193  int width = -1, height = -1;
194  xml_read_int(&width, node, "width");
195  xml_read_int(&height, node, "height");
196 
197  cam->set_full_width(width);
198  cam->set_full_height(height);
199 
200  xml_read_node(state, cam, node);
201 
202  cam->set_matrix(state.tfm);
203 
204  cam->need_flags_update = true;
205  cam->update(state.scene);
206 }
207 
208 /* Shader */
209 
210 static void xml_read_shader_graph(XMLReadState &state, Shader *shader, xml_node graph_node)
211 {
212  xml_read_node(state, shader, graph_node);
213 
214  ShaderGraph *graph = new ShaderGraph();
215 
216  /* local state, shader nodes can't link to nodes outside the shader graph */
217  XMLReader graph_reader;
218  graph_reader.node_map[ustring("output")] = graph->output();
219 
220  for (xml_node node = graph_node.first_child(); node; node = node.next_sibling()) {
221  ustring node_name(node.name());
222 
223  if (node_name == "connect") {
224  /* connect nodes */
225  vector<string> from_tokens, to_tokens;
226 
227  string_split(from_tokens, node.attribute("from").value());
228  string_split(to_tokens, node.attribute("to").value());
229 
230  if (from_tokens.size() == 2 && to_tokens.size() == 2) {
231  ustring from_node_name(from_tokens[0]);
232  ustring from_socket_name(from_tokens[1]);
233  ustring to_node_name(to_tokens[0]);
234  ustring to_socket_name(to_tokens[1]);
235 
236  /* find nodes and sockets */
238  ShaderInput *input = NULL;
239 
240  if (graph_reader.node_map.find(from_node_name) != graph_reader.node_map.end()) {
241  ShaderNode *fromnode = (ShaderNode *)graph_reader.node_map[from_node_name];
242 
243  foreach (ShaderOutput *out, fromnode->outputs)
244  if (string_iequals(out->socket_type.name.string(), from_socket_name.string()))
245  output = out;
246 
247  if (!output)
248  fprintf(stderr,
249  "Unknown output socket name \"%s\" on \"%s\".\n",
250  from_node_name.c_str(),
251  from_socket_name.c_str());
252  }
253  else
254  fprintf(stderr, "Unknown shader node name \"%s\".\n", from_node_name.c_str());
255 
256  if (graph_reader.node_map.find(to_node_name) != graph_reader.node_map.end()) {
257  ShaderNode *tonode = (ShaderNode *)graph_reader.node_map[to_node_name];
258 
259  foreach (ShaderInput *in, tonode->inputs)
260  if (string_iequals(in->socket_type.name.string(), to_socket_name.string()))
261  input = in;
262 
263  if (!input)
264  fprintf(stderr,
265  "Unknown input socket name \"%s\" on \"%s\".\n",
266  to_socket_name.c_str(),
267  to_node_name.c_str());
268  }
269  else
270  fprintf(stderr, "Unknown shader node name \"%s\".\n", to_node_name.c_str());
271 
272  /* connect */
273  if (output && input)
274  graph->connect(output, input);
275  }
276  else
277  fprintf(stderr, "Invalid from or to value for connect node.\n");
278 
279  continue;
280  }
281 
282  ShaderNode *snode = NULL;
283 
284 #ifdef WITH_OSL
285  if (node_name == "osl_shader") {
286  ShaderManager *manager = state.scene->shader_manager;
287 
288  if (manager->use_osl()) {
289  std::string filepath;
290 
291  if (xml_read_string(&filepath, node, "src")) {
292  if (path_is_relative(filepath)) {
293  filepath = path_join(state.base, filepath);
294  }
295 
296  snode = OSLShaderManager::osl_node(graph, manager, filepath, "");
297 
298  if (!snode) {
299  fprintf(stderr, "Failed to create OSL node from \"%s\".\n", filepath.c_str());
300  continue;
301  }
302  }
303  else {
304  fprintf(stderr, "OSL node missing \"src\" attribute.\n");
305  continue;
306  }
307  }
308  else {
309  fprintf(stderr, "OSL node without using --shadingsys osl.\n");
310  continue;
311  }
312  }
313  else
314 #endif
315  {
316  /* exception for name collision */
317  if (node_name == "background")
318  node_name = "background_shader";
319 
320  const NodeType *node_type = NodeType::find(node_name);
321 
322  if (!node_type) {
323  fprintf(stderr, "Unknown shader node \"%s\".\n", node.name());
324  continue;
325  }
326  else if (node_type->type != NodeType::SHADER) {
327  fprintf(stderr, "Node type \"%s\" is not a shader node.\n", node_type->name.c_str());
328  continue;
329  }
330  else if (node_type->create == NULL) {
331  fprintf(stderr, "Can't create abstract node type \"%s\".\n", node_type->name.c_str());
332  continue;
333  }
334 
335  snode = (ShaderNode *)node_type->create(node_type);
336  }
337 
338  xml_read_node(graph_reader, snode, node);
339 
340  if (node_name == "image_texture") {
341  ImageTextureNode *img = (ImageTextureNode *)snode;
342  ustring filename(path_join(state.base, img->get_filename().string()));
343  img->set_filename(filename);
344  }
345  else if (node_name == "environment_texture") {
347  ustring filename(path_join(state.base, env->get_filename().string()));
348  env->set_filename(filename);
349  }
350 
351  if (snode) {
352  /* add to graph */
353  graph->add(snode);
354  }
355  }
356 
357  shader->set_graph(graph);
358  shader->tag_update(state.scene);
359 }
360 
361 static void xml_read_shader(XMLReadState &state, xml_node node)
362 {
363  Shader *shader = new Shader();
365  state.scene->shaders.push_back(shader);
366 }
367 
368 /* Background */
369 
371 {
372  /* Background Settings */
373  xml_read_node(state, state.scene->background, node);
374 
375  /* Background Shader */
376  Shader *shader = state.scene->default_background;
378 }
379 
380 /* Mesh */
381 
382 static Mesh *xml_add_mesh(Scene *scene, const Transform &tfm)
383 {
384  /* create mesh */
385  Mesh *mesh = new Mesh();
386  scene->geometry.push_back(mesh);
387 
388  /* create object*/
389  Object *object = new Object();
390  object->set_geometry(mesh);
391  object->set_tfm(tfm);
392  scene->objects.push_back(object);
393 
394  return mesh;
395 }
396 
397 static void xml_read_mesh(const XMLReadState &state, xml_node node)
398 {
399  /* add mesh */
400  Mesh *mesh = xml_add_mesh(state.scene, state.tfm);
401  array<Node *> used_shaders = mesh->get_used_shaders();
402  used_shaders.push_back_slow(state.shader);
403  mesh->set_used_shaders(used_shaders);
404 
405  /* read state */
406  int shader = 0;
407  bool smooth = state.smooth;
408 
409  /* read vertices and polygons */
411  vector<float> UV;
412  vector<int> verts, nverts;
413 
415  xml_read_int_array(verts, node, "verts");
416  xml_read_int_array(nverts, node, "nverts");
417 
418  if (xml_equal_string(node, "subdivision", "catmull-clark")) {
419  mesh->set_subdivision_type(Mesh::SUBDIVISION_CATMULL_CLARK);
420  }
421  else if (xml_equal_string(node, "subdivision", "linear")) {
422  mesh->set_subdivision_type(Mesh::SUBDIVISION_LINEAR);
423  }
424 
425  array<float3> P_array;
426  P_array = P;
427 
428  if (mesh->get_subdivision_type() == Mesh::SUBDIVISION_NONE) {
429  /* create vertices */
430 
431  mesh->set_verts(P_array);
432 
433  size_t num_triangles = 0;
434  for (size_t i = 0; i < nverts.size(); i++)
435  num_triangles += nverts[i] - 2;
436  mesh->reserve_mesh(mesh->get_verts().size(), num_triangles);
437 
438  /* create triangles */
439  int index_offset = 0;
440 
441  for (size_t i = 0; i < nverts.size(); i++) {
442  for (int j = 0; j < nverts[i] - 2; j++) {
443  int v0 = verts[index_offset];
444  int v1 = verts[index_offset + j + 1];
445  int v2 = verts[index_offset + j + 2];
446 
447  assert(v0 < (int)P.size());
448  assert(v1 < (int)P.size());
449  assert(v2 < (int)P.size());
450 
451  mesh->add_triangle(v0, v1, v2, shader, smooth);
452  }
453 
454  index_offset += nverts[i];
455  }
456 
457  if (xml_read_float_array(UV, node, "UV")) {
458  ustring name = ustring("UVMap");
459  Attribute *attr = mesh->attributes.add(ATTR_STD_UV, name);
460  float2 *fdata = attr->data_float2();
461 
462  /* loop over the triangles */
463  index_offset = 0;
464  for (size_t i = 0; i < nverts.size(); i++) {
465  for (int j = 0; j < nverts[i] - 2; j++) {
466  int v0 = index_offset;
467  int v1 = index_offset + j + 1;
468  int v2 = index_offset + j + 2;
469 
470  assert(v0 * 2 + 1 < (int)UV.size());
471  assert(v1 * 2 + 1 < (int)UV.size());
472  assert(v2 * 2 + 1 < (int)UV.size());
473 
474  fdata[0] = make_float2(UV[v0 * 2], UV[v0 * 2 + 1]);
475  fdata[1] = make_float2(UV[v1 * 2], UV[v1 * 2 + 1]);
476  fdata[2] = make_float2(UV[v2 * 2], UV[v2 * 2 + 1]);
477  fdata += 3;
478  }
479 
480  index_offset += nverts[i];
481  }
482  }
483  }
484  else {
485  /* create vertices */
486  mesh->set_verts(P_array);
487 
488  size_t num_ngons = 0;
489  size_t num_corners = 0;
490  for (size_t i = 0; i < nverts.size(); i++) {
491  num_ngons += (nverts[i] == 4) ? 0 : 1;
492  num_corners += nverts[i];
493  }
494  mesh->reserve_subd_faces(nverts.size(), num_ngons, num_corners);
495 
496  /* create subd_faces */
497  int index_offset = 0;
498 
499  for (size_t i = 0; i < nverts.size(); i++) {
500  mesh->add_subd_face(&verts[index_offset], nverts[i], shader, smooth);
501  index_offset += nverts[i];
502  }
503 
504  /* uv map */
505  if (xml_read_float_array(UV, node, "UV")) {
506  ustring name = ustring("UVMap");
507  Attribute *attr = mesh->subd_attributes.add(ATTR_STD_UV, name);
508  float3 *fdata = attr->data_float3();
509 
510 #if 0
511  if (subdivide_uvs) {
512  attr->flags |= ATTR_SUBDIVIDED;
513  }
514 #endif
515 
516  index_offset = 0;
517  for (size_t i = 0; i < nverts.size(); i++) {
518  for (int j = 0; j < nverts[i]; j++) {
519  *(fdata++) = make_float3(UV[index_offset++]);
520  }
521  }
522  }
523 
524  /* setup subd params */
525  float dicing_rate = state.dicing_rate;
526  xml_read_float(&dicing_rate, node, "dicing_rate");
527  dicing_rate = std::max(0.1f, dicing_rate);
528 
529  mesh->set_subd_dicing_rate(dicing_rate);
530  mesh->set_subd_objecttoworld(state.tfm);
531  }
532 
533  /* we don't yet support arbitrary attributes, for now add vertex
534  * coordinates as generated coordinates if requested */
537  memcpy(
538  attr->data_float3(), mesh->get_verts().data(), sizeof(float3) * mesh->get_verts().size());
539  }
540 }
541 
542 /* Light */
543 
544 static void xml_read_light(XMLReadState &state, xml_node node)
545 {
546  Light *light = new Light();
547 
548  light->set_shader(state.shader);
549  xml_read_node(state, light, node);
550 
551  state.scene->lights.push_back(light);
552 }
553 
554 /* Transform */
555 
556 static void xml_read_transform(xml_node node, Transform &tfm)
557 {
558  if (node.attribute("matrix")) {
559  vector<float> matrix;
560  if (xml_read_float_array(matrix, node, "matrix") && matrix.size() == 16) {
561  ProjectionTransform projection = *(ProjectionTransform *)&matrix[0];
562  tfm = tfm * projection_to_transform(projection_transpose(projection));
563  }
564  }
565 
566  if (node.attribute("translate")) {
567  float3 translate = zero_float3();
568  xml_read_float3(&translate, node, "translate");
569  tfm = tfm * transform_translate(translate);
570  }
571 
572  if (node.attribute("rotate")) {
573  float4 rotate = zero_float4();
574  xml_read_float4(&rotate, node, "rotate");
575  tfm = tfm * transform_rotate(DEG2RADF(rotate.x), make_float3(rotate.y, rotate.z, rotate.w));
576  }
577 
578  if (node.attribute("scale")) {
579  float3 scale = zero_float3();
580  xml_read_float3(&scale, node, "scale");
581  tfm = tfm * transform_scale(scale);
582  }
583 }
584 
585 /* State */
586 
587 static void xml_read_state(XMLReadState &state, xml_node node)
588 {
589  /* read shader */
590  string shadername;
591 
592  if (xml_read_string(&shadername, node, "shader")) {
593  bool found = false;
594 
595  foreach (Shader *shader, state.scene->shaders) {
596  if (shader->name == shadername) {
597  state.shader = shader;
598  found = true;
599  break;
600  }
601  }
602 
603  if (!found)
604  fprintf(stderr, "Unknown shader \"%s\".\n", shadername.c_str());
605  }
606 
607  xml_read_float(&state.dicing_rate, node, "dicing_rate");
608 
609  /* read smooth/flat */
610  if (xml_equal_string(node, "interpolation", "smooth"))
611  state.smooth = true;
612  else if (xml_equal_string(node, "interpolation", "flat"))
613  state.smooth = false;
614 }
615 
616 /* Scene */
617 
618 static void xml_read_include(XMLReadState &state, const string &src);
619 
620 static void xml_read_scene(XMLReadState &state, xml_node scene_node)
621 {
622  for (xml_node node = scene_node.first_child(); node; node = node.next_sibling()) {
623  if (string_iequals(node.name(), "film")) {
624  xml_read_node(state, state.scene->film, node);
625  }
626  else if (string_iequals(node.name(), "integrator")) {
627  xml_read_node(state, state.scene->integrator, node);
628  }
629  else if (string_iequals(node.name(), "camera")) {
631  }
632  else if (string_iequals(node.name(), "shader")) {
634  }
635  else if (string_iequals(node.name(), "background")) {
637  }
638  else if (string_iequals(node.name(), "mesh")) {
640  }
641  else if (string_iequals(node.name(), "light")) {
643  }
644  else if (string_iequals(node.name(), "transform")) {
645  XMLReadState substate = state;
646 
647  xml_read_transform(node, substate.tfm);
648  xml_read_scene(substate, node);
649  }
650  else if (string_iequals(node.name(), "state")) {
651  XMLReadState substate = state;
652 
653  xml_read_state(substate, node);
654  xml_read_scene(substate, node);
655  }
656  else if (string_iequals(node.name(), "include")) {
657  string src;
658 
659  if (xml_read_string(&src, node, "src"))
660  xml_read_include(state, src);
661  }
662  else
663  fprintf(stderr, "Unknown node \"%s\".\n", node.name());
664  }
665 }
666 
667 /* Include */
668 
669 static void xml_read_include(XMLReadState &state, const string &src)
670 {
671  /* open XML document */
672  xml_document doc;
673  xml_parse_result parse_result;
674 
675  string path = path_join(state.base, src);
676  parse_result = doc.load_file(path.c_str());
677 
678  if (parse_result) {
679  XMLReadState substate = state;
680  substate.base = path_dirname(path);
681 
682  xml_node cycles = doc.child("cycles");
683  xml_read_scene(substate, cycles);
684  }
685  else {
686  fprintf(stderr, "%s read error: %s\n", src.c_str(), parse_result.description());
687  exit(EXIT_FAILURE);
688  }
689 }
690 
691 /* File */
692 
693 void xml_read_file(Scene *scene, const char *filepath)
694 {
696 
697  state.scene = scene;
698  state.tfm = transform_identity();
699  state.shader = scene->default_surface;
700  state.smooth = false;
701  state.dicing_rate = 1.0f;
702  state.base = path_dirname(filepath);
703 
705 
707 }
708 
typedef float(TangentPoint)[2]
#define DEG2RADF(_deg)
struct Light Light
struct Mesh Mesh
struct Object Object
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Shader
ATTR_WARN_UNUSED_RESULT const BMVert * v2
#define output
SIMD_FORCE_INLINE btVector3 rotate(const btVector3 &wAxis, const btScalar angle) const
Return a rotated version of this vector.
Attribute * add(ustring name, TypeDesc type, AttributeElement element)
Definition: attribute.cpp:428
uint flags
Definition: attribute.h:55
float3 * data_float3()
Definition: attribute.h:86
float2 * data_float2()
Definition: attribute.h:81
bool need_attribute(Scene *scene, AttributeStandard std)
Definition: geometry.cpp:102
AttributeSet attributes
Definition: geometry.h:81
@ BVH_STATIC
Definition: scene.h:161
BVHType bvh_type
Definition: scene.h:175
const SocketType & socket_type
Definition: graph.h:110
virtual bool use_osl()
Definition: shader.h:184
vector< ShaderOutput * > outputs
Definition: graph.h:224
vector< ShaderInput * > inputs
Definition: graph.h:223
const SocketType & socket_type
Definition: graph.h:138
Definition: shader.h:80
size_t size() const
Definition: util_array.h:203
void push_back_slow(const T &t)
Definition: util_array.h:263
static bool xml_read_float4(float4 *value, xml_node node, const char *name)
Definition: cycles_xml.cpp:153
static bool xml_read_float3(float3 *value, xml_node node, const char *name)
Definition: cycles_xml.cpp:127
static void xml_read_include(XMLReadState &state, const string &src)
Definition: cycles_xml.cpp:669
static void xml_read_shader_graph(XMLReadState &state, Shader *shader, xml_node graph_node)
Definition: cycles_xml.cpp:210
static bool xml_read_int_array(vector< int > &value, xml_node node, const char *name)
Definition: cycles_xml.cpp:81
static bool xml_read_int(int *value, xml_node node, const char *name)
Definition: cycles_xml.cpp:69
static bool xml_read_float_array(vector< float > &value, xml_node node, const char *name)
Definition: cycles_xml.cpp:110
void xml_read_file(Scene *scene, const char *filepath)
Definition: cycles_xml.cpp:693
static bool xml_read_string(string *str, xml_node node, const char *name)
Definition: cycles_xml.cpp:165
static void xml_read_mesh(const XMLReadState &state, xml_node node)
Definition: cycles_xml.cpp:397
static Mesh * xml_add_mesh(Scene *scene, const Transform &tfm)
Definition: cycles_xml.cpp:382
static bool xml_equal_string(xml_node node, const char *name, const char *value)
Definition: cycles_xml.cpp:177
static bool xml_read_float3_array(vector< float3 > &value, xml_node node, const char *name)
Definition: cycles_xml.cpp:139
static void xml_read_light(XMLReadState &state, xml_node node)
Definition: cycles_xml.cpp:544
static void xml_read_state(XMLReadState &state, xml_node node)
Definition: cycles_xml.cpp:587
static void xml_read_camera(XMLReadState &state, xml_node node)
Definition: cycles_xml.cpp:189
static void xml_read_transform(xml_node node, Transform &tfm)
Definition: cycles_xml.cpp:556
static bool xml_read_float(float *value, xml_node node, const char *name)
Definition: cycles_xml.cpp:98
static void xml_read_scene(XMLReadState &state, xml_node scene_node)
Definition: cycles_xml.cpp:620
static void xml_read_shader(XMLReadState &state, xml_node node)
Definition: cycles_xml.cpp:361
static void xml_read_background(XMLReadState &state, xml_node node)
Definition: cycles_xml.cpp:370
OperationNode * node
Depsgraph * graph
Scene scene
#define str(s)
static float verts[][3]
#define CCL_NAMESPACE_END
#define make_float2(x, y)
#define make_float4(x, y, z, w)
#define make_float3(x, y, z)
void KERNEL_FUNCTION_FULL_NAME() shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int filter, int i, int offset, int sample)
@ ATTR_STD_UV
Definition: kernel_types.h:748
@ ATTR_STD_GENERATED
Definition: kernel_types.h:752
@ ATTR_SUBDIVIDED
Definition: kernel_types.h:778
static float P(float k)
Definition: math_interp.c:41
static ulong state[N]
void xml_read_node(XMLReader &reader, Node *node, xml_node xml_node)
Definition: node_xml.cpp:54
bool need_flags_update
Definition: camera.h:192
void update(Scene *scene)
Definition: camera.cpp:231
void reserve_subd_faces(int numfaces, int num_ngons, int numcorners)
Definition: mesh.cpp:260
float size[3]
void reserve_mesh(int numverts, int numfaces)
Definition: mesh.cpp:230
@ SUBDIVISION_NONE
Definition: mesh.h:133
@ SUBDIVISION_LINEAR
Definition: mesh.h:134
@ SUBDIVISION_CATMULL_CLARK
Definition: mesh.h:135
void add_triangle(int v0, int v1, int v2, int shader, bool smooth)
Definition: mesh.cpp:352
void add_subd_face(int *corners, int num_corners, int shader_, bool smooth_)
Definition: mesh.cpp:370
Type type
Definition: node_type.h:129
CreateFunc create
Definition: node_type.h:133
ustring name
Definition: node_type.h:128
static const NodeType * find(ustring name)
vector< Geometry * > geometry
Definition: scene.h:235
SceneParams params
Definition: scene.h:264
Shader * default_surface
Definition: scene.h:253
vector< Object * > objects
Definition: scene.h:234
ustring name
Definition: node_type.h:85
Scene * scene
Definition: cycles_xml.cpp:54
Transform tfm
Definition: cycles_xml.cpp:55
Shader * shader
Definition: cycles_xml.cpp:57
float dicing_rate
Definition: cycles_xml.cpp:59
map< ustring, Node * > node_map
Definition: node_xml.h:28
float max
#define foreach(x, y)
Definition: util_foreach.h:22
ccl_device_inline float3 zero_float3()
ccl_device_inline float4 zero_float4()
string path_dirname(const string &path)
Definition: util_path.cpp:412
bool path_is_relative(const string &path)
Definition: util_path.cpp:455
string path_join(const string &dir, const string &file)
Definition: util_path.cpp:426
string path_filename(const string &path)
Definition: util_path.cpp:389
ccl_device_inline Transform projection_to_transform(const ProjectionTransform &a)
ccl_device_inline ProjectionTransform projection_transpose(const ProjectionTransform &a)
bool string_iequals(const string &a, const string &b)
Definition: util_string.cpp:64
void string_split(vector< string > &tokens, const string &str, const string &separators, bool skip_empty_tokens)
Definition: util_string.cpp:77
ccl_device_inline Transform transform_identity()
ccl_device_inline Transform transform_rotate(float angle, float3 axis)
ccl_device_inline Transform transform_translate(float3 t)
ccl_device_inline Transform transform_scale(float3 s)