Jump to content

Getting the visible points of an object


Vilius

Recommended Posts

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 by Vilius
Link to comment
Share on other sites

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 by Botre
Link to comment
Share on other sites

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;
	}
  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...