Creating a 3d object

Blitz3D Forums/Blitz3D Programming/Creating a 3d object

Chevron(Posted 2006) [#1]
Hi heres what I would like to do.

From a 2-d line create a 3d cylindrical object which edges conform to the contour of the 2d line. I would use readpixel from the image and then move the vertexs to match the ofset from the centre line of the 2-d image.

The reason i want to do this is that i am developing software to control a metal lathe that is hooked up with stepper motors and would like to design the object to be cut in a 2d drawing app and then produce a 3-d image on the computer screen that represents the final designed object.

Hope somebody understands what I mean.

Any sample code would be greatly appreiciated that demostrates a method that I could use to acheive this.

Thanks in advance.


octothorpe(Posted 2006) [#2]
Something like this, perhaps?


Or constructing a mesh instead of using primatives:



DJWoodgate(Posted 2006) [#3]
I guess you mean construction of a 3d solid around a centre of rotation from a series of 2d line segments or perhaps splines extrapolated from an outline 2d image. You then specify the centre of rotation and for simplicity probably rotate the image so that this axis is vertical or horizontal.

I am thinking you would probably want to use splines to smooth out the pixel outline and get nice curves. This should perhaps be optional though as perhaps you may not always want curves or maybe have a mixture of both, so you should be able to modify and edit the 2d data that has been generated from the image accordingly.

If you are going to do that though you might as well write the drawing part of it youself and avoid image interpretation. If you are drawing this thing as a vector object you will loose a lot of accuracy by converting it to an image and so you will have to edit the resulting data in a lot of cases to get the exact form you are after.

With the splines you could vary the number of vertices or control points depending on their curvature and on output destination. You would probably want to send a lot of control data to the lathe, but would require somewhat less for the 3d visualisation. I guess you would do something similar for all the line segments.

Exactly how to code this is a little above my head though, but it sounds like an interesting project.


Chevron(Posted 2006) [#4]
Thanks for the code Octothorpe, I will give the mesh version a go and let you know how it works out in my app.

Yeah DJ thats it, youve got the idea of exactly what I am trying to achieve. The lathe has an acuracy of .1mm so i will need to interpolorate the 2d image to acheive the required resolution.

The 3d image doesnt need to be accurate to the same degree, it is mearly a graphical representation of the final object that will be made.

I intend to allow the x scale in the 2d editor to be specified to allow very detailed items to be lathed if required.

I have already cut 1/92 scale cannons using a pic processor to store the data and have acheived great succes so the next step is to get an all singing and dancing editor done to allow full pc control.

Thanks alot for the help and info so far guys.


Shifty Geezer(Posted 2006) [#5]
A linear interpolation of 2D points is going to create straight sections in your model. You'd need a way to derive a curve from several points (which I don't know how to do).


octothorpe(Posted 2006) [#6]
How are you going to model a curve with triangles? You're going to have to sample the data sooner or later.