Vilius Posted March 6, 2016 Share 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 Quote Link to comment Share on other sites More sharing options...
Botre Posted March 6, 2016 Share 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 Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted March 6, 2016 Share 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. Quote Link to comment Share on other sites More sharing options...
Vilius Posted March 6, 2016 Author Share 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 Quote Link to comment Share on other sites More sharing options...