
Список изменений
DirectGPU 1.0.20 for NeoForge 1.21.1 is built on CC:Tweaked 1.117.1.
DirectGPU displays work on Create entities, Create Aeronautics contraptions, and Elevator entities. Sable/ Create Aeronautics support means DirectGPU displays work on them.
Term redirect style support is available through gpu.run / termRender.
The controller API has been removed from DirectGPU since it has been made into its own mod: CC-Gamepads. https://github.com/tiktop101/CC-Gamepads
CC-Gamepads uses cc_event events and supports up to 4 bound gamepads.
There will probably be bugs I have not noticed or found yet, so let me know in my Discord server or as a GitHub issue. Suggestions can also go in either the Discord server or as a GitHub issue.
createDisplay("gui", pixelWidth, pixelHeight) creates a GUI on the computer used and on the front texture of the computer createDisplay("gui", pixelWidth, pixelHeight, [resolutionMultiplier]) same as "creates a GUI on the computer used and on the front texture of the computer" but with the optional arg to use the resolution multiplier.
Manual display creation also supports relative positions from the DirectGPU block.
createDisplay(x, y, z, facing, width, height, true) creates a display at a relative block offset from the DirectGPU block. createDisplay(x, y, z, facing, width, height, scale, true) does the same but with the optional scale arg.
Example: gpu.createDisplay(1, 0, 0, "north", 2, 1, true) gpu.createDisplay(1, 0, 0, "north", 2, 1, 1.0, true)
Example Term Redirect* script.
local gpu = peripheral.wrap("directgpu_1") or peripheral.find("directgpu") local id = gpu.autoDetectAndCreateDisplay(1)
gpu.run(id, "clear") gpu.run(id, "multishell")
Monitor anchor example
local gpu = peripheral.wrap("directgpu_1") or peripheral.find("directgpu")
local x, y, z = gpu.autoDetectMonitor("top") local displayId = gpu.createDisplayAt(x, y, z)
gpu.setOpacity(displayId, 100) gpu.setBackgroundOpacity(displayId, 0)
CC:Advanced Math Quaternion model rotation example
local gpu = peripheral.wrap("directgpu_1") or peripheral.find("directgpu") local displayId = gpu.autoDetectAndCreateDisplay(1)
local modelData = [[ v -0.5 -0.5 0 v 0.5 -0.5 0 v 0 0.5 0 f 1 2 3 ]]
local modelId = gpu.load3DModel(modelData)
gpu.setupCamera(displayId, 50, 0.05, 100) gpu.setCameraPosition(displayId, 0, 0, -4) gpu.lookAt(displayId, 0, 0, 0)
local angle = math.rad(90) local half = angle / 2
local qx = 0 local qy = math.sin(half) local qz = 0 local qw = math.cos(half)
gpu.clear(displayId, 0, 0, 0) gpu.clearZBuffer(displayId) gpu.draw3DModel(displayId, modelId, 0, 0, 0, 0, 0, 0, 1, 255, 255, 255, qx, qy, qz, qw)
if gpu.updateDisplay then gpu.updateDisplay(displayId) end
Textured quaternion model example
local gpu = peripheral.wrap("directgpu_1") or peripheral.find("directgpu") local displayId = gpu.autoDetectAndCreateDisplay(1)
local modelData = [[ v -0.5 -0.5 0 v 0.5 -0.5 0 v 0 0.5 0 vt 0 1 vt 1 1 vt 0.5 0 f 1/1 2/2 3/3 ]]
local textureData = "base64_png_here"
local modelId = gpu.load3DModel(modelData) local textureId = gpu.loadTexture(textureData)
gpu.setupCamera(displayId, 50, 0.05, 100) gpu.setCameraPosition(displayId, 0, 0, -4) gpu.lookAt(displayId, 0, 0, 0)
local angle = os.clock() local half = angle / 2
local qx = 0 local qy = math.sin(half) local qz = 0 local qw = math.cos(half)
gpu.clear(displayId, 0, 0, 0) gpu.clearZBuffer(displayId) gpu.draw3DModelTextured(displayId, modelId, textureId, 0, 0, 0, 0, 0, 0, 1, 255, 255, 255, qx, qy, qz, qw)
if gpu.updateDisplay then gpu.updateDisplay(displayId) end
DirectGPU Peripheral (gpu)
autoDetectAndCreateDisplay([resolutionMultiplier]) -> number autoDetectAndCreateDisplays([maxCount, resolutionMultiplier]) -> table autoDetectMonitor([nameOrSide]) -> x, y, z autoDetectMonitors([maxCount]) -> table createDisplay(x, y, z, facing, width, height, [relative]) -> number createDisplay(x, y, z, facing, width, height, [scale, relative]) -> number createDisplayAt(x, y, z, [relative]) -> number createDisplayAt(x, y, z, facing, width, height, [scale, relative]) -> number createDisplayWithResolution(x, y, z, facing, width, height, [resolutionMultiplier, relative]) -> number mirrorDisplay(sourceDisplayId, targetDisplayIds) -> table getDisplayPosition(displayId) -> table setDisplayPosition(displayId, x, y, z) getRotation(displayId) -> table setRotation(displayId, pitch, yaw) moveDisplay(displayId, targetX, targetY, targetZ, [speed, ...]) stopDisplayMovement(displayId) enableDeltaMode(displayId) getDisplayFrameJpeg(displayId, [quality]) -> string setOpacity(displayId, opacity) setBackgroundOpacity(displayId, opacity)
loadPNGFullscreen(displayId, base64PngData) loadPNGRegion(displayId, pngBinaryData, x, y, w, h) loadPNGRegionBytes(displayId, base64PngData, x, y, w, h) decodePNG(base64PngData) -> table decodeAndScalePNG(base64PngData, targetWidth, targetHeight) -> table getPNGDimensions(base64PngData) -> table
loadGIFFullscreen(displayId, gifData) loadGIFRegion(displayId, gifBinaryData, x, y, w, h) loadGIFRegionBytes(displayId, base64GifData, x, y, w, h) loadGIFFrame(displayId, gifData, frameIndex, x, y, w, h) stopGIF(displayId) decodeGIF(base64GifData) -> table decodeAndScaleGIF(base64GifData, targetWidth, targetHeight) -> table getGIFDimensions(base64GifData) -> table getGIFFrameInfo(base64GifData) -> table
loadImageFullscreen(displayId, base64ImageData) loadImageRegionBytes(displayId, base64ImageData, x, y, w, h) decodeImage(base64ImageData) -> table decodeAndScaleImage(base64ImageData, targetWidth, targetHeight) -> table getImageDimensions(base64ImageData) -> table detectImageFormat(base64ImageData) -> string
load3DModel(objData) -> number unload3DModel(modelId) draw3DModel(displayId, modelId, x, y, z, rotX, rotY, rotZ, scale, r, g, b, [qx, qy, qz, qw]) draw3DModel(displayId, modelId, x, y, z, rotX, rotY, rotZ, scale, r, g, b, [quaternion]) loadTexture(base64ImageData) -> number unloadTexture(textureId) draw3DModelTextured(displayId, modelId, textureId, x, y, z, rotX, rotY, rotZ, scale, r, g, b, [qx, qy, qz, qw]) draw3DModelTextured(displayId, modelId, textureId, x, y, z, rotX, rotY, rotZ, scale, r, g, b, [quaternion])
termRender(displayId, lines, ...) -> MethodResult run(displayId, program, ...) -> MethodResult
3D model quaternion args
draw3DModel still supports rotX, rotY, rotZ.
Quaternion rotation can be passed using qx, qy, qz, qw after the color args.
draw3DModel(displayId, modelId, x, y, z, 0, 0, 0, scale, r, g, b, qx, qy, qz, qw)
draw3DModel can also accept a quaternion object/table as the final arg.
draw3DModel(displayId, modelId, x, y, z, 0, 0, 0, scale, r, g, b, pose.orientation)
draw3DModelTextured supports the same optional quaternion args.
draw3DModelTextured(displayId, modelId, textureId, x, y, z, 0, 0, 0, scale, r, g, b, qx, qy, qz, qw)
draw3DModelTextured(displayId, modelId, textureId, x, y, z, 0, 0, 0, scale, r, g, b, pose.orientation)
Opacity
setOpacity(displayId, opacity) changes anything drawn to the display. setBackgroundOpacity(displayId, opacity) only changes the display background.
opacity is 0-100.
0 = invisible / fully transparent 100 = fully visible / fully opaque
"also now if directgpu and cc:gamepads is installed it makes one single tab instead of 2 separate tabs."
