Add animation smoothing plugin
This commit is contained in:
@@ -95,6 +95,57 @@ public abstract class RSClientMixin implements RSClient
|
||||
@Shadow("clientInstance")
|
||||
private static RSClient client;
|
||||
|
||||
@Inject
|
||||
private static boolean interpolatePlayerAnimations;
|
||||
|
||||
@Inject
|
||||
private static boolean interpolateNpcAnimations;
|
||||
|
||||
@Inject
|
||||
private static boolean interpolateObjectAnimations;
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public boolean isInterpolatePlayerAnimations()
|
||||
{
|
||||
return interpolatePlayerAnimations;
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public void setInterpolatePlayerAnimations(boolean interpolate)
|
||||
{
|
||||
interpolatePlayerAnimations = interpolate;
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public boolean isInterpolateNpcAnimations()
|
||||
{
|
||||
return interpolateNpcAnimations;
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public void setInterpolateNpcAnimations(boolean interpolate)
|
||||
{
|
||||
interpolateNpcAnimations = interpolate;
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public boolean isInterpolateObjectAnimations()
|
||||
{
|
||||
return interpolateObjectAnimations;
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public void setInterpolateObjectAnimations(boolean interpolate)
|
||||
{
|
||||
interpolateObjectAnimations = interpolate;
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public List<Player> getPlayers()
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.mixins;
|
||||
|
||||
import net.runelite.api.mixins.Copy;
|
||||
import net.runelite.api.mixins.FieldHook;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
import net.runelite.api.mixins.Mixin;
|
||||
import net.runelite.api.mixins.Replace;
|
||||
import net.runelite.api.mixins.Shadow;
|
||||
import net.runelite.rs.api.RSClient;
|
||||
import net.runelite.rs.api.RSDynamicObject;
|
||||
import net.runelite.rs.api.RSModel;
|
||||
|
||||
@Mixin(RSDynamicObject.class)
|
||||
public abstract class RSDynamicObjectMixin implements RSDynamicObject
|
||||
{
|
||||
@Shadow("clientInstance")
|
||||
private static RSClient client;
|
||||
|
||||
@Copy("getModel")
|
||||
public abstract RSModel rs$getModel();
|
||||
|
||||
@Replace("getModel")
|
||||
public RSModel rl$getModel()
|
||||
{
|
||||
try
|
||||
{
|
||||
// reset frame because it may have been set from the constructor
|
||||
// it should be set again inside the getModel method
|
||||
int animFrame = getAnimFrame();
|
||||
if (animFrame < 0)
|
||||
{
|
||||
setAnimFrame((animFrame ^ Integer.MIN_VALUE) & 0xFFFF);
|
||||
}
|
||||
return rs$getModel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
int animFrame = getAnimFrame();
|
||||
if (animFrame < 0)
|
||||
{
|
||||
setAnimFrame((animFrame ^ Integer.MIN_VALUE) & 0xFFFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@FieldHook("animCycleCount")
|
||||
@Inject
|
||||
public void onAnimCycleCountChanged(int idx)
|
||||
{
|
||||
if (client.isInterpolateObjectAnimations())
|
||||
{
|
||||
// sets the packed anim frame with the frame cycle
|
||||
int objectFrameCycle = client.getGameCycle() - getAnimCycleCount();
|
||||
setAnimFrame(Integer.MIN_VALUE | objectFrameCycle << 16 | getAnimFrame());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,9 @@ import net.runelite.api.model.Jarvis;
|
||||
import net.runelite.api.model.Triangle;
|
||||
import net.runelite.api.model.Vertex;
|
||||
import net.runelite.rs.api.RSClient;
|
||||
import net.runelite.rs.api.RSFrame;
|
||||
import net.runelite.rs.api.RSFrameMap;
|
||||
import net.runelite.rs.api.RSFrames;
|
||||
import net.runelite.rs.api.RSModel;
|
||||
|
||||
@Mixin(RSModel.class)
|
||||
@@ -95,6 +98,140 @@ public abstract class RSModelMixin implements RSModel
|
||||
return triangles;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void interpolateFrames(RSFrames frames, int frameId, RSFrames nextFrames, int nextFrameId, int interval,
|
||||
int intervalCount)
|
||||
{
|
||||
if (getVertexGroups() != null)
|
||||
{
|
||||
if (frameId != -1)
|
||||
{
|
||||
RSFrame frame = frames.getFrames()[frameId];
|
||||
RSFrameMap skin = frame.getSkin();
|
||||
RSFrame nextFrame = null;
|
||||
if (nextFrames != null)
|
||||
{
|
||||
nextFrame = nextFrames.getFrames()[nextFrameId];
|
||||
if (nextFrame.getSkin() != skin)
|
||||
{
|
||||
nextFrame = null;
|
||||
}
|
||||
}
|
||||
|
||||
client.setAnimOffsetX(0);
|
||||
client.setAnimOffsetY(0);
|
||||
client.setAnimOffsetZ(0);
|
||||
|
||||
interpolateFrames(skin, frame, nextFrame, interval, intervalCount);
|
||||
resetBounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void interpolateFrames(RSFrameMap skin, RSFrame frame, RSFrame nextFrame, int interval, int intervalCount)
|
||||
{
|
||||
if (nextFrame == null || interval == 0)
|
||||
{
|
||||
// if there is no next frame or interval then animate the model as we normally would
|
||||
for (int i = 0; i < frame.getTransformCount(); i++)
|
||||
{
|
||||
int type = frame.getTransformTypes()[i];
|
||||
this.animate(skin.getTypes()[type], skin.getList()[type], frame.getTranslatorX()[i],
|
||||
frame.getTranslatorY()[i], frame.getTranslatorZ()[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int transformIndex = 0;
|
||||
int nextTransformIndex = 0;
|
||||
for (int i = 0; i < skin.getCount(); i++)
|
||||
{
|
||||
boolean frameValid = false;
|
||||
if (transformIndex < frame.getTransformCount()
|
||||
&& frame.getTransformTypes()[transformIndex] == i)
|
||||
{
|
||||
frameValid = true;
|
||||
}
|
||||
boolean nextFrameValid = false;
|
||||
if (nextTransformIndex < nextFrame.getTransformCount()
|
||||
&& nextFrame.getTransformTypes()[nextTransformIndex] == i)
|
||||
{
|
||||
nextFrameValid = true;
|
||||
}
|
||||
if (frameValid || nextFrameValid)
|
||||
{
|
||||
int staticFrame = 0;
|
||||
int type = skin.getTypes()[i];
|
||||
if (type == 3 || type == 10)
|
||||
{
|
||||
staticFrame = 128;
|
||||
}
|
||||
int currentTranslateX = staticFrame;
|
||||
int currentTranslateY = staticFrame;
|
||||
int currentTranslateZ = staticFrame;
|
||||
if (frameValid)
|
||||
{
|
||||
currentTranslateX = frame.getTranslatorX()[transformIndex];
|
||||
currentTranslateY = frame.getTranslatorY()[transformIndex];
|
||||
currentTranslateZ = frame.getTranslatorZ()[transformIndex];
|
||||
transformIndex++;
|
||||
}
|
||||
int nextTranslateX = staticFrame;
|
||||
int nextTranslateY = staticFrame;
|
||||
int nextTranslateZ = staticFrame;
|
||||
if (nextFrameValid)
|
||||
{
|
||||
nextTranslateX = nextFrame.getTranslatorX()[nextTransformIndex];
|
||||
nextTranslateY = nextFrame.getTranslatorY()[nextTransformIndex];
|
||||
nextTranslateZ = nextFrame.getTranslatorZ()[nextTransformIndex];
|
||||
nextTransformIndex++;
|
||||
}
|
||||
int translateX;
|
||||
int translateY;
|
||||
int translateZ;
|
||||
if (type == 2)
|
||||
{
|
||||
int deltaX = nextTranslateX - currentTranslateX & 0x3fff;
|
||||
int deltaY = nextTranslateY - currentTranslateY & 0x3fff;
|
||||
int deltaZ = nextTranslateZ - currentTranslateZ & 0x3fff;
|
||||
if (deltaX >= 8192)
|
||||
{
|
||||
deltaX -= 16384;
|
||||
}
|
||||
if (deltaY >= 8192)
|
||||
{
|
||||
deltaY -= 16384;
|
||||
}
|
||||
if (deltaZ >= 8192)
|
||||
{
|
||||
deltaZ -= 16384;
|
||||
}
|
||||
translateX = currentTranslateX + deltaX * interval / intervalCount & 0x3fff;
|
||||
translateY = currentTranslateY + deltaY * interval / intervalCount & 0x3fff;
|
||||
translateZ = currentTranslateZ + deltaZ * interval / intervalCount & 0x3fff;
|
||||
}
|
||||
else if (type == 5)
|
||||
{
|
||||
// don't interpolate alpha transformations
|
||||
// alpha
|
||||
translateX = currentTranslateX;
|
||||
translateY = 0;
|
||||
translateZ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
translateX = currentTranslateX + (nextTranslateX - currentTranslateX) * interval / intervalCount;
|
||||
translateY = currentTranslateY + (nextTranslateY - currentTranslateY) * interval / intervalCount;
|
||||
translateZ = currentTranslateZ + (nextTranslateZ - currentTranslateZ) * interval / intervalCount;
|
||||
}
|
||||
// use interpolated translations to animate
|
||||
animate(type, skin.getList()[i], translateX, translateY, translateZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject
|
||||
public Polygon getConvexHull(int localX, int localY, int orientation)
|
||||
|
||||
@@ -24,14 +24,22 @@
|
||||
*/
|
||||
package net.runelite.mixins;
|
||||
|
||||
import net.runelite.api.mixins.Copy;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
import net.runelite.api.mixins.Mixin;
|
||||
import net.runelite.api.mixins.Replace;
|
||||
import net.runelite.api.mixins.Shadow;
|
||||
import net.runelite.rs.api.RSClient;
|
||||
import net.runelite.rs.api.RSModel;
|
||||
import net.runelite.rs.api.RSNPC;
|
||||
import net.runelite.rs.api.RSNPCComposition;
|
||||
|
||||
@Mixin(RSNPC.class)
|
||||
public abstract class RSNPCMixin implements RSNPC
|
||||
{
|
||||
@Shadow("clientInstance")
|
||||
private static RSClient client;
|
||||
|
||||
@Inject
|
||||
private int npcIndex;
|
||||
|
||||
@@ -72,4 +80,35 @@ public abstract class RSNPCMixin implements RSNPC
|
||||
{
|
||||
npcIndex = id;
|
||||
}
|
||||
|
||||
@Copy("getModel")
|
||||
public abstract RSModel rs$getModel();
|
||||
|
||||
@Replace("getModel")
|
||||
public RSModel rl$getModel()
|
||||
{
|
||||
if (!client.isInterpolateNpcAnimations())
|
||||
{
|
||||
return rs$getModel();
|
||||
}
|
||||
int actionFrame = getActionFrame();
|
||||
int poseFrame = getPoseFrame();
|
||||
int spotAnimFrame = getSpotAnimFrame();
|
||||
try
|
||||
{
|
||||
// combine the frames with the frame cycle so we can access this information in the sequence methods
|
||||
// without having to change method calls
|
||||
setActionFrame(Integer.MIN_VALUE | getActionFrameCycle() << 16 | actionFrame);
|
||||
setPoseFrame(Integer.MIN_VALUE | getPoseFrameCycle() << 16 | poseFrame);
|
||||
setSpotAnimFrame(Integer.MIN_VALUE | getSpotAnimFrameCycle() << 16 | spotAnimFrame);
|
||||
return rs$getModel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
// reset frames
|
||||
setActionFrame(actionFrame);
|
||||
setPoseFrame(poseFrame);
|
||||
setSpotAnimFrame(spotAnimFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,15 @@ import java.util.List;
|
||||
import net.runelite.api.Model;
|
||||
import net.runelite.api.Perspective;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.mixins.Copy;
|
||||
import net.runelite.api.mixins.Replace;
|
||||
import net.runelite.api.model.Triangle;
|
||||
import net.runelite.api.model.Vertex;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
import net.runelite.api.mixins.Mixin;
|
||||
import net.runelite.api.mixins.Shadow;
|
||||
import net.runelite.rs.api.RSClient;
|
||||
import net.runelite.rs.api.RSModel;
|
||||
import net.runelite.rs.api.RSName;
|
||||
import net.runelite.rs.api.RSPlayer;
|
||||
|
||||
@@ -158,4 +161,35 @@ public abstract class RSPlayerMixin implements RSPlayer
|
||||
{
|
||||
this.playerIndex = index;
|
||||
}
|
||||
|
||||
@Copy("getModel")
|
||||
public abstract RSModel rs$getModel();
|
||||
|
||||
@Replace("getModel")
|
||||
public RSModel rl$getModel()
|
||||
{
|
||||
if (!client.isInterpolatePlayerAnimations())
|
||||
{
|
||||
return rs$getModel();
|
||||
}
|
||||
int actionFrame = getActionFrame();
|
||||
int poseFrame = getPoseFrame();
|
||||
int spotAnimFrame = getSpotAnimFrame();
|
||||
try
|
||||
{
|
||||
// combine the frames with the frame cycle so we can access this information in the sequence methods
|
||||
// without having to change method calls
|
||||
setActionFrame(Integer.MIN_VALUE | getActionFrameCycle() << 16 | actionFrame);
|
||||
setPoseFrame(Integer.MIN_VALUE | getPoseFrameCycle() << 16 | poseFrame);
|
||||
setSpotAnimFrame(Integer.MIN_VALUE | getSpotAnimFrameCycle() << 16 | spotAnimFrame);
|
||||
return rs$getModel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
// reset frames
|
||||
setActionFrame(actionFrame);
|
||||
setPoseFrame(poseFrame);
|
||||
setSpotAnimFrame(spotAnimFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.mixins;
|
||||
|
||||
import net.runelite.api.mixins.Copy;
|
||||
import net.runelite.api.mixins.Mixin;
|
||||
import net.runelite.api.mixins.Replace;
|
||||
import net.runelite.api.mixins.Shadow;
|
||||
import net.runelite.rs.api.RSClient;
|
||||
import net.runelite.rs.api.RSFrames;
|
||||
import net.runelite.rs.api.RSModel;
|
||||
import net.runelite.rs.api.RSSequence;
|
||||
|
||||
@Mixin(RSSequence.class)
|
||||
public abstract class RSSequenceMixin implements RSSequence
|
||||
{
|
||||
@Shadow("clientInstance")
|
||||
private static RSClient client;
|
||||
|
||||
@Copy("applyTransformations")
|
||||
public abstract RSModel rs$applyTransformations(RSModel model, int actionFrame, RSSequence poseSeq, int poseFrame);
|
||||
|
||||
@Replace("applyTransformations")
|
||||
public RSModel rl$applyTransformations(RSModel model, int actionFrame, RSSequence poseSeq, int poseFrame)
|
||||
{
|
||||
// reset frame ids because we're not interpolating this
|
||||
if (actionFrame < 0)
|
||||
{
|
||||
int packed = actionFrame ^ Integer.MIN_VALUE;
|
||||
actionFrame = packed & 0xFFFF;
|
||||
}
|
||||
if (poseFrame < 0)
|
||||
{
|
||||
int packed = poseFrame ^ Integer.MIN_VALUE;
|
||||
poseFrame = packed & 0xFFFF;
|
||||
}
|
||||
return rs$applyTransformations(model, actionFrame, poseSeq, poseFrame);
|
||||
}
|
||||
|
||||
@Copy("transformActorModel")
|
||||
public abstract RSModel rs$transformActorModel(RSModel model, int frameIdx);
|
||||
|
||||
@Replace("transformActorModel")
|
||||
public RSModel rl$transformActorModel(RSModel model, int frame)
|
||||
{
|
||||
// check if the frame has been modified
|
||||
if (frame < 0)
|
||||
{
|
||||
// remove flag to check if the frame has been modified
|
||||
int packed = frame ^ Integer.MIN_VALUE;
|
||||
int interval = packed >> 16;
|
||||
frame = packed & 0xFFFF;
|
||||
int nextFrame = frame + 1;
|
||||
if (nextFrame >= getFrameIDs().length)
|
||||
{
|
||||
// dont interpolate last frame
|
||||
nextFrame = -1;
|
||||
}
|
||||
int[] frameIds = getFrameIDs();
|
||||
int frameId = frameIds[frame];
|
||||
RSFrames frames = client.getFrames(frameId >> 16);
|
||||
int frameIdx = frameId & 0xFFFF;
|
||||
|
||||
int nextFrameIdx = -1;
|
||||
RSFrames nextFrames = null;
|
||||
if (nextFrame != -1)
|
||||
{
|
||||
int nextFrameId = frameIds[nextFrame];
|
||||
nextFrames = client.getFrames(nextFrameId >> 16);
|
||||
nextFrameIdx = nextFrameId & 0xFFFF;
|
||||
}
|
||||
|
||||
if (frames == null)
|
||||
{
|
||||
// not sure what toSharedModel does but it is needed
|
||||
return model.toSharedModel(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
RSModel animatedModel = model.toSharedModel(!frames.getFrames()[frameIdx].isShowing());
|
||||
animatedModel.interpolateFrames(frames, frameIdx, nextFrames, nextFrameIdx, interval,
|
||||
getFrameLenths()[frame]);
|
||||
return animatedModel;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return rs$transformActorModel(model, frame);
|
||||
}
|
||||
}
|
||||
|
||||
@Copy("transformObjectModel")
|
||||
public abstract RSModel rs$transformObjectModel(RSModel model, int frame, int rotation);
|
||||
|
||||
@Replace("transformObjectModel")
|
||||
public RSModel rl$transformObjectModel(RSModel model, int frame, int rotation)
|
||||
{
|
||||
// check if the frame has been modified
|
||||
if (frame < 0)
|
||||
{
|
||||
// remove flag to check if the frame has been modified
|
||||
int packed = frame ^ Integer.MIN_VALUE;
|
||||
int interval = packed >> 16;
|
||||
frame = packed & 0xFFFF;
|
||||
|
||||
int nextFrame = frame + 1;
|
||||
if (nextFrame >= getFrameIDs().length)
|
||||
{
|
||||
// dont interpolate last frame
|
||||
nextFrame = -1;
|
||||
}
|
||||
int[] frameIds = getFrameIDs();
|
||||
int frameId = frameIds[frame];
|
||||
RSFrames frames = client.getFrames(frameId >> 16);
|
||||
int frameIdx = frameId & 0xFFFF;
|
||||
|
||||
int nextFrameIdx = -1;
|
||||
RSFrames nextFrames = null;
|
||||
if (nextFrame != -1)
|
||||
{
|
||||
int nextFrameId = frameIds[nextFrame];
|
||||
nextFrames = client.getFrames(nextFrameId >> 16);
|
||||
nextFrameIdx = nextFrameId & 0xFFFF;
|
||||
}
|
||||
|
||||
if (frames == null)
|
||||
{
|
||||
return model.toSharedModel(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
RSModel animatedModel = model.toSharedModel(!frames.getFrames()[frameIdx].isShowing());
|
||||
// reset rotation before animating
|
||||
rotation &= 3;
|
||||
if (rotation == 1)
|
||||
{
|
||||
animatedModel.rotateY270Ccw();
|
||||
}
|
||||
else if (rotation == 2)
|
||||
{
|
||||
animatedModel.rotateY180Ccw();
|
||||
}
|
||||
else if (rotation == 3)
|
||||
{
|
||||
animatedModel.rotateY90Ccw();
|
||||
}
|
||||
animatedModel.interpolateFrames(frames, frameIdx, nextFrames, nextFrameIdx, interval,
|
||||
getFrameLenths()[frame]);
|
||||
// reapply rotation after animating
|
||||
if (rotation == 1)
|
||||
{
|
||||
animatedModel.rotateY90Ccw();
|
||||
}
|
||||
else if (rotation == 2)
|
||||
{
|
||||
animatedModel.rotateY180Ccw();
|
||||
}
|
||||
else if (rotation == 3)
|
||||
{
|
||||
animatedModel.rotateY270Ccw();
|
||||
}
|
||||
return animatedModel;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return rs$transformObjectModel(model, frame, rotation);
|
||||
}
|
||||
}
|
||||
|
||||
@Copy("transformSpotAnimModel")
|
||||
public abstract RSModel rs$transformSpotAnimModel(RSModel model, int frame);
|
||||
|
||||
@Replace("transformSpotAnimModel")
|
||||
public RSModel rl$transformSpotAnimModel(RSModel model, int frame)
|
||||
{
|
||||
// check if the frame has been modified
|
||||
if (frame < 0)
|
||||
{
|
||||
// remove flag to check if the frame has been modified
|
||||
int packed = frame ^ Integer.MIN_VALUE;
|
||||
int interval = packed >> 16;
|
||||
frame = packed & 0xFFFF;
|
||||
int nextFrame = frame + 1;
|
||||
if (nextFrame >= getFrameIDs().length)
|
||||
{
|
||||
// dont interpolate last frame
|
||||
nextFrame = -1;
|
||||
}
|
||||
int[] frameIds = getFrameIDs();
|
||||
int frameId = frameIds[frame];
|
||||
RSFrames frames = client.getFrames(frameId >> 16);
|
||||
int frameIdx = frameId & 0xFFFF;
|
||||
|
||||
int nextFrameIdx = -1;
|
||||
RSFrames nextFrames = null;
|
||||
if (nextFrame != -1)
|
||||
{
|
||||
int nextFrameId = frameIds[nextFrame];
|
||||
nextFrames = client.getFrames(nextFrameId >> 16);
|
||||
nextFrameIdx = nextFrameId & 0xFFFF;
|
||||
}
|
||||
|
||||
if (frames == null)
|
||||
{
|
||||
return model.toSharedSpotAnimModel(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
RSModel animatedModel = model.toSharedSpotAnimModel(!frames.getFrames()[frameIdx].isShowing());
|
||||
animatedModel.interpolateFrames(frames, frameIdx, nextFrames, nextFrameIdx, interval,
|
||||
getFrameLenths()[frame]);
|
||||
return animatedModel;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return rs$transformSpotAnimModel(model, frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user