rename actor animation mask entry
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
e9067af287
commit
4f663a322c
@ -41,7 +41,7 @@ import electrosphere.entity.types.item.ItemUtils;
|
|||||||
import electrosphere.entity.types.terrain.TerrainChunk;
|
import electrosphere.entity.types.terrain.TerrainChunk;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.renderer.actor.instance.InstancedActor;
|
import electrosphere.renderer.actor.instance.InstancedActor;
|
||||||
import electrosphere.renderer.actor.mask.ActorAnimationMask;
|
import electrosphere.renderer.actor.mask.ActorAnimationMaskEntry;
|
||||||
import electrosphere.renderer.anim.AnimChannel;
|
import electrosphere.renderer.anim.AnimChannel;
|
||||||
import electrosphere.renderer.anim.Animation;
|
import electrosphere.renderer.anim.Animation;
|
||||||
import electrosphere.renderer.model.Bone;
|
import electrosphere.renderer.model.Bone;
|
||||||
@ -293,8 +293,8 @@ public class ImGuiEntityMacros {
|
|||||||
|
|
||||||
//animation queue
|
//animation queue
|
||||||
if(ImGui.collapsingHeader("Animation Queue")){
|
if(ImGui.collapsingHeader("Animation Queue")){
|
||||||
Set<ActorAnimationMask> animationQueue = poseActor.getAnimationQueue();
|
Set<ActorAnimationMaskEntry> animationQueue = poseActor.getAnimationQueue();
|
||||||
for(ActorAnimationMask mask : animationQueue){
|
for(ActorAnimationMaskEntry mask : animationQueue){
|
||||||
ImGui.text(mask.getAnimationName() + " - " + mask.getPriority());
|
ImGui.text(mask.getAnimationName() + " - " + mask.getPriority());
|
||||||
ImGui.text(mask.getDuration() + " " + mask.getTime());
|
ImGui.text(mask.getDuration() + " " + mask.getTime());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import electrosphere.entity.types.tree.ProceduralTree;
|
|||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.renderer.actor.Actor;
|
import electrosphere.renderer.actor.Actor;
|
||||||
import electrosphere.renderer.actor.instance.InstancedActor;
|
import electrosphere.renderer.actor.instance.InstancedActor;
|
||||||
import electrosphere.renderer.actor.mask.ActorAnimationMask;
|
import electrosphere.renderer.actor.mask.ActorAnimationMaskEntry;
|
||||||
import electrosphere.renderer.actor.mask.ActorMeshMask;
|
import electrosphere.renderer.actor.mask.ActorMeshMask;
|
||||||
import electrosphere.renderer.anim.AnimChannel;
|
import electrosphere.renderer.anim.AnimChannel;
|
||||||
import electrosphere.renderer.anim.Animation;
|
import electrosphere.renderer.anim.Animation;
|
||||||
@ -75,8 +75,8 @@ public class ImGuiEntityActorTab {
|
|||||||
|
|
||||||
//animation queue
|
//animation queue
|
||||||
if(ImGui.collapsingHeader("Animation Queue")){
|
if(ImGui.collapsingHeader("Animation Queue")){
|
||||||
Set<ActorAnimationMask> animationQueue = actor.getAnimationQueue();
|
Set<ActorAnimationMaskEntry> animationQueue = actor.getAnimationQueue();
|
||||||
for(ActorAnimationMask mask : animationQueue){
|
for(ActorAnimationMaskEntry mask : animationQueue){
|
||||||
ImGui.text(mask.getAnimationName() + " - " + mask.getPriority());
|
ImGui.text(mask.getAnimationName() + " - " + mask.getPriority());
|
||||||
ImGui.text(mask.getDuration() + " " + mask.getTime());
|
ImGui.text(mask.getDuration() + " " + mask.getTime());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import electrosphere.logger.LoggerInterface;
|
|||||||
import electrosphere.mem.JomlPool;
|
import electrosphere.mem.JomlPool;
|
||||||
import electrosphere.renderer.OpenGLState;
|
import electrosphere.renderer.OpenGLState;
|
||||||
import electrosphere.renderer.RenderPipelineState;
|
import electrosphere.renderer.RenderPipelineState;
|
||||||
import electrosphere.renderer.actor.mask.ActorAnimationMask;
|
import electrosphere.renderer.actor.mask.ActorAnimationMaskEntry;
|
||||||
import electrosphere.renderer.actor.mask.ActorMeshMask;
|
import electrosphere.renderer.actor.mask.ActorMeshMask;
|
||||||
import electrosphere.renderer.actor.mask.ActorShaderMask;
|
import electrosphere.renderer.actor.mask.ActorShaderMask;
|
||||||
import electrosphere.renderer.actor.mask.ActorTextureMask;
|
import electrosphere.renderer.actor.mask.ActorTextureMask;
|
||||||
@ -131,7 +131,7 @@ public class Actor {
|
|||||||
/**
|
/**
|
||||||
* The stack of animations being applied to a given actor
|
* The stack of animations being applied to a given actor
|
||||||
*/
|
*/
|
||||||
private Set<ActorAnimationMask> animationQueue = new TreeSet<ActorAnimationMask>();
|
private Set<ActorAnimationMaskEntry> animationQueue = new TreeSet<ActorAnimationMaskEntry>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mask for overwriting meshes in a given actor
|
* Mask for overwriting meshes in a given actor
|
||||||
@ -171,7 +171,7 @@ public class Actor {
|
|||||||
/**
|
/**
|
||||||
* Used for caching animation masks that should be removed
|
* Used for caching animation masks that should be removed
|
||||||
*/
|
*/
|
||||||
private List<ActorAnimationMask> toRemoveMasks = new LinkedList<ActorAnimationMask>();
|
private List<ActorAnimationMaskEntry> toRemoveMasks = new LinkedList<ActorAnimationMaskEntry>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ public class Actor {
|
|||||||
*/
|
*/
|
||||||
public void incrementAnimationTime(double deltaTime){
|
public void incrementAnimationTime(double deltaTime){
|
||||||
toRemoveMasks.clear();
|
toRemoveMasks.clear();
|
||||||
for(ActorAnimationMask mask : animationQueue){
|
for(ActorAnimationMaskEntry mask : animationQueue){
|
||||||
if(mask.getFreezeFrames() > 0){
|
if(mask.getFreezeFrames() > 0){
|
||||||
mask.setFreezeFrames(mask.getFreezeFrames() - 1);
|
mask.setFreezeFrames(mask.getFreezeFrames() - 1);
|
||||||
} else {
|
} else {
|
||||||
@ -226,7 +226,7 @@ public class Actor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask mask : toRemoveMasks){
|
for(ActorAnimationMaskEntry mask : toRemoveMasks){
|
||||||
animationQueue.remove(mask);
|
animationQueue.remove(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ public class Actor {
|
|||||||
* @return The time into the animation, -1 if the animation is not being played
|
* @return The time into the animation, -1 if the animation is not being played
|
||||||
*/
|
*/
|
||||||
public double getAnimationTime(String animation){
|
public double getAnimationTime(String animation){
|
||||||
ActorAnimationMask mask = this.getAnimationMask(animation);
|
ActorAnimationMaskEntry mask = this.getAnimationMask(animation);
|
||||||
if(mask != null){
|
if(mask != null){
|
||||||
return mask.getTime();
|
return mask.getTime();
|
||||||
}
|
}
|
||||||
@ -253,7 +253,7 @@ public class Actor {
|
|||||||
if(animationName == null){
|
if(animationName == null){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask mask : animationQueue){
|
for(ActorAnimationMaskEntry mask : animationQueue){
|
||||||
if(mask.getAnimationName().equals(animationName)){
|
if(mask.getAnimationName().equals(animationName)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -270,7 +270,7 @@ public class Actor {
|
|||||||
if(animationData == null){
|
if(animationData == null){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask mask : animationQueue){
|
for(ActorAnimationMaskEntry mask : animationQueue){
|
||||||
if(animationData.getNameFirstPerson() != null && mask.getAnimationName().contains(animationData.getNameFirstPerson())){
|
if(animationData.getNameFirstPerson() != null && mask.getAnimationName().contains(animationData.getNameFirstPerson())){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -281,18 +281,26 @@ public class Actor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the actor is playing an animation
|
||||||
|
* @return true if it is playing an animation, false otherwise
|
||||||
|
*/
|
||||||
public boolean isPlayingAnimation(){
|
public boolean isPlayingAnimation(){
|
||||||
return animationQueue.size() > 0;
|
return animationQueue.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops playing an animation on the actor
|
||||||
|
* @param animationName The name of the animation
|
||||||
|
*/
|
||||||
public void stopAnimation(String animationName){
|
public void stopAnimation(String animationName){
|
||||||
List<ActorAnimationMask> toRemove = new LinkedList<ActorAnimationMask>();
|
List<ActorAnimationMaskEntry> toRemove = new LinkedList<ActorAnimationMaskEntry>();
|
||||||
for(ActorAnimationMask mask : animationQueue){
|
for(ActorAnimationMaskEntry mask : animationQueue){
|
||||||
if(mask.getAnimationName().contains(animationName)){
|
if(mask.getAnimationName().contains(animationName)){
|
||||||
toRemove.add(mask);
|
toRemove.add(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask mask : toRemove){
|
for(ActorAnimationMaskEntry mask : toRemove){
|
||||||
animationQueue.remove(mask);
|
animationQueue.remove(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -306,18 +314,18 @@ public class Actor {
|
|||||||
Model model = Globals.assetManager.fetchModel(baseModelPath);
|
Model model = Globals.assetManager.fetchModel(baseModelPath);
|
||||||
if(model != null && model.getAnimation(animationName) != null){
|
if(model != null && model.getAnimation(animationName) != null){
|
||||||
double length = model.getAnimation(animationName).duration;
|
double length = model.getAnimation(animationName).duration;
|
||||||
ActorAnimationMask animMask = new ActorAnimationMask(priority, animationName, 0, length);
|
ActorAnimationMaskEntry animMask = new ActorAnimationMaskEntry(priority, animationName, 0, length);
|
||||||
for(Bone bone : model.getBones()){
|
for(Bone bone : model.getBones()){
|
||||||
animMask.addBone(bone.boneID);
|
animMask.addBone(bone.boneID);
|
||||||
}
|
}
|
||||||
toRemoveMasks.clear();
|
toRemoveMasks.clear();
|
||||||
for(ActorAnimationMask currentMask : animationQueue){
|
for(ActorAnimationMaskEntry currentMask : animationQueue){
|
||||||
if(currentMask.getPriority() == animMask.getPriority()){
|
if(currentMask.getPriority() == animMask.getPriority()){
|
||||||
toRemoveMasks.add(currentMask);
|
toRemoveMasks.add(currentMask);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask currentMask : toRemoveMasks){
|
for(ActorAnimationMaskEntry currentMask : toRemoveMasks){
|
||||||
animationQueue.remove(currentMask);
|
animationQueue.remove(currentMask);
|
||||||
}
|
}
|
||||||
animationQueue.add(animMask);
|
animationQueue.add(animMask);
|
||||||
@ -393,15 +401,15 @@ public class Actor {
|
|||||||
double length = model.getAnimation(animationName).duration;
|
double length = model.getAnimation(animationName).duration;
|
||||||
|
|
||||||
//construct the animation mask
|
//construct the animation mask
|
||||||
ActorAnimationMask animMask;
|
ActorAnimationMaskEntry animMask;
|
||||||
if(boneMask == null){
|
if(boneMask == null){
|
||||||
animMask = new ActorAnimationMask(
|
animMask = new ActorAnimationMaskEntry(
|
||||||
priority,
|
priority,
|
||||||
animationName,
|
animationName,
|
||||||
length
|
length
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
animMask = new ActorAnimationMask(
|
animMask = new ActorAnimationMaskEntry(
|
||||||
priority,
|
priority,
|
||||||
animationName,
|
animationName,
|
||||||
length,
|
length,
|
||||||
@ -419,13 +427,13 @@ public class Actor {
|
|||||||
|
|
||||||
//clear existing masks that are lower priority
|
//clear existing masks that are lower priority
|
||||||
toRemoveMasks.clear();
|
toRemoveMasks.clear();
|
||||||
for(ActorAnimationMask currentMask : animationQueue){
|
for(ActorAnimationMaskEntry currentMask : animationQueue){
|
||||||
if(currentMask.getPriority() == animMask.getPriority()){
|
if(currentMask.getPriority() == animMask.getPriority()){
|
||||||
toRemoveMasks.add(currentMask);
|
toRemoveMasks.add(currentMask);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask currentMask : toRemoveMasks){
|
for(ActorAnimationMaskEntry currentMask : toRemoveMasks){
|
||||||
animationQueue.remove(currentMask);
|
animationQueue.remove(currentMask);
|
||||||
}
|
}
|
||||||
animationQueue.add(animMask);
|
animationQueue.add(animMask);
|
||||||
@ -455,12 +463,12 @@ public class Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toRemoveMasks.clear();
|
toRemoveMasks.clear();
|
||||||
for(ActorAnimationMask mask : this.animationQueue){
|
for(ActorAnimationMaskEntry mask : this.animationQueue){
|
||||||
if(mask.getAnimationName() == animationName && mask.getPriority() == priority){
|
if(mask.getAnimationName() == animationName && mask.getPriority() == priority){
|
||||||
toRemoveMasks.add(mask);
|
toRemoveMasks.add(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask currentMask : toRemoveMasks){
|
for(ActorAnimationMaskEntry currentMask : toRemoveMasks){
|
||||||
animationQueue.remove(currentMask);
|
animationQueue.remove(currentMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -469,15 +477,15 @@ public class Actor {
|
|||||||
Model model = Globals.assetManager.fetchModel(baseModelPath);
|
Model model = Globals.assetManager.fetchModel(baseModelPath);
|
||||||
if(model != null){
|
if(model != null){
|
||||||
double length = model.getAnimation(animationName).duration;
|
double length = model.getAnimation(animationName).duration;
|
||||||
ActorAnimationMask animMask = new ActorAnimationMask(priority, animationName, 0, length, boneMask);
|
ActorAnimationMaskEntry animMask = new ActorAnimationMaskEntry(priority, animationName, 0, length, boneMask);
|
||||||
toRemoveMasks.clear();
|
toRemoveMasks.clear();
|
||||||
for(ActorAnimationMask currentMask : animationQueue){
|
for(ActorAnimationMaskEntry currentMask : animationQueue){
|
||||||
if(currentMask.getPriority() == animMask.getPriority()){
|
if(currentMask.getPriority() == animMask.getPriority()){
|
||||||
toRemoveMasks.add(currentMask);
|
toRemoveMasks.add(currentMask);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask currentMask : toRemoveMasks){
|
for(ActorAnimationMaskEntry currentMask : toRemoveMasks){
|
||||||
animationQueue.remove(currentMask);
|
animationQueue.remove(currentMask);
|
||||||
}
|
}
|
||||||
animationQueue.add(animMask);
|
animationQueue.add(animMask);
|
||||||
@ -488,7 +496,7 @@ public class Actor {
|
|||||||
* Gets the animation queue
|
* Gets the animation queue
|
||||||
* @return The animation queue
|
* @return The animation queue
|
||||||
*/
|
*/
|
||||||
public Set<ActorAnimationMask> getAnimationQueue(){
|
public Set<ActorAnimationMaskEntry> getAnimationQueue(){
|
||||||
return animationQueue;
|
return animationQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,7 +507,7 @@ public class Actor {
|
|||||||
private void applyAnimationMasks(Model model){
|
private void applyAnimationMasks(Model model){
|
||||||
List<String> bonesUsed = new LinkedList<String>();
|
List<String> bonesUsed = new LinkedList<String>();
|
||||||
List<String> currentAnimationMask = new LinkedList<String>();
|
List<String> currentAnimationMask = new LinkedList<String>();
|
||||||
for(ActorAnimationMask mask : animationQueue){
|
for(ActorAnimationMaskEntry mask : animationQueue){
|
||||||
currentAnimationMask.clear();
|
currentAnimationMask.clear();
|
||||||
for(String currentBone : mask.getBones()){
|
for(String currentBone : mask.getBones()){
|
||||||
if(!bonesUsed.contains(currentBone)){
|
if(!bonesUsed.contains(currentBone)){
|
||||||
@ -539,8 +547,8 @@ public class Actor {
|
|||||||
* @param animationName The animation's name
|
* @param animationName The animation's name
|
||||||
* @return The animation mask if the actor is playing the animation, null otherwise
|
* @return The animation mask if the actor is playing the animation, null otherwise
|
||||||
*/
|
*/
|
||||||
public ActorAnimationMask getAnimationMask(String animationName){
|
public ActorAnimationMaskEntry getAnimationMask(String animationName){
|
||||||
for(ActorAnimationMask mask : this.getAnimationQueue()){
|
for(ActorAnimationMaskEntry mask : this.getAnimationQueue()){
|
||||||
if(mask.getAnimationName().equals(animationName)){
|
if(mask.getAnimationName().equals(animationName)){
|
||||||
return mask;
|
return mask;
|
||||||
} else if(mask.getAnimationName().equalsIgnoreCase(animationName)){
|
} else if(mask.getAnimationName().equalsIgnoreCase(animationName)){
|
||||||
@ -942,7 +950,7 @@ public class Actor {
|
|||||||
if(numFrames < 1){
|
if(numFrames < 1){
|
||||||
throw new Error("Num frames less than 1 !" + numFrames);
|
throw new Error("Num frames less than 1 !" + numFrames);
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask mask : this.animationQueue){
|
for(ActorAnimationMaskEntry mask : this.animationQueue){
|
||||||
if(mask.getAnimationName().contains(animationPath)){
|
if(mask.getAnimationName().contains(animationPath)){
|
||||||
mask.setFreezeFrames(numFrames);
|
mask.setFreezeFrames(numFrames);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* An animation mask. Combines an animation name, priority, and a list of bones to apply that animation to
|
* An animation mask. Combines an animation name, priority, and a list of bones to apply that animation to
|
||||||
*/
|
*/
|
||||||
public class ActorAnimationMask implements Comparable<ActorAnimationMask> {
|
public class ActorAnimationMaskEntry implements Comparable<ActorAnimationMaskEntry> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The priority of the mask
|
* The priority of the mask
|
||||||
@ -46,7 +46,7 @@ public class ActorAnimationMask implements Comparable<ActorAnimationMask> {
|
|||||||
* @param timeMax
|
* @param timeMax
|
||||||
* @param boneMask
|
* @param boneMask
|
||||||
*/
|
*/
|
||||||
public ActorAnimationMask(int priority, String animationName, double time, double timeMax, List<String> boneMask){
|
public ActorAnimationMaskEntry(int priority, String animationName, double time, double timeMax, List<String> boneMask){
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
this.animationName = animationName;
|
this.animationName = animationName;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
@ -61,7 +61,7 @@ public class ActorAnimationMask implements Comparable<ActorAnimationMask> {
|
|||||||
* @param timeMax
|
* @param timeMax
|
||||||
* @param boneMask
|
* @param boneMask
|
||||||
*/
|
*/
|
||||||
public ActorAnimationMask(int priority, String animationName, double timeMax, List<String> boneMask){
|
public ActorAnimationMaskEntry(int priority, String animationName, double timeMax, List<String> boneMask){
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
this.animationName = animationName;
|
this.animationName = animationName;
|
||||||
this.timeMax = timeMax;
|
this.timeMax = timeMax;
|
||||||
@ -75,7 +75,7 @@ public class ActorAnimationMask implements Comparable<ActorAnimationMask> {
|
|||||||
* @param time
|
* @param time
|
||||||
* @param timeMax
|
* @param timeMax
|
||||||
*/
|
*/
|
||||||
public ActorAnimationMask(int priority, String animationName, double time, double timeMax){
|
public ActorAnimationMaskEntry(int priority, String animationName, double time, double timeMax){
|
||||||
this(priority, animationName, time, timeMax, new LinkedList<String>());
|
this(priority, animationName, time, timeMax, new LinkedList<String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ public class ActorAnimationMask implements Comparable<ActorAnimationMask> {
|
|||||||
* @param animationName
|
* @param animationName
|
||||||
* @param timeMax
|
* @param timeMax
|
||||||
*/
|
*/
|
||||||
public ActorAnimationMask(int priority, String animationName, double timeMax){
|
public ActorAnimationMaskEntry(int priority, String animationName, double timeMax){
|
||||||
this(priority, animationName, 0, timeMax, new LinkedList<String>());
|
this(priority, animationName, 0, timeMax, new LinkedList<String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,8 +162,8 @@ public class ActorAnimationMask implements Comparable<ActorAnimationMask> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(ActorAnimationMask o) {
|
public int compareTo(ActorAnimationMaskEntry o) {
|
||||||
ActorAnimationMask otherMask = (ActorAnimationMask)o;
|
ActorAnimationMaskEntry otherMask = (ActorAnimationMaskEntry)o;
|
||||||
if(otherMask.priority > this.priority){
|
if(otherMask.priority > this.priority){
|
||||||
return -1;
|
return -1;
|
||||||
} else if(otherMask.priority < this.priority){
|
} else if(otherMask.priority < this.priority){
|
||||||
@ -19,7 +19,7 @@ import electrosphere.entity.state.AnimationPriorities;
|
|||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.renderer.actor.ActorBoneRotator;
|
import electrosphere.renderer.actor.ActorBoneRotator;
|
||||||
import electrosphere.renderer.actor.ActorStaticMorph;
|
import electrosphere.renderer.actor.ActorStaticMorph;
|
||||||
import electrosphere.renderer.actor.mask.ActorAnimationMask;
|
import electrosphere.renderer.actor.mask.ActorAnimationMaskEntry;
|
||||||
import electrosphere.renderer.model.Bone;
|
import electrosphere.renderer.model.Bone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,7 +40,7 @@ public class PoseActor {
|
|||||||
/**
|
/**
|
||||||
* Priority queue of animations to play. Allows masking a higher priority animation over a lower priority one.
|
* Priority queue of animations to play. Allows masking a higher priority animation over a lower priority one.
|
||||||
*/
|
*/
|
||||||
Set<ActorAnimationMask> animationQueue = new TreeSet<ActorAnimationMask>();
|
Set<ActorAnimationMaskEntry> animationQueue = new TreeSet<ActorAnimationMaskEntry>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bone rotation map. Used to apply rotator functionality to bones (think hair, cloth, and camera rotation on looking)
|
* Bone rotation map. Used to apply rotator functionality to bones (think hair, cloth, and camera rotation on looking)
|
||||||
@ -79,7 +79,7 @@ public class PoseActor {
|
|||||||
|
|
||||||
//Used to keep track of which animations have completed and therefore should be removed
|
//Used to keep track of which animations have completed and therefore should be removed
|
||||||
//Separate variable so no concurrent modification to anim lists/maps
|
//Separate variable so no concurrent modification to anim lists/maps
|
||||||
List<ActorAnimationMask> toRemoveMasks = new LinkedList<ActorAnimationMask>();
|
List<ActorAnimationMaskEntry> toRemoveMasks = new LinkedList<ActorAnimationMaskEntry>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increments time of all currently played animations
|
* Increments time of all currently played animations
|
||||||
@ -87,13 +87,13 @@ public class PoseActor {
|
|||||||
*/
|
*/
|
||||||
public void incrementAnimationTime(double deltaTime){
|
public void incrementAnimationTime(double deltaTime){
|
||||||
toRemoveMasks.clear();
|
toRemoveMasks.clear();
|
||||||
for(ActorAnimationMask mask : animationQueue){
|
for(ActorAnimationMaskEntry mask : animationQueue){
|
||||||
mask.setTime(mask.getTime() + deltaTime * animationScalar);
|
mask.setTime(mask.getTime() + deltaTime * animationScalar);
|
||||||
if(mask.getTime() > mask.getDuration()){
|
if(mask.getTime() > mask.getDuration()){
|
||||||
toRemoveMasks.add(mask);
|
toRemoveMasks.add(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask mask : toRemoveMasks){
|
for(ActorAnimationMaskEntry mask : toRemoveMasks){
|
||||||
animationQueue.remove(mask);
|
animationQueue.remove(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ public class PoseActor {
|
|||||||
* @return The current time of the animation if it exists, -1.0f otherwise
|
* @return The current time of the animation if it exists, -1.0f otherwise
|
||||||
*/
|
*/
|
||||||
public double getAnimationTime(String animationName){
|
public double getAnimationTime(String animationName){
|
||||||
for(ActorAnimationMask mask : animationQueue){
|
for(ActorAnimationMaskEntry mask : animationQueue){
|
||||||
if(mask.getAnimationName().contains(animationName)){
|
if(mask.getAnimationName().contains(animationName)){
|
||||||
return mask.getTime();
|
return mask.getTime();
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ public class PoseActor {
|
|||||||
* @return True if the animation is playing, false otherwise
|
* @return True if the animation is playing, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isPlayingAnimation(String animationName){
|
public boolean isPlayingAnimation(String animationName){
|
||||||
for(ActorAnimationMask mask : animationQueue){
|
for(ActorAnimationMaskEntry mask : animationQueue){
|
||||||
if(mask.getAnimationName().contains(animationName)){
|
if(mask.getAnimationName().contains(animationName)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ public class PoseActor {
|
|||||||
if(animationData == null){
|
if(animationData == null){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask mask : animationQueue){
|
for(ActorAnimationMaskEntry mask : animationQueue){
|
||||||
if(mask.getAnimationName().contains(animationData.getNameThirdPerson())){
|
if(mask.getAnimationName().contains(animationData.getNameThirdPerson())){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -156,13 +156,13 @@ public class PoseActor {
|
|||||||
* @param animationName The name of the animation to stop playing
|
* @param animationName The name of the animation to stop playing
|
||||||
*/
|
*/
|
||||||
public void stopAnimation(String animationName){
|
public void stopAnimation(String animationName){
|
||||||
List<ActorAnimationMask> toRemove = new LinkedList<ActorAnimationMask>();
|
List<ActorAnimationMaskEntry> toRemove = new LinkedList<ActorAnimationMaskEntry>();
|
||||||
for(ActorAnimationMask mask : animationQueue){
|
for(ActorAnimationMaskEntry mask : animationQueue){
|
||||||
if(mask.getAnimationName().contains(animationName)){
|
if(mask.getAnimationName().contains(animationName)){
|
||||||
toRemove.add(mask);
|
toRemove.add(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask mask : toRemove){
|
for(ActorAnimationMaskEntry mask : toRemove){
|
||||||
animationQueue.remove(mask);
|
animationQueue.remove(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,18 +176,18 @@ public class PoseActor {
|
|||||||
PoseModel model = Globals.assetManager.fetchPoseModel(modelPath);
|
PoseModel model = Globals.assetManager.fetchPoseModel(modelPath);
|
||||||
if(model != null && model.getAnimation(animationName) != null){
|
if(model != null && model.getAnimation(animationName) != null){
|
||||||
double length = model.getAnimation(animationName).duration;
|
double length = model.getAnimation(animationName).duration;
|
||||||
ActorAnimationMask animMask = new ActorAnimationMask(priority, animationName, 0, length);
|
ActorAnimationMaskEntry animMask = new ActorAnimationMaskEntry(priority, animationName, 0, length);
|
||||||
for(Bone bone : model.bones){
|
for(Bone bone : model.bones){
|
||||||
animMask.addBone(bone.boneID);
|
animMask.addBone(bone.boneID);
|
||||||
}
|
}
|
||||||
toRemoveMasks.clear();
|
toRemoveMasks.clear();
|
||||||
for(ActorAnimationMask currentMask : animationQueue){
|
for(ActorAnimationMaskEntry currentMask : animationQueue){
|
||||||
if(currentMask.getPriority() == animMask.getPriority()){
|
if(currentMask.getPriority() == animMask.getPriority()){
|
||||||
toRemoveMasks.add(currentMask);
|
toRemoveMasks.add(currentMask);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask currentMask : toRemoveMasks){
|
for(ActorAnimationMaskEntry currentMask : toRemoveMasks){
|
||||||
animationQueue.remove(currentMask);
|
animationQueue.remove(currentMask);
|
||||||
}
|
}
|
||||||
animationQueue.add(animMask);
|
animationQueue.add(animMask);
|
||||||
@ -255,15 +255,15 @@ public class PoseActor {
|
|||||||
double length = model.getAnimation(animationName).duration;
|
double length = model.getAnimation(animationName).duration;
|
||||||
|
|
||||||
//construct the animation mask
|
//construct the animation mask
|
||||||
ActorAnimationMask animMask;
|
ActorAnimationMaskEntry animMask;
|
||||||
if(boneMask == null){
|
if(boneMask == null){
|
||||||
animMask = new ActorAnimationMask(
|
animMask = new ActorAnimationMaskEntry(
|
||||||
priority,
|
priority,
|
||||||
animationName,
|
animationName,
|
||||||
length
|
length
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
animMask = new ActorAnimationMask(
|
animMask = new ActorAnimationMaskEntry(
|
||||||
priority,
|
priority,
|
||||||
animationName,
|
animationName,
|
||||||
length,
|
length,
|
||||||
@ -281,13 +281,13 @@ public class PoseActor {
|
|||||||
|
|
||||||
//clear existing masks that are lower priority
|
//clear existing masks that are lower priority
|
||||||
toRemoveMasks.clear();
|
toRemoveMasks.clear();
|
||||||
for(ActorAnimationMask currentMask : animationQueue){
|
for(ActorAnimationMaskEntry currentMask : animationQueue){
|
||||||
if(currentMask.getPriority() == animMask.getPriority()){
|
if(currentMask.getPriority() == animMask.getPriority()){
|
||||||
toRemoveMasks.add(currentMask);
|
toRemoveMasks.add(currentMask);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask currentMask : toRemoveMasks){
|
for(ActorAnimationMaskEntry currentMask : toRemoveMasks){
|
||||||
animationQueue.remove(currentMask);
|
animationQueue.remove(currentMask);
|
||||||
}
|
}
|
||||||
animationQueue.add(animMask);
|
animationQueue.add(animMask);
|
||||||
@ -317,12 +317,12 @@ public class PoseActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toRemoveMasks.clear();
|
toRemoveMasks.clear();
|
||||||
for(ActorAnimationMask mask : this.animationQueue){
|
for(ActorAnimationMaskEntry mask : this.animationQueue){
|
||||||
if(mask.getAnimationName() == animationName && mask.getPriority() == priority){
|
if(mask.getAnimationName() == animationName && mask.getPriority() == priority){
|
||||||
toRemoveMasks.add(mask);
|
toRemoveMasks.add(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask currentMask : toRemoveMasks){
|
for(ActorAnimationMaskEntry currentMask : toRemoveMasks){
|
||||||
animationQueue.remove(currentMask);
|
animationQueue.remove(currentMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,15 +337,15 @@ public class PoseActor {
|
|||||||
PoseModel model = Globals.assetManager.fetchPoseModel(modelPath);
|
PoseModel model = Globals.assetManager.fetchPoseModel(modelPath);
|
||||||
if(model != null){
|
if(model != null){
|
||||||
double length = model.getAnimation(animationName).duration;
|
double length = model.getAnimation(animationName).duration;
|
||||||
ActorAnimationMask animMask = new ActorAnimationMask(priority, animationName, 0, length, boneMask);
|
ActorAnimationMaskEntry animMask = new ActorAnimationMaskEntry(priority, animationName, 0, length, boneMask);
|
||||||
toRemoveMasks.clear();
|
toRemoveMasks.clear();
|
||||||
for(ActorAnimationMask currentMask : animationQueue){
|
for(ActorAnimationMaskEntry currentMask : animationQueue){
|
||||||
if(currentMask.getPriority() == animMask.getPriority()){
|
if(currentMask.getPriority() == animMask.getPriority()){
|
||||||
toRemoveMasks.add(currentMask);
|
toRemoveMasks.add(currentMask);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ActorAnimationMask currentMask : toRemoveMasks){
|
for(ActorAnimationMaskEntry currentMask : toRemoveMasks){
|
||||||
animationQueue.remove(currentMask);
|
animationQueue.remove(currentMask);
|
||||||
}
|
}
|
||||||
animationQueue.add(animMask);
|
animationQueue.add(animMask);
|
||||||
@ -359,7 +359,7 @@ public class PoseActor {
|
|||||||
private void applyAnimationMasks(PoseModel model){
|
private void applyAnimationMasks(PoseModel model){
|
||||||
List<String> bonesUsed = new LinkedList<String>();
|
List<String> bonesUsed = new LinkedList<String>();
|
||||||
List<String> currentAnimationMask = new LinkedList<String>();
|
List<String> currentAnimationMask = new LinkedList<String>();
|
||||||
for(ActorAnimationMask mask : animationQueue){
|
for(ActorAnimationMaskEntry mask : animationQueue){
|
||||||
currentAnimationMask.clear();
|
currentAnimationMask.clear();
|
||||||
for(String currentBone : mask.getBones()){
|
for(String currentBone : mask.getBones()){
|
||||||
if(!bonesUsed.contains(currentBone)){
|
if(!bonesUsed.contains(currentBone)){
|
||||||
@ -375,7 +375,7 @@ public class PoseActor {
|
|||||||
* Gets the animation queue
|
* Gets the animation queue
|
||||||
* @return The animation queue
|
* @return The animation queue
|
||||||
*/
|
*/
|
||||||
public Set<ActorAnimationMask> getAnimationQueue(){
|
public Set<ActorAnimationMaskEntry> getAnimationQueue(){
|
||||||
return animationQueue;
|
return animationQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user