Panda3D

cLwoSurfaceBlockTMap.cxx
Go to the documentation of this file.
1 /**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file cLwoSurfaceBlockTMap.cxx
10 * @author drose
11 * @date 2001-04-30
12 */
13
14 #include "cLwoSurfaceBlockTMap.h"
15 #include "lwoToEggConverter.h"
16
17 #include "lwoSurfaceBlockTransform.h"
18 #include "lwoSurfaceBlockRefObj.h"
19 #include "compose_matrix.h"
20 #include "dcast.h"
21
22 /**
23 *
24 */
25 CLwoSurfaceBlockTMap::
26 CLwoSurfaceBlockTMap(LwoToEggConverter *converter, const LwoSurfaceBlockTMap *tmap) :
27 _converter(converter),
28 _tmap(tmap)
29 {
30 _center.set(0.0, 0.0, 0.0);
31 _size.set(1.0, 1.0, 1.0);
32 _rotation.set(0.0, 0.0, 0.0);
33 _csys = LwoSurfaceBlockCoordSys::T_object;
34 _reference_object = "(none)";
35
36 // Scan the chunks in the body.
37 int num_chunks = _tmap->get_num_chunks();
38 for (int i = 0; i < num_chunks; i++) {
39 const IffChunk *chunk = _tmap->get_chunk(i);
40
41 if (chunk->is_of_type(LwoSurfaceBlockTransform::get_class_type())) {
42 const LwoSurfaceBlockTransform *trans = DCAST(LwoSurfaceBlockTransform, chunk);
43 if (trans->get_id() == IffId("CNTR")) {
44 _center = trans->_vec;
45 } else if (trans->get_id() == IffId("SIZE")) {
46 _size = trans->_vec;
47 } else if (trans->get_id() == IffId("ROTA")) {
48 _rotation = trans->_vec;
49 }
50
51 } else if (chunk->is_of_type(LwoSurfaceBlockRefObj::get_class_type())) {
52 const LwoSurfaceBlockRefObj *ref = DCAST(LwoSurfaceBlockRefObj, chunk);
53 _reference_object = ref->_name;
54
55 } else if (chunk->is_of_type(LwoSurfaceBlockCoordSys::get_class_type())) {
56 const LwoSurfaceBlockCoordSys *csys = DCAST(LwoSurfaceBlockCoordSys, chunk);
57 _csys = csys->_type;
58 }
59 }
60 }
61
62 /**
63 * Fills up the indicated matrix with the net transform indicated by the TMAP
64 * chunk, accounting for scale, rotate, and translate.
65 */
66 void CLwoSurfaceBlockTMap::
67 get_transform(LMatrix4d &mat) const {
68 LPoint3d hpr(rad_2_deg(_rotation[0]),
69 rad_2_deg(-_rotation[1]),
70 rad_2_deg(-_rotation[2]));
71 compose_matrix(mat, LCAST(double, _size), hpr,
72 LCAST(double, _center), CS_yup_left);
73 }
cLwoSurfaceBlockTMap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CLwoSurfaceBlockTMap::get_transform
void get_transform(LMatrix4d &mat) const
Fills up the indicated matrix with the net transform indicated by the TMAP chunk, accounting for scal...
Definition: cLwoSurfaceBlockTMap.cxx:67
IffChunk
The basic kind of record in an EA "IFF" file, which the LightWave object file is based on.
Definition: iffChunk.h:30
IffChunk::get_id
IffId get_id() const
Returns the ID associated with this chunk.
Definition: iffChunk.I:25
IffId
A four-byte chunk ID appearing in an "IFF" file.
Definition: iffId.h:26
LwoSurfaceBlockCoordSys
Specifies whether texture coordinates are computed based on the vertices' world coordinates or local ...
Definition: lwoSurfaceBlockCoordSys.h:25
LwoSurfaceBlockRefObj
Specifies a reference object that the texture UV's are to be computed relative to.
Definition: lwoSurfaceBlockRefObj.h:25
LwoSurfaceBlockTMap
The tMap chunk within a LwoSurfaceBlock chunk.
Definition: lwoSurfaceBlockTMap.h:24
LwoSurfaceBlockTransform
Specifies a center point, scale, or rotation for the texture coordinates in this shader's texture map...
Definition: lwoSurfaceBlockTransform.h:29
LwoToEggConverter
This class supervises the construction of an EggData structure from the data represented by the LwoHe...
Definition: lwoToEggConverter.h:38
TypedObject::is_of_type
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
Definition: typedObject.I:28
compose_matrix.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dcast.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
lwoSurfaceBlockRefObj.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
lwoSurfaceBlockTransform.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
lwoToEggConverter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.