00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "cLwoPoints.h"
00020 #include "lwoToEggConverter.h"
00021 #include "cLwoLayer.h"
00022
00023 #include <lwoVertexMap.h>
00024 #include <string_utils.h>
00025
00026
00027
00028
00029
00030
00031
00032
00033 void CLwoPoints::
00034 add_vmap(const LwoVertexMap *lwo_vmap) {
00035 IffId map_type = lwo_vmap->_map_type;
00036 const string &name = lwo_vmap->_name;
00037
00038 bool inserted;
00039 if (map_type == IffId("TXUV")) {
00040 inserted =
00041 _txuv.insert(VMap::value_type(name, lwo_vmap)).second;
00042
00043 } else if (map_type == IffId("PICK")) {
00044 inserted =
00045 _pick.insert(VMap::value_type(name, lwo_vmap)).second;
00046
00047 } else {
00048 return;
00049 }
00050
00051 if (!inserted) {
00052 nout << "Multiple vertex maps on the same points of type "
00053 << map_type << " named " << name << "\n";
00054 }
00055 }
00056
00057
00058
00059
00060
00061
00062
00063
00064 bool CLwoPoints::
00065 get_uv(const string &uv_name, int n, LPoint2f &uv) const {
00066 VMap::const_iterator ni = _txuv.find(uv_name);
00067 if (ni == _txuv.end()) {
00068 return false;
00069 }
00070
00071 const LwoVertexMap *vmap = (*ni).second;
00072 if (vmap->_dimension != 2) {
00073 nout << "Unexpected dimension of " << vmap->_dimension
00074 << " for UV map " << uv_name << "\n";
00075 return false;
00076 }
00077
00078 if (!vmap->has_value(n)) {
00079 return false;
00080 }
00081
00082 PTA_float value = vmap->get_value(n);
00083
00084 uv.set(value[0], value[1]);
00085 return true;
00086 }
00087
00088
00089
00090
00091
00092
00093
00094 void CLwoPoints::
00095 make_egg() {
00096
00097
00098 string vpool_name = "layer" + format_string(_layer->get_number());
00099 _egg_vpool = new EggVertexPool(vpool_name);
00100 }
00101
00102
00103
00104
00105
00106
00107 void CLwoPoints::
00108 connect_egg() {
00109 if (!_egg_vpool->empty()) {
00110 _layer->_egg_group->add_child(_egg_vpool.p());
00111 }
00112 }
00113