Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
aucourantify
aucourantify's Profile
1
Posts
0
Responses
1
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
dynamic text at nodes on a sphere?
[0 Replies]
05-May-2013 12:56 PM
Forum:
Programming Questions
Hello all... New to processing and I've been following along with the examples from this great book: "Generative Art".
I'm using a piece of mr. pearson's code to animate a "Heliosphere":
// July 2009
//
http://www.abandonedart.org
//
http://www.zenbullets.com
//
// This work is licensed under a Creative Commons 3.0 License.
// (Attribution - NonCommerical - ShareAlike)
//
http://creativecommons.org/licenses/by-nc-sa/3.0/
//
// This basically means, you are free to use it as long as you:
// 1. give
http://www.zenbullets.com
a credit
// 2. don't use it for commercial gain
// 3. share anything you create with it in the same way I have
//
// These conditions can be waived if you want to do something groovy with it
// though, so feel free to email me via
http://www.zenbullets.com
//================================= global vars
int _num = 1500;
int _numSpheres = 80;
int _threshold;
float _maxRad, _maxNoise;
HPoint[] _pointArr = {};
Sphere[] _sphereArr = {};
//================================= init
void setup() {
size(1280, 900, P3D);
smooth();
_maxNoise = random(1);
restart();
}
void restart() {
background(255);
newSpheres();
newPoints();
}
void clearBackground() {
background(255);
}
void newSpheres() {
_sphereArr = (Sphere[])expand(_sphereArr, 0);
for (int x = 0; x <= _numSpheres; x++) {
Sphere thisSphere = new Sphere();
_sphereArr = (Sphere[])append(_sphereArr, thisSphere);
}
}
void newPoints() {
_pointArr = (HPoint[])expand(_pointArr, 0);
for (int x = 0; x <= _num; x++) {
HPoint thisPoint = new HPoint(random(860), random(860));
_pointArr = (HPoint[])append(_pointArr, thisPoint);
}
}
//================================= interaction
void mousePressed() {
restart();
}
//================================= frame loop
void draw() {
clearBackground();
// update
_maxNoise += 0.001;
_maxRad = noise(_maxNoise) * 200;
_threshold = int(_maxRad / 3);
for (int s = 0; s < _sphereArr.length; s++) {
Sphere thisS = _sphereArr[s];
thisS.update();
}
for (int x = 0; x < _pointArr.length; x++) {
HPoint thisHP = _pointArr[x];
thisHP.update();
}
// draw
pushMatrix();
translate(width/2, height/2, 0);
rotateY(frameCount * 0.01);
for (int y = 0; y < _pointArr.length; y++) {
HPoint fromHP = _pointArr[y];
stroke(fromHP.col, 150);
noFill();
for (int z = 0; z < _pointArr.length; z++) {
HPoint toHP = _pointArr[z];
float diff = dist(fromHP.x, fromHP.y, fromHP.z, toHP.x, toHP.y, toHP.z);
if (diff < _threshold) {
line(fromHP.x, fromHP.y, fromHP.z, toHP.x, toHP.y, toHP.z);
}
}
}
popMatrix();
}
//================================= objects
class Sphere {
float radius, radNoise;
Sphere() {
radNoise = random(5);
}
void update() {
radNoise += 0.01;
radius = 200 + (noise(radNoise) * _maxRad);
}
}
class HPoint {
float s, t;
float x, y, z;
int mySphere;
color col;
HPoint(float es, float tee) {
s = es; t = tee;
col = color(100 - (10*mySphere), 110, /*(300*mySphere)*/ 150, 30);
mySphere = int(random(_numSpheres));
}
void update() {
Sphere myS = _sphereArr[mySphere];
x = myS.radius * cos(s) * sin(t);
y = myS.radius * sin(s) * sin(t);
z = myS.radius * cos(t);
}
}
I'm wondering if there is a way to have some dummy text appear at some of the nodes on the sphere?
In other words, text that appears to be tethered to a node, animating with it in geosynchronous orbit?
«Prev
Next »
Moderate user : aucourantify
Forum