GM: d3d draw ellipsoid
From GMpedia.org Wiki
- The correct title of this article is d3d_draw_ellipsoid(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat,steps). It appears incorrectly here because of technical restrictions.
|
d3d_draw_ellipsoid() | |
| Type: | function |
| Arguments: | x1, y1, z1, x2, y2, z2 = Real valued co-ordinates that define the position and size of the block.
texid = the id of the texture to draw the block with. hrepeat = How many times the texture should be repeated horizontally. vrepeat = How many times the texture should be repeated vertically. steps = Integer defining how many faces the cylinder should have around the outside. |
| Limitations: | Registered |
This function will draw an ellipsoid, with or without a texture, in the current drawing colour. An ellipsoid is like a ball, but it doesn't have to be perfectly spherical. When defining the coordinates for the ellipsoid, think of it inside a box like this.
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 an ellipsoid.
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 vrepeat to how many times the texture should be repeated along the horizontal edges of faces, and hrepeat 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_ellipsoid(0,16,16,16,16,0,spr_texture,5,5,16)
The additional parameter for a sphere is steps. Steps is the number of rotational steps used to draw the ellipsoid. 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 your ellipsoid would look something like this:
Here is some sample code that could be used to draw a skybox around the camera in a fps.
/* draw the "skybox" relative to the camera's position to give it the impression of massiveness. also have a larger portion of the "skybox" below the camera to give a more realistic effect.*/ d3d_draw_ellipsoid(camera.x-3000, camera.y-3000, -5000, camera.x+3000, camera.y+3000, 1000, texture_sky, 5, 5, 18);
See the talk page for details



