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

pandatool/src/lwoegg/cLwoSurfaceBlockTMap.cxx

Go to the documentation of this file.
00001 // Filename: cLwoSurfaceBlockTMap.cxx
00002 // Created by:  drose (30Apr01)
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 "cLwoSurfaceBlockTMap.h"
00020 #include "lwoToEggConverter.h"
00021 
00022 #include "lwoSurfaceBlockTransform.h"
00023 #include "lwoSurfaceBlockRefObj.h"
00024 #include "compose_matrix.h"
00025 #include "dcast.h"
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: CLwoSurfaceBlockTMap::Constructor
00029 //       Access: Public
00030 //  Description:
00031 ////////////////////////////////////////////////////////////////////
00032 CLwoSurfaceBlockTMap::
00033 CLwoSurfaceBlockTMap(LwoToEggConverter *converter, const LwoSurfaceBlockTMap *tmap) :
00034   _converter(converter),
00035   _tmap(tmap)
00036 {
00037   _center.set(0.0, 0.0, 0.0);
00038   _size.set(1.0, 1.0, 1.0);
00039   _rotation.set(0.0, 0.0, 0.0);
00040   _csys = LwoSurfaceBlockCoordSys::T_object;
00041   _reference_object = "(none)";
00042 
00043   // Scan the chunks in the body.
00044   int num_chunks = _tmap->get_num_chunks();
00045   for (int i = 0; i < num_chunks; i++) {
00046     const IffChunk *chunk = _tmap->get_chunk(i);
00047 
00048     if (chunk->is_of_type(LwoSurfaceBlockTransform::get_class_type())) {
00049       const LwoSurfaceBlockTransform *trans = DCAST(LwoSurfaceBlockTransform, chunk);
00050       if (trans->get_id() == IffId("CNTR")) {
00051         _center = trans->_vec;
00052       } else if (trans->get_id() == IffId("SIZE")) {
00053         _size = trans->_vec;
00054       } else if (trans->get_id() == IffId("ROTA")) {
00055         _rotation = trans->_vec;
00056       }
00057 
00058     } else if (chunk->is_of_type(LwoSurfaceBlockRefObj::get_class_type())) {
00059       const LwoSurfaceBlockRefObj *ref = DCAST(LwoSurfaceBlockRefObj, chunk);
00060       _reference_object = ref->_name;
00061 
00062     } else if (chunk->is_of_type(LwoSurfaceBlockCoordSys::get_class_type())) {
00063       const LwoSurfaceBlockCoordSys *csys = DCAST(LwoSurfaceBlockCoordSys, chunk);
00064       _csys = csys->_type;
00065    }
00066   }
00067 }
00068 
00069 ////////////////////////////////////////////////////////////////////
00070 //     Function: CLwoSurfaceBlockTMap::get_transform
00071 //       Access: Public
00072 //  Description: Fills up the indicated matrix with the net transform
00073 //               indicated by the TMAP chunk, accounting for scale,
00074 //               rotate, and translate.
00075 ////////////////////////////////////////////////////////////////////
00076 void CLwoSurfaceBlockTMap::
00077 get_transform(LMatrix4d &mat) const {
00078   LPoint3d hpr(rad_2_deg(_rotation[0]),
00079                rad_2_deg(-_rotation[1]),
00080                rad_2_deg(-_rotation[2]));
00081   compose_matrix(mat, LCAST(double, _size), hpr,
00082                  LCAST(double, _center), CS_yup_left);
00083 }

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