vrml.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "pv.h"
  2. void vrml_begin(FILE * vout)
  3. {
  4. #ifdef VRML2
  5. vrml_putline(0, vout, "#VRML V2.0 utf8");
  6. #else
  7. vrml_putline(0, vout, "#VRML V1.0 ascii");
  8. vrml_putline(1, vout, "Separator {");
  9. vrml_putline(1, vout, "ShapeHints {");
  10. vrml_putline(0, vout, "vertexOrdering COUNTERCLOCKWISE");
  11. vrml_putline(0, vout, "faceType CONVEX");
  12. vrml_putline(0, vout, "creaseAngle 0.5");
  13. vrml_putline(-1, vout, "}");
  14. #endif
  15. }
  16. void vrml_end(FILE * vout)
  17. {
  18. #ifdef VRML2
  19. #else
  20. vrml_putline(-1, vout, "}");
  21. #endif
  22. }
  23. /* To make it easier to read - uses tabs to increase or
  24. decrease the level of indentation. For better storage,
  25. just comment out the tab printing.
  26. */
  27. void vrml_putline(int indent, FILE * vout, char *str)
  28. {
  29. static int ind = 0;
  30. int i;
  31. if (indent < 0)
  32. ind += indent; /* pre-decrement */
  33. for (i = 0; i < ind; i++)
  34. fprintf(vout, "\t");
  35. fprintf(vout, "%s\n", str);
  36. if (indent > 0)
  37. ind += indent; /* post-increment */
  38. if (ind < 0)
  39. ind = 0;
  40. }