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();
}
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;
}
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;
}
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);
}
}
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);
}
}
Aggregations