org.lwjgl.assimp.AIVector3D Java Examples

The following examples show how to use org.lwjgl.assimp.AIVector3D. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnimMeshesLoader.java    From lwjglbook with Apache License 2.0 6 votes vote down vote up
private static void buildTransFormationMatrices(AINodeAnim aiNodeAnim, Node node) {
    int numFrames = aiNodeAnim.mNumPositionKeys();
    AIVectorKey.Buffer positionKeys = aiNodeAnim.mPositionKeys();
    AIVectorKey.Buffer scalingKeys = aiNodeAnim.mScalingKeys();
    AIQuatKey.Buffer rotationKeys = aiNodeAnim.mRotationKeys();

    for (int i = 0; i < numFrames; i++) {
        AIVectorKey aiVecKey = positionKeys.get(i);
        AIVector3D vec = aiVecKey.mValue();

        Matrix4f transfMat = new Matrix4f().translate(vec.x(), vec.y(), vec.z());

        AIQuatKey quatKey = rotationKeys.get(i);
        AIQuaternion aiQuat = quatKey.mValue();
        Quaternionf quat = new Quaternionf(aiQuat.x(), aiQuat.y(), aiQuat.z(), aiQuat.w());
        transfMat.rotate(quat);

        if (i < aiNodeAnim.mNumScalingKeys()) {
            aiVecKey = scalingKeys.get(i);
            vec = aiVecKey.mValue();
            transfMat.scale(vec.x(), vec.y(), vec.z());
        }

        node.addTransformation(transfMat);
    }
}
 
Example #2
Source File: AnimMeshesLoader.java    From lwjglbook with Apache License 2.0 6 votes vote down vote up
private static void buildTransFormationMatrices(AINodeAnim aiNodeAnim, Node node) {
    int numFrames = aiNodeAnim.mNumPositionKeys();
    AIVectorKey.Buffer positionKeys = aiNodeAnim.mPositionKeys();
    AIVectorKey.Buffer scalingKeys = aiNodeAnim.mScalingKeys();
    AIQuatKey.Buffer rotationKeys = aiNodeAnim.mRotationKeys();

    for (int i = 0; i < numFrames; i++) {
        AIVectorKey aiVecKey = positionKeys.get(i);
        AIVector3D vec = aiVecKey.mValue();

        Matrix4f transfMat = new Matrix4f().translate(vec.x(), vec.y(), vec.z());

        AIQuatKey quatKey = rotationKeys.get(i);
        AIQuaternion aiQuat = quatKey.mValue();
        Quaternionf quat = new Quaternionf(aiQuat.x(), aiQuat.y(), aiQuat.z(), aiQuat.w());
        transfMat.rotate(quat);

        if (i < aiNodeAnim.mNumScalingKeys()) {
            aiVecKey = scalingKeys.get(i);
            vec = aiVecKey.mValue();
            transfMat.scale(vec.x(), vec.y(), vec.z());
        }

        node.addTransformation(transfMat);
    }
}
 
Example #3
Source File: AssimpAPI.java    From WraithEngine with Apache License 2.0 5 votes vote down vote up
@Override
public void getVertexUV(float[] data, int pos, int index, int uvLayer)
{
    AIVector3D vec = mesh.mTextureCoords(uvLayer)
                         .get(index);

    data[pos] = vec.x();
    data[pos + 1] = vec.y();
}
 
Example #4
Source File: StaticMeshesLoader.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
protected static void processNormals(AIMesh aiMesh, List<Float> normals) {
    AIVector3D.Buffer aiNormals = aiMesh.mNormals();
    while (aiNormals != null && aiNormals.remaining() > 0) {
        AIVector3D aiNormal = aiNormals.get();
        normals.add(aiNormal.x());
        normals.add(aiNormal.y());
        normals.add(aiNormal.z());
    }
}
 
Example #5
Source File: AssimpAPI.java    From WraithEngine with Apache License 2.0 5 votes vote down vote up
@Override
public void getVertexBitangent(float[] data, int pos, int index)
{
    AIVector3D vec = mesh.mBitangents()
                         .get(index);

    data[pos] = vec.x();
    data[pos + 1] = vec.y();
    data[pos + 2] = vec.z();
}
 
Example #6
Source File: AssimpAPI.java    From WraithEngine with Apache License 2.0 5 votes vote down vote up
@Override
public void getVertexTangent(float[] data, int pos, int index)
{
    AIVector3D vec = mesh.mTangents()
                         .get(index);

    data[pos] = vec.x();
    data[pos + 1] = vec.y();
    data[pos + 2] = vec.z();
}
 
Example #7
Source File: AssimpAPI.java    From WraithEngine with Apache License 2.0 5 votes vote down vote up
@Override
public void getVertexNormal(float[] data, int pos, int index)
{
    AIVector3D vec = mesh.mNormals()
                         .get(index);

    data[pos] = vec.x();
    data[pos + 1] = vec.y();
    data[pos + 2] = vec.z();
}
 
Example #8
Source File: AssimpAPI.java    From WraithEngine with Apache License 2.0 5 votes vote down vote up
@Override
public void getVertexPosition(float[] data, int pos, int index)
{
    AIVector3D vec = mesh.mVertices()
                         .get(index);

    data[pos] = vec.x();
    data[pos + 1] = vec.y();
    data[pos + 2] = vec.z();
}
 
Example #9
Source File: AssimpAPI.java    From WraithEngine with Apache License 2.0 5 votes vote down vote up
@Override
public void getVertexUV(float[] data, int pos, int index, int uvLayer)
{
    AIVector3D vec = mesh.mTextureCoords(uvLayer)
                         .get(index);

    data[pos] = vec.x();
    data[pos + 1] = vec.y();
}
 
Example #10
Source File: AssimpAPI.java    From WraithEngine with Apache License 2.0 5 votes vote down vote up
@Override
public void getVertexBitangent(float[] data, int pos, int index)
{
    AIVector3D vec = mesh.mBitangents()
                         .get(index);

    data[pos] = vec.x();
    data[pos + 1] = vec.y();
    data[pos + 2] = vec.z();
}
 
Example #11
Source File: AssimpAPI.java    From WraithEngine with Apache License 2.0 5 votes vote down vote up
@Override
public void getVertexTangent(float[] data, int pos, int index)
{
    AIVector3D vec = mesh.mTangents()
                         .get(index);

    data[pos] = vec.x();
    data[pos + 1] = vec.y();
    data[pos + 2] = vec.z();
}
 
Example #12
Source File: AssimpAPI.java    From WraithEngine with Apache License 2.0 5 votes vote down vote up
@Override
public void getVertexNormal(float[] data, int pos, int index)
{
    AIVector3D vec = mesh.mNormals()
                         .get(index);

    data[pos] = vec.x();
    data[pos + 1] = vec.y();
    data[pos + 2] = vec.z();
}
 
Example #13
Source File: AssimpAPI.java    From WraithEngine with Apache License 2.0 5 votes vote down vote up
@Override
public void getVertexPosition(float[] data, int pos, int index)
{
    AIVector3D vec = mesh.mVertices()
                         .get(index);

    data[pos] = vec.x();
    data[pos + 1] = vec.y();
    data[pos + 2] = vec.z();
}
 
Example #14
Source File: StaticMeshesLoader.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
protected static void processVertices(AIMesh aiMesh, List<Float> vertices) {
    AIVector3D.Buffer aiVertices = aiMesh.mVertices();
    while (aiVertices.remaining() > 0) {
        AIVector3D aiVertex = aiVertices.get();
        vertices.add(aiVertex.x());
        vertices.add(aiVertex.y());
        vertices.add(aiVertex.z());
    }
}
 
Example #15
Source File: StaticMeshesLoader.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
protected static void processTextCoords(AIMesh aiMesh, List<Float> textures) {
    AIVector3D.Buffer textCoords = aiMesh.mTextureCoords(0);
    int numTextCoords = textCoords != null ? textCoords.remaining() : 0;
    for (int i = 0; i < numTextCoords; i++) {
        AIVector3D textCoord = textCoords.get();
        textures.add(textCoord.x());
        textures.add(1 - textCoord.y());
    }
}
 
Example #16
Source File: StaticMeshesLoader.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
protected static void processNormals(AIMesh aiMesh, List<Float> normals) {
    AIVector3D.Buffer aiNormals = aiMesh.mNormals();
    while (aiNormals != null && aiNormals.remaining() > 0) {
        AIVector3D aiNormal = aiNormals.get();
        normals.add(aiNormal.x());
        normals.add(aiNormal.y());
        normals.add(aiNormal.z());
    }
}
 
Example #17
Source File: StaticMeshesLoader.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private static void processTextCoords(AIMesh aiMesh, List<Float> textures) {
    AIVector3D.Buffer textCoords = aiMesh.mTextureCoords(0);
    int numTextCoords = textCoords != null ? textCoords.remaining() : 0;
    for (int i = 0; i < numTextCoords; i++) {
        AIVector3D textCoord = textCoords.get();
        textures.add(textCoord.x());
        textures.add(1 - textCoord.y());
    }
}
 
Example #18
Source File: StaticMeshesLoader.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private static void processNormals(AIMesh aiMesh, List<Float> normals) {
    AIVector3D.Buffer aiNormals = aiMesh.mNormals();
    while (aiNormals != null && aiNormals.remaining() > 0) {
        AIVector3D aiNormal = aiNormals.get();
        normals.add(aiNormal.x());
        normals.add(aiNormal.y());
        normals.add(aiNormal.z());
    }
}
 
Example #19
Source File: StaticMeshesLoader.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private static void processVertices(AIMesh aiMesh, List<Float> vertices) {
    AIVector3D.Buffer aiVertices = aiMesh.mVertices();
    while (aiVertices.remaining() > 0) {
        AIVector3D aiVertex = aiVertices.get();
        vertices.add(aiVertex.x());
        vertices.add(aiVertex.y());
        vertices.add(aiVertex.z());
    }
}
 
Example #20
Source File: StaticMeshesLoader.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
protected static void processVertices(AIMesh aiMesh, List<Float> vertices) {
    AIVector3D.Buffer aiVertices = aiMesh.mVertices();
    while (aiVertices.remaining() > 0) {
        AIVector3D aiVertex = aiVertices.get();
        vertices.add(aiVertex.x());
        vertices.add(aiVertex.y());
        vertices.add(aiVertex.z());
    }
}
 
Example #21
Source File: StaticMeshesLoader.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
protected static void processTextCoords(AIMesh aiMesh, List<Float> textures) {
    AIVector3D.Buffer textCoords = aiMesh.mTextureCoords(0);
    int numTextCoords = textCoords != null ? textCoords.remaining() : 0;
    for (int i = 0; i < numTextCoords; i++) {
        AIVector3D textCoord = textCoords.get();
        textures.add(textCoord.x());
        textures.add(1 - textCoord.y());
    }
}