My favorites
▼
|
Sign in
lingeringleftovers2
here and now
Project Home
Issues
Source
Export to GitHub
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
2
attachment: DrawSingleModel.java
(2.9 KB)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package org.rsbot.event.impl;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import org.rsbot.accessors.LDModel;
import org.rsbot.accessors.Model;
import org.rsbot.accessors.RSAnimable;
import org.rsbot.bot.Bot;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.script.Calculations;
import org.rsbot.script.Methods;
//Draws a nice wire frame on the currently specified interactable objects on screen.
//Thanks to Kosaki for his initial idea and part of this code:)
//Thanks to zzSleepzz for this listener.
public class DrawSingleModel extends Methods implements PaintListener {
private org.rsbot.script.wrappers.RSObject obj = null;
public final void setModel(org.rsbot.script.wrappers.RSObject o) {
obj = o;
}
public static final DrawSingleModel inst = new DrawSingleModel();
public void onRepaint(Graphics render) {
if (Bot.debugLogging)
log.info("DrawSingleModel onRepaint called");
if (obj==null)
return;
if (Bot.debugLogging) {
log.info("Painting object ID="+this.obj.getID()+" at "+this.obj.getLocation().toString());
}
render.setColor(Color.GREEN);
RSAnimable animable = (RSAnimable) obj.getObject();
Model model;
try { model = obj.getModel(); }
catch(AbstractMethodError e) { return; }
if(model == null || !(model instanceof LDModel))
return;
//Calculate screen coords of the model
Point[] screenCoords = new Point[model.getXPoints().length];
for(int i = 0; i < screenCoords.length; i++)
{
int x = model.getXPoints()[i] + animable.getX();
int z = model.getZPoints()[i] + animable.getY();
int y = model.getYPoints()[i] + Calculations.tileHeight(animable.getX(), animable.getY());
screenCoords[i] = Calculations.w2s(x, y, z);
}
int[] xPoints = new int[4];
int[] yPoints = new int[4];
int length = ((LDModel) model).getIndices3().length;
for (int i = 0; i < length; i++) {
int index1 = ((LDModel) model).getIndices1()[i];
if(screenCoords[index1].x == -1 || screenCoords[index1].y == -1)
continue;
xPoints[0] = screenCoords[index1].x;
yPoints[0] = screenCoords[index1].y;
xPoints[3] = screenCoords[index1].x;
yPoints[3] = screenCoords[index1].y;
int index2 = ((LDModel) model).getIndices2()[i];
if(screenCoords[index2].x == -1 || screenCoords[index2].y == -1)
continue;
xPoints[1] = screenCoords[index2].x;
yPoints[1] = screenCoords[index2].y;
int index3 = ((LDModel) model).getIndices3()[i];
if(screenCoords[index3].x == -1 || screenCoords[index3].y == -1)
continue;
xPoints[2] = screenCoords[index3].x;
yPoints[2] = screenCoords[index3].y;
render.drawPolyline(xPoints, yPoints, 4);
}
}
}
Powered by
Google Project Hosting