Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

99 Zeilen
2.6 KiB

  1. //
  2. // v002MeshHelper.h
  3. // v002 Model Importer
  4. //
  5. // Created by vade on 9/26/10.
  6. // Copyright 2010 __MyCompanyName__. All rights reserved.
  7. //
  8. #import <Cocoa/Cocoa.h>
  9. #import <OpenGL/OpenGL.h>
  10. #import "color4.h"
  11. #import "vector3.h"
  12. #import "vector2.h"
  13. #import "matrix4x4.h"
  14. /* workflow:
  15. 1) create a new scene wrapper
  16. 2) populate an array of of meshHelpers for each mesh in the original scene
  17. 3) (eventually) create an animator instance
  18. 4) scale the asset (needed?)
  19. 5) create the asset data (GL resources, textures etc)
  20. 5a) for each mesh create a material instance
  21. 5b) create a static vertex buffer
  22. 5c) create index buffer
  23. 5d) populate the index buffer
  24. 5e) (eventually) gather weights
  25. */
  26. #define BUFFER_OFFSET(i) ((char *)NULL + (i))
  27. struct Vertex
  28. {
  29. aiVector3D vPosition;
  30. aiVector3D vNormal;
  31. aiColor4D dColorDiffuse;
  32. aiVector3D vTangent;
  33. aiVector3D vBitangent;
  34. aiVector3D vTextureUV;
  35. aiVector3D vTextureUV2;
  36. unsigned char mBoneIndices[4];
  37. unsigned char mBoneWeights[4]; // last Weight not used, calculated inside the vertex shader
  38. };
  39. // Helper Class to store GPU related resources from a given aiMesh
  40. // Modeled after AssimpView asset helper
  41. @interface MeshHelper : NSObject
  42. {
  43. // Display list ID, this one shots *all drawing* of the mesh. Only ever use this to draw. Booya.
  44. GLuint displayList;
  45. // VAO that encapsulates all VBO drawing state
  46. GLuint vao;
  47. // VBOs
  48. GLuint vertexBuffer;
  49. GLuint indexBuffer;
  50. GLuint normalBuffer;
  51. GLuint numIndices;
  52. // texture
  53. GLuint textureID;
  54. // Material
  55. aiColor4D diffuseColor;
  56. aiColor4D specularColor;
  57. aiColor4D ambientColor;
  58. aiColor4D emissiveColor;
  59. GLfloat opacity;
  60. GLfloat shininess;
  61. GLfloat specularStrength;
  62. BOOL twoSided;
  63. }
  64. @property (readwrite, assign) GLuint vao;
  65. @property (readwrite, assign) GLuint displayList;
  66. @property (readwrite, assign) GLuint vertexBuffer;
  67. @property (readwrite, assign) GLuint indexBuffer;
  68. @property (readwrite, assign) GLuint normalBuffer;
  69. @property (readwrite, assign) GLuint numIndices;
  70. @property (readwrite, assign) GLuint textureID;
  71. @property (readwrite, assign) aiColor4D* diffuseColor;
  72. @property (readwrite, assign) aiColor4D* specularColor;
  73. @property (readwrite, assign) aiColor4D* ambientColor;
  74. @property (readwrite, assign) aiColor4D* emissiveColor;
  75. @property (readwrite, assign) GLfloat opacity;
  76. @property (readwrite, assign) GLfloat shininess;
  77. @property (readwrite, assign) GLfloat specularStrength;
  78. @property (readwrite, assign) BOOL twoSided;
  79. @end