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