本文整理汇总了Java中com.jme3.animation.BoneTrack类的典型用法代码示例。如果您正苦于以下问题:Java BoneTrack类的具体用法?Java BoneTrack怎么用?Java BoneTrack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoneTrack类属于com.jme3.animation包,在下文中一共展示了BoneTrack类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: extractAnimation
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
/**
* Extract an animation from a source animation.
*
* @param source the source animation.
* @param newName the new name of a sub animation.
* @param startFrame the start frame.
* @param endFrame the end frame.
* @return the new sub animation.
*/
@NotNull
@FromAnyThread
public static Animation extractAnimation(@NotNull final Animation source, @NotNull final String newName,
final int startFrame, final int endFrame) {
final Track[] sourceTracks = source.getTracks();
final BoneTrack firstSourceTrack = (BoneTrack) sourceTracks[0];
final float[] sourceTimes = firstSourceTrack.getTimes();
final float newLength = (source.getLength() / (float) sourceTimes.length) * (float) (endFrame - startFrame);
final Animation result = new Animation(newName, newLength);
final Array<Track> newTracks = ArrayFactory.newArray(Track.class);
for (final Track sourceTrack : sourceTracks) {
if (sourceTrack instanceof BoneTrack) {
newTracks.add(extractBoneTrack((BoneTrack) sourceTrack, startFrame, endFrame));
}
}
result.setTracks(newTracks.toArray(Track.class));
return result;
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:33,代码来源:AnimationUtils.java
示例2: setupBoneTrack
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
public int setupBoneTrack(AnimControl control) {
Skeleton skel = control.getSkeleton();
if (skel != null && boneIndex < 0) {
boneIndex = skel.getBoneIndex(boneName);
if (boneIndex > -1) {
Bone bone = skel.getBone(boneIndex);
//Convert rotations, translations, scales to the "bind pose" space (BoneTrack combine initialXxx with transformation)
Quaternion rotationInv = bone.getBindRotation().inverse(); // wrong name : it's the initialRot in PARENT Bone space
Vector3f scaleInv = new Vector3f(1f/bone.getBindScale().x, 1/bone.getBindScale().y, 1/bone.getBindScale().z); // wrong name : it's the initialScale in PARENT Bone space
Vector3f translationInv = bone.getBindPosition().mult(-1); // wrong name : it's the initialPos in PARENT Bone space
delegate = new BoneTrack(boneIndex, times,
(Vector3f[])Arrays.stream(translations).map((v) -> v.add(translationInv)).collect(Collectors.toList()).toArray(),
(Quaternion[])Arrays.stream(rotations).map((v) -> rotationInv.mult(v)).collect(Collectors.toList()).toArray(),
(Vector3f[])Arrays.stream(scales).map((v) -> v.mult(scaleInv)).collect(Collectors.toList()).toArray()
);
}
}
return boneIndex;
}
开发者ID:xbuf,项目名称:jme3_xbuf,代码行数:20,代码来源:NamedBoneTrack.java
示例3: getTracks249
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
/**
* This method retuns the bone tracks for animation for blender version 2.49
* (and probably several lower versions too).
*
* @param actionStructure
* the structure containing the tracks
* @param blenderContext
* the blender context
* @return a list of tracks for the specified animation
* @throws BlenderFileException
* an exception is thrown when there are problems with the blend
* file
*/
private BoneTrack[] getTracks249(Structure actionStructure, Skeleton skeleton, BlenderContext blenderContext) throws BlenderFileException {
LOGGER.log(Level.FINE, "Getting tracks!");
IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class);
int fps = blenderContext.getBlenderKey().getFps();
Structure chanbase = (Structure) actionStructure.getFieldValue("chanbase");
List<Structure> actionChannels = chanbase.evaluateListBase(blenderContext);// bActionChannel
List<BoneTrack> tracks = new ArrayList<BoneTrack>();
for (Structure bActionChannel : actionChannels) {
String name = bActionChannel.getFieldValue("name").toString();
int boneIndex = this.getBoneIndex(skeleton, name);
if (boneIndex >= 0) {
Pointer p = (Pointer) bActionChannel.getFieldValue("ipo");
if (!p.isNull()) {
Structure ipoStructure = p.fetchData(blenderContext.getInputStream()).get(0);
Bone bone = skeleton.getBone(boneIndex);
Ipo ipo = ipoHelper.fromIpoStructure(ipoStructure, blenderContext);
if (ipo != null) {
tracks.add((BoneTrack) ipo.calculateTrack(boneIndex, bone.getLocalRotation(), 0, ipo.getLastFrame(), fps, false));
}
}
}
}
return tracks.toArray(new BoneTrack[tracks.size()]);
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:39,代码来源:ArmatureHelper.java
示例4: computeAnimationTimeBoundaries
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
/**
* Computes the maximum frame and time for the animation. Different tracks
* can have different lengths so here the maximum one is being found.
*
* @param animation
* the animation
* @return maximum frame and time of the animation
*/
private float[] computeAnimationTimeBoundaries(Animation animation) {
int maxFrame = Integer.MIN_VALUE;
float maxTime = Float.MIN_VALUE;
for (Track track : animation.getTracks()) {
if (track instanceof BoneTrack) {
maxFrame = Math.max(maxFrame, ((BoneTrack) track).getTranslations().length);
maxTime = Math.max(maxTime, ((BoneTrack) track).getTimes()[((BoneTrack) track).getTimes().length - 1]);
} else if (track instanceof SpatialTrack) {
maxFrame = Math.max(maxFrame, ((SpatialTrack) track).getTranslations().length);
maxTime = Math.max(maxTime, ((SpatialTrack) track).getTimes()[((SpatialTrack) track).getTimes().length - 1]);
} else {
throw new IllegalStateException("Unsupported track type for simuation: " + track);
}
}
return new float[] { maxFrame, maxTime };
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:25,代码来源:SimulationNode.java
示例5: computeName
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
@NotNull
@Override
protected String computeName() {
final BoneTrack boneTrack = getElement();
final AnimControl control = notNull(getControl());
final Skeleton skeleton = control.getSkeleton();
final Bone bone = skeleton.getBone(boneTrack.getTargetBoneIndex());
return "Bone track : " + bone.getName();
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:10,代码来源:AnimationBoneTrackTreeNode.java
示例6: extractBoneTrack
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
/**
* Extract a bone track from a source animation to sub animation.
*
* @param boneTrack the source bone track.
* @param startFrame the start frame.
* @param endFrame the end frame.
* @return the extracted bone track.
*/
@NotNull
private static BoneTrack extractBoneTrack(@NotNull final BoneTrack boneTrack, final int startFrame,
final int endFrame) {
final float[] sourceTimes = boneTrack.getTimes();
final Vector3f[] newTranslations = new Vector3f[endFrame - startFrame];
final Quaternion[] newRotations = new Quaternion[endFrame - startFrame];
final Vector3f[] newScales = new Vector3f[endFrame - startFrame];
final float[] newTimes = new float[endFrame - startFrame];
for (int i = startFrame; i < endFrame; i++) {
final int newFrame = i - startFrame;
final Vector3f sourceTranslation = boneTrack.getTranslations()[i];
final Vector3f sourceScale = boneTrack.getScales()[i];
final Quaternion sourceRotation = boneTrack.getRotations()[i];
newTimes[newFrame] = sourceTimes[i] - sourceTimes[startFrame];
newTranslations[newFrame] = sourceTranslation.clone();
newRotations[newFrame] = sourceRotation.clone();
newScales[newFrame] = sourceScale.clone();
}
return new BoneTrack(boneTrack.getTargetBoneIndex(), newTimes, newTranslations, newRotations, newScales);
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:36,代码来源:AnimationUtils.java
示例7: getFrameCount
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
/**
* Get frame count of an animation/
*
* @param animation the animation.
* @return the frame count or -1.
*/
@FromAnyThread
public static int getFrameCount(@NotNull final Animation animation) {
int min = Integer.MAX_VALUE;
final Track[] tracks = animation.getTracks();
for (final Track track : tracks) {
if (track instanceof BoneTrack) {
min = Math.min(min, ((BoneTrack) track).getTimes().length);
}
}
return min == Integer.MAX_VALUE ? -1 : min;
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:21,代码来源:AnimationUtils.java
示例8: setAnimation
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
public void setAnimation(Animation animation) {
_animation = animation;
_txtStartFrame.setValue(0);
if (animation.getTracks().length <= 0) {
throw new IllegalArgumentException("No Tracks found");
}
if (animation.getTracks()[0].getClass() != BoneTrack.class) {
throw new UnsupportedOperationException("Only Bonetracks are supported");
}
_txtEndFrame.setValue(((BoneTrack) animation.getTracks()[0]).getTimes().length);
}
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:13,代码来源:ExtractSubAnimationDialog.java
示例9: setName
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
private void setName() {
if (track instanceof BoneTrack) {
BoneTrack boneTrack = (BoneTrack) track;
super.setName("BoneTrack : " + control.getSkeleton().getBone(boneTrack.getTargetBoneIndex()).getName());
} else if (track instanceof EffectTrack) {
EffectTrack effectTrack = (EffectTrack) track;
super.setName("EffectTrack : " + effectTrack.getEmitter().getName());
} else if (track instanceof AudioTrack) {
AudioTrack audioTrack = (AudioTrack) track;
super.setName("AudioTrack : " + audioTrack.getAudio().getName());
} else {
super.setName(track.getClass().getSimpleName());
}
}
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:16,代码来源:JmeTrack.java
示例10: getIcon
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
@Override
public Image getIcon(int type) {
if (track instanceof BoneTrack) {
return iconBoneTrack;
} else if (track instanceof EffectTrack) {
return iconEffectTrack;
} else if (track instanceof AudioTrack) {
return iconAudioTrack;
}
return iconTrack;
}
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:13,代码来源:JmeTrack.java
示例11: getOpenedIcon
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
@Override
public Image getOpenedIcon(int type) {
if (track instanceof BoneTrack) {
return iconBoneTrack;
} else if (track instanceof EffectTrack) {
return iconEffectTrack;
} else if (track instanceof AudioTrack) {
return iconAudioTrack;
}
return iconTrack;
}
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:12,代码来源:JmeTrack.java
示例12: toJME
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
public Track toJME(Skeleton skel) {
if(boneName==_SPATIAL){
return new SpatialTrack(times,translations,rotations,scales);
}
if(skel!=null){
int boneIndex=skel.getBoneIndex(boneName);
if(boneIndex>-1){
Bone bone=skel.getBone(boneIndex);
//Convert rotations, translations, scales to the "bind pose" space (BoneTrack combine initialXxx with transformation)
Quaternion rotationInv=bone.getBindRotation().inverse();// it's the initialRot in PARENT Bone space
Vector3f scaleInv=new Vector3f(1f/bone.getBindScale().x,1/bone.getBindScale().y,1/bone.getBindScale().z); //it's the initialScale in PARENT Bone space
Vector3f translationInv=bone.getBindPosition().mult(-1);// it's the initialPos in PARENT Bone space
Vector3f actualTranslations[]=new Vector3f[translations.length];
for(int i=0;i<translations.length;i++)
actualTranslations[i]=translations[i].add(translationInv);
Vector3f actualScales[]=new Vector3f[scales.length];
for(int i=0;i<scales.length;i++)
actualScales[i]=scales[i].mult(scaleInv);
Quaternion actualRotations[]=new Quaternion[rotations.length];
for(int i=0;i<rotations.length;i++)
actualRotations[i]=rotationInv.mult(rotations[i]);
BoneTrack track=new BoneTrack(boneIndex,times,actualTranslations,actualRotations,actualScales);
return track;
}
}
return null;
}
开发者ID:xbuf,项目名称:jme3_xbuf,代码行数:33,代码来源:XbufTrack.java
示例13: buildAnimation
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
/**
* builds the animation for jmonkey. every joint uses two jme bones, one for
* rotation and one for translation.
*/
public void buildAnimation() {
if (seq.shp != null) {
animation = new Animation("Animation" + id, 0.5f);
for (int i = 0; i < seq.numJoints; ++i) {
float[] times = { 0.0f };
// rotation bone
BoneTrack track = new BoneTrack(i);
Vector3f[] translations = { Vector3f.ZERO };
Quaternion[] rotations = { quaternions[i] };
track.setKeyframes(times, translations, rotations);
animation.addTrack(track);
// translation bone
// not for root
if (i > 0) {
BoneTrack track2 = new BoneTrack(i + seq.numJoints);
Vector3f[] translations2 = { new Vector3f(
seq.shp.joints[i].length, 0, 0) };
Quaternion[] rotations2 = { Quaternion.IDENTITY };
track2.setKeyframes(times, translations2, rotations2);
animation.addTrack(track2);
}
}
}
}
开发者ID:morris,项目名称:vstools-java,代码行数:34,代码来源:SEQAnimation.java
示例14: getTracks250
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
/**
* This method retuns the bone tracks for animation for blender version 2.50
* and higher.
*
* @param actionStructure
* the structure containing the tracks
* @param blenderContext
* the blender context
* @return a list of tracks for the specified animation
* @throws BlenderFileException
* an exception is thrown when there are problems with the blend
* file
*/
private BoneTrack[] getTracks250(Structure actionStructure, Skeleton skeleton, BlenderContext blenderContext) throws BlenderFileException {
LOGGER.log(Level.FINE, "Getting tracks!");
IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class);
int fps = blenderContext.getBlenderKey().getFps();
Structure groups = (Structure) actionStructure.getFieldValue("groups");
List<Structure> actionGroups = groups.evaluateListBase(blenderContext);// bActionGroup
List<BoneTrack> tracks = new ArrayList<BoneTrack>();
for (Structure actionGroup : actionGroups) {
String name = actionGroup.getFieldValue("name").toString();
int boneIndex = this.getBoneIndex(skeleton, name);
if (boneIndex >= 0) {
List<Structure> channels = ((Structure) actionGroup.getFieldValue("channels")).evaluateListBase(blenderContext);
BezierCurve[] bezierCurves = new BezierCurve[channels.size()];
int channelCounter = 0;
for (Structure c : channels) {
int type = ipoHelper.getCurveType(c, blenderContext);
Pointer pBezTriple = (Pointer) c.getFieldValue("bezt");
List<Structure> bezTriples = pBezTriple.fetchData(blenderContext.getInputStream());
bezierCurves[channelCounter++] = new BezierCurve(type, bezTriples, 2);
}
Bone bone = skeleton.getBone(boneIndex);
Ipo ipo = new Ipo(bezierCurves, fixUpAxis, blenderContext.getBlenderVersion());
tracks.add((BoneTrack) ipo.calculateTrack(boneIndex, bone.getLocalRotation(), 0, ipo.getLastFrame(), fps, false));
}
}
return tracks.toArray(new BoneTrack[tracks.size()]);
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:42,代码来源:ArmatureHelper.java
示例15: canDestroy
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
@Override
public boolean canDestroy() {
return !(track instanceof BoneTrack);
}
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:5,代码来源:JmeTrack.java
示例16: calculateTrack
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
@Override
public BoneTrack calculateTrack(int boneIndex, Quaternion localQuaternionRotation, int startFrame, int stopFrame, int fps, boolean boneTrack) {
throw new IllegalStateException("Constatnt ipo object cannot be used for calculating bone tracks!");
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:5,代码来源:IpoHelper.java
示例17: getTracks
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
/**
* This method retuns the bone tracks for animation.
*
* @param actionStructure
* the structure containing the tracks
* @param blenderContext
* the blender context
* @return a list of tracks for the specified animation
* @throws BlenderFileException
* an exception is thrown when there are problems with the blend
* file
*/
public BoneTrack[] getTracks(Structure actionStructure, Skeleton skeleton, BlenderContext blenderContext) throws BlenderFileException {
if (blenderVersion < 250) {
return this.getTracks249(actionStructure, skeleton, blenderContext);
} else {
return this.getTracks250(actionStructure, skeleton, blenderContext);
}
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:20,代码来源:ArmatureHelper.java
示例18: getAsBoneTrack
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
/**
* 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]));
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:14,代码来源:VirtualTrack.java
示例19: AnimationBoneTrackTreeNode
import com.jme3.animation.BoneTrack; //导入依赖的package包/类
/**
* Instantiates a new Animation bone track model node.
*
* @param element the element
* @param objectId the object id
*/
public AnimationBoneTrackTreeNode(@NotNull final BoneTrack element, final long objectId) {
super(element, objectId);
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:10,代码来源:AnimationBoneTrackTreeNode.java
注:本文中的com.jme3.animation.BoneTrack类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论