model-viewer: fix some of the orientation issues
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package net.runelite.cache.definitions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import net.runelite.cache.models.CircularAngle;
|
||||
import net.runelite.cache.models.FaceNormal;
|
||||
import net.runelite.cache.models.VertexNormal;
|
||||
|
||||
@@ -153,7 +155,8 @@ public class ModelDefinition
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the UV coordinates for every three-vertex face that has a texture.
|
||||
* Computes the UV coordinates for every three-vertex face that has a
|
||||
* texture.
|
||||
*/
|
||||
public void computeTextureUVCoordinates()
|
||||
{
|
||||
@@ -266,4 +269,80 @@ public class ModelDefinition
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void rotate(int orientation)
|
||||
{
|
||||
int sin = CircularAngle.SINE[orientation];
|
||||
int cos = CircularAngle.COSINE[orientation];
|
||||
|
||||
assert vertexPositionsX.length == vertexPositionsY.length;
|
||||
assert vertexPositionsY.length == vertexPositionsZ.length;
|
||||
|
||||
for (int i = 0; i < vertexPositionsX.length; ++i)
|
||||
{
|
||||
vertexPositionsX[i] = vertexPositionsX[i] * cos + vertexPositionsZ[i] * sin >> 16;
|
||||
vertexPositionsZ[i] = vertexPositionsZ[i] * cos - vertexPositionsX[i] * sin >> 16;
|
||||
}
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
public void method1493()
|
||||
{
|
||||
int var1;
|
||||
for (var1 = 0; var1 < this.vertexCount; ++var1)
|
||||
{
|
||||
this.vertexPositionsZ[var1] = -this.vertexPositionsZ[var1];
|
||||
}
|
||||
|
||||
for (var1 = 0; var1 < this.faceCount; ++var1)
|
||||
{
|
||||
int var2 = this.faceVertexIndices1[var1];
|
||||
this.faceVertexIndices1[var1] = this.faceVertexIndices3[var1];
|
||||
this.faceVertexIndices3[var1] = var2;
|
||||
}
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
public void rotate1()
|
||||
{
|
||||
for (int var1 = 0; var1 < this.vertexCount; ++var1)
|
||||
{
|
||||
int var2 = this.vertexPositionsX[var1];
|
||||
this.vertexPositionsX[var1] = this.vertexPositionsZ[var1];
|
||||
this.vertexPositionsZ[var1] = -var2;
|
||||
}
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
public void rotate2()
|
||||
{
|
||||
for (int var1 = 0; var1 < this.vertexCount; ++var1)
|
||||
{
|
||||
this.vertexPositionsX[var1] = -this.vertexPositionsX[var1];
|
||||
this.vertexPositionsZ[var1] = -this.vertexPositionsZ[var1];
|
||||
}
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
public void rotate3()
|
||||
{
|
||||
for (int var1 = 0; var1 < this.vertexCount; ++var1)
|
||||
{
|
||||
int var2 = this.vertexPositionsZ[var1];
|
||||
this.vertexPositionsZ[var1] = this.vertexPositionsX[var1];
|
||||
this.vertexPositionsX[var1] = -var2;
|
||||
}
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
private void reset()
|
||||
{
|
||||
faceNormals = null;
|
||||
faceTextureUCoordinates = faceTextureVCoordinates = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class ObjectDefinition
|
||||
private int anInt2105 = -1;
|
||||
private int anInt2106 = -1;
|
||||
private int[] configChangeDest;
|
||||
private boolean aBool2108 = false;
|
||||
private boolean isRotated = false;
|
||||
private int configId = -1;
|
||||
private int anInt2110 = -1;
|
||||
private boolean aBool2111 = false;
|
||||
@@ -434,14 +434,14 @@ public class ObjectDefinition
|
||||
this.configChangeDest = configChangeDest;
|
||||
}
|
||||
|
||||
public boolean isaBool2108()
|
||||
public boolean isRotated()
|
||||
{
|
||||
return aBool2108;
|
||||
return isRotated;
|
||||
}
|
||||
|
||||
public void setaBool2108(boolean aBool2108)
|
||||
public void setIsRotated(boolean isRotated)
|
||||
{
|
||||
this.aBool2108 = aBool2108;
|
||||
this.isRotated = isRotated;
|
||||
}
|
||||
|
||||
public int getConfigId()
|
||||
|
||||
@@ -199,7 +199,7 @@ public class ObjectLoader
|
||||
}
|
||||
else if (62 == opcode)
|
||||
{
|
||||
def.setaBool2108(true);
|
||||
def.setIsRotated(true);
|
||||
}
|
||||
else if (opcode == 64)
|
||||
{
|
||||
|
||||
42
cache/src/main/java/net/runelite/cache/models/CircularAngle.java
vendored
Normal file
42
cache/src/main/java/net/runelite/cache/models/CircularAngle.java
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.cache.models;
|
||||
|
||||
public class CircularAngle
|
||||
{
|
||||
private static final double UNIT = Math.PI / 1024d; // How much of the circle each unit of SINE/COSINE is
|
||||
|
||||
public static final int[] SINE = new int[2048]; // sine angles for each of the 2048 units, * 65536 and stored as an int
|
||||
public static final int[] COSINE = new int[2048]; // cosine
|
||||
|
||||
static
|
||||
{
|
||||
for (int i = 0; i < 2048; ++i)
|
||||
{
|
||||
SINE[i] = (int) (65536.0D * Math.sin((double) i * UNIT));
|
||||
COSINE[i] = (int) (65536.0D * Math.cos((double) i * UNIT));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user