Blender V2.61 - r43446

LOD_ExternVColorEditor.cpp

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00033 #include "LOD_ExternVColorEditor.h"
00034 
00035 #include <vector>
00036 
00037 using namespace std;
00038 
00039 
00040 LOD_ExternVColorEditor::
00041 LOD_ExternVColorEditor(
00042     LOD_Decimation_InfoPtr extern_info
00043 ) :
00044     m_extern_info (extern_info)
00045 {
00046 }
00047 
00048     LOD_ExternVColorEditor *
00049 LOD_ExternVColorEditor::
00050 New(
00051     LOD_Decimation_InfoPtr extern_info
00052 ){
00053     if (extern_info == NULL) return NULL;
00054     
00055     NanPtr<LOD_ExternVColorEditor> output(new LOD_ExternVColorEditor(extern_info));
00056 
00057     return output.Release();
00058 };
00059     
00060 
00061 // vertex normals
00063 
00064     void
00065 LOD_ExternVColorEditor::
00066 RemoveVertexColors(
00067     const vector<LOD_VertexInd> &sorted_verts
00068 ){
00069 
00070     float * vertex_colors = m_extern_info->vertex_color_buffer;
00071 
00072     // assumption here that the vertexs normal number corresponds with 
00073     // the number of vertices !
00074 
00075     int vertex_color_num = m_extern_info->vertex_num; 
00076 
00077     vector<LOD_VertexInd>::const_iterator it_start = sorted_verts.begin();
00078     vector<LOD_VertexInd>::const_iterator it_end = sorted_verts.end();
00079 
00080     for (; it_start != it_end; ++it_start) {
00081 
00082         if (vertex_color_num > 0) {
00083 
00084             float * vertex_color = vertex_colors + int(*it_start)*3;
00085             float * last_color = vertex_colors + ((vertex_color_num-1)*3);
00086 
00087             MT_Vector3 last_c(last_color);
00088             last_c.getValue(vertex_color);
00089 
00090             vertex_color_num--;
00091         }
00092 
00093         // FIXME - throw exception
00094     }
00095 };
00096 
00097 // Return the color for vertex v
00098 
00099     MT_Vector3
00100 LOD_ExternVColorEditor::
00101 IndexColor(
00102     const LOD_VertexInd &v
00103 ) const {
00104     return MT_Vector3(m_extern_info->vertex_color_buffer + int(v)*3);
00105 }
00106 
00107 
00108 // Set the color for vertex v
00109 
00110     void
00111 LOD_ExternVColorEditor::
00112 SetColor(
00113     MT_Vector3 c,
00114     const LOD_VertexInd &v
00115 ) {
00116     c.getValue(m_extern_info->vertex_color_buffer + int(v)*3);
00117 }
00118 
00119 
00120 
00121 
00122