home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / include / k3d / k3dsdk / blobby.h < prev    next >
C/C++ Source or Header  |  2008-11-16  |  5KB  |  155 lines

  1. #ifndef K3DSDK_BLOBBY_H
  2. #define K3DSDK_BLOBBY_H
  3.  
  4. // K-3D
  5. // Copyright (c) 1995-2008, Timothy M. Shead
  6. //
  7. // Contact: tshead@k-3d.com
  8. //
  9. // This program is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2 of the License, or (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. // General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public
  20. // License along with this program; if not, write to the Free Software
  21. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  22.  
  23. #include "mesh.h"
  24.  
  25. namespace k3d
  26. {
  27.  
  28. namespace blobby
  29. {
  30.  
  31. /// Predefined primitive types from the RenderMan Specification
  32. enum primitive_type
  33. {
  34.     CONSTANT = 1000,
  35.     ELLIPSOID = 1001,
  36.     SEGMENT = 1002,
  37. };
  38.  
  39. /// Predefined operator types from the RenderMan Specification
  40. enum operator_type
  41. {
  42.     ADD = 0,
  43.     MULTIPLY = 1,
  44.     MAXIMUM = 2,
  45.     MINIMUM = 3,
  46.     SUBTRACT = 4,
  47.     DIVIDE = 5,
  48.     NEGATE = 6,
  49.     IDENTITY = 7,
  50. };
  51.  
  52. /// Gathers the member arrays of a blobby primitive into a convenient package
  53. class const_primitive
  54. {
  55. public:
  56.     const_primitive(
  57.         const mesh::indices_t& FirstPrimitives,
  58.         const mesh::counts_t& PrimitiveCounts,
  59.         const mesh::indices_t& FirstOperators,
  60.         const mesh::counts_t& OperatorCounts,
  61.         const mesh::materials_t& Materials,
  62.         const typed_array<int32_t>& Primitives,
  63.         const mesh::indices_t& PrimitiveFirstFloats,
  64.         const mesh::counts_t& PrimitiveFloatCounts,
  65.         const typed_array<int32_t>& Operators,
  66.         const mesh::indices_t& OperatorFirstOperands,
  67.         const mesh::counts_t& OperatorOperandCounts,
  68.         const mesh::doubles_t& Floats,
  69.         const mesh::indices_t& Operands,
  70.         const mesh::attribute_arrays_t& ConstantData,
  71.         const mesh::attribute_arrays_t& UniformData,
  72.         const mesh::attribute_arrays_t& VaryingData,
  73.         const mesh::attribute_arrays_t& VertexData
  74.         );
  75.  
  76.     const mesh::indices_t& first_primitives;
  77.     const mesh::counts_t& primitive_counts;
  78.     const mesh::indices_t& first_operators;
  79.     const mesh::counts_t& operator_counts;
  80.     const mesh::materials_t& materials;
  81.     const typed_array<int32_t>& primitives;
  82.     const mesh::indices_t& primitive_first_floats;
  83.     const mesh::counts_t& primitive_float_counts;
  84.     const typed_array<int32_t>& operators;
  85.     const mesh::indices_t& operator_first_operands;
  86.     const mesh::counts_t& operator_operand_counts;
  87.     const mesh::doubles_t& floats;
  88.     const mesh::indices_t& operands;
  89.     const mesh::attribute_arrays_t& constant_data;
  90.     const mesh::attribute_arrays_t& uniform_data;
  91.     const mesh::attribute_arrays_t& varying_data;
  92.     const mesh::attribute_arrays_t& vertex_data;
  93. };
  94.  
  95. /// Gathers the member arrays of a blobby primitive into a convenient package
  96. class primitive
  97. {
  98. public:
  99.     primitive(
  100.         mesh::indices_t& FirstPrimitives,
  101.         mesh::counts_t& PrimitiveCounts,
  102.         mesh::indices_t& FirstOperators,
  103.         mesh::counts_t& OperatorCounts,
  104.         mesh::materials_t& Materials,
  105.         typed_array<int32_t>& Primitives,
  106.         mesh::indices_t& PrimitiveFirstFloats,
  107.         mesh::counts_t& PrimitiveFloatCounts,
  108.         typed_array<int32_t>& Operators,
  109.         mesh::indices_t& OperatorFirstOperands,
  110.         mesh::counts_t& OperatorOperandCounts,
  111.         mesh::doubles_t& Floats,
  112.         mesh::indices_t& Operands,
  113.         mesh::attribute_arrays_t& ConstantData,
  114.         mesh::attribute_arrays_t& UniformData,
  115.         mesh::attribute_arrays_t& VaryingData,
  116.         mesh::attribute_arrays_t& VertexData
  117.         );
  118.  
  119.     mesh::indices_t& first_primitives;
  120.     mesh::counts_t& primitive_counts;
  121.     mesh::indices_t& first_operators;
  122.     mesh::counts_t& operator_counts;
  123.     mesh::materials_t& materials;
  124.     typed_array<int32_t>& primitives;
  125.     mesh::indices_t& primitive_first_floats;
  126.     mesh::counts_t& primitive_float_counts;
  127.     typed_array<int32_t>& operators;
  128.     mesh::indices_t& operator_first_operands;
  129.     mesh::counts_t& operator_operand_counts;
  130.     mesh::doubles_t& floats;
  131.     mesh::indices_t& operands;
  132.     mesh::attribute_arrays_t& constant_data;
  133.     mesh::attribute_arrays_t& uniform_data;
  134.     mesh::attribute_arrays_t& varying_data;
  135.     mesh::attribute_arrays_t& vertex_data;
  136. };
  137.  
  138. /// Creates a new blobby mesh primitive, returning references to its member arrays.
  139. /// The caller is responsible for the lifetime of the returned object.
  140. primitive* create(mesh& Mesh);
  141.  
  142. /// Tests the given mesh primitive to see if it is a valid blobby primitive, returning references to its member arrays, or NULL.
  143. /// The caller is responsible for the lifetime of the returned object.
  144. const_primitive* validate(const mesh::primitive& GenericPrimitive);
  145. /// Tests the given mesh primitive to see if it is a valid blobby primitive, returning references to its member arrays, or NULL.
  146. /// The caller is responsible for the lifetime of the returned object.
  147. primitive* validate(mesh::primitive& GenericPrimitive);
  148.  
  149. } // namespace blobby
  150.  
  151. } // namespace k3d
  152.  
  153. #endif // !K3DSDK_BLOBBY_H
  154.  
  155.