public static void main(String[] args) throws IOException { try { Set<String> a = new HashSet<String>(); for (String arg : args) a.add(arg); Skeleton skeleton = new Skeleton(Skeleton.defaultJoints, new Float(args[1])); skeleton.setData(new CsvIn(args[0])); skeleton.setRepeat(a.contains("-r")); DefaultJava2D.create(skeleton); } catch (Exception e) { System.out.println(e); throw e; } }
private void createLimbInstance( Skeleton skeleton, int limb, int[] limb_about, List<Attribute> limb_att) { int att = 1; Instance ist = new DenseInstance((SPATIAL_COORD * limb_about.length) + 1); limb_att = classifier.getLimbFeatureDataSet(limb); for (int i = 0; i < limb_about.length; i++) { if (limb_about[i] != TORSO) { /* * il punto di riferimento per tutti i joint (meno che per il * TORSO), ossia il centro degli assi che descrivono lo spazio * in cui si possono muovere è il TORSO stesso. */ Point3D<Float> joint = skeleton.getJoint(SKELETON_JOINT(limb_about[i])).getPosition(); ist.setValue((Attribute) limb_att.get(att), (joint.getX() - x_torso)); ist.setValue((Attribute) limb_att.get(att + 1), (joint.getY() - y_torso)); ist.setValue((Attribute) limb_att.get(att + 2), (joint.getZ() - z_torso)); att += 3; } else { /* * il punto di riferimento per il BODY invece è il punto con * coordinate (0, -Ytorso, 0), e cioè, il punto sul pavimento * esattamente perpendicolare al TORSO stesso */ Point3D<Float> left_foot = skeleton.getJoint(JointType.LEFT_FOOT).getPosition(); Point3D<Float> right_foot = skeleton.getJoint(JointType.RIGHT_FOOT).getPosition(); // save the two probably torso's new coordinates float torso_footSX = y_torso - left_foot.getY(); float torso_footDX = y_torso - right_foot.getY(); float y_torso_rifFoot = (torso_footSX > torso_footDX) ? torso_footSX : torso_footDX; ist.setValue((Attribute) limb_att.get(att), 0); ist.setValue((Attribute) limb_att.get(att + 1), y_torso_rifFoot); ist.setValue((Attribute) limb_att.get(att + 2), 0); att += 3; } } skeletonIstances.add(ist); }
/** * Given corner should be fully linked into the network. Needs to be removed as it connects two * parallel faces. We remove toAdd.nextL */ private void removeCorner(Corner toAdd) { if (holdRemoves) { removes.add(toAdd); return; } // update corners toAdd.prevC.nextC = toAdd.nextC; toAdd.nextC.prevC = toAdd.prevC; // update edges toAdd.nextC.prevL = toAdd.prevL; // update main corner list skel.liveCorners.remove(toAdd); // brute force search for all references to old edge (if this was on a // per face basis it'd be much nicer) for (Corner lc : skel.liveCorners) { if (lc.nextL == toAdd.nextL) { lc.nextL = toAdd.prevL; } if (lc.prevL == toAdd.nextL) { lc.prevL = toAdd.prevL; } } if (toAdd.prevL != toAdd.nextL) { // update live edge list skel.liveEdges.remove(toAdd.nextL); // update output edge list (the two input edges give one output // face) // skel.inputEdges.remove(toAdd.nextL); // update edges's live corners for (Corner c : toAdd.nextL.currentCorners) if (toAdd.prevL.currentCorners.add(c)) ; // also adds toAdd.nextC // merge output corner lists // add to the results map likewise skel.output.merge(toAdd.prevC, toAdd); // toAdd.prevL.addOutputSidesFrom // (toAdd.nextL); // all collisions need recalculation. This situation could be // avoided if collisions occur strictly with infinite faces. // recurse through all consecutive colinear faces...? skel.refindAllFaceEventsLater(); } // update edges's live corners (might have copied this over from nextL) toAdd.prevL.currentCorners.remove(toAdd); // todo: we've merged two machines! (pick an arbitrary one?) // assert ( toAdd.prevL.machine == toAdd.nextL.machine ); }
public static Job saveJob(String title) { int id = getNewJobId(); String jobDirName = JOBS_DIR_NAME + "/" + id; File jobDir = new File(jobDirName); jobDir.mkdirs(); Job job = new Job(id, title); job.saveProperties(); Skeleton.copyFiles(jobDirName); return job; }
/** * @param boneName the name of the bone * @return the node attached to this bone */ public Node getAttachmentsNode(String boneName) { Bone b = skeleton.getBone(boneName); if (b == null) { throw new IllegalArgumentException("Given bone name does not exist " + "in the skeleton."); } Node n = b.getAttachmentsNode(); Node model = (Node) spatial; model.attachChild(n); return n; }
private void createSkeletonInstances(UserData user) throws Exception { skeletonIstances = new ArrayList<Instance>(); Skeleton skeleton = user.getSkeleton(); double torso_conf = skeleton.getJoint(JointType.TORSO).getPositionConfidence(); if (torso_conf >= TORSO_CONF) { // se TORSO rilevato correttamente : IMPORTANTE per la correttezza // delle distanze dei vari limb Point3D<Float> torso_pos = skeleton.getJoint(JointType.TORSO).getPosition(); // save origin's coordinates x_torso = (Float) torso_pos.getX(); y_torso = (Float) torso_pos.getY(); z_torso = (Float) torso_pos.getZ(); createLimbInstance(skeleton, TRACKER_HEAD_LIMB, HEAD_ABOUT, head_att); createLimbInstance(skeleton, TRACKER_BODY_UPRIGHT_LIMB, BODY_UPRIGHT_ABOUT, body_upright_att); createLimbInstance( skeleton, TRACKER_BODY_STAN_SLANTING_LIMB, BODY_STAN_SLANTING_ABOUT, body_stan_slanting_att); createLimbInstance( skeleton, TRACKER_BODY_SIT_SLANTING_LIMB, BODY_SIT_SLANTING_ABOUT, body_sit_slanting_att); createLimbInstance(skeleton, TRACKER_LEFT_ARM_LIMB, LEFT_ARM_ABOUT, left_arm_att); createLimbInstance(skeleton, TRACKER_RIGHT_ARM_LIMB, RIGHT_ARM_ABOUT, right_arm_att); createLimbInstance(skeleton, TRACKER_LEFT_LEG_LIMB, LEFT_LEG_ABOUT, left_leg_att); createLimbInstance(skeleton, TRACKER_RIGHT_LEG_LIMB, RIGHT_LEG_ABOUT, right_leg_att); sendInstance(); } }
@Override protected void controlRender(RenderManager rm, ViewPort vp) { if (!wasMeshUpdated) { resetToBind(); // reset morph meshes to bind pose Matrix4f[] offsetMatrices = skeleton.computeSkinningMatrices(); // if hardware skinning is supported, the matrices and weight buffer // will be sent by the SkinningShaderLogic object assigned to the shader for (int i = 0; i < targets.length; i++) { // NOTE: This assumes that code higher up // Already ensured those targets are animated // otherwise a crash will happen in skin update // if (isMeshAnimated(targets[i])) { softwareSkinUpdate(targets[i], offsetMatrices); // } } wasMeshUpdated = true; } }
public Animation(Skeleton skeleton, int frame, float delay) { frames = new BoneTransform[skeleton.getBoneSize()][frame]; this.frame = frame; this.delay = delay; }
public static double getMaxHpByEntity(LivingEntity e) { switch (e.getType()) { case BLAZE: return hpOfBlaze; case CAVE_SPIDER: return hpOfCaveSpider; case CHICKEN: return hpOfChicken; case COW: return hpOfCow; case CREEPER: return hpOfCreeper; case ENDERMAN: return hpOfEnderman; case ENDER_DRAGON: return hpOfEnderDragon; case GHAST: return hpOfGhast; case GIANT: return hpOfGiant; case IRON_GOLEM: return hpOfIronGolem; case MAGMA_CUBE: int size = ((MagmaCube) e).getSize(); switch (size) { case 1: return hpOfMagmaCubeTiny; case 2: return hpOfMagmaCubeSmall; case 3: case 4: return hpOfMagmaCubeBig; } if (size >= 3) { return hpOfMagmaCubeBig; } return 0; case MUSHROOM_COW: return hpOfMooshroom; case OCELOT: return hpOfOcelot; case PIG: return hpOfPig; case PIG_ZOMBIE: return hpOfZombiePigman; case SHEEP: return hpOfSheep; case SILVERFISH: return hpOfSilverfish; case SKELETON: Skeleton sk = (Skeleton) e; if (sk.getSkeletonType() == SkeletonType.WITHER) { return hpOfWitherSkeleton; } else { return hpOfSkeleton; } case WITHER: return hpOfWither; case SLIME: int s = ((Slime) e).getSize(); switch (s) { case 1: return hpOfSlimeTiny; case 2: return hpOfSlimeSmall; } if (s >= 3) { return hpOfSlimeBig; } case SNOWMAN: return hpOfSnowGolem; case SPIDER: return hpOfSpider; case SQUID: return hpOfSquid; case WITCH: return hpOfWitch; case HORSE: return hpOfHorse; case VILLAGER: return hpOfVillager; case WOLF: if (((Wolf) e).isTamed()) { return hpOfWolfTamed; } else { return hpOfWolf; } case ZOMBIE: if (e instanceof Zombie) { Zombie z = (Zombie) e; if (z.isVillager()) { if (z.isBaby()) { return hpOfZombieBabyVillager; } else { return hpOfZombieVillager; } } else { if (z.isBaby()) { return hpOfBabyZombie; } else { return hpOfZombie; } } } else { return e.getMaxHealth(); } case BAT: return hpOfBat; default: break; } return e.getMaxHealth(); }
protected SpellResult alterEntity(Entity entity) { EntityType entityType = entity.getType(); switch (entityType) { case PAINTING: registerModified(entity); Painting painting = (Painting) entity; Art[] artValues = Art.values(); Art oldArt = painting.getArt(); Art newArt = oldArt; int ordinal = (oldArt.ordinal() + 1); for (int i = 0; i < artValues.length; i++) { newArt = artValues[ordinal++ % artValues.length]; painting.setArt(newArt); newArt = painting.getArt(); if (oldArt != newArt) { break; } } if (oldArt == newArt) { return SpellResult.FAIL; } mage.sendDebugMessage("Altering art from " + oldArt + " to " + newArt); break; case ITEM_FRAME: ItemFrame itemFrame = (ItemFrame) entity; ItemStack frameItem = itemFrame.getItem(); if (frameItem == null || frameItem.getType() != Material.MAP) { return SpellResult.NO_TARGET; } short data = frameItem.getDurability(); data++; MapView mapView = DeprecatedUtils.getMap(data); if (mapView == null) { data = 0; mapView = DeprecatedUtils.getMap(data); if (mapView == null) { return SpellResult.NO_TARGET; } } registerModified(entity); frameItem.setDurability(data); itemFrame.setItem(frameItem); break; case HORSE: registerModified(entity); Horse horse = (Horse) entity; Color color = horse.getColor(); Color[] colorValues = Color.values(); color = colorValues[(color.ordinal() + 1) % colorValues.length]; Variant variant = horse.getVariant(); Variant[] variantValues = Variant.values(); variant = variantValues[(variant.ordinal() + 1) % variantValues.length]; Style horseStyle = horse.getStyle(); Style[] styleValues = Style.values(); horseStyle = styleValues[(horseStyle.ordinal() + 1) % styleValues.length]; horse.setStyle(horseStyle); horse.setColor(color); horse.setVariant(variant); break; case OCELOT: registerModified(entity); Ocelot ocelot = (Ocelot) entity; Type catType = ocelot.getCatType(); Type[] typeValues = Type.values(); catType = typeValues[(catType.ordinal() + 1) % typeValues.length]; ocelot.setCatType(catType); break; case VILLAGER: registerModified(entity); Villager villager = (Villager) entity; Profession profession = villager.getProfession(); Profession[] professionValues = Profession.values(); profession = professionValues[(profession.ordinal() + 1) % professionValues.length]; villager.setProfession(profession); break; case WOLF: registerModified(entity); Wolf wolf = (Wolf) entity; DyeColor wolfColor = wolf.getCollarColor(); DyeColor[] wolfColorValues = DyeColor.values(); wolfColor = wolfColorValues[(wolfColor.ordinal() + 1) % wolfColorValues.length]; wolf.setCollarColor(wolfColor); break; case SHEEP: registerModified(entity); Sheep sheep = (Sheep) entity; DyeColor dyeColor = sheep.getColor(); DyeColor[] dyeColorValues = DyeColor.values(); dyeColor = dyeColorValues[(dyeColor.ordinal() + 1) % dyeColorValues.length]; sheep.setColor(dyeColor); break; case SKELETON: registerModified(entity); Skeleton skeleton = (Skeleton) entity; SkeletonType skeletonType = skeleton.getSkeletonType(); SkeletonType[] skeletonTypeValues = SkeletonType.values(); skeletonType = skeletonTypeValues[(skeletonType.ordinal() + 1) % skeletonTypeValues.length]; skeleton.setSkeletonType(skeletonType); break; default: return SpellResult.NO_TARGET; } ; registerForUndo(); return SpellResult.CAST; }
static void addSkeleton(Skeleton skeleton) { localSkeletons.put(skeleton.name(), skeleton); }
public DeathDetail(EntityDeathEvent event) { player = (Player) event.getEntity(); entityDeathEvent = event; // Support for setHealth(0) which is used by essentials to do a suicide try { EntityDamageEvent damageEvent = event.getEntity().getLastDamageCause(); if (damageEvent instanceof EntityDamageByEntityEvent) { Entity damager = ((EntityDamageByEntityEvent) damageEvent).getDamager(); log.debug("damager", damager.toString()); if (damager instanceof Player) { log.debug("Killed by an other player"); if (((Player) damager).getItemInHand().getType().equals(Material.AIR)) { causeOfDeath = DeathEventType.PVP_FISTS; } else { causeOfDeath = DeathEventType.PVP; } murderWeapon = ((Player) damager).getItemInHand().getType().toString(); killer = (Player) damager; } else if (damager instanceof Creature || damager instanceof Slime) { log.debug("We have a creature or slime"); if (damager instanceof Tameable && ((Tameable) damager).isTamed()) { causeOfDeath = DeathEventType.PVP_TAMED; murderWeapon = damager.getType().toString(); killer = (Player) ((Tameable) damager).getOwner(); } else { try { causeOfDeath = DeathEventType.valueOf(damager.getType().toString()); if (damager instanceof Skeleton) { Skeleton skeleton = (Skeleton) damager; causeOfDeath = skeleton.getSkeletonType() == SkeletonType.WITHER ? DeathEventType.WITHER_SKELETON : DeathEventType.SKELETON; } else if (damager instanceof Zombie) { Zombie zombie = (Zombie) damager; causeOfDeath = zombie.isVillager() ? DeathEventType.ZOMBIE_VILLAGER : DeathEventType.ZOMBIE; } } catch (IllegalArgumentException iae) { log.severe("Please notify the developer of the following Error:"); log.severe( "The following damager is not correctly implemented: " + damager.getType().toString()); causeOfDeath = DeathEventType.UNKNOWN; } log.debug("and it is: " + causeOfDeath); } } else if (damager instanceof Projectile) { log.debug("this is a projectile"); log.debug("shooter", ((Projectile) damager).getShooter()); if (((Projectile) damager).getShooter() instanceof Player) { causeOfDeath = DeathEventType.PVP; murderWeapon = ((Projectile) damager).toString().replace("Craft", ""); killer = (Player) ((Projectile) damager).getShooter(); } if (((Projectile) damager).getShooter() == null) { // let's assume that null will only be caused by a dispenser! causeOfDeath = DeathEventType.DISPENSER; murderWeapon = ((Projectile) damager).toString().replace("Craft", ""); } if (((Projectile) damager).getShooter().toString().equalsIgnoreCase("CraftSkeleton")) { causeOfDeath = DeathEventType.SKELETON; murderWeapon = ((Projectile) damager).toString().replace("Craft", ""); } } else if (damager instanceof TNTPrimed) { causeOfDeath = DeathEventType.BLOCK_EXPLOSION; } else { log.info("unknown enitity damager" + damager); } } else if (damageEvent != null) { log.debug("DamageEvent is not by Entity"); try { causeOfDeath = DeathEventType.valueOf(damageEvent.getCause().toString()); } catch (IllegalArgumentException e) { causeOfDeath = DeathEventType.UNKNOWN; } } } catch (NullPointerException npe) { log.debug("normal detection of damageevent failed", npe); log.debug("assuming you did use essentials or similar"); log.debug("which uses setHealth(0) to kill people"); log.info("Deathcause is being set to SUICIDE!"); causeOfDeath = DeathEventType.SUICIDE; murderWeapon = "Essentials"; } if (causeOfDeath == null) { causeOfDeath = DeathEventType.UNKNOWN; murderWeapon = "unknown"; } log.debug("causeOfDeath", causeOfDeath); log.debug("murderWeapon", murderWeapon); log.debug("killer", killer); }