Rev 1788 | Rev 1801 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1720 | chris | 1 | package com.gebauz.bauzoid2.graphics.model; |
| 2 | |||
| 1782 | chris | 3 | import com.gebauz.bauzoid2.math.Matrix4; |
| 1778 | chris | 4 | import com.gebauz.bauzoid2.math.Quaternion; |
| 5 | import com.gebauz.bauzoid2.math.Vector3; |
||
| 6 | |||
| 1720 | chris | 7 | /** |
| 8 | * Created by chris on 14.12.2014. |
||
| 9 | */ |
||
| 10 | public class ModelPart |
||
| 11 | { |
||
| 12 | // Constants======================================================================================== |
||
| 13 | |||
| 14 | |||
| 1778 | chris | 15 | |
| 1720 | chris | 16 | // Fields=========================================================================================== |
| 17 | |||
| 18 | private String mName = null; |
||
| 19 | |||
| 20 | private MeshGroup mMeshGroup = null; |
||
| 21 | private Material mMaterial = null; |
||
| 22 | |||
| 1779 | chris | 23 | private ModelNode[] mBoneInfluences = null; |
| 1782 | chris | 24 | private Matrix4[] mMatrices = null; |
| 1779 | chris | 25 | |
| 1720 | chris | 26 | // Methods========================================================================================== |
| 27 | |||
| 28 | public ModelPart(String name, MeshGroup group, Material material) |
||
| 29 | { |
||
| 30 | mName = name; |
||
| 31 | |||
| 32 | mMeshGroup = group; |
||
| 33 | mMaterial = material; |
||
| 34 | } |
||
| 35 | |||
| 1788 | chris | 36 | public Matrix4[] calcBoneMatrices() |
| 37 | { |
||
| 38 | mMatrices = new Matrix4[mBoneInfluences.length]; |
||
| 39 | for (int i = 0; i < mMatrices.length; i++) |
||
| 1800 | chris | 40 | { |
| 41 | ModelNode bone = mBoneInfluences[i]; |
||
| 1788 | chris | 42 | |
| 1800 | chris | 43 | Quaternion q = new Quaternion(0.5f, -0.5f, 0.5f, 0.5f); |
| 44 | |||
| 45 | mMatrices[i] = new Matrix4(); |
||
| 46 | mMatrices[i].identity(); |
||
| 47 | //mMatrices[i].copyFrom(bone.getGlobalTransform()); |
||
| 48 | |||
| 49 | mMatrices[i].multiply(bone.transform.calcMatrix()); |
||
| 50 | mMatrices[i].multiply(bone.bindPose.calcMatrix().getInverse()); |
||
| 51 | |||
| 52 | } |
||
| 53 | |||
| 1788 | chris | 54 | return mMatrices; |
| 55 | } |
||
| 56 | |||
| 1720 | chris | 57 | // Getters/Setters================================================================================== |
| 1723 | chris | 58 | |
| 1777 | chris | 59 | public final Material getMaterial() { return mMaterial; } |
| 1723 | chris | 60 | |
| 1777 | chris | 61 | public final MeshGroup getMeshGroup() { return mMeshGroup; } |
| 62 | |||
| 1780 | chris | 63 | public final void setBoneInfluences(ModelNode[] influences) |
| 64 | { |
||
| 65 | mBoneInfluences = influences; |
||
| 66 | |||
| 1782 | chris | 67 | mMatrices = new Matrix4[influences.length]; |
| 68 | for (int i = 0; i < mMatrices.length; i++) |
||
| 69 | mMatrices[i] = Matrix4.createIdentity(); |
||
| 1780 | chris | 70 | } |
| 1782 | chris | 71 | |
| 1779 | chris | 72 | public final ModelNode[] getBoneInfluences() { return mBoneInfluences; } |
| 73 | |||
| 1782 | chris | 74 | public final Matrix4[] getBoneMatrices() { return mMatrices; } |
| 75 | |||
| 76 | |||
| 1720 | chris | 77 | } |