Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/lwoegg/cLwoPoints.cxx

Go to the documentation of this file.
00001 // Filename: cLwoPoints.cxx
00002 // Created by:  drose (25Apr01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
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 //     Function: CLwoPoints::add_vmap
00028 //       Access: Public
00029 //  Description: Associates the indicated VertexMap with the points
00030 //               set.  This may define such niceties as UV coordinates
00031 //               or per-vertex color.
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 //     Function: CLwoPoints::get_uv
00059 //       Access: Public
00060 //  Description: Returns true if there is a UV of the indicated name
00061 //               associated with the given vertex, false otherwise.
00062 //               If true, fills in uv with the value.
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 //     Function: CLwoPoints::make_egg
00090 //       Access: Public
00091 //  Description: Creates the egg structures associated with this
00092 //               Lightwave object.
00093 ////////////////////////////////////////////////////////////////////
00094 void CLwoPoints::
00095 make_egg() {
00096   // Generate a vpool name based on the layer index, for lack of
00097   // anything better.
00098   string vpool_name = "layer" + format_string(_layer->get_number());
00099   _egg_vpool = new EggVertexPool(vpool_name);
00100 }
00101 
00102 ////////////////////////////////////////////////////////////////////
00103 //     Function: CLwoPoints::connect_egg
00104 //       Access: Public
00105 //  Description: Connects all the egg structures together.
00106 ////////////////////////////////////////////////////////////////////
00107 void CLwoPoints::
00108 connect_egg() {
00109   if (!_egg_vpool->empty()) {
00110     _layer->_egg_group->add_child(_egg_vpool.p());
00111   }
00112 }
00113 

Generated on Fri May 2 03:21:08 2003 for Panda-Tool by doxygen1.3