Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package zombie.core.skinnedmodel;
- import java.io.IOException;
- import java.io.PrintStream;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Comparator;
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.Iterator;
- import java.util.Stack;
- import org.lwjgl.opengl.GL11;
- import zombie.characters.IsoGameCharacter;
- import zombie.characters.IsoZombie;
- import zombie.characters.SurvivorDesc;
- import zombie.core.PerformanceSettings;
- import zombie.core.SpriteRenderer;
- import zombie.core.opengl.RenderThread;
- import zombie.core.skinnedmodel.animation.AnimationPlayer;
- import zombie.core.skinnedmodel.animation.AnimationTrack;
- import zombie.core.skinnedmodel.model.Model;
- import zombie.core.skinnedmodel.model.ModelInstance;
- import zombie.core.skinnedmodel.model.format.ModelLoader;
- import zombie.core.skinnedmodel.model.format.ModelLoader.ModelFormat;
- import zombie.core.textures.ColorInfo;
- import zombie.core.textures.Texture;
- import zombie.core.textures.TextureFBO;
- import zombie.core.textures.TextureID;
- import zombie.core.utils.OnceEvery;
- import zombie.interfaces.ITexture;
- import zombie.inventory.types.HandWeapon;
- import zombie.iso.IsoCell;
- import zombie.iso.IsoDirections;
- import zombie.iso.IsoLightSource;
- import zombie.iso.IsoUtils;
- import zombie.iso.IsoWorld;
- import zombie.iso.LosUtil;
- import zombie.iso.LosUtil.TestResults;
- import zombie.iso.sprite.IsoAnim;
- import zombie.iso.sprite.IsoDirectionFrame;
- import zombie.iso.sprite.IsoSprite;
- import zombie.iso.sprite.IsoSpriteInstance;
- public class ModelManager
- {
- public static ModelManager instance = new ModelManager();
- public HashMap ModelMap = new HashMap();
- public ArrayList ModelSlots = new ArrayList();
- public TextureFBO bitmap;
- public boolean bCreated = false;
- public boolean bDebugEnableModels = true;
- public HashSet Contains = new HashSet();
- public boolean returnContext = true;
- OnceEvery removeModels = new OnceEvery(2.0F);
- public ArrayList ToRemove = new ArrayList();
- ArrayList ToResetNextFrame = new ArrayList();
- static Comparator comp = new Comparator()
- {
- public int compare(IsoLightSource a, IsoLightSource b)
- {
- float aScore = ModelManager.compChar.DistTo(a.x, a.y);
- float bScore = ModelManager.compChar.DistTo(b.x, b.y);
- return aScore < bScore ? -1 : aScore > bScore ? 1 : 0;
- }
- };
- static IsoGameCharacter compChar = null;
- public Stack lights = new Stack();
- private Stack lightsTemp = new Stack();
- public static String locationTextures = "media/textures/";
- public static String locationModels = "media/models/";
- public void create()
- {
- String zExtension = "." + ModelLoader.ModelFormat.zomboid.getExtension();
- if ((!this.bCreated) && (PerformanceSettings.modelsEnabled))
- {
- Texture tex = new Texture(256, 256);
- try
- {
- try
- {
- TextureID.bUseCompression = false;
- this.bitmap = new TextureFBO(tex, true);
- }
- finally
- {
- TextureID.bUseCompression = TextureID.bUseCompressionOption;
- }
- }
- catch (Exception var6)
- {
- var6.printStackTrace();
- PerformanceSettings.modelsEnabled = false;
- System.out.println("Models not compatible with gfx card at this time. Reverting to 2D sprites.");
- return;
- }
- loadStaticZomboidModel("weapons_baseballbatspiked", locationModels + "weapons_baseballbatspiked" + zExtension, locationTextures + "Objects_BaseballBatSpiked" + ".png");
- loadStaticZomboidModel("weapons_baseballbat", locationModels + "weapons_baseballbat" + zExtension, locationTextures + "Objects_BaseballBat" + ".png");
- loadStaticZomboidModel("weapons_fireaxe", locationModels + "weapons_fireaxe" + zExtension, locationTextures + "Objects_Fireaxe" + ".png");
- loadStaticZomboidModel("weapons_fryingpan", locationModels + "weapons_fryingpan" + zExtension, locationTextures + "Objects_FryingPan" + ".png");
- loadStaticZomboidModel("weapons_golfclub", locationModels + "weapons_golfclub" + zExtension, locationTextures + "Objects_GolfClub" + ".png");
- loadStaticZomboidModel("weapons_hammer", locationModels + "weapons_hammer" + zExtension, locationTextures + "Objects_Hammer" + ".png");
- loadStaticZomboidModel("weapons_handgun", locationModels + "weapons_handgun" + zExtension, locationTextures + "Objects_Handgun" + ".png");
- loadStaticZomboidModel("weapons_knife", locationModels + "weapons_knife" + zExtension, locationTextures + "Objects_Knife" + ".png");
- loadStaticZomboidModel("weapons_poolcue", locationModels + "weapons_poolcue" + zExtension, locationTextures + "Objects_PoolCue" + ".png");
- loadStaticZomboidModel("weapons_rollingpin", locationModels + "weapons_rollingpin" + zExtension, locationTextures + "Objects_RollingPin" + ".png");
- loadStaticZomboidModel("weapons_shotgun", locationModels + "weapons_shotgun" + zExtension, locationTextures + "Objects_Shotgun" + ".png");
- loadStaticZomboidModel("weapons_shotgunsawn", locationModels + "weapons_shotgunsawn" + zExtension, locationTextures + "Objects_ShotgunSawn" + ".png");
- loadStaticZomboidModel("weapons_shovel", locationModels + "weapons_shovel" + zExtension, locationTextures + "Objects_Shovel" + ".png");
- loadStaticZomboidModel("weapons_sledgehammer", locationModels + "weapons_sledgehammer" + zExtension, locationTextures + "Objects_Sledgehammer" + ".png");
- loadStaticZomboidModel("weapons_woodplank", locationModels + "weapons_woodplank" + zExtension, locationTextures + "Objects_WoodPlank" + ".png");
- loadZomboidModel("male", locationModels + "male" + zExtension, null);
- loadZomboidModel("kate", locationModels + "kate" + zExtension, null);
- loadZomboidModel("Shirt", locationModels + "Shirt" + zExtension, null);
- loadZomboidModel("Trousers", locationModels + "Trousers" + zExtension, null);
- loadZomboidModel("vest", locationModels + "vest" + zExtension, null);
- loadZomboidModel("f_vest", locationModels + "f_vest" + zExtension, null);
- loadZomboidModel("f_trousers", locationModels + "f_trousers" + zExtension, null);
- loadZomboidModel("f_skirt", locationModels + "f_skirt" + zExtension, null);
- loadZomboidModel("f_blouse", locationModels + "f_blouse" + zExtension, null);
- loadZomboidModel("beard_only", locationModels + "beard_only" + zExtension, null);
- loadZomboidModel("beard_moustache", locationModels + "beard_moustache" + zExtension, null);
- loadZomboidModel("beard_goatee", locationModels + "beard_goatee" + zExtension, null);
- loadZomboidModel("beard_full", locationModels + "beard_full" + zExtension, null);
- loadZomboidModel("beard_chops", locationModels + "beard_chops" + zExtension, null);
- loadZomboidModel("f_hair_overeye", locationModels + "f_hair_overeye" + zExtension, null);
- loadZomboidModel("f_hair_long2", locationModels + "f_hair_long2" + zExtension, null);
- loadZomboidModel("f_hair_long", locationModels + "f_hair_long" + zExtension, null);
- loadZomboidModel("f_hair_kate", locationModels + "f_hair_kate" + zExtension, null);
- loadZomboidModel("f_hair_bob", locationModels + "f_hair_bob" + zExtension, null);
- loadZomboidModel("f_hair_long2", locationModels + "f_hair_long2" + zExtension, null);
- loadZomboidModel("f_hair_long2", locationModels + "f_hair_long2" + zExtension, null);
- loadZomboidModel("hair_baldspot", locationModels + "hair_baldspot" + zExtension, null);
- loadZomboidModel("hair_messy", locationModels + "hair_messy" + zExtension, null);
- loadZomboidModel("hair_picard", locationModels + "hair_picard" + zExtension, null);
- loadZomboidModel("hair_recede", locationModels + "hair_recede" + zExtension, null);
- loadZomboidModel("hair_short", locationModels + "hair_short" + zExtension, null);
- this.bCreated = true;
- }
- }
- public Model loadStaticObjModel(String name, String modelLocation, String textureLocation)
- {
- try
- {
- Model e = ModelLoader.loaderObj.load(modelLocation, textureLocation,
- true);
- this.ModelMap.put(name.toLowerCase(), e);
- e.Name = name;
- return e;
- }
- catch (IOException var5)
- {
- var5.printStackTrace();
- return null;
- }
- catch (RuntimeException var6) {}
- return null;
- }
- public Model loadStaticZomboidModel(String name, String modelLocation, String textureLocation)
- {
- try
- {
- Model var5 = ModelLoader.loaderZomboid.load(modelLocation,
- textureLocation, true);
- this.ModelMap.put(name.toLowerCase(), var5);
- var5.Name = name;
- return var5;
- }
- catch (IOException var51)
- {
- var51.printStackTrace();
- }
- return null;
- }
- public Model loadZomboidModel(String name, String modelLocation, String textureLocation)
- {
- try
- {
- Model var5 = ModelLoader.loaderZomboid.load(modelLocation,
- textureLocation, false);
- this.ModelMap.put(name.toLowerCase(), var5);
- var5.Name = name;
- return var5;
- }
- catch (IOException var51)
- {
- var51.printStackTrace();
- }
- return null;
- }
- public void DoRender(int ID)
- {
- if (!((ModelSlot)this.ModelSlots.get(ID)).active)
- {
- GL11.glPushClientAttrib(-1);
- GL11.glPushAttrib(1048575);
- instance.bitmap.startDrawing(true, false);
- GL11.glClearColor(1.0F, 0.0F, 0.0F, 1.0F);
- GL11.glClear(16384);
- GL11.glClearColor(0.0F, 0.0F, 0.0F, 1.0F);
- instance.bitmap.endDrawing();
- GL11.glPopAttrib();
- GL11.glPopClientAttrib();
- }
- else
- {
- synchronized (((ModelSlot)this.ModelSlots.get(ID)).model.AnimPlayer)
- {
- GL11.glPushClientAttrib(-1);
- GL11.glPushAttrib(1048575);
- GL11.glEnable(2929);
- GL11.glEnable(3042);
- GL11.glBlendFunc(770, 771);
- GL11.glEnable(3008);
- GL11.glAlphaFunc(516, 0.0F);
- ModelSlot modelSlot = (ModelSlot)this.ModelSlots.get(ID);
- modelSlot.Start();
- modelSlot.Render();
- modelSlot.End();
- GL11.glPopAttrib();
- GL11.glPopClientAttrib();
- GL11.glEnable(3553);
- SpriteRenderer.ringBuffer.restoreVBOs = true;
- GL11.glEnable(2929);
- GL11.glEnable(3042);
- GL11.glBlendFunc(770, 771);
- GL11.glEnable(3008);
- GL11.glAlphaFunc(516, 0.0F);
- }
- }
- }
- public void DoneRendering(int ID)
- {
- if ((ID >= 0) && (ID < this.ModelSlots.size()))
- {
- ModelSlot modelSlot = (ModelSlot)this.ModelSlots.get(ID);
- modelSlot.bRendering = false;
- }
- }
- public void Reset(IsoGameCharacter chr)
- {
- if ((chr.legsSprite != null) && (chr.legsSprite.modelSlot != null))
- {
- RenderThread.borrowContext();
- while (SpriteRenderer.instance.DoingRender) {
- try
- {
- Thread.sleep(2L);
- }
- catch (InterruptedException var3)
- {
- var3.printStackTrace();
- }
- }
- DoCharacterModelParts(chr, chr.legsSprite.modelSlot);
- chr.legsSprite.modelSlot.UpdateLights();
- RenderThread.returnContext();
- }
- }
- public void Add(IsoGameCharacter chr)
- {
- if ((this.bCreated) && (PerformanceSettings.modelsEnabled) && (PerformanceSettings.support3D))
- {
- RenderThread.borrowContext();
- this.Contains.add(chr);
- ModelSlot slot = getSlot(chr);
- if (!this.ModelSlots.contains(slot)) {
- this.ModelSlots.add(slot);
- }
- if (((IsoDirectionFrame)chr.legsSprite.CurrentAnim.Frames.get(0)).getTexture(IsoDirections.N) != null)
- {
- String chrSprite = null;
- chrSprite = ((IsoDirectionFrame)chr.legsSprite.CurrentAnim.Frames.get(0)).getTexture(IsoDirections.N).getName();
- chrSprite = chrSprite.substring(0, chrSprite.indexOf("_"));
- String chrTex = chr.legsSprite.name;
- assert ((!(chr instanceof IsoZombie)) || (((IsoZombie)chr).SpriteName.equals(chr.legsSprite.name)));
- slot.model = newInstance((Model)this.ModelMap.get(chrSprite.toLowerCase().contains("kate") ? "kate" : "male"), chr, null);
- slot.model.LoadTexture(chrTex + "_Body");
- }
- DoCharacterModelParts(chr, slot);
- slot.active = true;
- chr.legsSprite.modelSlot = slot;
- slot.UpdateLights();
- RenderThread.returnContext();
- }
- }
- private void DoCharacterModelParts(IsoGameCharacter chr, ModelSlot slot)
- {
- slot.sub.clear();
- String chrSprite = null;
- if (((IsoDirectionFrame)chr.legsSprite.CurrentAnim.Frames.get(0)).getTexture(IsoDirections.N) != null)
- {
- chrSprite = ((IsoDirectionFrame)chr.legsSprite.CurrentAnim.Frames.get(0)).getTexture(IsoDirections.N).getName();
- chrSprite = chrSprite.substring(0, chrSprite.indexOf("_"));
- slot.model.LoadTexture(chr.legsSprite.name + "_Body");
- slot.model.tintR = chr.legsSprite.getTintMod().r;
- slot.model.tintG = chr.legsSprite.getTintMod().g;
- slot.model.tintB = chr.legsSprite.getTintMod().b;
- }
- if ((chr.bottomsSprite != null) && (!chr.bottomsSprite.CurrentAnim.Frames.isEmpty()) && (((IsoDirectionFrame)chr.bottomsSprite.CurrentAnim.Frames.get(0)).getTexture(IsoDirections.N) != null))
- {
- String trouserSprite = ((IsoDirectionFrame)chr.bottomsSprite.CurrentAnim.Frames.get(0)).getTexture(IsoDirections.N).getName();
- trouserSprite = trouserSprite.replace(chrSprite + "_", "");
- if (trouserSprite.contains("F_")) {
- trouserSprite = trouserSprite.substring(0, trouserSprite.indexOf("_", 2));
- } else {
- trouserSprite = trouserSprite.substring(0, trouserSprite.indexOf("_"));
- }
- ModelInstance topSprite = newInstance((Model)this.ModelMap.get(trouserSprite.toLowerCase()), chr, slot.model.AnimPlayer);
- topSprite.LoadTexture(trouserSprite + "_White");
- topSprite.tintR = chr.bottomsSprite.getTintMod().r;
- topSprite.tintG = chr.bottomsSprite.getTintMod().g;
- topSprite.tintB = chr.bottomsSprite.getTintMod().b;
- slot.sub.add(topSprite);
- }
- if ((chr.topSprite != null) && (!chr.topSprite.CurrentAnim.Frames.isEmpty()) && (((IsoDirectionFrame)chr.topSprite.CurrentAnim.Frames.get(0)).getTexture(IsoDirections.N) != null))
- {
- String var12 = ((IsoDirectionFrame)chr.topSprite.CurrentAnim.Frames.get(0)).getTexture(IsoDirections.N).getName();
- var12 = var12.replace(chrSprite + "_", "");
- if (var12.contains("F_")) {
- var12 = var12.substring(0, var12.indexOf("_", 2));
- } else {
- var12 = var12.substring(0, var12.indexOf("_"));
- }
- ModelInstance hairSprite = newInstance((Model)this.ModelMap.get(var12.toLowerCase()), chr, slot.model.AnimPlayer);
- hairSprite.LoadTexture(var12 + "_White");
- hairSprite.tintR = chr.topSprite.getTintMod().r;
- hairSprite.tintG = chr.topSprite.getTintMod().g;
- hairSprite.tintB = chr.topSprite.getTintMod().b;
- slot.sub.add(hairSprite);
- }
- if ((chr.getDescriptor() != null) && (chr.getDescriptor().getHair() != null) && (!chr.getDescriptor().getHair().isEmpty()))
- {
- String var13 = chr.getDescriptor().getHair();
- var13 = var13.replace("_White", "");
- if (var13.equals("F_Hair")) {
- var13 = "f_hair_kate";
- }
- if (this.ModelMap.get(var13.toLowerCase()) != null)
- {
- ModelInstance weapon = newInstance((Model)this.ModelMap.get(var13.toLowerCase()), chr, slot.model.AnimPlayer);
- weapon.LoadTexture(var13.replace("_kate", "") + "_White");
- weapon.tintR = chr.hairSprite.getTintMod().r;
- weapon.tintG = chr.hairSprite.getTintMod().g;
- weapon.tintB = chr.hairSprite.getTintMod().b;
- slot.sub.add(weapon);
- }
- }
- try
- {
- for (int var14 = 0; var14 < chr.extraSprites.size(); var14++)
- {
- IsoSprite weaponSprite = (IsoSprite)chr.extraSprites.get(var14);
- if ((weaponSprite != null) && (weaponSprite.CurrentAnim != null) && (!weaponSprite.CurrentAnim.Frames.isEmpty()) && (((IsoDirectionFrame)weaponSprite.CurrentAnim.Frames.get(0)).getTexture(IsoDirections.N) != null))
- {
- String inst = ((IsoDirectionFrame)weaponSprite.CurrentAnim.Frames.get(0)).getTexture(IsoDirections.N).getName();
- inst = inst.replace(chrSprite + "_", "");
- inst = inst.substring(0, inst.lastIndexOf("_"));
- inst = inst.substring(0, inst.lastIndexOf("_"));
- inst = inst.substring(0, inst.lastIndexOf("_"));
- inst = inst.substring(0, inst.lastIndexOf("_"));
- inst = inst.replace("_White", "");
- if (inst.equals("F_Hair")) {
- inst = "f_hair_kate";
- }
- if (this.ModelMap.containsKey(inst.toLowerCase()))
- {
- ModelInstance inst1 = newInstance((Model)this.ModelMap.get(inst.toLowerCase()), chr, slot.model.AnimPlayer);
- inst1.LoadTexture(inst.replace("_kate", "") + "_White");
- inst1.tintR = weaponSprite.getTintMod().r;
- inst1.tintG = weaponSprite.getTintMod().g;
- inst1.tintB = weaponSprite.getTintMod().b;
- slot.sub.add(inst1);
- }
- }
- }
- }
- catch (Exception var11)
- {
- var11.printStackTrace();
- }
- if ((chr.getPrimaryHandItem() instanceof HandWeapon))
- {
- HandWeapon var15 = (HandWeapon)chr.getPrimaryHandItem();
- String var16 = var15.getWeaponSprite();
- if ((var16 != null) && (this.ModelMap.containsKey("weapons_" + var16.toLowerCase())))
- {
- ModelInstance var17 = newInstance((Model)this.ModelMap.get("weapons_" + var16.toLowerCase()), chr, slot.model.AnimPlayer);
- slot.sub.add(var17);
- }
- }
- }
- public void update()
- {
- for (int n = 0; n < this.ToResetNextFrame.size(); n++) {
- Reset((IsoGameCharacter)this.ToResetNextFrame.get(n));
- }
- this.ToResetNextFrame.clear();
- if (this.removeModels.Check()) {
- for (n = 0; n < this.ToRemove.size(); n++) {
- if (DoRemove((IsoGameCharacter)this.ToRemove.get(n), false)) {
- this.ToRemove.remove(n--);
- }
- }
- }
- this.lights.clear();
- if ((IsoWorld.instance != null) && (IsoWorld.instance.CurrentCell != null)) {
- this.lights.addAll(IsoWorld.instance.CurrentCell.getLamppostPositions());
- }
- }
- private ModelSlot getSlot(IsoGameCharacter chr)
- {
- for (int n = 0; n < this.ModelSlots.size(); n++)
- {
- ModelSlot slot = (ModelSlot)this.ModelSlots.get(n);
- if (slot.character == chr) {
- return slot;
- }
- }
- return new ModelSlot(this.ModelSlots.size(), newInstance(chr.isFemale() ? (Model)this.ModelMap.get("kate") : (Model)this.ModelMap.get("male"), chr, null), chr);
- }
- private boolean DoRemove(IsoGameCharacter chr, boolean quitting)
- {
- if (this.Contains.contains(chr)) {
- for (int n = 0; n < this.ModelSlots.size(); n++)
- {
- ModelSlot slot = (ModelSlot)this.ModelSlots.get(n);
- if ((slot.character == chr) && ((quitting) || (!slot.bRendering)))
- {
- this.Contains.remove(chr);
- slot.active = false;
- slot.bRemove = false;
- chr.legsSprite.modelSlot = null;
- return true;
- }
- }
- }
- return false;
- }
- public void Remove(IsoGameCharacter chr)
- {
- if ((chr.hasActiveModel()) &&
- (this.Contains.contains(chr)) && (!this.ToRemove.contains(chr)))
- {
- chr.legsSprite.modelSlot.bRemove = true;
- this.ToRemove.add(chr);
- }
- }
- public void ResetNextFrame(IsoGameCharacter isoGameCharacter)
- {
- this.ToResetNextFrame.add(isoGameCharacter);
- }
- public void Reset()
- {
- for (int ex = 0; ex < this.ToRemove.size(); ex++) {
- DoRemove((IsoGameCharacter)this.ToRemove.get(ex), true);
- }
- this.ToRemove.clear();
- try
- {
- if (!this.Contains.isEmpty())
- {
- IsoGameCharacter[] var7 = (IsoGameCharacter[])this.Contains.toArray(new IsoGameCharacter[this.Contains.size()]);
- IsoGameCharacter[] arr$ = var7;
- int len$ = var7.length;
- for (int i$ = 0; i$ < len$; i$++)
- {
- IsoGameCharacter chr = arr$[i$];
- DoRemove(chr, true);
- }
- }
- this.ModelSlots.clear();
- }
- catch (Exception var6)
- {
- var6.printStackTrace();
- }
- RenderThread.returnContext();
- this.lights.clear();
- this.lightsTemp.clear();
- compChar = null;
- }
- public void getClosestThreeLights(IsoGameCharacter chr, IsoLightSource[] ret)
- {
- compChar = chr;
- this.lightsTemp.clear();
- for (int n = 0; n < this.lights.size(); n++)
- {
- IsoLightSource light = (IsoLightSource)this.lights.get(n);
- if ((light.bActive) && ((light.localToBuilding == null) || (chr.getCurrentBuilding() == light.localToBuilding)) && (IsoUtils.DistanceTo(chr.x, chr.y, light.x + 0.5F, light.y + 0.5F) < light.radius) && (LosUtil.lineClear(IsoWorld.instance.CurrentCell, (int)compChar.x, (int)compChar.y, (int)compChar.z, light.x, light.y, light.z, false) != LosUtil.TestResults.Blocked)) {
- this.lightsTemp.add(light);
- }
- }
- Collections.sort(this.lightsTemp, comp);
- tmp193_192 = (ret[2] = = null);ret[1] = tmp193_192;ret[0] = tmp193_192;
- if (this.lightsTemp.size() > 0) {
- ret[0] = ((IsoLightSource)this.lightsTemp.get(0));
- }
- if (this.lightsTemp.size() > 1) {
- ret[1] = ((IsoLightSource)this.lightsTemp.get(1));
- }
- if (this.lightsTemp.size() > 2) {
- ret[2] = ((IsoLightSource)this.lightsTemp.get(2));
- }
- }
- public ModelInstance newInstance(Model model, IsoGameCharacter chr, AnimationPlayer player)
- {
- if (model == null) {
- int i = 0;
- }
- ModelInstance modelInst1 = new ModelInstance(model, chr, player);
- modelInst1.UpdateDir();
- if (modelInst1.AnimPlayer != null) {
- modelInst1.AnimPlayer.angle = modelInst1.AnimPlayer.targetAngle;
- }
- AnimationTrack t = modelInst1.Play(chr.legsSprite.CurrentAnim.name, chr.def.Looped, chr.def.Finished, chr);
- if (t != null)
- {
- t.syncToFrame(chr.def, chr.legsSprite.CurrentAnim);
- modelInst1.AnimPlayer.Update(0.0F, true, null);
- }
- if ((model.Name.equals("male")) || (model.Name.equals("kate"))) {
- modelInst1.updateLights = true;
- }
- return modelInst1;
- }
- public static class AnimRequest
- {
- public float angle;
- public String anim;
- public SurvivorDesc desc;
- }
- public static class ModelSlot
- {
- public int ID;
- public ModelInstance model;
- public IsoGameCharacter character;
- ArrayList sub = new ArrayList();
- public boolean active;
- public boolean bRemove;
- public boolean bRendering;
- public ModelSlot(int ID, ModelInstance model, IsoGameCharacter character)
- {
- this.ID = ID;
- this.model = model;
- this.character = character;
- }
- public void Start()
- {
- GL11.glEnable(2929);
- GL11.glEnable(3042);
- GL11.glBlendFunc(770, 771);
- GL11.glEnable(3008);
- GL11.glAlphaFunc(516, 0.0F);
- GL11.glDisable(3089);
- ModelManager.instance.bitmap.startDrawing(true, true);
- ModelCamera.instance.w = ModelManager.instance.bitmap.getTexture().getWidth();
- ModelCamera.instance.h = ModelManager.instance.bitmap.getTexture().getHeight();
- }
- public void Render()
- {
- this.model.Draw();
- for (int n = 0; n < this.sub.size(); n++) {
- ((ModelInstance)this.sub.get(n)).Draw();
- }
- }
- public void End()
- {
- ModelManager.instance.bitmap.endDrawing();
- }
- public void Play(String name, boolean looped, boolean finished, IsoGameCharacter chr)
- {
- this.model.Play(name, looped, finished, chr);
- for (int n = 0; n < this.sub.size(); n++) {
- ((ModelInstance)this.sub.get(n)).Play(name, looped, finished, chr);
- }
- }
- public void Update()
- {
- float del = this.character.def.AnimFrameIncrease / this.character.legsSprite.CurrentAnim.Frames.size();
- if (this.character.getLastSquare() != this.character.getCurrentSquare()) {
- UpdateLights();
- }
- AnimationPlayer var2 = this.model.AnimPlayer;
- synchronized (this.model.AnimPlayer)
- {
- this.model.UpdateDir();
- this.model.Update(del);
- for (int n = 0; n < this.sub.size(); n++)
- {
- ((ModelInstance)this.sub.get(n)).lights = this.model.lights;
- ((ModelInstance)this.sub.get(n)).AnimPlayer = this.model.AnimPlayer;
- }
- }
- }
- public void UpdateLights()
- {
- if ((this.model != null) && (this.character != null))
- {
- IsoLightSource[] var1 = this.model.lights;
- synchronized (this.model.lights)
- {
- ModelManager.instance.getClosestThreeLights(this.character, this.model.lights);
- for (int n = 0; n < this.sub.size(); n++) {
- ((ModelInstance)this.sub.get(n)).lights = this.model.lights;
- }
- }
- }
- }
- public void ResetToFrameOne()
- {
- AnimationPlayer var1 = this.model.AnimPlayer;
- synchronized (this.model.AnimPlayer)
- {
- this.model.AnimPlayer.ResetToFrameOne();
- Iterator i$ = this.sub.iterator();
- while (i$.hasNext())
- {
- ModelInstance subModel = (ModelInstance)i$.next();
- subModel.AnimPlayer.ResetToFrameOne();
- }
- }
- }
- public void DisableBlendingFrom(String clipName)
- {
- AnimationTrack track = this.model.AnimPlayer.getAnimTrack(clipName);
- if (track != null) {
- track.bFinished = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement