00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "cLwoSurfaceBlockTMap.h"
00016 #include "lwoToEggConverter.h"
00017
00018 #include "lwoSurfaceBlockTransform.h"
00019 #include "lwoSurfaceBlockRefObj.h"
00020 #include "compose_matrix.h"
00021 #include "dcast.h"
00022
00023
00024
00025
00026
00027
00028 CLwoSurfaceBlockTMap::
00029 CLwoSurfaceBlockTMap(LwoToEggConverter *converter, const LwoSurfaceBlockTMap *tmap) :
00030 _converter(converter),
00031 _tmap(tmap)
00032 {
00033 _center.set(0.0, 0.0, 0.0);
00034 _size.set(1.0, 1.0, 1.0);
00035 _rotation.set(0.0, 0.0, 0.0);
00036 _csys = LwoSurfaceBlockCoordSys::T_object;
00037 _reference_object = "(none)";
00038
00039
00040 int num_chunks = _tmap->get_num_chunks();
00041 for (int i = 0; i < num_chunks; i++) {
00042 const IffChunk *chunk = _tmap->get_chunk(i);
00043
00044 if (chunk->is_of_type(LwoSurfaceBlockTransform::get_class_type())) {
00045 const LwoSurfaceBlockTransform *trans = DCAST(LwoSurfaceBlockTransform, chunk);
00046 if (trans->get_id() == IffId("CNTR")) {
00047 _center = trans->_vec;
00048 } else if (trans->get_id() == IffId("SIZE")) {
00049 _size = trans->_vec;
00050 } else if (trans->get_id() == IffId("ROTA")) {
00051 _rotation = trans->_vec;
00052 }
00053
00054 } else if (chunk->is_of_type(LwoSurfaceBlockRefObj::get_class_type())) {
00055 const LwoSurfaceBlockRefObj *ref = DCAST(LwoSurfaceBlockRefObj, chunk);
00056 _reference_object = ref->_name;
00057
00058 } else if (chunk->is_of_type(LwoSurfaceBlockCoordSys::get_class_type())) {
00059 const LwoSurfaceBlockCoordSys *csys = DCAST(LwoSurfaceBlockCoordSys, chunk);
00060 _csys = csys->_type;
00061 }
00062 }
00063 }
00064
00065
00066
00067
00068
00069
00070
00071
00072 void CLwoSurfaceBlockTMap::
00073 get_transform(LMatrix4d &mat) const {
00074 LPoint3d hpr(rad_2_deg(_rotation[0]),
00075 rad_2_deg(-_rotation[1]),
00076 rad_2_deg(-_rotation[2]));
00077 compose_matrix(mat, LCAST(double, _size), hpr,
00078 LCAST(double, _center), CS_yup_left);
00079 }