/** * Returns the track as a bone track. * * @param targetBoneIndex * the bone index * @return the bone track */ public BoneTrack getAsBoneTrack(int targetBoneIndex) { if (translations == null && rotations == null && scales == null) { return null; } return new BoneTrack(targetBoneIndex, this.createTimes(), translations.toArray(new Vector3f[maxFrame]), rotations.toArray(new Quaternion[maxFrame]), scales.toArray(new Vector3f[maxFrame])); }
calculatedTrack = new SpatialTrack(times, translations, rotations, scales); } else { calculatedTrack = new BoneTrack(targetIndex, times, translations, rotations, scales);
Bone bone = nameToBone.get(boneName); int index = skeleton.getBoneIndex(bone); track = new BoneTrack(index); } else if (qName.equals("boneparent")) { assert elementStack.peek().equals("bonehierarchy");
Bone bone = nameToBone.get(boneName); int index = skeleton.getBoneIndex(bone); track = new BoneTrack(index); } else if (qName.equals("boneparent")) { assert elementStack.peek().equals("bonehierarchy");
Bone bone = nameToBone.get(boneName); int index = skeleton.getBoneIndex(bone); track = new BoneTrack(index); } else if (qName.equals("boneparent")) { assert elementStack.peek().equals("bonehierarchy");
/** * This method creates a clone of the current object. * @return a clone of the current object */ @Override public BoneTrack clone() { int tablesLength = times.length; float[] times = this.times.clone(); Vector3f[] sourceTranslations = this.getTranslations(); Quaternion[] sourceRotations = this.getRotations(); Vector3f[] sourceScales = this.getScales(); Vector3f[] translations = new Vector3f[tablesLength]; Quaternion[] rotations = new Quaternion[tablesLength]; Vector3f[] scales = new Vector3f[tablesLength]; for (int i = 0; i < tablesLength; ++i) { translations[i] = sourceTranslations[i].clone(); rotations[i] = sourceRotations[i].clone(); scales[i] = sourceScales != null ? sourceScales[i].clone() : new Vector3f(1.0f, 1.0f, 1.0f); } // Need to use the constructor here because of the final fields used in this class return new BoneTrack(targetBoneIndex, times, translations, rotations, scales); }
Vector3f[] translations = {new Vector3f(0, 0, 0), new Vector3f(0, 2, 0)}; Quaternion[] rotations = {new Quaternion(0, 0, 0, 1), new Quaternion(0, 0, 0, 1)}; BoneTrack boneTrack = new BoneTrack(0, times, translations, rotations);
private Animation createAnimation(DAENode animationNode, Bone bone, Skeleton skeleton) { DAENode channel = animationNode.getChild(Names.CHANNEL); DAENode sampler = animationNode.getChild(Names.SAMPLER); DAENode times = sampler.getChild(Names.INPUT, Names.SEMANTIC, Semantic.INPUT.name()).getLinkedSource(); DAENode values = sampler.getChild(Names.INPUT, Names.SEMANTIC, Semantic.OUTPUT.name()).getLinkedSource(); float[] timeValues = times.getChild(Names.FLOAT_ARRAY).getContent(FLOAT_LIST).get(); float[] outputValues = values.getChild(Names.FLOAT_ARRAY).getContent(FLOAT_LIST).get(); ChannelTarget channelTarget = ChannelTarget.forName(channel.getAttribute(Names.TARGET, TEXT).get()); Conditions.checkTrue(sampler.isDefined()); Conditions.checkTrue(times.isDefined()); Conditions.checkTrue(values.isDefined()); Conditions.checkTrue(channel.isDefined()); Conditions.checkNotNull(channelTarget); Conditions.checkNotNull(timeValues); Conditions.checkNotNull(outputValues); Transform[] transformList = channelTarget.transform(outputValues).get(); Conditions.checkNotNull(transformList); Conditions.checkValue(transformList.length, timeValues.length); int boneIndex = skeleton.getBoneIndex(bone); float animationLength = max(timeValues); Quaternion[] rotations = getRotations(transformList); Vector3f[] translations = getTranslations(transformList); BoneTrack track = new BoneTrack(boneIndex, timeValues, translations, rotations); Animation anim = new Animation(animationNode.getAttribute(Names.ID, TEXT).get(), animationLength); anim.setTracks(new BoneTrack[] {track}); return anim; }