2
* Make a donation http://sourceforge.net/donate/index.php?group_id=98797
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* Contact Josh DeFord jdeford@microcrowd.com
22
package com.microcrowd.loader.java3d.max3ds.chunks;
24
import javax.media.j3d.Transform3D;
25
import javax.vecmath.Point3f;
26
import com.microcrowd.loader.java3d.max3ds.ChunkChopper;
29
* Extracts the local coordinate that will act
30
* as a shape's axis that will be used by the mesh
33
public class AxisChunk extends Chunk
38
* Loads the local coordinate system for the current mesh.
40
* @param chopper the ChunkChopper containing the state of the parser.
42
* The location of the local coordinate system is defined relative to
43
* positions and rotations at frame 0. But the orientation is absolutely
46
* With either 3x3 or 4x4 rotation, translation, there
47
* is a simple relationship between each matrix and the resulting coordinate
48
* system. The first three columns of the matrix define the direction vector of the
49
* X, Y and Z axii respectively.
50
* If a 4x4 matrix is defined as:
57
* Then the direction vector for each axis is as follows:
65
* @return the actual number of bytes read.
67
public void loadData(ChunkChopper chopper)
69
Point3f xAxis = new Point3f();
70
xAxis = chopper.getPoint();
71
Point3f zAxis = chopper.getPoint();
72
Point3f yAxis = chopper.getPoint();
73
Point3f origin = chopper.getPoint();
75
Transform3D transform = new Transform3D(new double[]{
76
xAxis.x, xAxis.y, xAxis.z, origin.x,
77
yAxis.x, yAxis.y, yAxis.z, origin.y,
78
-zAxis.x, -zAxis.y, -zAxis.z, origin.z,
80
String meshName = chopper.getObjectName();
81
chopper.getKeyFramer().setCoordinateSystem(meshName, transform);