Welcome to mirror list, hosted at ThFree Co, Russian Federation.

collada_internal.h « collada « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 278cd37ac66b18b98233adea98cbb70f3bb2549e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef BLENDER_COLLADA_H
#define BLENDER_COLLADA_H

#include "COLLADAFWFileInfo.h"
#include "Math/COLLADABUMathMatrix4.h"

class UnitConverter
{
private:
	COLLADAFW::FileInfo::Unit unit;
	COLLADAFW::FileInfo::UpAxisType up_axis;

public:

	UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP) {}

	void read_asset(const COLLADAFW::FileInfo* asset)
	{
	}

	// TODO
	// convert vector vec from COLLADA format to Blender
	void convertVec3(float *vec)
	{
	}
		
	// TODO need also for angle conversion, time conversion...

	void dae_matrix_to_mat4(float out[][4], const COLLADABU::Math::Matrix4& in)
	{
		// in DAE, matrices use columns vectors, (see comments in COLLADABUMathMatrix4.h)
		// so here, to make a blender matrix, we swap columns and rows
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				out[i][j] = in[j][i];
			}
		}
	}

	void mat4_to_dae(float out[][4], float in[][4])
	{
		copy_m4_m4(out, in);
		transpose_m4(out);
	}

	void mat4_to_dae_double(double out[][4], float in[][4])
	{
		float mat[4][4];

		mat4_to_dae(mat, in);

		for (int i = 0; i < 4; i++)
			for (int j = 0; j < 4; j++)
				out[i][j] = mat[i][j];
	}
};

class TransformBase
{
public:
	void decompose(float mat[][4], float *loc, float eul[3], float quat[4], float *size)
	{
		mat4_to_size(size, mat);
		if (eul)
			mat4_to_eul(eul, mat);
		if (quat)
			mat4_to_quat(quat, mat);
		copy_v3_v3(loc, mat[3]);
	}
};

#endif