00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00029
00030
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
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
00071
00072
00073
00074
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 }