00001 // Filename: cLwoLayer.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 "cLwoLayer.h" 00020 #include "lwoToEggConverter.h" 00021 00022 #include <eggData.h> 00023 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Function: CLwoLayer::make_egg 00027 // Access: Public 00028 // Description: Creates the egg structures associated with this 00029 // Lightwave object. 00030 //////////////////////////////////////////////////////////////////// 00031 void CLwoLayer:: 00032 make_egg() { 00033 _egg_group = new EggGroup(_layer->_name); 00034 00035 if (_layer->_pivot != LPoint3f::zero()) { 00036 // If we have a nonzero pivot point, that's a translation 00037 // transform. 00038 LPoint3d translate = LCAST(double, _layer->_pivot); 00039 _egg_group->set_transform(LMatrix4d::translate_mat(translate)); 00040 _egg_group->set_group_type(EggGroup::GT_instance); 00041 } 00042 } 00043 00044 //////////////////////////////////////////////////////////////////// 00045 // Function: CLwoLayer::connect_egg 00046 // Access: Public 00047 // Description: Connects all the egg structures together. 00048 //////////////////////////////////////////////////////////////////// 00049 void CLwoLayer:: 00050 connect_egg() { 00051 if (_layer->_parent != -1) { 00052 const CLwoLayer *parent = _converter->get_layer(_layer->_parent); 00053 if (parent != (CLwoLayer *)NULL) { 00054 parent->_egg_group->add_child(_egg_group.p()); 00055 return; 00056 } 00057 00058 nout << "No layer found with number " << _layer->_parent 00059 << "; cannot parent layer " << _layer->_number << " properly.\n"; 00060 } 00061 00062 _converter->get_egg_data().add_child(_egg_group.p()); 00063 } 00064