Panda3D
|
00001 // Filename: vertexElementArray.h 00002 // Created by: aignacio (Jan06) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef VERTEX_ELEMENT_ARRAY_H 00016 #define VERTEX_ELEMENT_ARRAY_H 00017 00018 00019 enum 00020 { 00021 VS_END = 0, 00022 00023 VS_POSITION_XYZ, 00024 VS_POSITION_XYZW, 00025 VS_NORMAL, 00026 VS_DIFFUSE, 00027 VS_SPECULAR, 00028 VS_TEXTURE_U, 00029 VS_TEXTURE_UV, 00030 VS_TEXTURE_UVW, 00031 VS_TANGENT, 00032 VS_BINORMAL, 00033 00034 VS_ERROR, 00035 00036 VS_TOTAL_TYPES 00037 }; 00038 00039 typedef struct 00040 { 00041 int vs_input_type; // this is VS_XXXXX from the enum above 00042 int index; 00043 int stream; 00044 int offset; 00045 } 00046 VERTEX_ELEMENT_TYPE; 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Class : VertexElementArray 00050 // Description : This class gives the ability for a user-friendly way 00051 // of creating a vertex declaration for DirectX 9. 00052 // Since a vertex shader has a fixed input, the vertex 00053 // element array can be cached so that a new vertex 00054 // declaration for different vertex buffers can be 00055 // quickly created. Be sure to call 00056 // add_end_vertex_element ( ) when finished creating a 00057 // vertex element array. 00058 // VERTEX_ELEMENT_TYPE is used for a simplified mapping 00059 // of vertex buffer data to vertex shader inputs. 00060 // This class is used with DXShaderContext9 and in 00061 // conjunction with DXVertexBufferContext9. 00062 //////////////////////////////////////////////////////////////////// 00063 class VertexElementArray 00064 { 00065 public: 00066 00067 VertexElementArray (int maximum_vertex_elements); 00068 ~VertexElementArray ( ); 00069 00070 int set_vertex_element_offset (int vertex_element_index, int offset); 00071 void set_vs_input_type (int vs_input_type, VERTEX_ELEMENT_TYPE *vertex_element_type); 00072 00073 void add_position_xyz_vertex_element (int stream_index); 00074 void add_position_xyzw_vertex_element (int stream_index); 00075 void add_normal_vertex_element (int stream_index); 00076 void add_binormal_vertex_element (int stream_index); 00077 void add_tangent_vertex_element (int stream_index); 00078 void add_diffuse_color_vertex_element (int stream_index); 00079 void add_specular_color_vertex_element (int stream_index); 00080 void add_u_vertex_element (int stream_index); 00081 void add_uv_vertex_element (int stream_index); 00082 void add_uvw_vertex_element (int stream_index); 00083 int add_end_vertex_element (void); 00084 00085 int offset; 00086 int total_elements; 00087 int maximum_vertex_elements; 00088 int total_texture_coordinate_elements; 00089 int vertex_element_type_counter_array [VS_TOTAL_TYPES]; 00090 DIRECT_3D_VERTEX_ELEMENT *vertex_element_array; 00091 VERTEX_ELEMENT_TYPE *vertex_element_type_array; 00092 }; 00093 00094 #endif