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