View Full Version : How can I draw a line on a surface?

Aquileo

12-18-2003, 03:20 AM

I'm doing a CAD program and I must draw a line on a surface.

I need some example or PDF for How can I do.

I already have two points of the line on the surface.

I use a matrix with the structure of triangles:

TTringle **structureMesh;

where TTriangle is a class. The structure of TTriangle is:

class TTriangle

{

TCPoint3D v1;

TCPoint3D v2;

TCPoint3D v3;

TCPoint3D normal;

}

and TCPoint3D is:

typedef struct TCPoint3D

{

float x;

float y;

float z;

}

Thank you very much.

Aquileo.

Originally posted by Aquileo:

I already have two points of the line on the surface.

So what ? Just draw a line between the two points.

Ah, it is not what you meant maybe ? http://www.opengl.org/discussion_boards/ubb/smile.gif

Principle :

Well, try to find the nearest triangle for each of you endpoints (A and B). Nice. Now find each adjacent triangle for A. Repeat recursively for each of these adjacent triangles. Once you find triangle B you are done.

Optimizations :

- Try to precompute and store all the directly adjacent triangles for each triangle.

- if you want to find the 'shortest way' (in number of triangles) to reach triangle B, do a breath-first graph/tree traversal. If you don't understand this, try to find google docs/tuts concerning 'graph theory' 'tree traversal' 'depth first or breadth first traversal' 'binary search algorithms' etc.

If you want to draw a line onto an already drawn polygon glPolygonOffset() is your friend.

Aquileo

12-18-2003, 10:59 AM

Hong, thank you, but my problem is that I have a lot of triangles (over 40.000 points, 80.000 triangles). How should I use glPolygonOffset with the triangles?

Thank you very much.

maximian

12-18-2003, 11:22 AM

glPolygonOffset does not care about the number of polygons you have. You just need to pick the two values correctly. Best is to just experiment, since different dimensions of meshes coupled with the size of your view volume will affect glPolygonOffset.

As a reference I have used glPolygonOffset on

Models w/ 60,000 -100,000 polygons multipass and had no problems. But models were scaled down to with less 5 units.

The polygon offset usable value will depend on your z-buffer precision.

Having 24 bits zbuffer will allow you to use a smaller value than 16 bits zbuffer, and it will depend on the z-near and z-far values.

Relic

12-19-2003, 06:54 AM

Not exactly, polygon offset factors and units are expressed in minimum distinguishable zbuffer values.

Means the units parameters set to 1.0 should move the primitive one zbuffer value to the far direction in default settings.

Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.