Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. private void createObjects() throws TextureException, ParsingException, SkeletalAnimationException {
  2. SkeletalAnimationObject3D root = new SkeletalAnimationObject3D();
  3. root.uBoneMatrix = mBindPoseMatrix;
  4. root.mInverseBindPoseMatrix = mInverseBindPoseMatrix;
  5. root.setJoints(mJoints);
  6. mRootObject = root;
  7. for (int i = 0; i < mNumMeshes; ++i) {
  8. SkeletonMeshData mesh = mMeshes[i];
  9. SkeletalAnimationChildObject3D o = new SkeletalAnimationChildObject3D();
  10. o.setData(
  11. mesh.vertices, GLES20.GL_STREAM_DRAW,
  12. mesh.normals, GLES20.GL_STREAM_DRAW,
  13. mesh.textureCoordinates, GLES20.GL_STATIC_DRAW,
  14. null, GLES20.GL_STATIC_DRAW,
  15. mesh.indices, GLES20.GL_STATIC_DRAW,
  16. false);
  17. o.setMaxBoneWeightsPerVertex(mesh.maxBoneWeightsPerVertex);
  18. o.setSkeletonMeshData(mesh.numVertices, mesh.boneVertices, mesh.numWeights, mesh.boneWeights);
  19. o.setName("MD5Mesh_" + i);
  20. o.setSkeleton(mRootObject);
  21. o.setInverseZScale(true);
  22.  
  23. boolean hasTexture = mesh.textureName != null && mesh.textureName.length() > 0;
  24.  
  25. Material mat = new Material();
  26. mat.addPlugin(new SkeletalAnimationMaterialPlugin(mNumJoints, mesh.maxBoneWeightsPerVertex));
  27. mat.enableLighting(true);
  28. mat.setDiffuseMethod(new DiffuseMethod.Lambert());
  29. o.setMaterial(mat);
  30. if (!hasTexture) {
  31. o.setColor(0xff000000 + (int) (Math.random() * 0xffffff));
  32. } else {
  33. int identifier = mResources.getIdentifier(mesh.textureName, "drawable",
  34. mResources.getResourcePackageName(mResourceId));
  35. if (identifier == 0) {
  36. throw new ParsingException("Couldn't find texture " + mesh.textureName);
  37. }
  38. mat.setColorInfluence(0);
  39. mat.addTexture(new Texture("md5tex" + i, identifier));
  40. }
  41. mRootObject.addChild(o);
  42.  
  43. mesh.destroy();
  44. mesh = null;
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement