PDA

View Full Version : Can i make a point transparents?



HanWu
12-18-2002, 07:34 AM
Can i make a point transparents? i am doing a cad program that needs to draw a tracker on the selected object.

typedef struct any{
float x;
float y;
float z;
}POLY3;

POLY3 CSbomView::GetWindowPoint(POLY3 point)
{
GLdouble objx, objy, objz;

::glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
::glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
::glGetIntegerv(GL_VIEWPORT, viewport);

gluProject(point.x, point.y, point.z,
modelMatrix,projMatrix,viewport,
&objx, &objy, &objz);

objy=floor(winHeight - (GLint) objy - 1);

POLY3 point3d;

point3d.x=objx;
point3d.y=objy;
point3d.z=objz;

return point3d;
}
POLY3 CSbomView::GetWorldPoint(POLY3 point)
{
GLdouble objx, objy, objz;


::glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
::glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
::glGetIntegerv(GL_VIEWPORT, viewport);

GLuint realy = winHeight - (GLint) point.y - 1;

gluUnProject(point.x, realy, point.z,
modelMatrix, projMatrix, viewport,
&objx, &objy, &objz);

POLY3 point3d;

point3d.x=objx;
point3d.y=objy;
point3d.z=objz;

return point3d;
}
void tracker(POLY3 p){

POLY3 jor=pView->GetWindowPoint(p);

if(jor.y>=pView->winHeight-5)
return;
else {

POLY3 temp,papar,papar1;
glBegin(GL_LINE_STRIP);
glColor3f(1.0f,0.0f,1.0f);
temp.x=jor.x-LEBAR;
temp.y=jor.y+LEBAR;
temp.z=jor.z;
papar=pView->GetWorldPoint(temp);
papar1=papar;
// first points of the tracker
glVertex3f(papar.x,papar.y,papar.z);


temp.x=jor.x-LEBAR;
temp.y=jor.y-LEBAR;
temp.z=jor.z;
papar=pView->GetWorldPoint(temp);
// second points of the tracker

glVertex3f(papar.x,papar.y,papar.z);


temp.x=jor.x+LEBAR;
temp.y=jor.y-LEBAR;
temp.z=jor.z;
papar=pView->GetWorldPoint(temp);
// 3rd points of the tracker

glVertex3f(papar.x,papar.y,papar.z);

temp.x=jor.x+LEBAR;
temp.y=jor.y+LEBAR;
temp.z=jor.z;
papar=pView->GetWorldPoint(temp);
// forth points of the tracker
glVertex3f(papar.x,papar.y,papar.z);

glVertex3f(papar1.x,papar1.y,papar1.z);
}
the method i am using works but it takes much time to process when the number of points of the object is too great.
so do u have any suggestion to draw a tracker
just like what autocad did.

[This message has been edited by chengseesin (edited 12-18-2002).]

zeckensack
12-18-2002, 08:38 AM
http://nehe.gamedev.net/tutorials/lesson.asp?l=08