Skip to main content
gamedev.net
🔒 Locked

Highlighting an object

Started by Numsgil Apr 12, 2005 at 7:13 AM 1 replies 550+ views
Original Post
Numsgil
Numsgil
I'm working on a point and select interface for my game. When the user clicks, I'd like to be able to highlight what he clicked on with a circle. I've gone through NeHe's tutorial for selecting an object and done the general case for when the object is at (0,0,0) Here's my code for that:

glTranslatef(xtranslate, ytranslate, 0);
glTranslatef(0, 0, zoomfactor);

if highlighted
	CreateCircle(48, 1.2*targetradius, 0, 0);

glRotatef(xrot, 1, 0, 0);
glRotatef(yrot, 0, 1, 0);

//draw object
The problem now is if the object is at (x,y,z). The circle obviously won't be highlighting the object anymore. How do I get the circle to recenter on the object? I've tried using glTranslate(object.x, object.y, object.z) but that doesn't seem to work, or I'm not using it right, I don't know.
[size=2]Darwinbots - [size=2]Artificial life simulation
Aeluned
Aeluned
before any transformations, determine the extents of the object (xmin,xmax,ymin
ymax,zmin,zmax). This is done once when you load the object by examining each
vertex.

you use these extents to draw the bounding box,sphere,circle,whatever...

now, when the object is transformed, use that same modelview matrix to transform
the extents...

your bounding shape will thus always follow your object around.


...that's one way to do it.
white skies
white skies
In addition to what aeluned said...
Did you use glPushMatrix() and glPopMatrix() when you tried to move the highlighting to another object?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.