public ArmatureDebugger addArmatureFrom(SkinningControl skinningControl) { Armature armature = skinningControl.getArmature(); Spatial forSpatial = skinningControl.getSpatial(); return addArmatureFrom(armature, forSpatial); }
/** * Update the mesh according to the given transformation matrices * * @param mesh then mesh * @param offsetMatrices the transformation matrices to apply */ private void softwareSkinUpdate(Mesh mesh, Matrix4f[] offsetMatrices) { VertexBuffer tb = mesh.getBuffer(Type.Tangent); if (tb == null) { //if there are no tangents use the classic skinning applySkinning(mesh, offsetMatrices); } else { //if there are tangents use the skinning with tangents applySkinningTangents(mesh, offsetMatrices, tb); } }
@Override protected void controlRender(RenderManager rm, ViewPort vp) { if (!wasMeshUpdated) { updateTargetsAndMaterials(spatial); hwSkinningSupported = testHardwareSupported(rm); switchToSoftware(); switchToHardware(); hwSkinningEnabled = true; } else if (!hwSkinningDesired && hwSkinningEnabled) { switchToSoftware(); hwSkinningEnabled = false; controlRenderHardware(); } else { controlRenderSoftware();
SkinningControl ac = new SkinningControl(armature); Node node = new Node("Test Armature"); ac.setHardwareSkinningPreferred(false); armature = ac.getArmature(); composer.setCurrentAction("anim");
@Override public void visit(Spatial spatial) { SkeletonControl control = spatial.getControl(SkeletonControl.class); if (control != null) { Armature armature = skeletonArmatureMap.get(control.getSkeleton()); SkinningControl skinningControl = new SkinningControl(armature); Map<String, List<Spatial>> attachedSpatials = new HashMap<>(); for (int i = 0; i < control.getSkeleton().getBoneCount(); i++) { Bone b = control.getSkeleton().getBone(i); Node n = control.getAttachmentsNode(b.getName()); n.removeFromParent(); if (!n.getChildren().isEmpty()) { attachedSpatials.put(b.getName(), n.getChildren()); } } spatial.removeControl(control); spatial.addControl(skinningControl); for (String name : attachedSpatials.keySet()) { List<Spatial> spatials = attachedSpatials.get(name); for (Spatial child : spatials) { skinningControl.getAttachmentsNode(name).attachChild(child); } } } }
SkinningControl skinningControl = new SkinningControl(animData.armature);
SkinningControl ac = new SkinningControl(armature); ac.setHardwareSkinningPreferred(false); Node node = new Node("Test Armature");
skinData.skinningControl.getAttachmentsNode(bw.joint.getName()).attachChild(bw.attachedSpatial);
composer.makeLayer("LeftArm", ArmatureMask.createMask(sc.getArmature(), "shoulder.L"));
private void findTargets(Node node) { for (Spatial child : node.getChildren()) { if (child instanceof Geometry) { findTargets((Geometry) child); } else if (child instanceof Node) { findTargets((Node) child); } } }
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule in = im.getCapsule(this); armature = (Armature) in.readSavable("armature", null); numberOfJointsParam = (MatParamOverride) in.readSavable("numberOfBonesParam", null); jointMatricesParam = (MatParamOverride) in.readSavable("boneMatricesParam", null); if (numberOfJointsParam == null) { numberOfJointsParam = new MatParamOverride(VarType.Int, "NumberOfBones", null); jointMatricesParam = new MatParamOverride(VarType.Matrix4Array, "BoneMatrices", null); getSpatial().addMatParamOverride(numberOfJointsParam); getSpatial().addMatParamOverride(jointMatricesParam); } }
SkinData skinData = new SkinData(); skinData.joints = joints; skinData.skinningControl = new SkinningControl(armature); skinData.animComposer = new AnimComposer(); addToCache("skins", index, skinData, nodes.size());
/** * Update the lists of animation targets. * * @param spatial the controlled spatial */ private void updateTargetsAndMaterials(Spatial spatial) { targets.clear(); if (spatial instanceof Node) { findTargets((Node) spatial); } else if (spatial instanceof Geometry) { findTargets((Geometry) spatial); } } }