Untitled conversation
- User
local EPSILON = 0.00001 function vector3D(x, y, z) return { x = x, y = y, z = z } end function renderDrawLine3D(v1, v2, width, color) local r1, x1, y1 = convert3DCoordsToScreenEx(v1.x, v1.y, v1.z) local r2, x2, y2 = convert3DCoordsToScreenEx(v2.x, v2.y, v2.z) if r1 and r2 and isPointOnScreen(v1.x, v1.y, v1.z, EPSILON) and isPointOnScreen(v2.x, v2.y, v2.z, EPSILON) then renderDrawLine(x1, y1, x2, y2, width, color) end end function generateSphereVertices(center, radius, latSegments, lonSegments) local vertices = {} for i = 0, latSegments do local theta = i * math.pi / latSegments local sinTheta = math.sin(theta) local cosTheta = math.cos(theta) for j = 0, lonSegments do local phi = j * 2 * math.pi / lonSegments local sinPhi = math.sin(phi) local cosPhi = math.cos(phi) local x = center.x + radius * sinTheta * cosPhi local y = center.y + radius * sinTheta * sinPhi local z = center.z + radius * cosTheta table.insert(vertices, vector3D(x, y, z)) end end return vertices end function drawSphere(center, radius, latSegments, lonSegments, width, color) local vertices = generateSphereVertices(center, radius, latSegments, lonSegments) for i = 0, latSegments - 1 do for j = 0, lonSegments - 1 do local first = i * (lonSegments + 1) + j + 1 local second = first + lonSegments + 1 renderDrawLine3D(vertices[first], vertices[first + 1], width, color) renderDrawLine3D(vertices[first], vertices[second], width, color) end end end function main() while not isSampAvailable() do wait(0) end local center = vector3D(0, 0, 0) -- Центр сферы local radius = 5 -- Радиус сферы local latSegments = 16 -- Количество сегментов по широте local lonSegments = 16 -- Количество сегментов по долготе local width = 1 -- Толщина линии local color = 0xFFFFFFFF -- Цвет линии (белый) while true do wait(0) drawSphere(center, radius, latSegments, lonSegments, width, color) end endСделай чтобы сфера закрашивалась, а не было прозрачной. Вот все функции рендера: renderDrawLine(float pos1X, float pos1Y, float pos2X, float pos2Y, float width, uint color) renderDrawBox(float posX, float posY, float sizeX, float sizeY, uint color) renderDrawBoxWithBorder(float posX, float posY, float sizeX, float sizeY, uint color, float bsize, uint bcolor) float length = renderGetFontDrawTextLength(DxFont font, zstring text, [bool ignoreColorTags=false]) float height = renderGetFontDrawHeight(DxFont font) uint index = renderGetFontCharIndexAt(DxFont font, string text, float x, [bool ignoreColorTags=false]) float width = renderGetFontCharWidth(DxFont font, string/uint char) DxFont font = renderCreateFont(zstring font, int height, uint flags, [uint charset]) renderReleaseFont(DxFont font) renderFontDrawText(DxFont font, zstring text, float posX, float posY, uint color, [bool ignoreColorTags=false]) renderDrawPolygon(float posX, float posY, float sizeX, float sizeY, int corners, float rotation, uint color) DxTexture texture = renderLoadTextureFromFile(zstring file) renderReleaseTexture(DxTexture texture) renderDrawTexture(DxTexture texture, float posX, float posY, float sizeX, float sizeY, float rotation, uint color) renderBegin(int type) renderEnd() renderColor(uint color) renderVertex(float vX, float vY) renderSetTexCoord(float posX, float posY) renderBindTexture(DxTexture texture) uint struct = renderGetTextureStruct(DxTexture texture) uint sprite = renderGetTextureSprite(DxTexture texture) uint sizeX, uint sizeY = renderGetTextureSize(DxTexture texture) renderSetRenderState(int state, uint value) DxTexture texture = renderLoadTextureFromFileInMemory(uint pointer, uint size)
- Assistant