Notifications
Clear all

[Closed] Need help to Generate Points based on a Mesh

Hi
I need to generate points/dummy based on a strip of Mesh.These points must be placed right in between the mesh and there placement must be equidistant. (See Images)
I cant rely on the vertex positions because the mesh is a mess.
Can any one throw any ideas how to go about writing a script to do this.
Attached images show the start and the required results.
Just for clarification these, points will be later exported as paths nodes to a game engine. The mesh is the Road Geometry.

My initial approach.
Create two shape along the edges and based on the curve length of both curves
creates points in between them. But this method fails as i cant get the select edges in loop (Model problem, Grrr…those modelers).
Hoping any of you guys might have a better idea to get me going.

Thanks

 [img] http://img184.imageshack.us/img184/8379/startdk8.jpg[/img][img] http://img184.imageshack.us/img184/8379/startdk8.jpg[/img][img]  g"/> [/img]

 [img] http://img184.imageshack.us/my.php?image=startdk8.jpg [/img]
 [img] http://img300.imageshack.us/my.php?image=finishto5.jpg [/img]
13 Replies
 JHN

I think I would try to extract splines based on the outer edges, and go in steps of lets say 5% per path and create a point between those 2 acquired vectors.

That would approximate the position as close as I can imagine, or you could go in really fancy and cast a ray from that position to hit the mesh and get that point, that would approximate the position very closely.

-Johan

take a peek at this script/conversation, they had a similar problem. http://tech-artists.org/forum/showthread.php?t=119

 JHN

My quick take on this


s = selection[1]
for i in 0. to 1. by 0.1 do
(
	p1 = pathInterp s 1 i
	p2 = pathInterp s 2 i
	p = ( p1 + p2 ) / 2
	point pos:p name:(uniqueName "trackPoint_" )
)

Create a spline from the 2 outer edges of the mesh (select edges: extract splines), make sure the splines have their first vertex on the same side!!!
Run the script and it will create points in the center of the the mesh… this is a quick and dirty approach no error checking and some handwork required with the creation of the splines.

-Johan

I would take the normal vector of a point along the inner line and get the position along the outer line at the intersection of that ray and then average the positions and create a new point there. Rebuild the middle line with equadistant points and voila! I have no idea how one would do that, but if I were to figure out how–those are the challenges I would attempt to address.

Hi
Thanks a lot for the inputs.
The spline method should work. Extract splines from both inner and outer edge loop. Increment the curve length along both the extracted curves and plot the center between them.
However in my case most of the models doesn’t have correct edge flows. so its impossible to procedurally select a clean inner or outer edge loop to extract a spline unless the model is cleaned or someone manually selects them.But this defeats the whole point of automating this process.There are some 100’s of road pieces for with the paths have to be generated.

i am working on another method which involves shooting rays in each point
in the bounding box of the mesh and checking for intersection. This will give me the
points on both the edges of the mesh. I know this is crude and slow, i will protype and post the code.

Thanks

and you can probably easily select the outer edges by way of converting to editable mesh, running an auto-edge with a low threshold, converting back to poly, and selecting the edge loops then. then you just need to work out deleting the ends, and normalizing, and then finding the distance between the splines inner and outer verts.

 eek

Firstly if the road has a thickness – you could use a section shape to get its outline. You could then removed each end of this shape to leave the outer and innner spline. Then use lengthInterp to build points between these.

Build a rough spline between the two original splines, and split it up into evenly lengthed curves. Use these curves to build a uniform set of points. Or a uniform cubic curve.

A threshold could be use for the lengths of the chunks, the small they are the more finite the detail.

Hi

shooting rays in the bounding box didn’t work. It would work if the road starting and endings are parallel with the bounding box edges. Most of the meshes don’t comply to this.

@Vsai
the auto-edge gets me the whole edge/border selection, any lead on how i can procedurally deselect the ends?

I wanted to make this an automated process without any inputs. But looks like
i have to take the two splines (inner and outer) as input for each piece and then generate the paths.

thanks

 JHN

If you have the enclosed splineshape, maybe you can find outr between segments what the angle is between a certain treshold… that should give you 4 segment groups, the 2 longest segment groups should be the ones you want…

Something like that?

-Johan

Page 1 / 2