Panda3D
cLwoLayer.cxx
1 // Filename: cLwoLayer.cxx
2 // Created by: drose (25Apr01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "cLwoLayer.h"
16 #include "lwoToEggConverter.h"
17 
18 #include "eggData.h"
19 
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: CLwoLayer::make_egg
23 // Access: Public
24 // Description: Creates the egg structures associated with this
25 // Lightwave object.
26 ////////////////////////////////////////////////////////////////////
27 void CLwoLayer::
29  _egg_group = new EggGroup(_layer->_name);
30 
31  if (_layer->_pivot != LPoint3::zero()) {
32  // If we have a nonzero pivot point, that's a translation
33  // transform.
34  LPoint3d translate = LCAST(double, _layer->_pivot);
35  _egg_group->set_transform3d(LMatrix4d::translate_mat(translate));
36  _egg_group->set_group_type(EggGroup::GT_instance);
37  }
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: CLwoLayer::connect_egg
42 // Access: Public
43 // Description: Connects all the egg structures together.
44 ////////////////////////////////////////////////////////////////////
45 void CLwoLayer::
47  if (_layer->_parent != -1) {
48  const CLwoLayer *parent = _converter->get_layer(_layer->_parent);
49  if (parent != (CLwoLayer *)NULL) {
50  parent->_egg_group->add_child(_egg_group.p());
51  return;
52  }
53 
54  nout << "No layer found with number " << _layer->_parent
55  << "; cannot parent layer " << _layer->_number << " properly.\n";
56  }
57 
58  _converter->get_egg_data()->add_child(_egg_group.p());
59 }
60 
static const LPoint3f & zero()
Returns a zero-length point.
Definition: lpoint3.h:259
EggData * get_egg_data()
Returns the EggData structure.
void make_egg()
Creates the egg structures associated with this Lightwave object.
Definition: cLwoLayer.cxx:28
static LMatrix4d translate_mat(const LVecBase3d &trans)
Returns a matrix that applies the indicated translation.
Definition: lmatrix.h:6662
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
Definition: eggGroup.h:36
This class is a wrapper around LwoLayer and stores additional information useful during the conversio...
Definition: cLwoLayer.h:32
CLwoLayer * get_layer(int number) const
Returns a pointer to the layer with the given index number, or NULL if there is no such layer...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:544
EggNode * add_child(EggNode *node)
Adds the indicated child to the group and returns it.
void connect_egg()
Connects all the egg structures together.
Definition: cLwoLayer.cxx:46