Archived

This topic is now archived and is closed to further replies.

MrRolf

beginner - just draw a cylinder

Recommended Posts

Using DX7, I trie to draw a cylinder, and stretch it longer and shorter. I did not find any cylinder , just circle in DDraw7. Shall i "construct" this cylinder of two cicles and lines, or do i have to juse "cylinder" model in x format?, in that case , is it possible to stretch that model, easy? any smal tip is worth millions, thanks

Share this post


Link to post
Share on other sites
Hi.
You might feel like using some trigonometry (I dont know whether this is the right word but what Im talking about involves sines and cosines so that you can bind points to form two parallel circles ad then bind each of those points (actually vertices if you use D3D) to its buddy on the other circle).
To change the size, I think you''s have to change the coordinates of the vertices. Transformation matrices arent that hard to learn and are explained everywhere (including DirectX SDK''s help files.) ENJOY YOURSELF !!!!!!!!
Hope Ive been useful.

Prog, Hex & Rock''n''Roll :
I don''t like the Prog but the Prog likes me.
Some nice poetry to sweeten your spirit and relax a bit before programming

Share this post


Link to post
Share on other sites
if you are using directdraw, most likely you will be using tiles instead of drawing filled primitives all over the screen. (notice I said most likely, which may not be the case). Use a picture/tile/texture or whatever you want to call it of a cylinder and just change the size of the destination rectangle to what you want it to be. or use 3 tiles, head, middle and end and just repeat the middle as many times as you need for the size of the cylinder.

If you must use filled primitives use 2 circles and a rectangle. AFAIK directdraw doesn''t have a line drawing function and you have to use pixel plotting to draw them which is just a pain. Or you could just draw conscutive circles/elipses on top of eachother in small increments giving the illusion of a cylinder (((((((((((((((().

Lots of options, but in directdraw, sadly only a few are going to be quick.

Share this post


Link to post
Share on other sites
thanks for all th good replies


I found a sort of drawcylinder in Direct3D, but i really wanted to "design" a cylinder in a tool and , skin , it , deside material etc..., but keep the ability to alter it size (make it shorter , longer ..).

If i use the x file format, can i alter the cylinders height in runtime, or i am on dangerous ground here

thanks a again.

Share this post


Link to post
Share on other sites
Do you want simple, computer-graphics cylinder or a real-world, pneumatic or hydraulic cylinder?
In the latter case, i suggest obtaining some modeler program, such as AutoCad, then exporting to .x via .3ds format.

After that, you need to learn to use basic transforms in your code (and of course to render something).

After you''ve grasped the concept of rendering things, and
have somehow modelled your parametric cylinder, things will be much clearer.

I used to model and visualize hydraulic systems professionally couple of years ago

Ask more help if needed!

Share this post


Link to post
Share on other sites
Yeah , thanks

Lets say i have a mesh model from example a x file, i will then alter the model''s height. I can eighter stretch it, or clip in the floor(not preferrable).

I guess the most convinient would be to clip it shorter, but keep the "bottom" there, but i''m not shure how to do it.

thanks again

Share this post


Link to post
Share on other sites
It sounds like you need separate meshes (not necessarily, though) for the cylinder shaft and pin.
When rendering, just manipulate the world matrix to 'move' the cylinder pin as desired.
In serious technical visualizations, there's rarely a place to use a simple uniform stretching (note the word 'uniform').

Just think that any actual hydraulical or pneumatical cylinder really has two separate main parts

If you need to clip the model (to look inside, for example), ogl and d3d do both have clip plane functionality.

And finally, if you want to alter the stroke length of the cylinder, you need to manipulate the vertices of the cylinder geometry. This, i'm afraid, can be very difficult task for one with your apparent experience level in 3d graphics (no offense).

[edited by - Nik02 on August 17, 2003 9:20:20 AM]

Share this post


Link to post
Share on other sites
Agree Nick, I have to do some work with DX, it is really hard.

I also think i could achieve the same result with "animating" a clipped object.

Anyway thanks all, some body have to learn.

Share this post


Link to post
Share on other sites