Mesh.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3      *
00003 *                (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS                    *
00004 *                                                                             *
00005 * This library is free software; you can redistribute it and/or modify it     *
00006 * under the terms of the GNU Lesser General Public License as published by    *
00007 * the Free Software Foundation; either version 2.1 of the License, or (at     *
00008 * your option) any later version.                                             *
00009 *                                                                             *
00010 * This library is distributed in the hope that it will be useful, but WITHOUT *
00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
00013 * for more details.                                                           *
00014 *                                                                             *
00015 * You should have received a copy of the GNU Lesser General Public License    *
00016 * along with this library; if not, write to the Free Software Foundation,     *
00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
00018 *******************************************************************************
00019 *                              SOFA :: Framework                              *
00020 *                                                                             *
00021 * Authors: M. Adam, J. Allard, B. Andre, P-J. Bensoussan, S. Cotin, C. Duriez,*
00022 * H. Delingette, F. Falipou, F. Faure, S. Fonteneau, L. Heigeas, C. Mendoza,  *
00023 * M. Nesme, P. Neumann, J-P. de la Plata Alcade, F. Poyer and F. Roy          *
00024 *                                                                             *
00025 * Contact information: contact@sofa-framework.org                             *
00026 ******************************************************************************/
00027 #include <sofa/helper/io/Mesh.h>
00028 #include <sofa/helper/Factory.inl>
00029 
00030 namespace sofa
00031 {
00032 
00033 namespace helper
00034 {
00035 
00036 namespace io
00037 {
00038 
00039 // commented by Sylvere
00040 // template class Factory<std::string, Mesh, std::string>;
00041 
00042 Mesh::Material::Material()
00043 {
00044   ambient =  Vec4f( 0.2f,0.2f,0.2f,1.0f);
00045   diffuse =  Vec4f( 0.75f,0.75f,0.75f,1.0f);
00046   specular =  Vec4f( 1.0f,1.0f,1.0f,1.0f);
00047   emissive =  Vec4f( 0.0f,0.0f,0.0f,0.0f);
00048 
00049   shininess =  45.0f;
00050   name = "Default";
00051   useAmbient =  true;
00052   useDiffuse =  true;
00053   useSpecular =  false;
00054   useEmissive =  false;
00055   useShininess =  false;
00056   activated = false;
00057 }
00058 
00059 void Mesh::Material::setColor(float r, float g, float b, float a)
00060 {
00061     float f[4] = { r, g, b, a };
00062     for (int i=0;i<4;i++)
00063     {
00064       ambient = Vec4f(f[0]*0.2f,f[1]*0.2f,f[2]*0.2f,f[3]);
00065       diffuse = Vec4f(f[0],f[1],f[2],f[3]);
00066       specular = Vec4f(f[0],f[1],f[2],f[3]);
00067       emissive = Vec4f(f[0],f[1],f[2],f[3]);
00068     }
00069 }
00070 
00071 Mesh* Mesh::Create(std::string filename)
00072 {
00073     std::string loader="default";
00074     std::string::size_type p = filename.rfind('.');
00075     if (p!=std::string::npos)
00076         loader = std::string(filename, p+1);
00077     return FactoryMesh::CreateObject(loader, filename);
00078 }
00079 
00080 } // namespace io
00081 
00082 } // namespace helper
00083 
00084 } // namespace sofa
00085 

Generated on Sun Nov 23 02:29:30 2008 for Sofa by  doxygen 1.5.7.1