PDA

View Full Version : Theory question



daug
02-24-2003, 10:34 AM
Hi all,

I can program in Perl and Javascript, so I figured I'd give Lscript a try to solve some in-house issues. So here is what I'm trying to do........

The CAD software we use builds 3d house models with parametric roofs, windows, etc.. When I export the model into Lightwave, the resulting mesh is not always continuous (see image.....

D:\Temp\wall-polys.gif

Now, what I would like to do search for instances of non-attached polys like the image shows and add points to polys so I have a continuous mesh.

What I have thought of doing is checking every poly to see if there are any points that are in line with any of the poly's edges. If it finds one or more, it will add the point(s) to the poly.

I am an extreme noob with Lscript, and this doesn't seem like a very efficient way to do this. Any ideas? Anybody have an alternate route to what I am trying accomplish? Any help would be appreciated. Thanks :)

daug
02-24-2003, 10:42 AM
Trying again............

daug
02-25-2003, 03:35 PM
Anyone?

Tom Winnicki
02-25-2003, 05:41 PM
Does the image you posted represent what the part looks like in LW Modeler? How does it look like in the CAD software? Does it always do that to polygons with holes in them?

daug
02-25-2003, 06:25 PM
Hi Tom,

The software we use works inside of Autocad. It builds polyface-meshes that always do what I showed in the image. It doesn't cause problems except for screwed up normals, so I always have to do double-sided textures. I only showed a space between the polys for illustrative purposes.

There is no actual space between the polys. The outside polys I showed only have 4 points, when I want them to have 6 points. Does this make sense? If not, I will post another image. Thanks.

Mike Pauza
02-25-2003, 09:14 PM
I don't think there's a command to make the thing "seamless" automatically. Have you thought about using the "merge" command then reconstructing the polys from the points as shown below?

Lynx3d
02-26-2003, 07:36 AM
Ah now is understood the problem...

Hm in theory it should be possible to check all edges if there is a vertex "on" it and add it, but don't expect to that to be a 5min programming job :D

However I think it's also possible with LScript, with MeshDataEdit commands you can get the points of a polygon ( the IDs with polyinfo, and their coordinates with pointinfo) and than you'd have to write an algorithm that checks if another point lies on the line between point 1 and 2 (with a certein threshold), also between 2 and 3 etc. until you checked all edges. If you found one, you can use polypoints() to add it to your polygon (if i understand the manual correctly...that would save you from delete and rebuild the polygon) Then you have to start again for the same poly until no new point is found.
And finally repeat the whole thing for every polygon :D

I guess it will execute rather slow, but it should work.

daug
02-26-2003, 08:00 AM
Thanks for the replies guys :)

Lynx3d,
You're on the same track that I am on. The only real drawback I'm seeing is that for every polygon I check, I have to check EVERY point to see if it is lies between two points on the poly. Fortunately, I will only be working on a couple thousand polys at most.

I was also thinking of impletementing some type of filter that would see if the point to check is within a certain distance. If it isn't, it won't calculate any further.

Mike,

I thought of that, but it would have to work for multiple walls at the same time. I'll post a screen capture from a modeler to show you an example a little bit later. Right now, I've got to go back to my CAD work :(

Mike Pauza
02-26-2003, 01:09 PM
Are the polygons all planer and verticle? That would make the code much simpler.

daug
02-26-2003, 01:27 PM
Hi Mike,

To answer your question: yes, and no, hehehe

The polys are always planar, but have the top, bottom, and sides. See the image, I would like to do this to that whole mesh. Unfortunately, they are never that simple :)

Mike Pauza
02-26-2003, 09:40 PM
IMHO you need to do several things to make it work:

Firstly, you need to merge common points.

Secondly, like Lynx3d said you need a way of knowing if neighboring polys vertices lie on a certain polys edge. You should be able to do that with bounding rectangles. That will be easy for "orthogonal" edges, but to solve it in general you'll have to make use of the equation of a straight line in 3D. That's not super difficult, but it's not simple either.

Then, you'll have to merge points again, select them in a clockwise fashion(get out the trig book) on a per poly basis then make polys out of them.



Thats how I'd do it at leaste. Maybe there's a simpler way?

daug
02-27-2003, 06:35 AM
Hi Mike,

So far, you're on the same track as my thought process. I almost got my first function working last night. It tests to see if point "b" is inline points "a" and "c". I thought that was going to be the tricky part, but it wasn't so bad.

The next issue is creating the new poly. Is there any way that I could just add the point onto the existing poly instead of deleting the poly and creating a new one?

I am going to keep on plugging and see what I come up with. Thanks for the info :)