Vilius Posted March 6, 2016 Posted March 6, 2016 (edited) So I want to get the visible points of an object, because sometimes doing isVisible() returns false although some points of an object are visible. I tried looking into the Model class of the api but didn't find anything useful to me. EDIT: I was guessing I could do something with getRasterizedPoints(), but the api doesn't tell what it really does Edited March 6, 2016 by Vilius
Botre Posted March 6, 2016 Posted March 6, 2016 (edited) get the model area of the object and check the intersection bounds with the game canvas. RS2Object object = ...; Rectangle modelBounds = object.getModel().getArea(object.getGridX(), object.getGridX(), object.getZ()).getBounds(); Rectangle canvasBounds = getBot().getCanvas().getBounds(); Rectangle intersection = modelBounds.intersection(canvasBounds); int minimumDimension = 5; boolean visible = intersection.width > minimumDimension && intersection.height > minimumDimension; Edited March 6, 2016 by Botre
Flamezzz Posted March 6, 2016 Posted March 6, 2016 You might want to look at GraphicUtilities#getSuitablePoint(MouseDestination destination). For an entity it calls GraphicUtilities#getModelMeshTriangles and checks what is within MAIN_SCREEN_CLIP, I think that's what you want.
Vilius Posted March 6, 2016 Author Posted March 6, 2016 You might want to look at GraphicUtilities#getSuitablePoint(MouseDestination destination). For an entity it calls GraphicUtilities#getModelMeshTriangles and checks what is within MAIN_SCREEN_CLIP, I think that's what you want. Thank you very much, exactly what I needed. Code for those who need it: private boolean isPointOnScreen(Entity e) { if (e != null) { ArrayList<Polygon> poly = GraphicUtilities.getModelMeshTriangles(bot, e.getGridX(), e.getGridY(), e.getZ(), e.getModel()); for (Polygon p : poly) { if (GraphicUtilities.MAIN_SCREEN_CLIP.contains(p.getBounds())) { return true; } } } return false; } 2