generated from processing/processing-library-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1391718
commit 32a3508
Showing
23 changed files
with
1,600 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,72 @@ | ||
# Processing Library Template | ||
This is a template to help developers of Processing libraries to develop and release. | ||
|
||
Please read the [documentation website](https://processing.github.io/processing-library-template/) | ||
for more information on how to use this template. | ||
|
||
Three important outputs are required to contribute a library to Processing, and this template provides | ||
help and guidance on them. They are: | ||
1. **The library's code** - This template will build your code into a jar file with Gradle. | ||
2. **A website for the library** - We recommend using [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) | ||
to create a static website for your library. It allows you to write content for your website | ||
using markdown, and structure the site using a yml configuration file. We provide a skeleton | ||
MkDocs website as part of this template. | ||
3. **A url that serves the release artifacts** - We have already configured Gradle tasks to create the | ||
release artifacts. If you host your code on Github, You can create a Github release that serves the | ||
release artifacts. | ||
|
||
|
||
References for developing libraries for Processing can be found on the following Github wiki pages: | ||
- https://github.com/benfry/processing4/wiki/Library-Basics | ||
- https://github.com/benfry/processing4/wiki/Library-Guidelines | ||
- https://github.com/benfry/processing4/wiki/Library-Overview | ||
|
||
> [!Note] | ||
> This template is based on Gradle. If you are looking for the old Ant-based template, see [processing/processing-library-template-ant](processing/processing-library-template-ant) | ||
## Contributors | ||
|
||
This template was created by Claudine Chen ([@mingness](https://github.com/mingness)) as part of the 2024 New Beginnings (pr05) Grant from the | ||
[Processing Foundation](https://github.com/processing), to simplify the | ||
workflows for libraries, tools, and modes, mentored by Stef Tervelde ([@Stefterv](https://github.com/stefterv)). | ||
|
||
It is based on and inspired by a number of Processing library templates, including: | ||
- https://github.com/processing/processing-library-template-gradle | ||
- https://github.com/enkatsu/processing-library-template-gradle | ||
- https://github.com/hamoid/processing-library-template/ | ||
|
||
I wish to thank the developers of these repositories, who generously provided | ||
guidance and time. This template has been developed in collaboration with | ||
[@enkatsu](https://github.com/enkatsu). | ||
## ziviDomeLive Library | ||
|
||
ziviDomeLive is a Processing library that facilitates the creation of immersive visual experiences for fulldome projections. It allows for interactive and sound-reactive scene manipulation, making it ideal for fulldome environments and other immersive installations. | ||
|
||
Features: | ||
- Support for dome projection techniques (e.g., equirectangular and domemaster shaders). | ||
- Interaction with 3D scenes in real time. | ||
- Sound-reactive visual effects to enhance audience experience. | ||
- Customizable scene managers for control over dome content. | ||
|
||
## Installation: | ||
|
||
Install with the Contribution Manager: | ||
- You can install ziviDomeLive using the Processing Contribution Manager: | ||
1. Open Processing and navigate to Sketch → Import Library... → Add Library.... | ||
2. Search for ziviDomeLive and click Install. | ||
|
||
- If the library is not available in the Contribution Manager, follow the manual installation steps below. | ||
|
||
Manual Install: | ||
1. Download ziviDomeLive from https://github.com/vicvalentim/zividomelive. | ||
2. Unzip the downloaded file. | ||
3. Copy the folder into the libraries directory of your Processing sketchbook. You can find the sketchbook location in Processing under Preferences. | ||
4. The folder structure should be as follows: | ||
|
||
Processing | ||
libraries | ||
ziviDomeLive | ||
examples | ||
library | ||
ziviDomeLive.jar | ||
reference | ||
src | ||
|
||
5. Restart Processing to use the library. | ||
|
||
## Usage: | ||
To use ziviDomeLive in your Processing sketch, import the library at the beginning of your code: | ||
|
||
import ziviDomeLive.*; | ||
|
||
ziviDomeLive dome; | ||
|
||
void setup() { | ||
size(800, 800, P3D); | ||
dome = new ziviDomeLive(this); | ||
dome.setup(); | ||
} | ||
|
||
void draw() { | ||
|
||
dome.draw(); | ||
|
||
} | ||
|
||
## Examples: | ||
Check out the examples folder for a variety of sample sketches that demonstrate how to use ziviDomeLive to create immersive, sound-reactive visual experiences. | ||
|
||
## Development: | ||
If you want to contribute to the development of ziviDomeLive: | ||
1. Fork the repository on GitHub: https://github.com/vicvalentim/zividomelive | ||
2. Clone your fork to your local machine. | ||
3. Make changes and test them locally. | ||
4. Push your changes and create a pull request. | ||
|
||
## Author: | ||
Developed by Victor Valentim. | ||
|
||
For more information, visit Victor Valentim's GitHub page: https://github.com/vicvalentim. | ||
|
||
## License: | ||
ziviDomeLive is licensed under the Apache License, Version 2.0. See the LICENSE file for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
the data folder: | ||
If your Library is using files like images, sound files, | ||
any data file, etc., put them into the data folder. | ||
When coding your Library you can use processing's internal loading | ||
functions like loadImage(), loadStrings(), etc. to load files | ||
located inside the data folder into your Library. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#version 410 core | ||
|
||
uniform sampler2D equirectangularMap; | ||
uniform vec2 resolution; // Resolução da tela ou imagem de saída | ||
uniform float fov; // Campo de visão em graus, permitindo até 360 graus | ||
out vec4 fragColor; | ||
|
||
const float PI = 3.1415926535897932384626433832795; | ||
|
||
vec3 equirectangularToDir(vec2 uv) { | ||
float theta = uv.y * PI; // de 0 a PI | ||
float phi = uv.x * 2.0 * PI; // de 0 a 2*PI | ||
return vec3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta)); | ||
} | ||
|
||
void main() { | ||
vec2 uv = (gl_FragCoord.xy / resolution) * 2.0 - 1.0; | ||
uv.x = -uv.x; // Inverter a coordenada x para girar 180 graus no eixo horizontal | ||
float phi = atan(uv.y, uv.x); | ||
float l = length(uv); | ||
|
||
if (l > 1.0) { | ||
discard; | ||
} else { | ||
float maxTheta = radians(min(fov, 360.0)) / 2.0; | ||
float theta = l * maxTheta; | ||
|
||
vec2 sphericalUV = vec2((phi / (2.0 * PI)) + 0.5, theta / PI); | ||
sphericalUV = clamp(sphericalUV, 0.0, 1.0); // Garante que UV fique dentro dos limites | ||
|
||
vec3 dir = equirectangularToDir(sphericalUV); | ||
|
||
float u = 0.5 + atan(dir.x, dir.z) / (2.0 * PI); | ||
float v = 0.5 - asin(clamp(dir.y, -1.0, 1.0)) / PI; | ||
u = fract(u); // Garante repetição sem exceder limites | ||
v = clamp(v, 0.0, 1.0); // Evita acesso fora dos limites verticais | ||
|
||
vec4 color = texture(equirectangularMap, vec2(u, v)); | ||
fragColor = color; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#version 410 core | ||
|
||
const float PI = 3.1415926535897932384626433832795; | ||
|
||
uniform sampler2D posX, negX, posY, negY, posZ, negZ; | ||
uniform vec2 resolution; | ||
|
||
out vec4 fragColor; | ||
|
||
void convert_xyz_to_cube_uv(float x, float y, float z, out int index, out vec2 uv) { | ||
float absX = abs(x); | ||
float absY = abs(y); | ||
float absZ = abs(z); | ||
|
||
bool isXPositive = x > 0.0; | ||
bool isYPositive = y > 0.0; | ||
bool isZPositive = z > 0.0; | ||
|
||
float maxAxis, uc, vc; | ||
|
||
// Determine the major axis of projection | ||
if (isXPositive && absX >= absY && absX >= absZ) { | ||
maxAxis = absX; | ||
uc = -z; | ||
vc = y; | ||
index = 0; // +X | ||
} else if (!isXPositive && absX >= absY && absX >= absZ) { | ||
maxAxis = absX; | ||
uc = z; | ||
vc = y; | ||
index = 1; // -X | ||
} else if (isYPositive && absY >= absX && absY >= absZ) { | ||
maxAxis = absY; | ||
uc = x; | ||
vc = -z; | ||
index = 2; // +Y | ||
} else if (!isYPositive && absY >= absX && absY >= absZ) { | ||
maxAxis = absY; | ||
uc = x; | ||
vc = z; | ||
index = 3; // -Y | ||
} else if (isZPositive && absZ >= absX && absZ >= absY) { | ||
maxAxis = absZ; | ||
uc = x; | ||
vc = y; | ||
index = 4; // +Z | ||
} else { | ||
maxAxis = absZ; | ||
uc = -x; | ||
vc = y; | ||
index = 5; // -Z | ||
} | ||
|
||
uv = 0.5 * (vec2(uc, vc) / maxAxis + 1.0); | ||
} | ||
|
||
void main() { | ||
vec2 uv = gl_FragCoord.xy / resolution; | ||
float theta = uv.x * 2.0 * PI; // Horizontal angle | ||
float phi = uv.y * PI; // Vertical angle | ||
vec3 dir = vec3(sin(phi) * sin(theta), cos(phi), sin(phi) * cos(theta)); | ||
|
||
// Rotate 180 degrees around the vertical axis | ||
dir.x = -dir.x; | ||
dir.z = -dir.z; | ||
|
||
vec2 uvCube; | ||
int index; | ||
convert_xyz_to_cube_uv(dir.x, dir.y, dir.z, index, uvCube); | ||
|
||
switch(index) { | ||
case 0: fragColor = texture(posX, uvCube); break; | ||
case 1: fragColor = texture(negX, uvCube); break; | ||
case 2: fragColor = texture(posY, uvCube); break; | ||
case 3: fragColor = texture(negY, uvCube); break; | ||
case 4: fragColor = texture(posZ, uvCube); break; | ||
case 5: fragColor = texture(negZ, uvCube); break; | ||
default: fragColor = vec4(0.0); break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import com.victorvalentim.zividomelive.*; | ||
import controlP5.*; | ||
import codeanticode.syphon.*; | ||
import spout.*; | ||
|
||
// Instâncias principais | ||
zividomelive ziviDome; // Instância da biblioteca zividomelive | ||
Scene currentScene; // Cena atual que implementa a interface Scene | ||
|
||
void settings() { | ||
size(1280, 720, P3D); // Define o tamanho da janela e o modo P3D | ||
} | ||
|
||
void setup() { | ||
// Inicializa a biblioteca zividomelive | ||
ziviDome = new zividomelive(this); | ||
ziviDome.setup(); // Configuração inicial da biblioteca | ||
|
||
// Inicializa a cena e a define na biblioteca | ||
currentScene = new Scene1(ziviDome); | ||
ziviDome.setScene(currentScene); | ||
|
||
} | ||
|
||
void draw() { | ||
// Chama o método draw da biblioteca para processar renderizações adicionais | ||
ziviDome.draw(); | ||
} | ||
|
||
// Implementação da cena Scene1 que usa a interface Scene | ||
class Scene1 implements Scene { | ||
zividomelive parent; | ||
|
||
Scene1(zividomelive parent) { | ||
this.parent = parent; | ||
} | ||
|
||
@Override | ||
public void setupScene() { | ||
// Configurações específicas da cena, se necessário | ||
println("Setup da Scene1 concluído."); | ||
} | ||
|
||
@Override | ||
public void sceneRender(PGraphics pg) { | ||
pg.pushMatrix(); | ||
pg.background(0, 0, 80, 0); | ||
float radius = 700; // Distância do centro | ||
int numPillars = 8; | ||
float angleStep = TWO_PI / numPillars; | ||
int[] colors = {#FF0000, #00FF00, #0000FF, #FFFF00, #FF00FF, #00FFFF, #FFFFFF, #FF8000}; | ||
float time = millis() / 2000.0; // Tempo em segundos para animação | ||
for (int i = 0; i < numPillars; i++) { | ||
float angle = angleStep * i + time; // Adiciona a animação de rotação | ||
float x = sin(angle) * radius; | ||
float y = cos(angle) * radius; | ||
pg.pushMatrix(); | ||
pg.translate(x, y, 0); | ||
pg.rotateX(time); // Adiciona a rotação no eixo X | ||
pg.fill(colors[i]); | ||
pg.box(200); // Altere os parâmetros conforme a necessidade para ajustar o tamanho | ||
pg.popMatrix(); | ||
} | ||
pg.popMatrix(); | ||
} | ||
|
||
@Override | ||
public void keyPressed(char key) { | ||
// Implementar lógica de resposta a teclas, se necessário | ||
println("Tecla pressionada na Scene1: " + key); | ||
} | ||
} | ||
|
||
// Encaminha eventos de teclas para a biblioteca | ||
void keyPressed() { | ||
ziviDome.keyPressed(); | ||
// Opcional: chamar keyPressed da cena atual | ||
if (currentScene != null) { | ||
currentScene.keyPressed(key); | ||
} | ||
} | ||
|
||
// Encaminha eventos de mouse para a biblioteca | ||
void mouseEvent(processing.event.MouseEvent event) { | ||
ziviDome.mouseEvent(event); | ||
} | ||
|
||
// Encaminha eventos de controle para a biblioteca | ||
void controlEvent(controlP5.ControlEvent theEvent) { | ||
ziviDome.controlEvent(theEvent); | ||
} |
Oops, something went wrong.