Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void createObjects() throws TextureException, ParsingException, SkeletalAnimationException {
- SkeletalAnimationObject3D root = new SkeletalAnimationObject3D();
- root.uBoneMatrix = mBindPoseMatrix;
- root.mInverseBindPoseMatrix = mInverseBindPoseMatrix;
- root.setJoints(mJoints);
- mRootObject = root;
- for (int i = 0; i < mNumMeshes; ++i) {
- SkeletonMeshData mesh = mMeshes[i];
- SkeletalAnimationChildObject3D o = new SkeletalAnimationChildObject3D();
- o.setData(
- mesh.vertices, GLES20.GL_STREAM_DRAW,
- mesh.normals, GLES20.GL_STREAM_DRAW,
- mesh.textureCoordinates, GLES20.GL_STATIC_DRAW,
- null, GLES20.GL_STATIC_DRAW,
- mesh.indices, GLES20.GL_STATIC_DRAW,
- false);
- o.setMaxBoneWeightsPerVertex(mesh.maxBoneWeightsPerVertex);
- o.setSkeletonMeshData(mesh.numVertices, mesh.boneVertices, mesh.numWeights, mesh.boneWeights);
- o.setName("MD5Mesh_" + i);
- o.setSkeleton(mRootObject);
- o.setInverseZScale(true);
- boolean hasTexture = mesh.textureName != null && mesh.textureName.length() > 0;
- Material mat = new Material();
- mat.addPlugin(new SkeletalAnimationMaterialPlugin(mNumJoints, mesh.maxBoneWeightsPerVertex));
- mat.enableLighting(true);
- mat.setDiffuseMethod(new DiffuseMethod.Lambert());
- o.setMaterial(mat);
- if (!hasTexture) {
- o.setColor(0xff000000 + (int) (Math.random() * 0xffffff));
- } else {
- int identifier = mResources.getIdentifier(mesh.textureName, "drawable",
- mResources.getResourcePackageName(mResourceId));
- if (identifier == 0) {
- throw new ParsingException("Couldn't find texture " + mesh.textureName);
- }
- mat.setColorInfluence(0);
- mat.addTexture(new Texture("md5tex" + i, identifier));
- }
- mRootObject.addChild(o);
- mesh.destroy();
- mesh = null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement