View Full Version : add point on poly??

06-18-2004, 06:23 AM
i searched in lscripting and find addpoint(0,0,0), but think this will add point in space , is it possible to add point on polygon, and to b more specific, if we have a polygon of 4 vertices, can a script add points near to each original points??

06-18-2004, 10:54 AM
polypoints([polygonID], [Array with pointIDs]);

will let you change what points a polygon should be made up of. As usual you will have to make sure the points in the array are in the correct order.

06-18-2004, 11:31 AM
thank u for ur reply evenflcw, i want to ask u, is it possible to do what i mentioned b4 using the polypoints, all i want is to add points on polygon and leave the old points not remove it, and this will be applied on a >4 vertices polygon.

06-18-2004, 12:59 PM
Don't know about the LScript function, but the SDK counterpart should have no problems with a different count of new points, so i guess the same apllies for LScript.

Just try out, make an array that consists of the old and new ones (in the correct order of course) and use polypoints();

06-18-2004, 02:43 PM
sorry guys but will polypoints add points?

06-18-2004, 03:07 PM
It will add a new set of point IDs to a polygon, not create the points.

So you can create new points with "pt = addpoint()", build an array with all old (don't know which LScript function gives you the point IDs of a poly) and new points that should make up the polygon and pass it to polypoints.

06-18-2004, 03:11 PM
but as i know addpoint is used to addpoint in space not on polygon, u know i want to add point on polygon.

06-18-2004, 04:48 PM
I'm not sure what you mean...

A point is a point, every point has an ID and a coordinate vector, and possibly many vertex maps assigned. The point doesn't really care if it belongs to a polygon or not (or not yet/anymore)...

So i'm not sure what you mean with "add point on polygon".
You can always add "isolated" points and create polygons with them, or make them part of an existing polygon. First the point has to be created before it can be part of anything.
Or is it a problem of how to get the coordinates for a point that is "on" (the plane) of a polygon?

06-18-2004, 05:08 PM
point on poly is not the same in lw modeller, i don't know if it's same function in scripting or sdk, finally i'm new to lscript but unfortunatly it's not well documented.
what i want to achieve is the following:
so adding points on polygon, that can affect polygon to have this point as part of it that can edit the edge of this polygon, sorry if it's a silly question but i can't figure it in the lscript help.

06-18-2004, 08:45 PM
dilaima, i think lynx3d answered your question.

the only way to add point onto a polygon is to rebuild that polygon with the new point in. a polygon object in lscript is composed of the points that it contains. you have to INSERT another point in between those other points. to do that, you have to rebuild the array.

06-19-2004, 05:44 AM
Yep, everything has pretty much been said, but I'll try to explain this better. Lightwave can't just add a point on a polygon, even if you were making a plugin you couldn't, you need your script to find out for itself where on the polygon it should be added.

So your polygon will bedescribed in an array such as this [surface, 1 , 2 , 3 , 4]

That is the polygon surface and the point ids. Now what you want to do is put a point on either side of each of those verticies right? So you need to get the position of the first and second points, find out where along that edge you want to add the point, and add it. You'd do this twice for every point. You'll probably want to keep an array of these new points too. Then just create a loop that'll add the id of one of the original points, then two of the new points to an array. Then get the surface name from the original array and put it in the polypoints([polygonID] command with the new array with the new point order in it.

This is probably very confusing, but hopefully it'll help. Maybe someone else can expand on it a bit more, but this is basically what your script will do.