/extra/game/models/collada/collada-docs.factor

http://github.com/abeaumont/factor · Factor · 85 lines · 62 code · 21 blank · 2 comment · 0 complexity · 42f80fd12c79e6e12f9539584558f92b MD5 · raw file

  1. ! Copyright (C) 2010 Erik Charlebois
  2. ! See http://factorcode.org/license.txt for BSD license.
  3. USING: help.markup help.crossref help.stylesheet help.topics help.syntax
  4. definitions io prettyprint summary arrays math sequences vocabs strings
  5. see xml.data hashtables assocs game.models.collada.private game.models
  6. game.models.util ;
  7. IN: game.models.collada
  8. ABOUT: "game.models.collada"
  9. ARTICLE: "game.models.collada" "Conversion of COLLADA assets"
  10. "The " { $vocab-link "game.models.collada" } " vocabulary implements words for converting COLLADA assets to data suitable for use with OpenGL. See the COLLADA documentation at " { $url "http://collada.org" } "." ;
  11. HELP: source
  12. { $class-description "Tuple of a vertex attribute semantic, offset in triangle index buffer and float data for a single vertex attribute." } ;
  13. HELP: up-axis
  14. { $description "Dynamically-scoped variable with the up axis of the tags being read." } ;
  15. HELP: unit-ratio
  16. { $description "Scaling ratio for the coordinates of the tags being read." } ;
  17. HELP: string>numbers
  18. { $values { "string" string } { "number-seq" sequence } }
  19. { $description "Splits a string on whitespace and converts the elements to a number sequence." } ;
  20. HELP: x-up { $class-description "Right-handed 3D coordinate system where X is up." } ;
  21. HELP: y-up { $class-description "Right-handed 3D coordinate system where Y is up." } ;
  22. HELP: z-up { $class-description "Right-handed 3D coordinate system where Z is up." } ;
  23. HELP: >y-up-axis!
  24. { $values { "seq" sequence } { "from-axis" rh-up } }
  25. { $description "Destructively swizzles the first three elements of the input sequence to a right-handed 3D coordinate system where Y is up and returns the modified sequence." } ;
  26. HELP: source>sequence
  27. { $values { "source-tag" tag } { "up-axis" rh-up } { "scale" number } { "sequence" sequence } }
  28. { $description "Convert the " { $emphasis "float_array" } " in a " { $emphasis "source tag" } " to a sequence of number sequences according to the element stride. The values are scaled according to " { $emphasis "scale" } " and swizzled from " { $emphasis "up-axis" } " so that the Y coordinate points up." } ;
  29. HELP: source>pair
  30. { $values { "source-tag" tag } { "pair" pair } }
  31. { $description "Convert the source tag to an id and number sequence pair." } ;
  32. HELP: mesh>sources
  33. { $values { "mesh-tag" tag } { "hashtable" pair } }
  34. { $description "Convert the mesh tag's source elements to a hashtable from id to number sequence." } ;
  35. HELP: mesh>vertices
  36. { $values { "mesh-tag" tag } { "pair" pair } }
  37. { $description "Convert the mesh tag's vertices element to a pair for further lookup in " { $link collect-sources } ". " } ;
  38. HELP: collect-sources
  39. { $values { "sources" hashtable } { "vertices" pair } { "inputs" tag sequence } { "seq" sequence } }
  40. { $description "Look up the sources for these " { $emphasis "input" } " elements and return a sequence of " { $link source } " tuples." } ;
  41. HELP: group-indices
  42. { $values { "index-stride" number } { "triangle-count" number } { "indices" sequence } { "grouped-indices" sequence } }
  43. { $description "Groups the index sequence by triangle and then groups each triangle's indices by vertex." } ;
  44. HELP: triangles>numbers
  45. { $values { "triangles-tag" tag } { "number-seq" sequence } }
  46. { $description "Converts the triangle data in a triangles tag from string form to a sequence of numbers." } ;
  47. HELP: largest-offset+1
  48. { $values { "source-seq" sequence } { "largest-offset+1" number } }
  49. { $description "Finds the largest offset in the sequence of " { $link source } " tuples and adds 1, which is the index stride for " { $link group-indices } "." } ;
  50. HELP: pack-attributes
  51. { $values { "source-indices" sequence } { "sources" sequence } { "attributes" sequence } }
  52. { $description "Packs the attributes for a single vertex into a sequence from a set of source data streams." } ;
  53. HELP: soa>aos
  54. { $values { "triangles-indices" sequence } { "sources" sequence } { "attribute-buffer" sequence } { "index-buffer" sequence } }
  55. { $description "Swizzles the input sources from a structure of arrays form to an array of structures form and generates a new index buffer." } ;
  56. HELP: triangles>model
  57. { $values { "sources" sequence } { "vertices" pair } { "triangles-tag" tag } { "model" model } }
  58. { $description "Creates a " { $link model } " tuple from the given triangles tag, source set and vertices pair." } ;
  59. HELP: mesh>triangles
  60. { $values { "sources" sequence } { "vertices" pair } { "mesh-tag" tag } { "models" sequence } }
  61. { $description "Creates a sequence of models from the triangles in the mesh tag." } ;
  62. HELP: mesh>models
  63. { $values { "mesh-tag" tag } { "models" sequence } }
  64. { $description "Converts a triangle mesh to a set of models suitable for rendering with OpenGL." } ;