View Full Version : Projecting a shape on a surface

mphanke

05-23-2002, 07:34 AM

Hi Folks,

what I want to do is to project a "selection shape" on an irregular mesh. From there I want to display the selected area (transparent mesh or something like that) and compute the area.

How can I do this? Can somebody help me out with some hints, tutorials or the math on how to do that??

Thanks alot,

Martin

NordFenris

05-23-2002, 09:51 AM

You mean, like a marquee? You want to know which parts of a mesh model are inside a 2D shape on your screen?

If so, then your solution is easy, although somewhat costly:

You need to keep the 2D coordinates of every vertex, as they are projected onto your screen - check out gluProject() - and then check which of these 2D coordinates are inside your 2D shape.

mphanke

05-24-2002, 01:26 AM

Hi,

I have all coords in my scenetree. I will have to create something like a 2 mesh above the object. Let's say I have a circle for selecting, if it is projected onto the surface the it will bend around it and become something more like an ellipse. I need to compute all this points and then triangulate it to be able to draw it. Triangulation is no problem, but the projection stuff is kinda mindbreaking for me.

Martin

Edited:

If I take a e.g. spline how will it bend to fit onto surface and do I get the points??

[This message has been edited by mphanke (edited 05-24-2002).]

Devulon

05-24-2002, 01:57 AM

Its a simply question and in theory the answer is simple but in reality the math/algo can get messy.

Basically all you need to do is project the points of your shape into the object and computer where they hit. Those points are the edges of the "partial surface" you are looking for. The problem (whether the shape is composed of lines, circles, splines, whatever) is all about tesselating. For example if you project a square shape onto a sphere the points of intersection are going to cause the porjected to shape to slice the object. You would need to tesselate the square so that it had more points so it would better fit the mesh that is being projected onto. This can be as simple as subdividing the shape or as complex as looking at the mesh and doing more of a beam tree/edge projection type of a deal. I don't know for sure I haven't really tried this (haven't had a need to although it sounds like an interesting topic). Of course this can all be done with a stencil buffer but I figure you want the geometry not just the final image.

Hope this helps.

Devulon

mphanke

05-24-2002, 02:36 AM

Hi,

thanks Devulon and you are right I need the shape, not the final image. I will play around with this until I find a solution.

Your hint is very usefull for me.

Thanks,

Martin

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.