goat3d

annotate src/material.cc @ 87:f0277d348c2c

fixed goat3d_get_node_<position|rotation|scaling> to return only the node's transformations
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 14 May 2014 18:28:38 +0300
parents 498ca7ac7047
children
rev   line source
nuclear@54 1 /*
nuclear@54 2 goat3d - 3D scene, character, and animation file format library.
nuclear@54 3 Copyright (C) 2013-2014 John Tsiombikas <nuclear@member.fsf.org>
nuclear@54 4
nuclear@54 5 This program is free software: you can redistribute it and/or modify
nuclear@54 6 it under the terms of the GNU Lesser General Public License as published by
nuclear@54 7 the Free Software Foundation, either version 3 of the License, or
nuclear@54 8 (at your option) any later version.
nuclear@54 9
nuclear@54 10 This program is distributed in the hope that it will be useful,
nuclear@54 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
nuclear@54 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
nuclear@54 13 GNU Lesser General Public License for more details.
nuclear@54 14
nuclear@54 15 You should have received a copy of the GNU Lesser General Public License
nuclear@54 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
nuclear@54 17 */
nuclear@9 18 #include "material.h"
nuclear@9 19
nuclear@47 20 using namespace g3dimpl;
nuclear@47 21
nuclear@15 22 MaterialAttrib Material::def_attr;
nuclear@15 23
nuclear@9 24 int Material::get_attrib_count() const
nuclear@9 25 {
nuclear@9 26 return (int)attrib.size();
nuclear@9 27 }
nuclear@9 28
nuclear@9 29 const char *Material::get_attrib_name(int idx) const
nuclear@9 30 {
nuclear@9 31 if(idx < 0 || idx >= get_attrib_count()) {
nuclear@9 32 return 0;
nuclear@9 33 }
nuclear@9 34
nuclear@9 35 std::map<std::string, MaterialAttrib>::const_iterator it = attrib.begin();
nuclear@9 36 for(int i=0; i<idx; i++) it++;
nuclear@9 37 return it->first.c_str();
nuclear@9 38 }
nuclear@9 39
nuclear@9 40 MaterialAttrib &Material::operator [](int idx)
nuclear@9 41 {
nuclear@9 42 if(idx < 0 || idx >= get_attrib_count()) {
nuclear@9 43 return def_attr;
nuclear@9 44 }
nuclear@9 45
nuclear@9 46 std::map<std::string, MaterialAttrib>::iterator it = attrib.begin();
nuclear@9 47 for(int i=0; i<idx; i++) it++;
nuclear@9 48 return it->second;
nuclear@9 49 }
nuclear@9 50
nuclear@9 51 const MaterialAttrib &Material::operator [](int idx) const
nuclear@9 52 {
nuclear@9 53 if(idx < 0 || idx >= get_attrib_count()) {
nuclear@9 54 return def_attr;
nuclear@9 55 }
nuclear@9 56
nuclear@9 57 std::map<std::string, MaterialAttrib>::const_iterator it = attrib.begin();
nuclear@9 58 for(int i=0; i<idx; i++) it++;
nuclear@9 59 return it->second;
nuclear@9 60 }
nuclear@9 61
nuclear@9 62 MaterialAttrib &Material::operator [](const std::string &name)
nuclear@9 63 {
nuclear@9 64 return attrib[name];
nuclear@9 65 }
nuclear@9 66
nuclear@9 67 const MaterialAttrib &Material::operator [](const std::string &name) const
nuclear@9 68 {
nuclear@9 69 std::map<std::string, MaterialAttrib>::const_iterator it;
nuclear@9 70 if((it = attrib.find(name)) != attrib.end()) {
nuclear@9 71 return it->second;
nuclear@9 72 }
nuclear@9 73 return def_attr;
nuclear@9 74 }
nuclear@9 75