GM: d3d draw cone
From GMpedia.org Wiki
- The correct title of this article is d3d_draw_cone(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat,closed,steps). It appears incorrectly here because of technical restrictions.
|
d3d_draw_cone() | |
| Type: | function |
| Arguments: | x1, y1, z1, x2, y2, z2 = Real valued co-ordinates that define the position and size of the block.
tepid = the id of the texture to draw the block with. repeat = How many times the texture should be repeated horizontally. repeat = How many times the texture should be repeated vertically. closed = True / False - Should the cylinder have caps at the end. steps = Integer defining how many faces the cylinder should have around the outside. |
| Limitations: | Registered |
This function will draw a vertical cone with or without a texture, using the current drawing colour. For the coordinates, think of the cone inside a box like this:
Notice that the pointy end of the cone is at the z2 coordinate. If you wanted to make the cone point downwards, you would have defined z2 to be less than z1. If you think like that, then you can apply the same techniques as used in d3d_draw_block. All the parameter details for drawing a block are applicable to drawing a cone.
To not use a texture for this primitive, put -1 in place of texid, else provide the id of a texture. Even if you don't use a texture, you must fill in the hrepeat and vrepeat parameters. If you are not using a texture, it does not matter what value you enter, I usually put a 0. If however you are using a texture, set hrepeat to how many times the texture should be repeated along the horizontal edges of faces, and vrepeat to how many times the texture should be repeated along the vertical edges of faces. Repeating a texture that tiles well can be used to cover large areas without losing definition.
[edit] Example
d3d_draw_cone(0,16,16,16,16,0,spr_texture,5,5,true,16)
The additional parameters in the cone are closed and steps. Steps is the number of rotational steps used to draw the round part of the cone. Because (most) 3d rendering software can not handle curved surfaces, we simply approximate a curved surface by drawing many flat surfaces. For example if you put steps as 5, the top view of your cone would look like this:
Example code for drawing a red cone like looking like the diagram above:
// set the drawing colour draw_set_color(c_red) // draw the cone. -1 for texture (no texture). tex repeat is irrelevant d3d_draw_cone(0, 32, 0, 32, 0, 32, -1, 0, 0, 1, 24)
See the talk page for details



