partway to rotators
This commit is contained in:
parent
4965c8f1a9
commit
c461f75480
@ -122,7 +122,7 @@
|
||||
"rotatorSystem" : {
|
||||
"rotatorItems" : [
|
||||
{
|
||||
"boneName" : "myTorsoBone",
|
||||
"boneName" : "Bone",
|
||||
"constraints" : [
|
||||
{
|
||||
"followsView" : true,
|
||||
@ -133,7 +133,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"boneName" : "myLeftLegBone",
|
||||
"boneName" : "Leg.L",
|
||||
"constraints" : [
|
||||
{
|
||||
"followsView" : false,
|
||||
@ -144,7 +144,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"boneName" : "myRightLegBone",
|
||||
"boneName" : "Leg.R",
|
||||
"constraints" : [
|
||||
{
|
||||
"followsView" : false,
|
||||
|
||||
@ -45,6 +45,7 @@ import electrosphere.net.parser.net.message.NetworkMessage;
|
||||
import electrosphere.net.server.Player;
|
||||
import electrosphere.renderer.Model;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.actor.ActorBoneRotator;
|
||||
import electrosphere.renderer.actor.ActorUtils;
|
||||
import electrosphere.renderer.light.PointLight;
|
||||
import electrosphere.util.ModelLoader;
|
||||
@ -301,6 +302,9 @@ public class CreatureUtils {
|
||||
if(rawType.getRotatorSystem() != null){
|
||||
RotatorSystem system = rawType.getRotatorSystem();
|
||||
for(RotatorItem item : system.getRotatorItems()){
|
||||
ActorBoneRotator newRotator = new ActorBoneRotator();
|
||||
newRotator.getRotation().rotationAxis((float)Math.PI/2.0f, new Vector3f(1,0,0));
|
||||
creatureActor.addBoneRotator(item.getBoneName(), newRotator);
|
||||
}
|
||||
}
|
||||
//add health system
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package electrosphere.renderer;
|
||||
|
||||
import electrosphere.renderer.actor.ActorAnimationMask;
|
||||
import electrosphere.renderer.actor.ActorBoneRotator;
|
||||
import electrosphere.renderer.actor.ActorMeshMask;
|
||||
import electrosphere.renderer.actor.ActorShaderMask;
|
||||
import electrosphere.renderer.actor.ActorTextureMask;
|
||||
@ -198,9 +199,9 @@ public class Model {
|
||||
}
|
||||
|
||||
public void draw(boolean setShader, boolean bufferStandardUniforms, boolean bufferNonStandardUniforms, boolean useMaterial, boolean useShadowMap, boolean setBones, boolean useLight){
|
||||
if(node_map != null && !node_map.isEmpty()){
|
||||
update_node_transform(root_anim_node);
|
||||
}
|
||||
// if(node_map != null && !node_map.isEmpty()){
|
||||
// update_node_transform(root_anim_node);
|
||||
// }
|
||||
Iterator<Mesh> mesh_Iterator = meshes.iterator();
|
||||
while(mesh_Iterator.hasNext()){
|
||||
Mesh currentMesh = mesh_Iterator.next();
|
||||
@ -370,11 +371,13 @@ public class Model {
|
||||
return node_object;
|
||||
}
|
||||
|
||||
public void updateNodeTransform(){
|
||||
update_node_transform(this.root_anim_node);
|
||||
public void updateNodeTransform(Map<String,ActorBoneRotator> boneRotators){
|
||||
if(this.root_anim_node != null){
|
||||
update_node_transform(this.root_anim_node,boneRotators);
|
||||
}
|
||||
}
|
||||
|
||||
void update_node_transform(AnimNode n){
|
||||
void update_node_transform(AnimNode n, Map<String,ActorBoneRotator> boneRotators){
|
||||
if(n.parent != null){
|
||||
n.transform = new Matrix4f(n.parent.transform);
|
||||
} else {
|
||||
@ -391,6 +394,9 @@ public class Model {
|
||||
*/
|
||||
Bone target_bone = boneMap.get(n.id);
|
||||
n.transform = n.transform.mul(target_bone.deform);
|
||||
if(boneRotators.containsKey(target_bone.boneID)){
|
||||
n.transform.rotate(boneRotators.get(target_bone.boneID).getRotation());
|
||||
}
|
||||
Matrix4f bone_matrix = new Matrix4f(n.transform).mul(target_bone.inverseBindPoseMatrix);
|
||||
bone_matrix = new Matrix4f(globalInverseTransform).mul(bone_matrix);
|
||||
target_bone.final_transform = bone_matrix;
|
||||
@ -413,15 +419,15 @@ public class Model {
|
||||
Iterator<AnimNode> node_iterator = n.children.iterator();
|
||||
while(node_iterator.hasNext()){
|
||||
AnimNode current_node = node_iterator.next();
|
||||
update_node_transform(current_node);
|
||||
update_node_transform(current_node,boneRotators);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void drawForDepthBuffer(){
|
||||
if(node_map != null && !node_map.isEmpty()){
|
||||
update_node_transform(root_anim_node);
|
||||
}
|
||||
// if(node_map != null && !node_map.isEmpty()){
|
||||
// update_node_transform(root_anim_node);
|
||||
// }
|
||||
Iterator<Mesh> mesh_Iterator = meshes.iterator();
|
||||
while(mesh_Iterator.hasNext()){
|
||||
Mesh currentMesh = mesh_Iterator.next();
|
||||
|
||||
@ -29,7 +29,7 @@ public class Actor {
|
||||
ActorMeshMask meshMask = new ActorMeshMask();
|
||||
List<ActorShaderMask> shaderMasks = new LinkedList<ActorShaderMask>();
|
||||
Map<String,ActorTextureMask> textureMap = null;
|
||||
Map<String,ActorNodeTransformMask> nodeTransformMaskMap;
|
||||
Map<String,ActorBoneRotator> boneRotators = new HashMap<String,ActorBoneRotator>();
|
||||
|
||||
public Actor(String modelPath){
|
||||
this.modelPath = modelPath;
|
||||
@ -162,7 +162,7 @@ public class Actor {
|
||||
}
|
||||
|
||||
void calculateNodeTransforms(Model model){
|
||||
model.updateNodeTransform();
|
||||
model.updateNodeTransform(boneRotators);
|
||||
}
|
||||
|
||||
// public boolean isPlayingAnimation(){
|
||||
@ -203,6 +203,7 @@ public class Actor {
|
||||
model.getShaderMask().put(shaderMask.getMeshName(),shaderMask);
|
||||
}
|
||||
}
|
||||
calculateNodeTransforms(model);
|
||||
if(textureOverride != null){
|
||||
Texture overrideTextureObject = Globals.assetManager.fetchTexture(textureOverride);
|
||||
if(overrideTextureObject != null){
|
||||
@ -230,6 +231,7 @@ public class Actor {
|
||||
// }
|
||||
// }
|
||||
applyAnimationMasks(model);
|
||||
calculateNodeTransforms(model);
|
||||
model.drawForDepthBuffer();
|
||||
}
|
||||
}
|
||||
@ -346,4 +348,13 @@ public class Actor {
|
||||
}
|
||||
|
||||
|
||||
public void addBoneRotator(String bone, ActorBoneRotator rotator){
|
||||
boneRotators.put(bone, rotator);
|
||||
}
|
||||
|
||||
public ActorBoneRotator getBoneRotator(String bone){
|
||||
return boneRotators.get(bone);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
package electrosphere.renderer.actor;
|
||||
|
||||
import org.joml.Quaternionf;
|
||||
|
||||
public class ActorBoneRotator {
|
||||
|
||||
Quaternionf rotation = new Quaternionf().identity();
|
||||
|
||||
public Quaternionf getRotation(){
|
||||
return rotation;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
package electrosphere.renderer.actor;
|
||||
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class ActorNodeTransformMask {
|
||||
|
||||
Vector3f translation;
|
||||
Quaternionf rotation;
|
||||
Vector3f scale;
|
||||
|
||||
public ActorNodeTransformMask(Vector3f translation, Quaternionf rotation, Vector3f scale){
|
||||
this.translation = translation;
|
||||
this.rotation = rotation;
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public Vector3f getTranslation(){
|
||||
return translation;
|
||||
}
|
||||
|
||||
public Quaternionf getRotation(){
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public Vector3f getScale(){
|
||||
return scale;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user