Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Bending a Cylinder Like a Bezier Curve

Author
Message
CompuWiz
23
Years of Service
User Offline
Joined: 21st Nov 2002
Location:
Posted: 6th Oct 2003 08:19
Hey,

I was wondering if it is possible to convert a cylinder to a bezier curve. If you don't know what that is, a bezier curve is a line with a "control point" on each end. These control points can be manipulated to curve and bend the line. I am pretty sure there are no bezier curve commands in DBPro, so I have drawn just a long cylinder on screen. Now I need a way to bend that cylinder. From there, I can create my own control points and everything.

Basically, my question is: Are there any Bezier Curve commands in DBPro? If not, is it possible to "bend" or "curve" a cylinder?

Thanks,
Nick.

The only way to prevent all lag in a game is not to make the game.
AlecM
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Concord, MA
Posted: 6th Oct 2003 09:35
Not nativly. You could work out the math and do it yourself. Or just do it in a modelling program.

[P4 2.8C @ 3.03 with an 866mhz FSB:: MSI Neo-2LS running PAT:: 1gb Mushkin PC-3500 DDR High Perf level 2@ 2,2,2 :: ATI Radeon9800ProAIW :: 120Gb SeagateBarracuda 7,200RPM SATA HD :: Antec Plus1080AMG]
CompuWiz
23
Years of Service
User Offline
Joined: 21st Nov 2002
Location:
Posted: 6th Oct 2003 10:11
The problem is these cylinders, or tubes, need to be made on the fly. The program collects user input and then bends the tubes to that shape. So it would be impossible for me to predict every single thing the user could make, as it is endless. I tried doing it with limbs, but have never used them before, and pretty much ended up with two big squares in the middle of my cylindes. Not what I wanted. But let me make this much simpler. Would it be possible to bend a cylinder at all?

The only way to prevent all lag in a game is not to make the game.
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Oct 2003 11:17
I guess you are used to 3D graphics apps. You could do a search for Mesh Deformation for some ideas on what has been done previously, but you are looking at some complex mathematics.

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
CompuWiz
23
Years of Service
User Offline
Joined: 21st Nov 2002
Location:
Posted: 6th Oct 2003 11:34
Ok, but that still doesn't answer my question. Is it even possible to bend a cylinder in DarkBASIC? I don't mind doing some research, but not if it's going to be a complete waste of time!

The only way to prevent all lag in a game is not to make the game.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Oct 2003 11:49
Pah, of course it's possible, you just gotta approach it from the right angle.

2D beziers are fairly straightforward, I have some code for them somewhere you could have, and making a 3D version would'nt be too tough. So once you can generate a 3D bezier based on waypoints, you need to make a sorta cylinder driller. The driller is an object that is pushed along the bezier, it has nodes that define vertice positions and you push the driller all the way through the bezier - grabbing the node limb positions each time and generating the strip of polygons around the driller. You would use a memblock to make the mesh after level loading, which would be normalised and textured on the fly. You might get a better FPS if you split the tunnel into sections, like maybe setting a number of polys per section. Also, a single tileable texture would be best for texturing, the space between each vert is not constant so overlap texturing will be needed, like longer sections need longer textures, texture wrapping will take care of that but you need to keep track of it. If you do get the texture wrapping right though it should look very cool.


Van-B

My cats breath smells of cat food.
CompuWiz
23
Years of Service
User Offline
Joined: 21st Nov 2002
Location:
Posted: 6th Oct 2003 12:21
See, I knew there was an answer! Well thanks Van-B, that helps A LOT. If you can find that 2D bezzier it would be even more helpful, but if not, then that's fine too.

Quote: "You might get a better FPS if you split the tunnel into sections"
I wouldn't exactly call 'em tunnels... more like "rails"... let's just say I've got a major sim in the making

The only way to prevent all lag in a game is not to make the game.
las6
23
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Finland
Posted: 6th Oct 2003 12:41
heh. I did that once in DBpro, but it made .x files out of randomized sine wave. Those .x files were sorta like rails that went on and on.

Keeping the distance between node checks even makes things a lot easier. Of course, the polycount is much higher, but it's easier to start this way.

CompuWiz
23
Years of Service
User Offline
Joined: 21st Nov 2002
Location:
Posted: 6th Oct 2003 13:01
Ok, well I can't even figure out how to START going about this. Any pointers in psuedo code?

The only way to prevent all lag in a game is not to make the game.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Oct 2003 13:40
Ohh, why not forget about beziers and use a point to point system. What you'd do is get a sorta string of waypoints, and you move through them, but instead of storing locations, you store angles and move at a constant rate. So you'd allow 3D rotation of each point, but sorta cloning too - if the waypoint is pointing a little down, and a little to the left for example - you could simply compare the previous waypoints and keep the angles constant, then the track would make a sorta corkscrew for as long as you kept adding points. - imagine the points are all spheres stuck together, only designated by the previous points angles. This would mean designing tracks would be like bending pipecleaners, but as long as you took your time and worked in sequence your track should come together fairly easily. If the track goes a bit nuts, a little smoothing of your waypoints should fix it. This method would be a lot easier o work with too - for example, moving objects along the tube can be done in a similar fashion to creating the tube.

If I was you I'd work on a 3D point to point editor, just a line really that you can alter in 3D, does'nt have to be smooth, just a line between points and a mouse interface. Here's a couple of tips for this sorta interface though:

* Make a dummy object, which is hidden - this can be used for 3D - Screen conversions.
* Step through each point in the line, and position a dummy object there, then get the screen position and draw a box. Your best checking the mouse at this point, maybe set a variable to the selected point if the mouse button is not clicked.
* If you click the mouse, you should rotate the point in 3D, left click could mean X and Y mouse movements affect the Z and X angle of the point, right click could change roll angle if necessary (very cool for rollercoasters ).


Van-B

My cats breath smells of cat food.
las6
23
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Finland
Posted: 6th Oct 2003 15:09
why not just calculate the angle by pointing from the point to the next one? (as long as you are not using beziers or other "curves")

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Oct 2003 15:30
Yeah, that would work too - as long as you can get an object at each point and point it in the same direction as the next point you can still make a sorta pipe from the data.

Once you get a little editor together, let me know and I'll fill you in on the mesh creation.


Van-B

My cats breath smells of cat food.
DonBecker
22
Years of Service
User Offline
Joined: 30th Sep 2003
Location:
Posted: 6th Oct 2003 15:38
I'm used to 3D drafting, so I've made alot of what you've said, just not with dark basic.

If the cylinder is bent but has a consistent diameter all the way through, your circle (the base or top of the cylinder) should be perpendicular to the curve that you're extruding along. I'd imagine that since you're making these on the fly, then you'd probably do it in several steps:

1. Generate the spline (the curve or path to extrude along)
2. Create the top or base of the circle, located in reference to the start of the spline.
3. Generate an array of points on the spline
4. Copy the circle to those points
5. Generate 3D cylinders at the corresponding locations.

That's similar to something I would do in a drafting program, but I'm not sure about dark basic.

I would imagine multi-dimensional arrays would be great for this, but I'm not sure off the top of my head that dark supports them. I'm used to visual basic.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Oct 2003 15:44
Nah, that's the thing I was talking about with the cylinder driller object, like a plate with dummy limbs along the rim - say 16, you'd line up the driller to the point, point it towards the next point, then make the polys between the last driller position and the current one - you can use the points on the drillers rim as the vertice locations on the tube your making. Hardly any trouble at all.


Van-B

My cats breath smells of cat food.
CompuWiz
23
Years of Service
User Offline
Joined: 21st Nov 2002
Location:
Posted: 9th Oct 2003 06:37
Ok, I have a basic node placing system. It allows you to place spheres (aka nodes or control points), move them, manipulate them (things such as banking and height), and remove them. So now how do I go about having a cylinder connect all these spheres? I thought of possibly making a mesh connecting them and then using the make object command, but theres no way to simply create a mesh from scratch in DBP.

Thanks,
Nick.

The only way to prevent all lag in a game is not to make the game.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Oct 2003 15:26
Well, there is - you will need that tube making model, like a plate with nodes along the rim, you use that to guage the positions of the verts, and construct the mesh using memblocks. If you email me the node system I'll make a mesh creation function for you, It's no biggie, seem to spend most of my time messing with memblocks these days.


Van-B

Login to post a reply

Server time is: 2026-07-26 05:02:27
Your offset time is: 2026-07-26 05:02:27