Public Group

#### Archived

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

# beginner - just draw a cylinder

This topic is 5574 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
It would be best using two circles and lines... but if you want 3D objects, you''d be better of with D3D..

##### 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 on other sites
*cough*He uses DirectDraw*cough*

##### 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 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 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

##### 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 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 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.

1. 1
Rutin
67
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633418
• Total Posts
3011786
• ### Who's Online (See full list)

There are no registered users currently online

×