Compare commits
No commits in common. "windows" and "master" have entirely different histories.
1
.gitignore
vendored
@ -91,4 +91,3 @@ Desktop.ini
|
|||||||
|
|
||||||
# Android
|
# Android
|
||||||
.csettings
|
.csettings
|
||||||
/.vs/Projekt_FORUM/v15
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"CurrentProjectSetting": "No Configurations"
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"ExpandedNodes": [
|
|
||||||
"",
|
|
||||||
"\\src"
|
|
||||||
],
|
|
||||||
"PreviewInSolutionExplorer": false
|
|
||||||
}
|
|
BIN
.vs/slnx.sqlite
@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LocalDebuggerWorkingDirectory>$(ProjectDir)/bin</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LocalDebuggerWorkingDirectory>$(ProjectDir)/bin</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LocalDebuggerWorkingDirectory>$(ProjectDir)/bin</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LocalDebuggerWorkingDirectory>$(ProjectDir)/bin</LocalDebuggerWorkingDirectory>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 2.5 KiB |
BIN
bin/data/Ohm.png
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 937 B |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 111 KiB |
@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"warps": [
|
|
||||||
{
|
|
||||||
"blend": {
|
|
||||||
"edges": "0, 0, 0.5, 0.5",
|
|
||||||
"exponent": 2.0,
|
|
||||||
"gamma": "1, 1, 1",
|
|
||||||
"luminance": "0.5, 0.5, 0.5"
|
|
||||||
},
|
|
||||||
"brightness": 1.0,
|
|
||||||
"type": 2,
|
|
||||||
"warp": {
|
|
||||||
"columns": 2,
|
|
||||||
"control points": [
|
|
||||||
"0, 0",
|
|
||||||
"1, 0",
|
|
||||||
"1, 1",
|
|
||||||
"0, 1"
|
|
||||||
],
|
|
||||||
"rows": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
#version 150
|
|
||||||
|
|
||||||
in vec2 vTexCoord;
|
|
||||||
in vec4 vColor;
|
|
||||||
|
|
||||||
out vec4 fragColor;
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
vec2 uv = vTexCoord * 2.0 - 1.0;
|
|
||||||
float d = dot(uv, uv);
|
|
||||||
float rim = smoothstep(0.7, 0.8, d);
|
|
||||||
rim += smoothstep(0.3, 0.4, d) - smoothstep(0.5, 0.6, d);
|
|
||||||
rim += smoothstep(0.1, 0.0, d);
|
|
||||||
fragColor = mix(vec4( 0.0, 0.0, 0.0, 0.25), vColor, rim);
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
#version 150
|
|
||||||
|
|
||||||
// OF default uniforms and attributes
|
|
||||||
uniform mat4 modelViewProjectionMatrix;
|
|
||||||
uniform vec4 globalColor;
|
|
||||||
|
|
||||||
in vec4 position;
|
|
||||||
in vec2 texcoord;
|
|
||||||
in vec4 color;
|
|
||||||
|
|
||||||
// App uniforms and attributes
|
|
||||||
in vec4 iPositionScale;
|
|
||||||
in vec4 iColor;
|
|
||||||
|
|
||||||
out vec2 vTexCoord;
|
|
||||||
out vec4 vColor;
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
vTexCoord = texcoord;
|
|
||||||
vColor = globalColor * iColor;
|
|
||||||
gl_Position = modelViewProjectionMatrix * vec4(position.xy * iPositionScale.z + iPositionScale.xy, position.zw);
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
#version 150
|
|
||||||
|
|
||||||
uniform sampler2D uTexture;
|
|
||||||
uniform vec4 uExtends;
|
|
||||||
uniform vec3 uLuminance;
|
|
||||||
uniform vec3 uGamma;
|
|
||||||
uniform vec4 uEdges;
|
|
||||||
uniform vec4 uCorners;
|
|
||||||
uniform float uExponent;
|
|
||||||
uniform bool uEditing;
|
|
||||||
|
|
||||||
in vec2 vTexCoord;
|
|
||||||
in vec4 vColor;
|
|
||||||
|
|
||||||
out vec4 fragColor;
|
|
||||||
|
|
||||||
float map(in float value, in float inMin, in float inMax, in float outMin, in float outMax)
|
|
||||||
{
|
|
||||||
return outMin + (outMax - outMin) * (value - inMin) / (inMax - inMin);
|
|
||||||
}
|
|
||||||
|
|
||||||
float grid(in vec2 uv, in vec2 size)
|
|
||||||
{
|
|
||||||
vec2 coord = uv / size;
|
|
||||||
vec2 grid = abs(fract(coord - 0.5) - 0.5) / (2.0 * fwidth(coord));
|
|
||||||
float line = min(grid.x, grid.y);
|
|
||||||
return 1.0 - min(line, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
vec4 texColor = texture(uTexture, vTexCoord);
|
|
||||||
|
|
||||||
vec2 mapCoord = vec2(map(vTexCoord.x, uCorners.x, uCorners.z, 0.0, 1.0), map(vTexCoord.y, uCorners.y, uCorners.w, 0.0, 1.0));
|
|
||||||
|
|
||||||
float a = 1.0;
|
|
||||||
if (uEdges.x > 0.0) a *= clamp(mapCoord.x / uEdges.x, 0.0, 1.0);
|
|
||||||
if (uEdges.y > 0.0) a *= clamp(mapCoord.y / uEdges.y, 0.0, 1.0);
|
|
||||||
if (uEdges.z > 0.0) a *= clamp((1.0 - mapCoord.x) / uEdges.z, 0.0, 1.0);
|
|
||||||
if (uEdges.w > 0.0) a *= clamp((1.0 - mapCoord.y) / uEdges.w, 0.0, 1.0);
|
|
||||||
|
|
||||||
const vec3 one = vec3(1.0);
|
|
||||||
vec3 blend = (a < 0.5) ? (uLuminance * pow(2.0 * a, uExponent)) : one - (one - uLuminance) * pow(2.0 * (1.0 - a), uExponent);
|
|
||||||
|
|
||||||
texColor.rgb *= pow(blend, one / uGamma);
|
|
||||||
|
|
||||||
if (uEditing)
|
|
||||||
{
|
|
||||||
float f = grid(mapCoord.xy * uExtends.xy, uExtends.zw);
|
|
||||||
vec4 gridColor = vec4(1.0f);
|
|
||||||
fragColor = mix(texColor * vColor, gridColor, f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fragColor = texColor * vColor;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
#version 150
|
|
||||||
|
|
||||||
// OF default uniforms and attributes
|
|
||||||
uniform mat4 modelViewProjectionMatrix;
|
|
||||||
uniform vec4 globalColor;
|
|
||||||
|
|
||||||
in vec4 position;
|
|
||||||
in vec2 texcoord;
|
|
||||||
in vec4 color;
|
|
||||||
|
|
||||||
// App uniforms and attributes
|
|
||||||
out vec2 vTexCoord;
|
|
||||||
out vec4 vColor;
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
vTexCoord = texcoord;
|
|
||||||
vColor = globalColor;
|
|
||||||
|
|
||||||
gl_Position = modelViewProjectionMatrix * position;
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
#version 150
|
|
||||||
|
|
||||||
uniform sampler2D uTexture;
|
|
||||||
uniform vec3 uLuminance;
|
|
||||||
uniform vec3 uGamma;
|
|
||||||
uniform vec4 uEdges;
|
|
||||||
uniform vec4 uCorners;
|
|
||||||
uniform float uExponent;
|
|
||||||
|
|
||||||
in vec2 vTexCoord;
|
|
||||||
in vec4 vColor;
|
|
||||||
|
|
||||||
out vec4 fragColor;
|
|
||||||
|
|
||||||
float map(in float value, in float inMin, in float inMax, in float outMin, in float outMax)
|
|
||||||
{
|
|
||||||
return outMin + (outMax - outMin) * (value - inMin) / (inMax - inMin);
|
|
||||||
}
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
vec4 texColor = texture(uTexture, vTexCoord);
|
|
||||||
|
|
||||||
vec2 mapCoord = vec2(map(vTexCoord.x, uCorners.x, uCorners.z, 0.0, 1.0), map(vTexCoord.y, uCorners.y, uCorners.w, 0.0, 1.0));
|
|
||||||
|
|
||||||
float a = 1.0;
|
|
||||||
if (uEdges.x > 0.0) a *= clamp(mapCoord.x / uEdges.x, 0.0, 1.0);
|
|
||||||
if (uEdges.y > 0.0) a *= clamp(mapCoord.y / uEdges.y, 0.0, 1.0);
|
|
||||||
if (uEdges.z > 0.0) a *= clamp((1.0 - mapCoord.x) / uEdges.z, 0.0, 1.0);
|
|
||||||
if (uEdges.w > 0.0) a *= clamp((1.0 - mapCoord.y) / uEdges.w, 0.0, 1.0);
|
|
||||||
|
|
||||||
const vec3 one = vec3(1.0);
|
|
||||||
vec3 blend = (a < 0.5) ? (uLuminance * pow(2.0 * a, uExponent)) : one - (one - uLuminance) * pow(2.0 * (1.0 - a), uExponent);
|
|
||||||
|
|
||||||
texColor.rgb *= pow(blend, one / uGamma);
|
|
||||||
|
|
||||||
fragColor = texColor * vColor;
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
#version 150
|
|
||||||
|
|
||||||
// OF default uniforms and attributes
|
|
||||||
uniform mat4 modelViewProjectionMatrix;
|
|
||||||
uniform vec4 globalColor;
|
|
||||||
|
|
||||||
in vec4 position;
|
|
||||||
in vec2 texcoord;
|
|
||||||
in vec4 color;
|
|
||||||
|
|
||||||
// App uniforms and attributes
|
|
||||||
out vec2 vTexCoord;
|
|
||||||
out vec4 vColor;
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
vTexCoord = texcoord;
|
|
||||||
vColor = globalColor;
|
|
||||||
|
|
||||||
gl_Position = modelViewProjectionMatrix * position;
|
|
||||||
}
|
|
Before Width: | Height: | Size: 28 KiB |
@ -1,10 +0,0 @@
|
|||||||
<default>
|
|
||||||
<sizeMin>0.05</sizeMin>
|
|
||||||
<sizeMax>4</sizeMax>
|
|
||||||
<mass>100</mass>
|
|
||||||
<drag>0</drag>
|
|
||||||
<maxLife>10</maxLife>
|
|
||||||
<velMin>-80</velMin>
|
|
||||||
<velMax>80</velMax>
|
|
||||||
<color></color>
|
|
||||||
</default>
|
|
@ -1,10 +0,0 @@
|
|||||||
<default>
|
|
||||||
<sizeMin>0.05</sizeMin>
|
|
||||||
<sizeMax>4</sizeMax>
|
|
||||||
<mass>100</mass>
|
|
||||||
<drag>0</drag>
|
|
||||||
<maxLife>10</maxLife>
|
|
||||||
<velMin>-80</velMin>
|
|
||||||
<velMax>80</velMax>
|
|
||||||
<color></color>
|
|
||||||
</default>
|
|
@ -1,10 +0,0 @@
|
|||||||
<default>
|
|
||||||
<sizeMin>0.05</sizeMin>
|
|
||||||
<sizeMax>4</sizeMax>
|
|
||||||
<mass>100</mass>
|
|
||||||
<drag>0</drag>
|
|
||||||
<maxLife>10</maxLife>
|
|
||||||
<velMin>-80</velMin>
|
|
||||||
<velMax>80</velMax>
|
|
||||||
<color></color>
|
|
||||||
</default>
|
|
@ -1,10 +0,0 @@
|
|||||||
<default>
|
|
||||||
<sizeMin>0.05</sizeMin>
|
|
||||||
<sizeMax>4</sizeMax>
|
|
||||||
<mass>100</mass>
|
|
||||||
<drag>0</drag>
|
|
||||||
<maxLife>10</maxLife>
|
|
||||||
<velMin>-80</velMin>
|
|
||||||
<velMax>80</velMax>
|
|
||||||
<color></color>
|
|
||||||
</default>
|
|
@ -1,10 +0,0 @@
|
|||||||
<default>
|
|
||||||
<sizeMin>0.05</sizeMin>
|
|
||||||
<sizeMax>4</sizeMax>
|
|
||||||
<mass>100</mass>
|
|
||||||
<drag>0</drag>
|
|
||||||
<maxLife>10</maxLife>
|
|
||||||
<velMin>-80</velMin>
|
|
||||||
<velMax>80</velMax>
|
|
||||||
<color></color>
|
|
||||||
</default>
|
|
@ -1,21 +0,0 @@
|
|||||||
<default>
|
|
||||||
<sizeMin>0.01</sizeMin>
|
|
||||||
<sizeMax>4.0</sizeMax>
|
|
||||||
<massMin>100</massMin>
|
|
||||||
<massMax>250</massMax>
|
|
||||||
<drag>0</drag>
|
|
||||||
<maxLife>ofRandom(maxAge - 5, maxAge)</maxLife>
|
|
||||||
<velMin>-80</velMin>
|
|
||||||
<velMax>80</velMax>
|
|
||||||
<color>(5, 241, 219)</color>
|
|
||||||
<age>0.0</age>
|
|
||||||
<valueToMoveToTop>0</valueToMoveToTop>
|
|
||||||
<valueToMoveToRight>0</valueToMoveToRight>
|
|
||||||
<counterToMoveParticlesToRight>70</counterToMoveParticlesToRight>
|
|
||||||
<particleLeftScene>false</particleLeftScene>
|
|
||||||
|
|
||||||
</default>
|
|
||||||
|
|
||||||
vel.set(ofRandom(-20.0, 20.0), ofRandom(-90, -100));
|
|
||||||
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
|||||||
// Created by Sebastian Holzki on 17.04.19.
|
// Created by Sebastian Holzki on 17.04.19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "avatar.h"
|
#include "avatar.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// avatar.h
|
// avatar.hpp
|
||||||
// emptyExample
|
// emptyExample
|
||||||
//
|
//
|
||||||
// Created by Sebastian Holzki on 17.04.19.
|
// Created by Sebastian Holzki on 17.04.19.
|
@ -1,159 +0,0 @@
|
|||||||
#include "drawableImage.h"
|
|
||||||
#include "images.h"
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
DrawableImage::DrawableImage(string imageName, float sceneSizeX, float sceneSizeY) {
|
|
||||||
//Color for symbol
|
|
||||||
redImageColor = 121;
|
|
||||||
greenImageColor = 205;
|
|
||||||
blueImageColor = 205;
|
|
||||||
|
|
||||||
pastMiddle = true;
|
|
||||||
fileImageHex.loadImage("Hexagon.png");
|
|
||||||
imageToDraw.loadImage(imageName);
|
|
||||||
fileImageHex = changeImageColor(fileImageHex, redImageColor, greenImageColor, blueImageColor);
|
|
||||||
imageToDraw = changeImageColor(imageToDraw, redImageColor, greenImageColor, blueImageColor);
|
|
||||||
xToMoveInCloud = ofRandom(1, 4);
|
|
||||||
yToMoveIntoCloud = 0;
|
|
||||||
ticksToMovePictureToRight = 150;
|
|
||||||
counterToMovePictureToRight = 0;
|
|
||||||
newMaxHeight = sceneSizeY - imageToDraw.getHeight() - 3;
|
|
||||||
imageHeight = imageToDraw.getHeight();
|
|
||||||
maxYpositionForPicture = setMaxHeightPosition(sceneSizeY);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
DrawableImage::~DrawableImage() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void DrawableImage::updateImage(float sceneSizeX, float sceneSizeY) {
|
|
||||||
|
|
||||||
if (cloudAttractorIsSet) {
|
|
||||||
doMovementOfImageAtCloud(maxYpositionForPicture, sceneSizeX, sceneSizeY);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (symbolAttractorIsSet) {
|
|
||||||
drawImage(sceneSizeX, sceneSizeY);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void DrawableImage::drawImage(float sceneSizeX, float sceneSizeY)
|
|
||||||
{
|
|
||||||
yToMoveIntoCloud = 0;
|
|
||||||
xToMoveInCloud = 0;
|
|
||||||
counterToMovePictureToRight = 0;
|
|
||||||
|
|
||||||
imageToDraw.draw((sceneSizeX / 2 - imageToDraw.getWidth() / 2), (sceneSizeY - imageToDraw.getHeight() - 5)); //Symbol at bottom
|
|
||||||
fileImageHex.draw((sceneSizeX / 2 - imageToDraw.getWidth() / 2), (sceneSizeY - imageToDraw.getHeight() - 5)); //Hexagon at bottom
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void DrawableImage::doMovementOfImageAtCloud(int maxYpositionForPicture, float sceneSizeX, float sceneSizeY)
|
|
||||||
{
|
|
||||||
if (yToMoveIntoCloud <= maxYpositionForPicture) { //y-Movement into cloud
|
|
||||||
yToMoveIntoCloud += 3;
|
|
||||||
}
|
|
||||||
else if (counterToMovePictureToRight < ticksToMovePictureToRight) {
|
|
||||||
counterToMovePictureToRight++;
|
|
||||||
}
|
|
||||||
else { //x-Movement in cloud
|
|
||||||
if (pastMiddle) { //from the middle to right: midpoint + x and x gets increased til its Scenesize
|
|
||||||
xToMoveInCloud += 3;
|
|
||||||
|
|
||||||
}
|
|
||||||
else { //From left to the middle: midpoint - x decreased til x is 0 again
|
|
||||||
xToMoveInCloud -= 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pastMiddle && xToMoveInCloud >= sceneSizeX / 2 + imageToDraw.getWidth()) { //Left from middle
|
|
||||||
pastMiddle = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pastMiddle && xToMoveInCloud <= 0) { //Rigth from middle
|
|
||||||
pastMiddle = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
imageToDraw.draw(getImagePosX(sceneSizeX), getImagePosY(sceneSizeY));
|
|
||||||
fileImageHex.draw(getImagePosX(sceneSizeX), getImagePosY(sceneSizeY));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int DrawableImage::setMaxHeightPosition(float sceneSizeY) // Array for max y-values (so that height of the hexagons fits together and can hook into one another in honeycomb structure)
|
|
||||||
{
|
|
||||||
for (float i = 0; i <= 4; i++) { //alculate the max y-values
|
|
||||||
newMaxHeight -= imageHeight / 2;
|
|
||||||
maxHeightPositions.push_back(newMaxHeight);
|
|
||||||
}
|
|
||||||
int rgen = ofRandom(0, 4);
|
|
||||||
return (int)maxHeightPositions.at(rgen); //random array position to choose random y-position
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
bool DrawableImage::imageIsOnTop(float sceneSizeY) { //see if symbol and particles reached cloud
|
|
||||||
|
|
||||||
return yToMoveIntoCloud >= maxYpositionForPicture;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
ofImage DrawableImage::changeImageColor(ofImage imageToDraw, int r, int g, int b) { //Processing the color information of the individual image pixels
|
|
||||||
int threshold = 1;
|
|
||||||
|
|
||||||
int picWidth = imageToDraw.getWidth();
|
|
||||||
int picHeight = imageToDraw.getHeight();
|
|
||||||
|
|
||||||
|
|
||||||
for (int x = 0; x < picWidth; x++) { //go through all pixel and set new rgb-values
|
|
||||||
for (int y = 0; y < picHeight; y++)
|
|
||||||
{
|
|
||||||
int index = (x + y * picWidth) * 4;
|
|
||||||
|
|
||||||
if (imageToDraw.getPixelsRef()[index + 3] >= threshold) {
|
|
||||||
imageToDraw.getPixelsRef()[index] = r;
|
|
||||||
imageToDraw.getPixelsRef()[index + 1] = g;
|
|
||||||
imageToDraw.getPixelsRef()[index + 2] = b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ofSetColor(255, 255, 255); //set color to white again so the colors don't distort themself
|
|
||||||
|
|
||||||
imageToDraw.update();
|
|
||||||
|
|
||||||
return imageToDraw;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
int DrawableImage::getHeight() {
|
|
||||||
return imageToDraw.getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
int DrawableImage::getWidth() {
|
|
||||||
return imageToDraw.getWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
int DrawableImage::getMaxHeight() {
|
|
||||||
return maxYpositionForPicture;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
float DrawableImage::getImagePosX(float sceneSizeX) {
|
|
||||||
if (pastMiddle)
|
|
||||||
return (sceneSizeX / 2 - imageToDraw.getWidth() / 2) + xToMoveInCloud;
|
|
||||||
else
|
|
||||||
return (sceneSizeX / 2 - imageToDraw.getWidth() / 2) - xToMoveInCloud;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
float DrawableImage::getImagePosY(float sceneSizeY) {
|
|
||||||
return (sceneSizeY - imageToDraw.getHeight() - 5) - yToMoveIntoCloud;
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
#ifndef drawableImage_h
|
|
||||||
#define drawableImage_h
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ofMain.h"
|
|
||||||
#include "ofxCv.h"
|
|
||||||
#include "ofxOpenCv.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DrawableImage
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DrawableImage(string imageName, float sceneSizeX, float sceneSizeY);
|
|
||||||
~DrawableImage();
|
|
||||||
|
|
||||||
ofColor color;
|
|
||||||
ofImage fileImageHex;
|
|
||||||
ofImage imageToDraw;
|
|
||||||
|
|
||||||
float maxLife;
|
|
||||||
float age;
|
|
||||||
float size;
|
|
||||||
float mass;
|
|
||||||
int yToMoveIntoCloud;
|
|
||||||
int xToMoveInCloud;
|
|
||||||
int maxYpositionForPicture;
|
|
||||||
int redImageColor;
|
|
||||||
int greenImageColor;
|
|
||||||
int blueImageColor;
|
|
||||||
int ticksToMovePictureToRight;
|
|
||||||
int counterToMovePictureToRight;
|
|
||||||
int imageHeight;
|
|
||||||
int newMaxHeight;
|
|
||||||
int getHeight();
|
|
||||||
int getWidth();
|
|
||||||
int getMaxHeight();
|
|
||||||
bool pL;
|
|
||||||
bool symbolAttractorIsSet;
|
|
||||||
bool cloudAttractorIsSet;
|
|
||||||
bool pastMiddle;
|
|
||||||
|
|
||||||
void updateImage(float sceneSizeX, float sceneSizeY);
|
|
||||||
void drawImage(float sceneSizeX, float sceneSizeY);
|
|
||||||
void doMovementOfImageAtCloud(int maxYpositionForPicture, float sceneSizeX, float sceneSizeY);
|
|
||||||
int setMaxHeightPosition(float sceneSizeY);
|
|
||||||
bool imageIsOnTop(float sceneSizeY);
|
|
||||||
float getImagePosX(float sceneSizeX);
|
|
||||||
float getImagePosY(float sceneSizeY);
|
|
||||||
vector<float>maxHeightPositions;
|
|
||||||
ofImage changeImageColor(ofImage imageToDraw, int r, int g, int b);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
#pragma once
|
|
80
src/greatWhole.cpp
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
//
|
||||||
|
// greatWhole.cpp
|
||||||
|
// emptyExample
|
||||||
|
//
|
||||||
|
// Created by Sebastian Holzki on 17.04.19.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "greatWhole.hpp"
|
||||||
|
#include "avatar.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GreatWhole::GreatWhole()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------
|
||||||
|
|
||||||
|
GreatWhole::~GreatWhole()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void GreatWhole::setup(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
void GreatWhole::update(vector<Avatar*> avatars){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
void GreatWhole::draw(){
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
draw the whole avatar vector
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
void GreatWhole::addAvatar(Avatar avatar){
|
||||||
|
|
||||||
|
|
||||||
|
// avatars.push_back(avatar);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Set coordinates in abhängigkeit vom letzten also bei avatars at (max-1)
|
||||||
|
clip avatar dann an den letzten, y und x angepasst an x und y von avatars.at(max-1)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
41
src/greatWhole.hpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
//
|
||||||
|
// greatWhole.hpp
|
||||||
|
// emptyExample
|
||||||
|
//
|
||||||
|
// Created by Sebastian Holzki on 17.04.19.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "ofMain.h"
|
||||||
|
#include "avatar.hpp"
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
/* Das Große Ganze beinhaltet eine unbestimmte Anzahl an bereits eingecheckten Personen, deren Infos in Avatare gespeichert werden.
|
||||||
|
Es bedarf eine setup(), update() und draw()-Methode. Dabei soll Platz für den vector<Avatar> geschaffen werden. In update wird eine
|
||||||
|
gewisse Bewegung der Avatar-"Bubbles" definiert. Draw zeichnet die Avatare auf die Stelen, also die entsprechenden Koordinaten. */
|
||||||
|
|
||||||
|
|
||||||
|
class GreatWhole {
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
GreatWhole();
|
||||||
|
~GreatWhole();
|
||||||
|
|
||||||
|
void setup();
|
||||||
|
void update(vector<Avatar*> avatars);
|
||||||
|
void draw();
|
||||||
|
|
||||||
|
void addAvatar(Avatar avatar);
|
||||||
|
Avatar getAvatarAt(int i);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
vector<Avatar*> avatars;
|
||||||
|
|
||||||
|
};
|
@ -1,236 +0,0 @@
|
|||||||
#include "imageParticleSystem.h"
|
|
||||||
|
|
||||||
|
|
||||||
ImageParticleSystem::ImageParticleSystem(int sceneSizeX, int sceneSizeY, ofImage fileImageHex, string imageName) {
|
|
||||||
this->imageToDraw = new DrawableImage(imageName, sceneSizeX, sceneSizeY);
|
|
||||||
this->imageHeight = imageToDraw->getHeight();
|
|
||||||
this->imageWidth = imageToDraw->getWidth();
|
|
||||||
|
|
||||||
this->sceneSizeX = sceneSizeX;
|
|
||||||
this->sceneSizeY = sceneSizeY;
|
|
||||||
|
|
||||||
this->fileImageHex = fileImageHex;
|
|
||||||
|
|
||||||
setAttractorsFromHexagonFromPicture();
|
|
||||||
maxParticle = 50;
|
|
||||||
|
|
||||||
setSymbolAttractorIsSet(true);
|
|
||||||
setCloudAttractorIsSet(false);
|
|
||||||
ticksToMoveImageToTop = 200;
|
|
||||||
counterToMoveImageToTop = 0;
|
|
||||||
fileImageCloud.loadImage("Hexagon.png");
|
|
||||||
|
|
||||||
imageReachedTopAndAttractorIsChanged = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
|
||||||
void ImageParticleSystem::updateParticleSystem() {
|
|
||||||
|
|
||||||
double deltaT = ofGetLastFrameTime();
|
|
||||||
time += deltaT;
|
|
||||||
|
|
||||||
if ((cloudAttractorIsSet == false) && (particles.size() < picPix / 7) && (this->imageToDraw->imageIsOnTop(sceneSizeY) == false)) { //Creating particles for symbol on bottom
|
|
||||||
createParticlesForHexagonInSymbol();
|
|
||||||
}
|
|
||||||
else if ((cloudAttractorIsSet == false) && (particles.size() < picPix / 7) && (this->imageToDraw->imageIsOnTop(sceneSizeY))) { //Creating particles for symbol in cloud
|
|
||||||
createParticlesForHexagonInCloud();
|
|
||||||
}
|
|
||||||
else if ((cloudAttractorIsSet == false) && (particles.size() > picPix / 7)) { //Deleting unused particles for hexagon on bottom
|
|
||||||
|
|
||||||
deleteParticlesForHexagon();
|
|
||||||
}
|
|
||||||
else if ((cloudAttractorIsSet == true) && (particles.size() > picPix / 7)) { //Deleting unused particles for rocketeffect
|
|
||||||
|
|
||||||
//deleteParticlesForRocketEffect();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Movement
|
|
||||||
for (int p = 0; p < particles.size(); p++) {
|
|
||||||
if (p * 7 < attractors.size()) {
|
|
||||||
if (cloudAttractorIsSet == true) { //Movement at rocketeffect
|
|
||||||
particles.at(p)->updateParticle(deltaT, attractors[p * 7],
|
|
||||||
cloudAttractorIsSet, this->imageToDraw->imageIsOnTop(sceneSizeY), true, imageHeight, imageWidth, sceneSizeX, sceneSizeY);
|
|
||||||
}
|
|
||||||
else if (symbolAttractorIsSet == true) //Movement at Symbol at the bottom
|
|
||||||
{
|
|
||||||
particles.at(p)->updateParticle(deltaT, attractors[p * 7],
|
|
||||||
cloudAttractorIsSet, this->imageToDraw->imageIsOnTop(sceneSizeY), true, imageHeight, imageWidth, sceneSizeX, sceneSizeY);
|
|
||||||
|
|
||||||
if (this->imageToDraw->imageIsOnTop(sceneSizeY)) //Deleting the particle after they left scene at right
|
|
||||||
{
|
|
||||||
deleteParticleAfterLeavingOntheRightAndCreateThemOnTheLeft(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (counterToMoveImageToTop < ticksToMoveImageToTop) { //Delay (every Frame) before the symbol and particle pass to the rocket effect
|
|
||||||
counterToMoveImageToTop++;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (counterToMoveImageToTop == ticksToMoveImageToTop) { //Symbol and particles do over in rocketeffect
|
|
||||||
changeAttractorImage(fileImageCloud);
|
|
||||||
setCloudAttractorIsSet(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->imageToDraw->imageIsOnTop(sceneSizeY)) { //Symbol and particles reached max. y-position and attractor gets changed from rocketeffect to hexagon
|
|
||||||
setAttractorsFromHexagonFromPicture();
|
|
||||||
cloudAttractorIsSet = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
|
||||||
void ImageParticleSystem::createParticlesForHexagonInSymbol()
|
|
||||||
{
|
|
||||||
int newPix = (picPix / 7) - particles.size();
|
|
||||||
for (int i = 1; i <= newPix; i++) { //Go through pixel i = 1 (there is no pixel 0)
|
|
||||||
particles.push_back(new Particle);
|
|
||||||
|
|
||||||
int x = sceneSizeX / 2;
|
|
||||||
int y = sceneSizeY;
|
|
||||||
|
|
||||||
particles.back()->setup(ofVec2f(x, y), 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
|
||||||
void ImageParticleSystem::createParticlesForHexagonInCloud()
|
|
||||||
{
|
|
||||||
int newPix = (picPix / 7) - particles.size();
|
|
||||||
for (int i = 1; i <= newPix; i++) { //Go through pixel i = 1 (there is no pixel 0)
|
|
||||||
particles.push_back(new Particle);
|
|
||||||
|
|
||||||
int x = sceneSizeX / 2;
|
|
||||||
int y = imageToDraw->getImagePosY(sceneSizeY) + imageHeight;
|
|
||||||
|
|
||||||
particles.back()->setup(ofVec2f(x, y), 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
|
||||||
void ImageParticleSystem::deleteParticlesForRocketEffect()
|
|
||||||
{
|
|
||||||
int newPix = (particles.size() - (picPix / 7));
|
|
||||||
for (int i = 0; i < newPix; i++) {
|
|
||||||
delete particles.at(0); //Deleting particle object
|
|
||||||
particles.erase(particles.begin()); //Deleting pointer to particle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
|
||||||
void ImageParticleSystem::deleteParticlesForHexagon()
|
|
||||||
{
|
|
||||||
int newPix = (particles.size() - (picPix / 7));
|
|
||||||
|
|
||||||
for (int i = 0; i < newPix; i++) {
|
|
||||||
delete particles.at(0); //Deleting particle object
|
|
||||||
particles.erase(particles.begin()); //Deleting pointer to particle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
|
||||||
void ImageParticleSystem::deleteParticleAfterLeavingOntheRightAndCreateThemOnTheLeft(int p)
|
|
||||||
{
|
|
||||||
bool particleToDelete = particles.at(p)->deleteAfterLeavingSceneX();
|
|
||||||
|
|
||||||
if (particleToDelete) {
|
|
||||||
|
|
||||||
delete particles.at(0); //Deleting particle object
|
|
||||||
particles.erase(particles.begin()); //Deleting pointer to particle
|
|
||||||
|
|
||||||
//Durchgehen ab Partikel i = 1 da es kein Pixel 0 gibt
|
|
||||||
particles.push_back(new Particle);
|
|
||||||
|
|
||||||
int x = -50;
|
|
||||||
int y = imageToDraw->getHeight();
|
|
||||||
|
|
||||||
particles.back()->setup(ofVec2f(x, y), 20);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
|
||||||
void ImageParticleSystem::changeAttractorImage(ofImage newAttractorImage) { //Attractor is changed between hexagon and cloud
|
|
||||||
attractors = pixelInVector(newAttractorImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
|
||||||
void ImageParticleSystem::setAttractorsFromHexagonFromPicture() { //Hexagon is attracot (pixel from hexagon get converted in attractors)
|
|
||||||
int picWidth = fileImageHex.getWidth();
|
|
||||||
int picHeight = fileImageHex.getHeight();
|
|
||||||
ofPixels pix;
|
|
||||||
pix = fileImageHex.getPixels();
|
|
||||||
vector<ofVec2f> pxPos;
|
|
||||||
picPix = 0;
|
|
||||||
for (int i = 3; i <= pix.size(); i += 4) { //i specifys that every fourth color information of the pixel is handled (rgba)
|
|
||||||
if (pix[i] > 0) {
|
|
||||||
int width = pix.getWidth();
|
|
||||||
|
|
||||||
int y = i / 4 / width;
|
|
||||||
|
|
||||||
int x = i / 4 % width;
|
|
||||||
|
|
||||||
ofVec2f vec;
|
|
||||||
|
|
||||||
vec.set(x + imageToDraw->getImagePosX(sceneSizeX), y + imageToDraw->getImagePosY(sceneSizeY)); //Gets position of image and so that the attractor follows movement
|
|
||||||
pxPos.push_back(vec);
|
|
||||||
|
|
||||||
picPix++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
attractors = pxPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
|
||||||
vector<ofVec2f> ImageParticleSystem::pixelInVector(ofImage a) { //Read in all the coloured pixels of image and vonvert them in vectors
|
|
||||||
int picWidth = a.getWidth();
|
|
||||||
int picHeight = a.getHeight();
|
|
||||||
ofPixels pix;
|
|
||||||
pix = a.getPixels();
|
|
||||||
vector<ofVec2f> pxPos;
|
|
||||||
picPix = 0;
|
|
||||||
for (int i = 3; i <= pix.size(); i += 4) { //i specifys that every fourth color information of the pixel is handled (rgba)
|
|
||||||
if (pix[i] > 0) {
|
|
||||||
int width = pix.getWidth();
|
|
||||||
|
|
||||||
int y = i / 4 / width;
|
|
||||||
|
|
||||||
int x = i / 4 % width;
|
|
||||||
|
|
||||||
ofVec2f vec;
|
|
||||||
|
|
||||||
vec.set(x + ((sceneSizeX / 2) - picWidth / 2), y - ((sceneSizeY)-picHeight - 7));
|
|
||||||
pxPos.push_back(vec);
|
|
||||||
|
|
||||||
picPix++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pxPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
|
||||||
void ImageParticleSystem::drawImageParticleSystem() { //Drawing of symbols and particles
|
|
||||||
|
|
||||||
imageToDraw->updateImage(sceneSizeX, sceneSizeY);
|
|
||||||
|
|
||||||
for (int i = 0; i < particles.size(); i++) {
|
|
||||||
particles.at(i)->draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
|
||||||
void ImageParticleSystem::setSymbolAttractorIsSet(bool value) {
|
|
||||||
|
|
||||||
imageToDraw->symbolAttractorIsSet = value;
|
|
||||||
symbolAttractorIsSet = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
|
||||||
void ImageParticleSystem::setCloudAttractorIsSet(bool value) {
|
|
||||||
|
|
||||||
imageToDraw->cloudAttractorIsSet = value;
|
|
||||||
cloudAttractorIsSet = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
|||||||
#ifndef imageParticleSystem_h
|
|
||||||
#define imageParticleSystem_h
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ofMain.h"
|
|
||||||
#include "ofxCv.h"
|
|
||||||
#include "ofxOpenCv.h"
|
|
||||||
#include "particle.h"
|
|
||||||
#include "drawableImage.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
class ImageParticleSystem
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
ImageParticleSystem(int sceneSizeX, int sceneSizeY, ofImage fileImageHex, string imageName);
|
|
||||||
~ImageParticleSystem();
|
|
||||||
|
|
||||||
vector<ofVec2f>attractors;
|
|
||||||
vector<Particle*> particles;
|
|
||||||
ofImage fileImageHex;
|
|
||||||
ofImage fileImageCloud;
|
|
||||||
|
|
||||||
int sceneSizeX;
|
|
||||||
int sceneSizeY;
|
|
||||||
int imageHeight;
|
|
||||||
int imageWidth;
|
|
||||||
int maxParticle;
|
|
||||||
int picPix;
|
|
||||||
int k;
|
|
||||||
int ticksToMoveImageToTop;
|
|
||||||
int counterToMoveImageToTop;
|
|
||||||
int status;
|
|
||||||
bool tornadoStarted;
|
|
||||||
bool editingWarp;
|
|
||||||
bool imageReachedTopAndAttractorIsChanged;
|
|
||||||
float birthCnt;
|
|
||||||
float maxLife;
|
|
||||||
float parAmount;
|
|
||||||
float height;
|
|
||||||
double time;
|
|
||||||
double tornadoStartTime;
|
|
||||||
|
|
||||||
void updateParticleSystem();
|
|
||||||
void deleteParticlesForRocketEffect();
|
|
||||||
void deleteParticlesForHexagon();
|
|
||||||
void createParticlesForHexagonInSymbol();
|
|
||||||
void createParticlesForHexagonInCloud();
|
|
||||||
void deleteParticleAfterLeavingOntheRightAndCreateThemOnTheLeft(int p);
|
|
||||||
void drawImageParticleSystem();
|
|
||||||
void setSymbolAttractorIsSet(bool value);
|
|
||||||
void setCloudAttractorIsSet(bool value);
|
|
||||||
void changeAttractorImage(ofImage newAttractorImage);
|
|
||||||
|
|
||||||
private:
|
|
||||||
DrawableImage* imageToDraw;
|
|
||||||
vector<ofVec2f> pixelInVector(ofImage a);
|
|
||||||
void setAttractorsFromHexagonFromPicture();
|
|
||||||
bool symbolAttractorIsSet;
|
|
||||||
bool cloudAttractorIsSet;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
#pragma once
|
|
10
src/main.cpp
@ -5,13 +5,11 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
int main( ){
|
int main( ){
|
||||||
|
|
||||||
ofGLFWWindowSettings settings;
|
|
||||||
settings.setGLVersion(3, 2);
|
|
||||||
settings.setSize(1280, 800);
|
|
||||||
ofCreateWindow(settings);
|
|
||||||
ofSetupOpenGL(1000,1000, OF_WINDOW); // <-------- setup the GL context
|
ofSetupOpenGL(1000,1000, OF_WINDOW); // <-------- setup the GL context
|
||||||
|
|
||||||
|
// this kicks off the running of my app
|
||||||
|
// can be OF_WINDOW or OF_FULLSCREEN
|
||||||
|
// pass in width and height too:
|
||||||
ofRunApp( new ofApp());
|
ofRunApp( new ofApp());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// Created by Sebastian Holzki on 11.06.19.
|
// Created by Sebastian Holzki on 11.06.19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "objectPhysics.h"
|
#include "objectPhysics.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -34,6 +34,17 @@ Attraktor::Attraktor(){
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// -----------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
//
|
//
|
||||||
// objectPhysics.h
|
// objectPhysics.hpp
|
||||||
// emptyExample
|
// emptyExample
|
||||||
//
|
//
|
||||||
// Created by Sebastian Holzki on 01.05.19.
|
// Created by Sebastian Holzki on 01.05.19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef objectPhysics_h
|
#ifndef objectPhysics_hpp
|
||||||
#define objectPhysics_h
|
#define objectPhysics_hpp
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "ofMain.h"
|
#include "ofMain.h"
|
||||||
#endif /* objectPhysics_h */
|
#endif /* objectPhysics_hpp */
|
||||||
|
|
||||||
|
|
||||||
class ObjectPhysics {
|
class ObjectPhysics {
|
144
src/ofApp.cpp
@ -8,66 +8,18 @@
|
|||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
void ofApp::setup(){
|
void ofApp::setup(){
|
||||||
|
|
||||||
currentImage = -1;
|
|
||||||
ofDisableArbTex();
|
|
||||||
ofBackground(0);
|
|
||||||
|
|
||||||
//test image
|
|
||||||
img.setUseTexture(false);
|
|
||||||
if (!img.load("testcard.png"))
|
|
||||||
{
|
|
||||||
ofLogError("ofApp::setup") << "Could not load image!";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->tex.enableMipmap();
|
|
||||||
this->tex.loadData(img.getPixels());
|
|
||||||
|
|
||||||
//scene properties
|
|
||||||
sceneSize.set(1280, 800);
|
|
||||||
area.set(0, 0, sceneSize.x, sceneSize.y);
|
|
||||||
fbo.allocate(sceneSize.x, sceneSize.y, GL_RGBA);
|
|
||||||
|
|
||||||
//clear fbo to make sure there's no scrap
|
|
||||||
fbo.begin();
|
|
||||||
ofClear(0);
|
|
||||||
fbo.end();
|
|
||||||
|
|
||||||
//load warp settings from file if present
|
|
||||||
//this->warpController.loadSettings("settings.json");
|
|
||||||
|
|
||||||
//if there is no file, generate warp
|
|
||||||
if (this->warpController.getWarps().empty())
|
|
||||||
{
|
|
||||||
std::shared_ptr<ofxWarpBase> warp;
|
|
||||||
|
|
||||||
warp = this->warpController.buildWarp<ofxWarpPerspective>();
|
|
||||||
warp->setSize(sceneSize.x, sceneSize.y);
|
|
||||||
warp->setEdges(glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
|
|
||||||
}
|
|
||||||
|
|
||||||
editingWarp = false;
|
|
||||||
|
|
||||||
//testing stuff
|
|
||||||
ofSetCircleResolution(60);
|
|
||||||
ofSetBackgroundColor(0, 0, 0);
|
|
||||||
//ofSetFrameRate(60);
|
|
||||||
|
|
||||||
fileImageHex.loadImage("Hexagon.png");
|
|
||||||
|
|
||||||
//rainIsActive = true;
|
|
||||||
//int particleSystemsForStele = 7; //number of rainparticlesystems (one for single stele)
|
|
||||||
//float sceneSizeForSingleParticleSystem = sceneSize.x / particleSystemsForStele; //calculate the widht for every single rainparticlesystem
|
|
||||||
//for (int i = 0; i <= particleSystemsForStele - 1; i++) { //create all rainparticlesystem
|
|
||||||
// rainParticleSyst.push_back(new RainParticleSystem(i * sceneSizeForSingleParticleSystem, sceneSizeForSingleParticleSystem, sceneSize.y));
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
VISITOR_COUNT = 0;
|
VISITOR_COUNT = 0;
|
||||||
VISITOR_COUNT_LASTFRAME = 0;
|
VISITOR_COUNT_LASTFRAME = 0;
|
||||||
PARTICLE_COUNT = 0;
|
PARTICLE_COUNT = 0;
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < particleSystems.size(); i++){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// *** OSC Setup *** OSC Setup *** OSC Setup ***
|
// *** OSC Setup *** OSC Setup *** OSC Setup ***
|
||||||
|
|
||||||
receiver.setup(PORT);
|
receiver.setup(PORT);
|
||||||
@ -78,7 +30,6 @@ void ofApp::setup() {
|
|||||||
void ofApp::update(){
|
void ofApp::update(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// *** OSC RECEIVER *** OSC RECEIVER *** OSC RECEIVER ***
|
// *** OSC RECEIVER *** OSC RECEIVER *** OSC RECEIVER ***
|
||||||
|
|
||||||
|
|
||||||
@ -196,39 +147,18 @@ void ofApp::update() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rainIsActive) { //Movement of the particles of the rainparticlesystems
|
|
||||||
for (int i = 0; i < rainParticleSyst.size(); i++) {
|
|
||||||
rainParticleSyst.at(i)->updateParticleSystem();
|
} //end of update()
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!rainIsActive){ //Movement of Imageparticlesystems and symbols when rain is false
|
|
||||||
for (int i = 0; i < imageParticleSystems.size(); i++) {
|
|
||||||
imageParticleSystems.at(i)->updateParticleSystem();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void ofApp::exit() {
|
|
||||||
//save warp settings on exit
|
|
||||||
this->warpController.saveSettings("settings.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
void ofApp::draw(){
|
void ofApp::draw(){
|
||||||
|
|
||||||
|
|
||||||
fbo.begin();
|
//draw all ParticleSystems that are in the particleSystems vector
|
||||||
ofClear(0, 0, 0);
|
|
||||||
//draw stuff here
|
|
||||||
|
|
||||||
//ofDrawRectangle(0, 0, 800, 800);
|
|
||||||
//ofDrawCircle(sceneSize.x *.5, sceneSize.y * .5, 300);
|
|
||||||
|
|
||||||
for(int p = 0; p < particleSystems.size(); p++)
|
for(int p = 0; p < particleSystems.size(); p++)
|
||||||
{
|
{
|
||||||
@ -236,29 +166,6 @@ void ofApp::draw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (rainIsActive) { //drawing the rainparticlesystems
|
|
||||||
for (int i = 0; i < rainParticleSyst.size(); i++) {
|
|
||||||
rainParticleSyst.at(i)->drawRainParticleSystem();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!rainIsActive) { //drawing the imageparticlesystems
|
|
||||||
for (int i = 0; i < imageParticleSystems.size(); i++) {
|
|
||||||
imageParticleSystems.at(i)->drawImageParticleSystem();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//draw all ParticleSystems that are in the particleSystems vector
|
|
||||||
|
|
||||||
|
|
||||||
fbo.end();
|
|
||||||
|
|
||||||
//do not draw past this point
|
|
||||||
//draw warp
|
|
||||||
warpController.getWarp(0)->begin();
|
|
||||||
fbo.draw(0, 0);
|
|
||||||
|
|
||||||
warpController.getWarp(0)->end();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
@ -268,36 +175,7 @@ void ofApp::keyPressed(int key) {
|
|||||||
|
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
void ofApp::keyReleased(int key){
|
void ofApp::keyReleased(int key){
|
||||||
if (key == 'f') //fullscreen
|
|
||||||
{
|
|
||||||
ofToggleFullscreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key == 'e') { //Mapping
|
|
||||||
editingWarp = !editingWarp;
|
|
||||||
warpController.getWarp(0)->setEditing(editingWarp);
|
|
||||||
}
|
|
||||||
|
|
||||||
//read in the single images and hand over all initial values
|
|
||||||
switch (key) {
|
|
||||||
case '1':
|
|
||||||
imageParticleSystems.push_back(new ImageParticleSystem(sceneSize.x, sceneSize.y, fileImageHex, "PktUmweltTechnik.png"));
|
|
||||||
rainIsActive = false;
|
|
||||||
currentImage++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '2':
|
|
||||||
imageParticleSystems.push_back(new ImageParticleSystem(sceneSize.x, sceneSize.y, fileImageHex, "PktAlltagTechnikUmwelt.png"));
|
|
||||||
rainIsActive = false;
|
|
||||||
currentImage++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '3':
|
|
||||||
imageParticleSystems.push_back(new ImageParticleSystem(sceneSize.x, sceneSize.y, fileImageHex, "PktAlltagWissenschaftUmwelt.png"));
|
|
||||||
rainIsActive = false;
|
|
||||||
currentImage++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
|
59
src/ofApp.h
@ -1,25 +1,17 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ofxWarp.h"
|
|
||||||
|
|
||||||
#include "particle.h"
|
|
||||||
#include "drawableImage.h"
|
|
||||||
#include "imageParticleSystem.h"
|
|
||||||
#include "rainParticleSystem.h"
|
|
||||||
#include "ofMain.h"
|
#include "ofMain.h"
|
||||||
#include "particleSystem.h"
|
#include "particleSystem.hpp"
|
||||||
#include "avatar.h"
|
#include "greatWhole.hpp"
|
||||||
|
#include "avatar.hpp"
|
||||||
#include "ofxOsc.h"
|
#include "ofxOsc.h"
|
||||||
#include "visitor.h"
|
#include "visitor.hpp"
|
||||||
#include "objectPhysics.h"
|
#include "objectPhysics.hpp"
|
||||||
#include "particle.h"
|
#include "particle.hpp"
|
||||||
#include "ofxOpenCv.h"
|
|
||||||
#include "ofTrueTypeFont.h"
|
|
||||||
#include "ofxCv.h"
|
|
||||||
|
|
||||||
|
|
||||||
//int WINDOWSIZE_WIDTH = 1000;
|
int WINDOWSIZE_WIDTH = 1000;
|
||||||
//int WINDOWSIZE_HEIGHT = 1000;
|
int WINDOWSIZE_HEIGHT = 1000;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +31,7 @@ public:
|
|||||||
void setup();
|
void setup();
|
||||||
void update();
|
void update();
|
||||||
void draw();
|
void draw();
|
||||||
void exit();
|
|
||||||
void keyPressed(int key);
|
void keyPressed(int key);
|
||||||
void keyReleased(int key);
|
void keyReleased(int key);
|
||||||
void mouseMoved(int x, int y);
|
void mouseMoved(int x, int y);
|
||||||
@ -74,38 +66,6 @@ private:
|
|||||||
|
|
||||||
int nBlobs; //count of the tracked visitors
|
int nBlobs; //count of the tracked visitors
|
||||||
|
|
||||||
// *** warp *** warp
|
|
||||||
ofxWarpController warpController;
|
|
||||||
ofTexture tex;
|
|
||||||
ofRectangle area;
|
|
||||||
ofVec2f sceneSize;
|
|
||||||
ofVec2f force;
|
|
||||||
|
|
||||||
ofImage img;
|
|
||||||
ofImage fileImageHex;
|
|
||||||
ofImage imageToDraw;
|
|
||||||
|
|
||||||
ofImage drawImage;
|
|
||||||
|
|
||||||
ofColor color;
|
|
||||||
|
|
||||||
ofFbo fbo;
|
|
||||||
|
|
||||||
vector<ofVec2f>attractors;
|
|
||||||
vector<Particle*> system;
|
|
||||||
|
|
||||||
vector<ImageParticleSystem*> imageParticleSystems;
|
|
||||||
vector<RainParticleSystem*> rainParticleSyst;
|
|
||||||
|
|
||||||
int currentImage;
|
|
||||||
int maxParticle;
|
|
||||||
int picPix;
|
|
||||||
int k;
|
|
||||||
int ticksToMoveParticlesToRight;
|
|
||||||
int counterToMoveParticlesToRight;
|
|
||||||
bool rainIsActive;
|
|
||||||
bool editingWarp;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -114,6 +74,7 @@ private:
|
|||||||
|
|
||||||
vector<ParticleSystem*> particleSystems;
|
vector<ParticleSystem*> particleSystems;
|
||||||
|
|
||||||
|
GreatWhole dasGrosseGanze;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
199
src/particle.cpp
@ -5,7 +5,7 @@
|
|||||||
// Created by Sebastian Holzki on 16.04.19.
|
// Created by Sebastian Holzki on 16.04.19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "particle.h"
|
#include "particle.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -23,228 +23,50 @@ Particle::~Particle()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
|
|
||||||
void Particle::setup(ofVec2f pos, float maxAge) {
|
|
||||||
|
|
||||||
this->position = pos; //Pointer to Position ofVec2f position
|
|
||||||
|
void Particle::setup(ofVec2f _position){
|
||||||
|
|
||||||
|
this->position = _position;
|
||||||
|
|
||||||
velocity.set(0,0);
|
velocity.set(0,0);
|
||||||
//vel.set(ofRandom(-20.0, 20.0), ofRandom(-90, -100)); //Movement direction
|
|
||||||
age = 0.0;
|
age = 0.0;
|
||||||
maxLife = 12.0;
|
maxLife = 12.0;
|
||||||
//maxLife = ofRandom(maxAge - 5, maxAge); //Max life of a particle
|
|
||||||
color.set(5, 241, 219);
|
color.set(250,250,250);
|
||||||
//size = 2.0;
|
size = 2.0;
|
||||||
//mass = 100;
|
mass = 100;
|
||||||
size = ofRandom(4.0, 0.01);
|
|
||||||
mass = ofRandom(100, 250); //Changes the particle velocity
|
|
||||||
valueToMoveToTop = 0; //Counter which causes the particle and the attractor to move to top
|
|
||||||
valueToMoveToRight = 0; //Counter which causes the particle and the attractor to move to right
|
|
||||||
ticksToMoveParticlesToRight = 70; //Framerate for movement velocity
|
|
||||||
counterToMoveParticlesToRight = 0; //Counter for delay on top
|
|
||||||
particleLeftScene = false; //Particle are out of ScenesizeX on the right side
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
|
|
||||||
void Particle::update(float deltaT){
|
void Particle::update(float deltaT){
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void Particle::updateParticle(double deltaT, ofVec2f attractor, bool cloudAttractorIsSet, bool imageIsOnTop, bool tornadoIsFinished, int imageHeight, int imageWidth, float sceneSizeX, float sceneSizeY) {
|
|
||||||
|
|
||||||
//Movement of particle in the different settings
|
|
||||||
|
|
||||||
//doMovementOfParticlesAtRain(tornadoIsFinished, deltaT, sceneSizeX);
|
|
||||||
|
|
||||||
if (cloudAttractorIsSet == true) {
|
|
||||||
doMovementOfParticlesAtRocketEffect(sceneSizeY, imageHeight, imageWidth, sceneSizeX, attractor, deltaT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tornadoIsFinished == true && cloudAttractorIsSet == false) {
|
|
||||||
doMovementOfParticlesAtSymbols(deltaT, attractor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (imageIsOnTop == true) {
|
|
||||||
doMovementOfHexagonOnTheTop(attractor, sceneSizeX, deltaT);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void Particle::doMovementOfParticlesAtRain(bool tornadoIsFinished, double deltaT, float sceneSizeX)
|
|
||||||
{
|
|
||||||
if (tornadoIsFinished == false) { //Movement of partile from bottom to top
|
|
||||||
position += vel * deltaT;
|
|
||||||
age += deltaT;
|
|
||||||
|
|
||||||
if (position.x >= sceneSizeX) {
|
|
||||||
position.x = ofRandom(-1, -5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void Particle::doMovementOfParticlesAtSymbols(double deltaT, ofVec2f &attractor)
|
|
||||||
{
|
|
||||||
valueToMoveToTop = 0;
|
|
||||||
valueToMoveToRight = 0;
|
|
||||||
counterToMoveParticlesToRight = 0;
|
|
||||||
|
|
||||||
age += deltaT;
|
|
||||||
vel *= 0.1;
|
|
||||||
ofVec2f force = attractor - position; //Attraction
|
|
||||||
|
|
||||||
if (50 < force.length() < 150) { //Movement of the particle which is located at a radius of 50 to 150 around the attractor
|
|
||||||
force = 10 * force.getNormalized();
|
|
||||||
|
|
||||||
vel += force; //Movement to attractor
|
|
||||||
vel = mass * vel.getNormalized();
|
|
||||||
}
|
|
||||||
else if (150 < force.length() < 500) { //Movement of the particle which is located at a radius of 150 to 500 around the attractor
|
|
||||||
force = 8 * force.getNormalized();
|
|
||||||
|
|
||||||
vel += force;
|
|
||||||
vel = mass * vel.getNormalized();
|
|
||||||
}
|
|
||||||
else { //Movement of the particle which is located at a radius more than 500 around the attractor
|
|
||||||
force = 2 * force.getNormalized();
|
|
||||||
vel += force;
|
|
||||||
vel = mass / 1.2* vel.getNormalized();
|
|
||||||
}
|
|
||||||
position += (vel / 1.5 * deltaT); //Position = m/s * s [particle placed static]
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void Particle::doMovementOfParticlesAtRocketEffect(float sceneSizeY, int imageHeight, int imageWidth, float sceneSizeX, ofVec2f &attractor, double deltaT)
|
|
||||||
{
|
|
||||||
int y = ((sceneSizeY / 2) + imageHeight); //Beginning height for attractor
|
|
||||||
int x = ofRandom(sceneSizeX / 2 - imageWidth / 2, sceneSizeX / 2 + imageWidth / 2); //Width for attractor
|
|
||||||
|
|
||||||
if (y - valueToMoveToTop - imageHeight > 200) { //Increase counter depending on velocity for movement to top
|
|
||||||
valueToMoveToTop += 3; //Movement by 3 to top (pro Frame)
|
|
||||||
}
|
|
||||||
else if (y - valueToMoveToTop - imageHeight > 10) { //Increase counter depending on velocity for movement to top
|
|
||||||
valueToMoveToTop += 2; //Movement by 3 to top (pro Frame)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (counterToMoveParticlesToRight < ticksToMoveParticlesToRight) { //Delay on top
|
|
||||||
counterToMoveParticlesToRight++;
|
|
||||||
}
|
|
||||||
else if (y - valueToMoveToTop - imageHeight <= 10) { //Increase counter depending on velocity for movement to right( Movement by 3 to right (pro Frame))
|
|
||||||
valueToMoveToRight += 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
attractor.set(x + valueToMoveToRight, y - valueToMoveToTop);
|
|
||||||
|
|
||||||
|
|
||||||
age += deltaT;
|
|
||||||
vel *= 0.1;
|
|
||||||
ofVec2f force = (attractor - position); //Attraction
|
|
||||||
|
|
||||||
if (30 < force.length() < 150) { //Movement of the particle which is located at a radius of 30 to 150 around the attractor
|
|
||||||
force = 17 * force.getNormalized();
|
|
||||||
|
|
||||||
vel += force; //Movement to attractor
|
|
||||||
vel = (mass / 1.2) * vel.getNormalized(); //Particle don't pass the symbol
|
|
||||||
}
|
|
||||||
else if (150 < force.length() < 250) { //Movement of the particle which is located at a radius of 150 to 250 around the attractor
|
|
||||||
force = 14 * force.getNormalized();
|
|
||||||
|
|
||||||
vel += force;
|
|
||||||
vel = mass * 10 * vel.getNormalized();
|
|
||||||
}
|
|
||||||
else if (250 < force.length() < 500) { //Movement of the particle which is located at a radius of 250 to 500 around the attractor
|
|
||||||
force = 14 * force.getNormalized();
|
|
||||||
|
|
||||||
vel += force;
|
|
||||||
vel = mass * 4 * vel.getNormalized();
|
|
||||||
}
|
|
||||||
else { //Movement of the particle which is located at a radius more than 500 around the attractor
|
|
||||||
force = 20 * force.getNormalized();
|
|
||||||
vel += force;
|
|
||||||
vel = mass * vel.getNormalized();
|
|
||||||
}
|
|
||||||
position += (vel / 1.7 * deltaT); //Position = m/s * s [particle placed static]
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void Particle::doMovementOfHexagonOnTheTop(ofVec2f &attractor, float sceneSizeX, double deltaT)
|
|
||||||
{
|
|
||||||
if (attractor.x + valueToMoveToRight >= sceneSizeX + 120) {
|
|
||||||
particleLeftScene = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
particleLeftScene = false;
|
|
||||||
}
|
|
||||||
age += deltaT;
|
|
||||||
vel *= 0.1;
|
|
||||||
ofVec2f force = attractor - position; //Attraction
|
|
||||||
|
|
||||||
if (50 < force.length() < 150) { //Movement of the particle which is located at a radius of 50 to 150 around the attractor
|
|
||||||
force = 60 * force.getNormalized(); //Anziehungskraft des Attraktors auf die Partikel
|
|
||||||
|
|
||||||
vel += force; //Bewegung zum Attraktor
|
|
||||||
vel = mass * vel.getNormalized();
|
|
||||||
}
|
|
||||||
else { //Movement of the particle which is located at a radius of more than 150 around the attractor
|
|
||||||
force = 100 * force.getNormalized();
|
|
||||||
|
|
||||||
vel += force;
|
|
||||||
vel = mass / 2 * vel.getNormalized();
|
|
||||||
}
|
|
||||||
position += (vel * deltaT); //Position = m/s * s [particle placed static]
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
|
|
||||||
void Particle::draw(){
|
void Particle::draw(){
|
||||||
if (position.x > 0 || position.x < 300) {
|
|
||||||
ofSetColor(this->color); //To make particle turquoise
|
|
||||||
color.set(getAgeNorm() * 241, 241 / getAgeNorm(), 219); //Color (Disco)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ofSetColor(255, 255, 255);
|
|
||||||
|
|
||||||
}
|
|
||||||
ofDrawCircle(position,size);
|
ofDrawCircle(position,size);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
float Particle::getAgeNorm() {
|
|
||||||
return age / maxLife;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
float Particle::deleteAfterLeavingSceneY() {
|
|
||||||
return position.y < 0 || position.y > ofGetHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
bool Particle::deleteAfterLeavingSceneX() {
|
|
||||||
return particleLeftScene;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
void Particle::setMode(particleMode newMode) {
|
|
||||||
mode = newMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
|
|
||||||
float Particle::getMaxLife(){
|
float Particle::getMaxLife(){
|
||||||
|
|
||||||
return maxLife;
|
return maxLife;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
@ -252,6 +74,7 @@ float Particle::getMaxLife() {
|
|||||||
float Particle::getAge(){
|
float Particle::getAge(){
|
||||||
|
|
||||||
return age;
|
return age;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
#ifndef particle_h
|
|
||||||
#define particle_h
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ofMain.h"
|
|
||||||
#include "ofxCv.h"
|
|
||||||
#include "ofxXmlSettings.h"
|
|
||||||
#include "ofxOpenCv.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
|
||||||
enum particleMode {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class Particle {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Particle();
|
|
||||||
~Particle();
|
|
||||||
|
|
||||||
void update(float deltaT);
|
|
||||||
void draw();
|
|
||||||
void mapParticle();
|
|
||||||
void setup(ofVec2f pos, float maxAge);
|
|
||||||
void updateParticle(double deltaT, ofVec2f attractor, bool cloudAttractorIsSet, bool imageIsOnTop, bool tornadoIsFinished, int imageHeight, int imageWidth, float sceneSizeX, float sceneSizeY);
|
|
||||||
void doMovementOfParticlesAtRain(bool tornadoIsFinished, double deltaT, float sceneSizeX);
|
|
||||||
void doMovementOfParticlesAtSymbols(double deltaT, ofVec2f &attractor);
|
|
||||||
void doMovementOfParticlesAtRocketEffect(float sceneSizeY, int imageHeight, int imageWidth, float sceneSizeX, ofVec2f &attractor, double deltaT);
|
|
||||||
void doMovementOfHexagonOnTheTop(ofVec2f &attractor, float sceneSizeX, double deltaT);
|
|
||||||
void setMode(particleMode newMode);
|
|
||||||
|
|
||||||
float getMaxLife();
|
|
||||||
float getAge();
|
|
||||||
float getAgeNorm();
|
|
||||||
bool borderCollission();
|
|
||||||
|
|
||||||
ofVec2f vel;
|
|
||||||
ofVec2f velocity2;
|
|
||||||
ofVec2f force;
|
|
||||||
|
|
||||||
particleMode mode;
|
|
||||||
|
|
||||||
float deleteAfterLeavingSceneY();
|
|
||||||
bool deleteAfterLeavingSceneX();
|
|
||||||
bool pL;
|
|
||||||
bool particleLeftScene;
|
|
||||||
|
|
||||||
int valueToMoveToTop;
|
|
||||||
int valueToMoveToRight;
|
|
||||||
int ticksToMoveParticlesToRight;
|
|
||||||
int counterToMoveParticlesToRight;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
ofVec2f velocity;
|
|
||||||
ofVec2f position;
|
|
||||||
|
|
||||||
float maxLife;
|
|
||||||
float age;
|
|
||||||
float size;
|
|
||||||
float mass;
|
|
||||||
|
|
||||||
ofColor color;
|
|
||||||
|
|
||||||
|
|
||||||
int stele;
|
|
||||||
//on which "stele" is the particle? --> will affect the movement (mapping), when it reaches borders of its "stele" !
|
|
||||||
//if border 1/2/3/4 (<,>,v,^), then map particle
|
|
||||||
|
|
||||||
};
|
|
||||||
#endif
|
|
54
src/particle.hpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
//
|
||||||
|
// particle.hpp
|
||||||
|
//
|
||||||
|
// Created by Sebastian Holzki on 16.04.19.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "ofMain.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Particle {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Particle();
|
||||||
|
~Particle();
|
||||||
|
|
||||||
|
void setup(ofVec2f position);
|
||||||
|
void update(float deltaT);
|
||||||
|
void draw();
|
||||||
|
|
||||||
|
float getMaxLife();
|
||||||
|
float getAge();
|
||||||
|
float getAgeNorm();
|
||||||
|
|
||||||
|
|
||||||
|
void mapParticle();
|
||||||
|
bool borderCollission();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
ofVec2f velocity;
|
||||||
|
ofVec2f position;
|
||||||
|
|
||||||
|
float maxLife;
|
||||||
|
float age;
|
||||||
|
float size;
|
||||||
|
float mass;
|
||||||
|
|
||||||
|
ofColor color;
|
||||||
|
|
||||||
|
|
||||||
|
int stele;
|
||||||
|
//on which "stele" is the particle? --> will affect the movement (mapping), when it reaches borders of its "stele" !
|
||||||
|
//if border 1/2/3/4 (<,>,v,^), then map particle
|
||||||
|
|
||||||
|
};
|
@ -5,7 +5,7 @@
|
|||||||
// Created by Sebastian Holzki on 16.04.19.
|
// Created by Sebastian Holzki on 16.04.19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "particleSystem.h"
|
#include "particleSystem.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// particleSystem.h
|
// particleSystem.hpp
|
||||||
// emptyExample
|
// emptyExample
|
||||||
//
|
//
|
||||||
// Created by Sebastian Holzki on 16.04.19.
|
// Created by Sebastian Holzki on 16.04.19.
|
||||||
@ -10,7 +10,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#include "particle.h"
|
#include "particle.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
|||||||
#include "rainParticleSystem.h"
|
|
||||||
|
|
||||||
|
|
||||||
RainParticleSystem::RainParticleSystem(float startSceneX, float sceneSizeX, float sceneSizeY) {
|
|
||||||
|
|
||||||
this->startSceneX = startSceneX;
|
|
||||||
this->sceneSizeX = sceneSizeX;
|
|
||||||
this->sceneSizeY = sceneSizeY;
|
|
||||||
|
|
||||||
maxParticle = 40;
|
|
||||||
birthCnt = 0;
|
|
||||||
parAmount = 2;
|
|
||||||
tornadoStartTime = -1000;
|
|
||||||
time = 0;
|
|
||||||
status = -1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void RainParticleSystem::updateParticleSystem() {
|
|
||||||
|
|
||||||
double deltaT = ofGetLastFrameTime();
|
|
||||||
time += deltaT;
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
|
||||||
if ((birthCnt >= 0) && (status == -1)) { //Create the particle for the rainparticlesystems
|
|
||||||
createParticlesForRain();
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------//Update particle (Movement)
|
|
||||||
|
|
||||||
|
|
||||||
for (int p = 0; p < particles.size(); p++) { //Movement of particles from bottom to top
|
|
||||||
particles.at(p)->updateParticle(deltaT, ofVec2f(ofRandom(startSceneX, startSceneX + sceneSizeX), 0),
|
|
||||||
false, false, false, 0, 0, startSceneX + sceneSizeX, sceneSizeY);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void RainParticleSystem::createParticlesForRain()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < parAmount; i++) {
|
|
||||||
|
|
||||||
particles.push_back(new Particle);
|
|
||||||
int rgen = ofRandom(startSceneX, startSceneX + sceneSizeX);
|
|
||||||
|
|
||||||
particles.back()->setup(ofVec2f(rgen, sceneSizeY), 20);
|
|
||||||
}
|
|
||||||
birthCnt = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void RainParticleSystem::drawRainParticleSystem() {
|
|
||||||
|
|
||||||
for (int i = 0; i < particles.size(); i++) {
|
|
||||||
particles.at(i)->draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
|||||||
#ifndef rainParticleSystem_h
|
|
||||||
#define rainParticleSystem_h
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ofMain.h"
|
|
||||||
#include "ofxCv.h"
|
|
||||||
#include "ofxOpenCv.h"
|
|
||||||
#include "particle.h"
|
|
||||||
#include "drawableImage.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
class RainParticleSystem
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
RainParticleSystem(float startSceneX, float sceneSizeX, float sceneSizeY);
|
|
||||||
~RainParticleSystem();
|
|
||||||
|
|
||||||
vector<ofVec2f>attractors;
|
|
||||||
vector<Particle*> particles;
|
|
||||||
|
|
||||||
int startSceneX;
|
|
||||||
int sceneSizeX;
|
|
||||||
int sceneSizeY;
|
|
||||||
int maxParticle;
|
|
||||||
int picPix;
|
|
||||||
int k;
|
|
||||||
int status;
|
|
||||||
bool tornadoStarted;
|
|
||||||
bool editingWarp;
|
|
||||||
float birthCnt;
|
|
||||||
float maxLife;
|
|
||||||
float parAmount;
|
|
||||||
float height;
|
|
||||||
double time;
|
|
||||||
double tornadoStartTime;
|
|
||||||
|
|
||||||
void updateParticleSystem();
|
|
||||||
void createParticlesForRain();
|
|
||||||
void drawRainParticleSystem();
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
|||||||
// Created by Sebastian Holzki on 11.06.19.
|
// Created by Sebastian Holzki on 11.06.19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "visitor.h"
|
#include "visitor.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -133,3 +133,33 @@ void Visitor::setY(float _y){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// visitor.h
|
// visitor.hpp
|
||||||
// particle_combined
|
// particle_combined
|
||||||
//
|
//
|
||||||
// Created by Sebastian Holzki on 11.06.19.
|
// Created by Sebastian Holzki on 11.06.19.
|