Search in sources :

Example 1 with Model

use of net.runelite.api.Model in project runelite by runelite.

the class RSPlayerMixin method getPolygons.

@Inject
@Override
public Polygon[] getPolygons() {
    Model model = getModel();
    if (model == null) {
        return null;
    }
    int localX = getX();
    int localY = getY();
    int orientation = getOrientation();
    List<Triangle> triangles = model.getTriangles();
    triangles = rotate(triangles, orientation);
    List<Polygon> polys = new ArrayList<Polygon>();
    for (Triangle triangle : triangles) {
        Vertex vx = triangle.getA();
        Vertex vy = triangle.getB();
        Vertex vz = triangle.getC();
        Point x = Perspective.worldToCanvas(client, localX - vx.getX(), localY - vx.getZ(), -vx.getY());
        Point y = Perspective.worldToCanvas(client, localX - vy.getX(), localY - vy.getZ(), -vy.getY());
        Point z = Perspective.worldToCanvas(client, localX - vz.getX(), localY - vz.getZ(), -vz.getY());
        int[] xx = { x.getX(), y.getX(), z.getX() };
        int[] yy = { x.getY(), y.getY(), z.getY() };
        polys.add(new Polygon(xx, yy, 3));
    }
    return polys.toArray(new Polygon[polys.size()]);
}
Also used : Vertex(net.runelite.api.model.Vertex) Model(net.runelite.api.Model) Triangle(net.runelite.api.model.Triangle) ArrayList(java.util.ArrayList) Point(net.runelite.api.Point) Polygon(java.awt.Polygon) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 2 with Model

use of net.runelite.api.Model in project runelite by runelite.

the class RSDecorativeObjectMixin method getModel.

@Inject
private RSModel getModel() {
    RSRenderable renderable = getRenderable();
    if (renderable == null) {
        return null;
    }
    RSModel model;
    if (renderable instanceof Model) {
        model = (RSModel) renderable;
    } else {
        model = renderable.getModel();
    }
    return model;
}
Also used : RSRenderable(net.runelite.rs.api.RSRenderable) RSModel(net.runelite.rs.api.RSModel) Model(net.runelite.api.Model) RSModel(net.runelite.rs.api.RSModel) Inject(net.runelite.api.mixins.Inject)

Aggregations

Model (net.runelite.api.Model)2 Inject (net.runelite.api.mixins.Inject)2 Polygon (java.awt.Polygon)1 ArrayList (java.util.ArrayList)1 Point (net.runelite.api.Point)1 Triangle (net.runelite.api.model.Triangle)1 Vertex (net.runelite.api.model.Vertex)1 RSModel (net.runelite.rs.api.RSModel)1 RSRenderable (net.runelite.rs.api.RSRenderable)1