Hologram Projector: Difference between revisions

From OpenComputers: Rebooted
Jump to navigation Jump to search
m Remove references to T2 projector being new; OC:R has always had T2 projector
Unify block and component API pages
Line 1: Line 1:
= Hologram Projector =
= Overview =


[[File:hologram1.png|128px]] [[File:hologram2.png|128px]]
[[File:hologram1.png|128px]] [[File:hologram2.png|128px]]
Line 29: Line 29:
[[File:t2hologram.png|200px]]
[[File:t2hologram.png|200px]]


== Contents ==
= Component API =
 
Component name: <code>hologram</code>. Callbacks:
 
== clear ==
 
<code>clear()</code>
 
Clears the hologram.
 
== get ==
 
<code>get(x:number, y:number, z:number):number</code>
 
Returns the value at the specified position.
 
== set ==
 
<code>set(x:number, y:number, z:number, value:number or boolean)</code>
 
Set the value for the specified position.
 
== fill ==
 
<code>fill(x:number, z:number[, minY:number], maxY:number, value:number)</code>
 
Fills an interval in the specified column column with the specified value. Will overwrite only the voxels in the interval. If minY is omitted it defaults to 1. The two interval ends are inclusive.
 
== copy ==
 
<code>copy(x:number, z:number, sx:number, sz:number, tx:number, tz:number)</code>
 
Copies an area of columns by the specified translation.
 
== getScale ==
 
<code>getScale():number</code>
 
Returns the current render scale of the hologram.
 
== setScale ==
 
<code>setScale(value:number)</code>
 
Set the render scale. A larger scale consumes more energy. The minimum scale is 0.33, where the hologram will fit in a single block space, the maximum scale is 3, where the hologram will take up a 9x6x9 block space.
 
== getTranslation ==
 
<code>getTranslation():number, number, number</code>
 
Return the current translation offset.
 
== setTranslation ==
 
<code>setTranslation(x:number, y:number, z:number)</code>
 
Set the translation vector. The hologram display will be offset by this vector from its normal location. The maximum allowable translation is a function of tier. Units are the hologram's size, so the distance translated increases and decreases with scale as well.
 
== maxDepth ==
 
<code>maxDepth():number</code>
 
The color depth supported by the hologram.
 
== getPaletteColor ==
 
<code>getPaletteColor(index:number):number</code>
 
Get the hex color defined for the specified value.
 
== setPaletteColor ==
 
<code>setPaletteColor(index:number, value:number):number</code>
 
Set the hex color defined for the specified value.
 
= Examples =
 
Simple example program that allows setting individual voxels:
<syntaxhighlight lang="lua">
local component = require("component")
local hologram = component.hologram
local args = {...}
hologram.set(tonumber(args[1]), tonumber(args[2]), tonumber(args[3]), args[4] == "true" or args[4] == "on")
</syntaxhighlight>
 
Example use (assuming it's saved as <code>holo-set.lua</code>): <code># holo-set 16 8 20 true</code>
 
Further examples:
 
* https://github.com/OpenPrograms/Sangar-Programs/blob/master/holo-flow.lua
 
This program generates a heightmap and 'moves' across it over time, creating the effect of a flowing terrain.
 
* https://github.com/OpenPrograms/Sangar-Programs/blob/master/holo-text.lua
 
This program generates a random heightmap and displays scrolling text above it.
 
Note, the second example is quite a bit more advanced then the
first. '''Important''': both scripts also need the
[https://github.com/OpenPrograms/Sangar-Programs/blob/master/noise.lua
noise.lua] script to be in the same folder.
 
= Contents =


{{:Block/contents}}
{{:Block/contents}}

Revision as of 00:10, 28 August 2026

Overview

This block projects a hologram in the area over it. The size of the hologram can be scaled from 1x1x1 block to 9x9x6 blocks. The number of 'voxels' will stay the same, regardless of scale though. It has resolution of 48x32x48 monochrome voxels (they can either be on or off). Each voxel in that 3D array can be set individually. Generated holograms will look like this.

The second tier of the hologram projector is also capable of displaying colored voxels - in three different colors. These colors can be set to any desired value, i.e. the color palette is editable.

The Tier 1 Hologram Projector is crafted using the following recipe:

The Tier 2 Hologram Projector is crafted using the following recipe:

Component API

Component name: hologram. Callbacks:

clear

clear()

Clears the hologram.

get

get(x:number, y:number, z:number):number

Returns the value at the specified position.

set

set(x:number, y:number, z:number, value:number or boolean)

Set the value for the specified position.

fill

fill(x:number, z:number[, minY:number], maxY:number, value:number)

Fills an interval in the specified column column with the specified value. Will overwrite only the voxels in the interval. If minY is omitted it defaults to 1. The two interval ends are inclusive.

copy

copy(x:number, z:number, sx:number, sz:number, tx:number, tz:number)

Copies an area of columns by the specified translation.

getScale

getScale():number

Returns the current render scale of the hologram.

setScale

setScale(value:number)

Set the render scale. A larger scale consumes more energy. The minimum scale is 0.33, where the hologram will fit in a single block space, the maximum scale is 3, where the hologram will take up a 9x6x9 block space.

getTranslation

getTranslation():number, number, number

Return the current translation offset.

setTranslation

setTranslation(x:number, y:number, z:number)

Set the translation vector. The hologram display will be offset by this vector from its normal location. The maximum allowable translation is a function of tier. Units are the hologram's size, so the distance translated increases and decreases with scale as well.

maxDepth

maxDepth():number

The color depth supported by the hologram.

getPaletteColor

getPaletteColor(index:number):number

Get the hex color defined for the specified value.

setPaletteColor

setPaletteColor(index:number, value:number):number

Set the hex color defined for the specified value.

Examples

Simple example program that allows setting individual voxels:

local component = require("component")
local hologram = component.hologram
local args = {...}
hologram.set(tonumber(args[1]), tonumber(args[2]), tonumber(args[3]), args[4] == "true" or args[4] == "on")

Example use (assuming it's saved as holo-set.lua): # holo-set 16 8 20 true

Further examples:

This program generates a heightmap and 'moves' across it over time, creating the effect of a flowing terrain.

This program generates a random heightmap and displays scrolling text above it.

Note, the second example is quite a bit more advanced then the first. Important: both scripts also need the [https://github.com/OpenPrograms/Sangar-Programs/blob/master/noise.lua noise.lua] script to be in the same folder.

Contents

Blocks
Computers Computer Case - Server Rack - Microcontrollers
Display Hologram Projector - Keyboard - Screen
Power and Networking Capacitor - Net Splitter - Power Converter - Power Distributor - Relay
Extensions Adapter - Cable - Disassembler - Disk Drive - Geolyzer - Motion Sensor - Redstone I/O - Transposer - 3D Printer
Robotics Assembler - Charger - Drone - Robot - Waypoint