2010-11-21 14:57:00 +00:00
|
|
|
//
|
|
|
|
// v002MeshHelper.h
|
|
|
|
// v002 Model Importer
|
|
|
|
//
|
|
|
|
// Created by vade on 9/26/10.
|
|
|
|
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
#import <OpenGL/OpenGL.h>
|
2013-09-21 17:59:13 +00:00
|
|
|
#import "color4.h"
|
|
|
|
#import "vector3.h"
|
|
|
|
#import "vector2.h"
|
|
|
|
#import "matrix4x4.h"
|
2010-11-21 14:57:00 +00:00
|
|
|
|
|
|
|
/* workflow:
|
|
|
|
|
2021-09-07 13:04:08 +00:00
|
|
|
1) create a new scene wrapper
|
2010-11-21 14:57:00 +00:00
|
|
|
2) populate an array of of meshHelpers for each mesh in the original scene
|
|
|
|
3) (eventually) create an animator instance
|
|
|
|
4) scale the asset (needed?)
|
|
|
|
5) create the asset data (GL resources, textures etc)
|
|
|
|
5a) for each mesh create a material instance
|
|
|
|
5b) create a static vertex buffer
|
|
|
|
5c) create index buffer
|
|
|
|
5d) populate the index buffer
|
2021-09-07 13:04:08 +00:00
|
|
|
5e) (eventually) gather weights
|
2010-11-21 14:57:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
|
|
|
|
|
2021-09-07 13:04:08 +00:00
|
|
|
struct Vertex
|
2010-11-21 14:57:00 +00:00
|
|
|
{
|
|
|
|
aiVector3D vPosition;
|
|
|
|
aiVector3D vNormal;
|
2021-09-07 13:04:08 +00:00
|
|
|
|
2010-11-21 14:57:00 +00:00
|
|
|
aiColor4D dColorDiffuse;
|
|
|
|
aiVector3D vTangent;
|
|
|
|
aiVector3D vBitangent;
|
|
|
|
aiVector3D vTextureUV;
|
|
|
|
aiVector3D vTextureUV2;
|
|
|
|
unsigned char mBoneIndices[4];
|
|
|
|
unsigned char mBoneWeights[4]; // last Weight not used, calculated inside the vertex shader
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Helper Class to store GPU related resources from a given aiMesh
|
|
|
|
// Modeled after AssimpView asset helper
|
2021-09-07 13:04:08 +00:00
|
|
|
@interface MeshHelper : NSObject
|
|
|
|
{
|
2010-11-21 14:57:00 +00:00
|
|
|
// Display list ID, this one shots *all drawing* of the mesh. Only ever use this to draw. Booya.
|
|
|
|
GLuint displayList;
|
2021-09-07 13:04:08 +00:00
|
|
|
|
2010-11-21 14:57:00 +00:00
|
|
|
// VAO that encapsulates all VBO drawing state
|
|
|
|
GLuint vao;
|
2021-09-07 13:04:08 +00:00
|
|
|
|
2010-11-21 14:57:00 +00:00
|
|
|
// VBOs
|
|
|
|
GLuint vertexBuffer;
|
|
|
|
GLuint indexBuffer;
|
|
|
|
GLuint normalBuffer;
|
|
|
|
GLuint numIndices;
|
2021-09-07 13:04:08 +00:00
|
|
|
|
2010-11-21 14:57:00 +00:00
|
|
|
// texture
|
|
|
|
GLuint textureID;
|
2021-09-07 13:04:08 +00:00
|
|
|
|
|
|
|
// Material
|
2010-11-21 14:57:00 +00:00
|
|
|
aiColor4D diffuseColor;
|
|
|
|
aiColor4D specularColor;
|
|
|
|
aiColor4D ambientColor;
|
|
|
|
aiColor4D emissiveColor;
|
2021-09-07 13:04:08 +00:00
|
|
|
|
2010-11-21 14:57:00 +00:00
|
|
|
GLfloat opacity;
|
|
|
|
GLfloat shininess;
|
|
|
|
GLfloat specularStrength;
|
2021-09-07 13:04:08 +00:00
|
|
|
|
2010-11-21 14:57:00 +00:00
|
|
|
BOOL twoSided;
|
|
|
|
}
|
|
|
|
|
|
|
|
@property (readwrite, assign) GLuint vao;
|
|
|
|
@property (readwrite, assign) GLuint displayList;
|
|
|
|
|
|
|
|
@property (readwrite, assign) GLuint vertexBuffer;
|
|
|
|
@property (readwrite, assign) GLuint indexBuffer;
|
|
|
|
@property (readwrite, assign) GLuint normalBuffer;
|
|
|
|
@property (readwrite, assign) GLuint numIndices;
|
|
|
|
|
|
|
|
@property (readwrite, assign) GLuint textureID;
|
|
|
|
|
|
|
|
@property (readwrite, assign) aiColor4D* diffuseColor;
|
|
|
|
@property (readwrite, assign) aiColor4D* specularColor;
|
|
|
|
@property (readwrite, assign) aiColor4D* ambientColor;
|
|
|
|
@property (readwrite, assign) aiColor4D* emissiveColor;
|
|
|
|
|
|
|
|
@property (readwrite, assign) GLfloat opacity;
|
|
|
|
@property (readwrite, assign) GLfloat shininess;
|
|
|
|
@property (readwrite, assign) GLfloat specularStrength;
|
|
|
|
@property (readwrite, assign) BOOL twoSided;
|
|
|
|
@end
|