Splines and meshes...

Blitz3D Forums/Blitz3D Programming/Splines and meshes...

DarkEagle(Posted 2003) [#1]
hiya,
im working on a city editor where you can place roads/buildings etc, and at the moment im using square blocks for everything... but what i would really like to do is to create the roads using splines.
the actual handling of the splines isnt a problem... what is a problem, is turning the spline into a mesh... also, junstions may pose a problem with this...
the roads would need to have a pavement (sidewalk) on each side, and be textured... and be about 10 blitz units wide...

soooo... any help?


DarkEagle(Posted 2003) [#2]
*whistles*


podperson(Posted 2003) [#3]
So in what sense is the handling of splines not a problem? (Cough)

Given that, for example, Adobe Illustrator didn't do this kind of stuff until maybe v5.5 and it was a serious pain to do it manually, I'm guessing the math is slightly non-trivial.


SSS(Posted 2003) [#4]
why dont you just use the spline as the center of the road, and then just use segments whenever it turns, kind of like the demo w/ the bike and the dynamic mesh


DarkEagle(Posted 2003) [#5]
i can do the spline maths, figuring out the location after t amount of time, but its just converting this to a mesh. basically, i know how wide i want my road to be, and i know that i want x amount of segments, and i know the center location and yaw of each of these segments... but creating the mesh and giving UV co-ords is beyond me.


DarkEagle(Posted 2003) [#6]
bwuahaha just figured a way... i think.

load a boned b3d model of a straight road made of 10-20 sections. asign a bone to each section, then find it in blitz and modify it! lets hope it works...


DarkEagle(Posted 2003) [#7]
wait... this is patches or something, isnt it?

anyway, i tried the boned b3d idea and it didnt go too well.

please help?


podperson(Posted 2003) [#8]
I started out trying to explain why the math is so hairy and this post got very long.

In essence, in the simplest case you need to solve a VERY complicated simultaneous equation to determine the intersection of two splines (even quadratic splines which are the simplest case you'd care about).

Then it occurred to me that there's a very simple solution: allow spline shaped segments of road, but force them to snap to right-angled intersections. Sure it's a restriction, but most traffic engineers avoid strange intersections like the plague (for good reasons).


jhocking(Posted 2003) [#9]
I don't know what you were getting at with the whole boned mesh thing but you are going to need to create the mesh, vertex by vertex, in code. Where to create vertices will be determined by the spline.


MattG(Posted 2003) [#10]
Hi DarkEagle ,

maybe we can talk sometime , as i am writing a racing track creator ( http://www.16vmini.co.uk/rtc )

would be happy to swap ideas/help .. as some of the things you are talking about i have done/ want to do.

Matt


DarkEagle(Posted 2003) [#11]
MattG

Wow! i like the look of that program! that is VERY nice! could you explain to me the actual code you use to create the road? i notice you can change the number of segments - i presume a vertex is created to the left and right of each segment point, then joined up somehow? id love to see some code to do this :)


MattG(Posted 2003) [#12]
well he is a basic function i use ( it can/will be improved

Function createroadface(mesh,p1.VEC3,p2.VEC3,p3.VEC3,p4.VEC3)
brush = LoadBrush(CurrentDir$() + "Data\profiles\road.bmp",49)
surface = CreateSurface(mesh,brush)

AddVertex surface,p1\x,p1\y,p1\z,1,1
AddVertex surface,p2\x,p2\y,p2\z,0,1
AddVertex surface,p3\x,p3\y,p3\z,0,0
AddVertex surface,p4\x,p4\y,p4\z,1,0
AddTriangle surface,2,1,0
AddTriangle surface,3,2,0
FreeBrush brush
End Function

i pass it 4 vectors , and then add to triangle to make a road section , create lots ..gives you a road.

Matt


MattG(Posted 2003) [#13]
just looked at the code , that function is what i used to use , it will work ..but i have found better ways of doing it .. that will get you started though.

Matt


DarkEagle(Posted 2003) [#14]
what data do these vectors contain, and where to they get thier info from? i think i need to see more before it "clicks" :)


MattG(Posted 2003) [#15]
i have what is called a track profile , take a cut line through a road , for a simple road you would have two points , left kerb, right kerb.

I then move these allong a path determined by other points , which you can move about , so making a track whaterver shape you want.

once i have all my kerb vectors , then then loop through them all one by one , so :

the first peice of road will be made up of the first two vectors (left/right kerb) and also the next section vectors.

not sure if that is any clearer

Matt