Search in sources :

Example 6 with Object3D

use of org.rajawali3d.Object3D in project Rajawali by Rajawali.

the class ArcballCamera method initialize.

private void initialize() {
    mStartFOV = mFieldOfView;
    mLookAtEnabled = true;
    setLookAt(0, 0, 0);
    mEmpty = new Object3D();
    mScratchMatrix = new Matrix4();
    mScratchVector = new Vector3();
    mCameraStartPos = new Vector3();
    mPrevSphereCoord = new Vector3();
    mCurrSphereCoord = new Vector3();
    mPrevScreenCoord = new Vector2();
    mCurrScreenCoord = new Vector2();
    mStartOrientation = new Quaternion();
    mCurrentOrientation = new Quaternion();
}
Also used : Vector2(org.rajawali3d.math.vector.Vector2) Quaternion(org.rajawali3d.math.Quaternion) Vector3(org.rajawali3d.math.vector.Vector3) Matrix4(org.rajawali3d.math.Matrix4) Object3D(org.rajawali3d.Object3D)

Example 7 with Object3D

use of org.rajawali3d.Object3D in project Rajawali by Rajawali.

the class Scene method getNumTriangles.

/**
	 * Retrieve the number of triangles this scene contains, recursive method
	 *
	 * @return int the total triangle count for the scene.
	 */
public int getNumTriangles() {
    int triangleCount = 0;
    ArrayList<Object3D> children = getChildrenCopy();
    for (int i = 0, j = children.size(); i < j; i++) {
        Object3D child = children.get(i);
        if (child.getGeometry() != null && child.getGeometry().getVertices() != null && child.isVisible())
            if (child.getNumChildren() > 0) {
                triangleCount += child.getNumTriangles();
            } else {
                triangleCount += child.getGeometry().getVertices().limit() / 9;
            }
    }
    return triangleCount;
}
Also used : Object3D(org.rajawali3d.Object3D)

Example 8 with Object3D

use of org.rajawali3d.Object3D in project Rajawali by Rajawali.

the class Scene method getNumObjects.

/**
	 * Retrieve the number of objects on the screen, recursive method
	 *
	 * @return int the total object count for the screen.
	 */
public int getNumObjects() {
    int objectCount = 0;
    ArrayList<Object3D> children = getChildrenCopy();
    for (int i = 0, j = children.size(); i < j; i++) {
        Object3D child = children.get(i);
        if (child.getGeometry() != null && child.getGeometry().getVertices() != null && child.isVisible())
            if (child.getNumChildren() > 0) {
                objectCount += child.getNumObjects() + 1;
            } else {
                objectCount++;
            }
    }
    return objectCount;
}
Also used : Object3D(org.rajawali3d.Object3D)

Example 9 with Object3D

use of org.rajawali3d.Object3D in project Rajawali by Rajawali.

the class Loader3DSMax method build.

public void build() throws TextureException {
    int num = mVertices.size();
    for (int j = 0; j < num; ++j) {
        ArrayList<Integer> indices = mIndices.get(j);
        ArrayList<Vector3> vertices = mVertices.get(j);
        ArrayList<Vector3> texCoords = null;
        ArrayList<Vector3> vertNormals = mVertNormals.get(j);
        if (mTexCoords.size() > 0)
            texCoords = mTexCoords.get(j);
        int len = indices.size();
        float[] aVertices = new float[len * 3];
        float[] aNormals = new float[len * 3];
        float[] aTexCoords = new float[len * 2];
        int[] aIndices = new int[len];
        int ic = 0;
        int itn = 0;
        int itc = 0;
        int ivi = 0;
        Vector3 coord;
        Vector3 texcoord;
        Vector3 normal;
        for (int i = 0; i < len; i += 3) {
            int v1 = indices.get(i);
            int v2 = indices.get(i + 1);
            int v3 = indices.get(i + 2);
            coord = vertices.get(v1);
            aVertices[ic++] = (float) coord.x;
            aVertices[ic++] = (float) coord.y;
            aVertices[ic++] = (float) coord.z;
            aIndices[ivi] = ivi++;
            coord = vertices.get(v2);
            aVertices[ic++] = (float) coord.x;
            aVertices[ic++] = (float) coord.y;
            aVertices[ic++] = (float) coord.z;
            aIndices[ivi] = ivi++;
            coord = vertices.get(v3);
            aVertices[ic++] = (float) coord.x;
            aVertices[ic++] = (float) coord.y;
            aVertices[ic++] = (float) coord.z;
            aIndices[ivi] = ivi++;
            if (texCoords != null && texCoords.size() > 0) {
                texcoord = texCoords.get(v1);
                aTexCoords[itc++] = (float) texcoord.x;
                aTexCoords[itc++] = (float) texcoord.y;
                texcoord = texCoords.get(v2);
                aTexCoords[itc++] = (float) texcoord.x;
                aTexCoords[itc++] = (float) texcoord.y;
                texcoord = texCoords.get(v3);
                aTexCoords[itc++] = (float) texcoord.x;
                aTexCoords[itc++] = (float) texcoord.y;
            }
            normal = vertNormals.get(v1);
            aNormals[itn++] = (float) normal.x;
            aNormals[itn++] = (float) normal.y;
            aNormals[itn++] = (float) normal.z;
            normal = vertNormals.get(v2);
            aNormals[itn++] = (float) normal.x;
            aNormals[itn++] = (float) normal.y;
            aNormals[itn++] = (float) normal.z;
            normal = vertNormals.get(v3);
            aNormals[itn++] = (float) normal.x;
            aNormals[itn++] = (float) normal.y;
            aNormals[itn++] = (float) normal.z;
        }
        Object3D targetObj = new Object3D(mObjNames.get(j));
        targetObj.setData(aVertices, aNormals, aTexCoords, null, aIndices, false);
        // -- diffuse material with random color. for now.
        Material material = new Material();
        material.setDiffuseMethod(new DiffuseMethod.Lambert());
        targetObj.setMaterial(material);
        targetObj.setColor(0xff000000 + (int) (Math.random() * 0xffffff));
        mRootObject.addChild(targetObj);
    }
}
Also used : DiffuseMethod(org.rajawali3d.materials.methods.DiffuseMethod) Vector3(org.rajawali3d.math.vector.Vector3) Material(org.rajawali3d.materials.Material) Object3D(org.rajawali3d.Object3D)

Example 10 with Object3D

use of org.rajawali3d.Object3D in project Rajawali by Rajawali.

the class LoaderAWD method onBlockParsingFinished.

/**
     * This is called when all blocks have finished parsing. This is the time to modify any block
     * data as needed from the passed list before conversion to {@link Object3D} or {@link
     * Scene} occurs.
     */
public void onBlockParsingFinished(List<IBlockParser> blockParsers) {
    Object3D temp;
    IBlockParser blockParser;
    for (int i = 0, j = blockParsers.size(); i < j; i++) {
        blockParser = blockParsers.get(i);
        if (!(blockParser instanceof AExportableBlockParser))
            continue;
        temp = ((AExportableBlockParser) blockParser).getBaseObject3D();
        if (temp != null)
            baseObjects.add(temp);
    }
}
Also used : AExportableBlockParser(org.rajawali3d.loader.awd.AExportableBlockParser) Object3D(org.rajawali3d.Object3D)

Aggregations

Object3D (org.rajawali3d.Object3D)18 Vector3 (org.rajawali3d.math.vector.Vector3)5 Material (org.rajawali3d.materials.Material)4 ArrayList (java.util.ArrayList)3 SkeletalAnimationChildObject3D (org.rajawali3d.animation.mesh.SkeletalAnimationChildObject3D)2 SkeletalAnimationObject3D (org.rajawali3d.animation.mesh.SkeletalAnimationObject3D)2 ParsingException (org.rajawali3d.loader.ParsingException)2 DiffuseMethod (org.rajawali3d.materials.methods.DiffuseMethod)2 TextureException (org.rajawali3d.materials.textures.ATexture.TextureException)2 Matrix4 (org.rajawali3d.math.Matrix4)2 Quaternion (org.rajawali3d.math.Quaternion)2 SparseArray (android.util.SparseArray)1 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 ByteBuffer (java.nio.ByteBuffer)1