I can't read your code and I don't understand the problem. If you click the icon in the upper right hand corner of the original post you will be able to edit it. Highlight your code and hit ctrl+o. Leave an empty line before and after the code for it to format properly. Then describe your problem and where it occurs.
I am still not sure what exactly the problem is, but I can point out that this is problematic:
for (int i =0; i< words.length; i++) {
String[] words = { "peur du noir", "suée nocturne", "troisième oeil", "sombre matière", "clair de nuit", "les lucioles", "trop de lux" };
This should result in error because you are trying to access the array words before it has been declared. And furthermore you are declaring it in every iteration of the loop. Move the array to the top level of the class.
This should result in error because you are trying to access the array words before it has been declared.
that's probably using the global definition of words on line 15. this repetition of that definiton looks wrong - why is it inside the loop? i'd delete line 81
you also need to add a pushMatrix() / popMatrix() in the sphere.display() loop or the translates will accumulate.
Thank you very much Koogs will do that later on. I'm at work now. I'm really a newbe to P5 and I really appreciate your help after I was looking for a solution for hours!
yes, that was the problem I was pointing out multiple jittery text for each sphere!
thanks for your quick answer and will check out if it works in a few hours !
for (int i = 0; i < words.length; i++) {
...
text(word, pos[i][0], pos[i][1] - 35, pos[i][2]);
you are printing all the text for each of the spheres.
what i think you want is for each sphere to have one word associated with it. so assign that word in the constructor and remove the loop in sphere.display().
yes I need to put the push/pop Style somewhere else that only the lines fade in/out according to the distance between spheres.
By the way, what do you mean by assign the word in the constructor?!
this is the constructor for Sphere. that last argument is copied to 'nom'
when you create the Spheres you use
sphere[i] = new Sphere( random(width), random(height), random(height/2),words[i]);
which gives each sphere a random position and a word from the list. one word is all the Sphere needs. this is good. what you had before was unnecessary.
Thank you so much Eeyorelife! I was so stressed I couldn't find a way out. Thank you koogs too, you are both my saviors. It's my 1rst time on the Forum and I am so happy. Thank you for your generosity and the time you spent on my little problem. I hope in few years i'll be able to help someone else too just like you! cu
Hi Koogs,
sorry I didn't pay attention and certainly ticked the'answered' by 'mistake' when eeyore answered me. As I told you then its'my 1rst time on the forum and I may make some mistake. You definitely helped me a lot and I thank you once again for your great help. I ticked the 'answered' everywhere now! Sorry I'll pay more attention to this next time. Best wishes
Hello,
I have an issue with selecting object (clickedMouse) and recursivity. I did a kind of solar system, a sun at the center, planets around and satellites around the planets. I manage to slect my planets and zoom towards them, but not to select the satellites!? If someone would take a look at my sketch, I'd be glad ! Thanks in advance.
import peasy.test.*;
import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;
import processing.opengl.*;
PeasyCam camera;
// nbre de Sphères
Sphere sun;
Sphere currentSphereCenter;
boolean pressed = false;
boolean locked = false;
float radiusSphere = 600;
float radius;
float range;
float rangeCount = 600;
PVector camPos;
float theta;
float phi;
String[] words = {
"peur du noir", "suée nocturne", "troisième oeil", "sombre matière", "clair de nuit", "les lucioles", "trop de lux"
};
String[][] satWords = {
{
"peur du noir", "couscous"
}
, {
"suée nocturne", "bbbb", "ghhtt"
}
, {
"troisième oeil", "bhbhiu", "jkjkjlkj", "ghhjkkklk"
}
, {
"sombre matière"
}
, {
"clair de nuit"
}
, {
"les lucioles"
}
, {
"trop de lux"
}
};
void setup() {
size (1200, 800, P3D);
hint(DISABLE_DEPTH_TEST);
camera = new PeasyCam(this, width/2, height/2, height/2, width);
range = rangeCount;
PFont Moonfont = createFont ("RNIB MOON", (52));
sun = new Sphere(0, 90, TWO_PI, PI/2, "Clair Obscur", Moonfont, null);
PFont [] fonts = new PFont [8];
for (int j=0; j<8; j++) {
println(j);
fonts [j] = createFont("Helvetica 45 Light", (32+4*j));
}
Sphere []spheres = new Sphere [words.length];
for (int i =0; i<spheres.length; i++) {
PFont f = fonts[floor(random(fonts.length))] ;
spheres[i] = new Sphere(radiusSphere, random(25, 50), random(0, TWO_PI), random(0, PI), words[i], f, sun);
// satWords = liste de liste des noms pr chaque satellite et [i] correspond à la planète
Sphere [] sats = new Sphere [satWords[i].length];
for (int k =0; k<satWords[i].length; k++) {
PFont g = fonts[floor(random(fonts.length))] ;
sats [k] = new Sphere(radiusSphere/4, random(10, 20), random(0, TWO_PI), random(0, PI), satWords[i][k], g, spheres[i]);
}
spheres [i].addSatellites(sats);
//String[] fontList = PFont.list();
// printArray(fontList);
}
sun.addSatellites(spheres);
println(rangeCount);
//selectSphere(sun);
frameRate(25);
}
void draw() {
background (0);
/*float[] rotations = camera.getRotations();
rotateX(rotations[0]);
rotateY(rotations[1]);
rotateZ(rotations[2]);*/
//directionalLight(200, 255, 255, 0, 0, 0);
sun.display();
pushMatrix();
translate (0, 0, 0);
noStroke();
stroke (75, 75, 75, 15);
getWeird(150, 0.1, radiusSphere);
popMatrix();
}
void getWeird(float sStep, float tStep, float radius) {
float s = 0;
float t = 0;
float lastx = 0;
float lasty = 0;
float lastz = 0;
while (t < 180) {
s += sStep;
t += tStep;
float radianS = radians(s);
float radianT = radians(t);
float thisx = 0 + (radius * cos(radianS) * sin(radianT)) + noise(random(10)*25);
float thisy = 0 + (radius * sin(radianS) * sin(radianT)) + noise(random(10)*25);
float thisz = 0 + (radius * cos(radianT)) + noise(random(10))*25;
if (lastx != 0) {
line(thisx, thisy, thisz, lastx, lasty, lastz);
}
lastx = thisx;
lasty = thisy;
lastz = thisz;
}
}
void mouseClicked () {
//println("mouseClicked");
//for (int i = 0; i < sun.spheres.length; i++) {
Sphere clickedSphere = sun.spheres[0];
float lastd = 10000;
for (Sphere s : sun.spheres) {
float x1 = screenX (s.x, s.y, s.z);
float y1 = screenY (s.x, s.y, s.z);
float d = dist(x1, y1, mouseX, mouseY);
//println ("x1: "+x1+", y1: "+y1+", d: "+ d);
if ( d < lastd) {
lastd = d;
clickedSphere = s;
}
}
if (lastd <= clickedSphere.radius*1.2) {
selectSphere (clickedSphere);
}else {
backLevel();
}
}
void backLevel() {
println("backLevel");
if (currentSphereCenter != sun){
selectSphere (currentSphereCenter.sphereCenter);
}
}
void selectSphere (Sphere s) {
int zoom = 5;
println ("planete la plus proche: "+ s.nom);
currentSphereCenter = s;
if (currentSphereCenter != sun){
camera.lookAt(s.x, s.y, s.z);
camera.getDistance();
float d = getDistance;
camera.setDistance ((d/d)*2);
if(mouseEvent.getClickCount()==2){
}
}
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
class Sphere {
float theta;
float phi;
float vTheta;
float vPhi;
float r, x, y, z;
float radius;
float radiusSphere;
String nom;
PFont font;
color c;
Sphere[] spheres;
Sphere sphereCenter;
Sphere (float radiusSphere, float rad, float theta, float phi, String s, PFont f, Sphere sC) {
this.theta = theta ;
this.phi = phi;
this.r = radiusSphere;
vTheta =0;
vPhi =0;
x = r * sin(phi) * cos(theta);
y = r * sin(phi) * sin(theta);
z = r * cos(phi);
radius = rad;
c = color(random(200, 255));
nom = s;
font = f;
sphereCenter = sC;
}
String printPos () {
return "x:"+x+ " y:"+y+" z:"+z;
}
void move() {
vTheta = noise (-0.0001, 0.0001);
theta+=vTheta/100;
if (theta < 0||theta > TWO_PI) {
vTheta*= -1;
}
vPhi = noise (-0.0001, 0.0001);
phi+=vPhi/100;
if (phi < 0 ||phi > PI) {
vPhi*= -1;
}
vPhi*=2;
vTheta*=2;
x = r * sin(phi) * cos(theta);
y = r * sin(phi) * sin(theta) ;
z = r * cos(phi);
if (spheres != null) {
for (int i = 0; i < spheres.length; i++) {
spheres[i].move();
}
}
}
void addSatellites (Sphere [] sats) {
spheres= sats;
}
void display () {
//println ("spheres["+i+"]:"+spheres[i].printPos());
textFont(font);
textAlign(CENTER);
pushMatrix();
fill(255);
noStroke();
float[] rotations = camera.getRotations();
translate(x, y - (radius+10), z);
rotateX(rotations[0]);
rotateY(rotations[1]);
rotateZ(rotations[2]);
scale(0.5);
text(nom, 0, 0, 0);
popMatrix();
pushMatrix();
translate(x, y, z);
fill(c);
stroke(c, 100);
getWeird(7, 0.1, radius);
if (spheres != null) {
// lignes qui pointent des spheres vers le sun
for (int i = 0; i < spheres.length; i++) {
float x1 = spheres[i].x;
float y1 = spheres[i].y;
float z1 = spheres[i].z;
strokeWeight(1);
stroke(random (180,255));
line (0, 0, 0, x1, y1, z1);
//line (radius * sin(phi) * cos(theta), radius * sin(phi) * sin(theta), radius * cos(phi), x1, y1, z1);
}
// dessin des lignes entre sphères
for (int i = 0; i < spheres.length; i++) {
float x1 = spheres[i].x;
float y1 = spheres[i].y;
float z1 = spheres[i].z;
int j =1;
for (j+=i; j<spheres.length; j++) {
float x2 = spheres[j].x;
float y2 = spheres[j].y;
float z2 = spheres[j].z;
float d= dist(x1, y1, z1, x2, y2, z2);
if (d<=range) {
float a = constrain((range - d)*3, 0, 255);
strokeWeight(1);
stroke(255, a);
line(x1, y1, z1, x2, y2, z2);
}
}
spheres[i].display();
spheres[i].move();
//println ("spheres["+i+"]:"+spheres[i].printPos());
}
// println("sphere "+ nom +" x: "+x+", y: "+y+", z: "+z+".");
}
popMatrix();
}
void getWeird(float sStep, float tStep, float radius) {
float s = 0;
float t = 0;
float lastx = 0;
float lasty = 0;
float lastz = 0;
while (t < 180) {
s += sStep;
t += tStep;
float radianS = radians(s);
float radianT = radians(t);
float thisx = 0 + (radius * cos(radianS) * sin(radianT)) + noise(random(10)*25);
float thisy = 0 + (radius * sin(radianS) * sin(radianT)) + noise(random(10)*25);
float thisz = 0 + (radius * cos(radianT)) + noise(random(10))*25;
if (lastx != 0) {
line(thisx, thisy, thisz, lastx, lasty, lastz);
}
lastx = thisx;
lasty = thisy;
lastz = thisz;
}
}
}
Please find my code below. I don't manage to select the satellites, just the spheres (in the mouseClicked method and the selectSphere method). A problem of recursivity I guess. Dont' find a way out ! Thanks in advance for your help.
import peasy.test.*;
import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;
import processing.opengl.*;
PeasyCam camera;
// nbre de Sphères
Sphere [] sats;
Sphere [] spheres;
Sphere sun;
Sphere currentSphereCenter;
boolean pressed = false;
boolean locked = false;
float radiusSphere = 600;
float radius;
float range;
float rangeCount = 600;
PVector camPos;
float theta;
float phi;
boolean resetOnDoubleClick =true;
String[] words = {
"peur du noir", "suée nocturne", "troisième oeil", "sombre matière", "clair de nuit", "les lucioles", "trop de lux"
};
String[][] satWords = {
{
"peur du noir", "couscous"
}
, {
"suée nocturne", "bbbb", "ghhtt"
}
, {
"troisième oeil", "bhbhiu", "jkjkjlkj", "ghhjkkklk"
}
, {
"sombre matière"
}
, {
"clair de nuit"
}
, {
"les lucioles"
}
, {
"trop de lux"
}
};
void setup() {
size (1200, 800, P3D);
hint(DISABLE_DEPTH_TEST);
camera = new PeasyCam(this, width/2, height/2, height/2, width);
range = rangeCount;
PFont Moonfont = createFont ("RNIB MOON", (52));
sun = new Sphere(0, 90, TWO_PI, PI/2, "Clair Obscur", Moonfont, null);
PFont [] fonts = new PFont [8];
for (int j=0; j<8; j++) {
println(j);
fonts [j] = createFont("Helvetica 45 Light", (32+4*j));
}
Sphere []spheres = new Sphere [words.length];
for (int i =0; i<spheres.length; i++) {
PFont f = fonts[floor(random(fonts.length))] ;
spheres[i] = new Sphere(radiusSphere, random(25, 50), random(0, TWO_PI), random(0, PI), words[i], f, sun);
// satWords = liste de liste des noms pr chaque satellite et [i] correspond à la planète
Sphere [] sats = new Sphere [satWords[i].length];
for (int k =0; k<satWords[i].length; k++) {
PFont g = fonts[floor(random(fonts.length))] ;
sats [k] = new Sphere(radiusSphere/4, random(10, 20), random(0, TWO_PI), random(0, PI), satWords[i][k], g, spheres[i]);
}
spheres [i].addSatellites(sats);
//String[] fontList = PFont.list();
// printArray(fontList);
}
sun.addSatellites(spheres);
println(rangeCount);
//selectSphere(sun);
frameRate(25);
}
void draw() {
background (0);
sun.display();
pushMatrix();
translate (0, 0, 0);
sphereWave();
/*noStroke();
stroke (75, 75, 75, 15);
getWeird(150, 0.1, radiusSphere);*/
popMatrix();
}
void sphereWave() {
float radious = radiusSphere;
float noiseScale = 0.01;
float timeScale = 0.03;
stroke (75, 75, 75, 100);
noFill();
//rotateZ(map(mouseX, 0, width, -PI * 2.0 / 3, PI * 2.0 / 3));
//rotateX(map(mouseY, 0, height, -PI * 2.0 / 3, PI * 2.0 / 3));
for (float y = -radious/3 * 2.0; y <= radious * 2.0 / 3; y += 12) {
float r = radious * cos(asin(abs(y / radious)));
beginShape();
for (float radian = 0; radian < TWO_PI; radian += PI / 128) {
float x = r * cos(radian);
float z = r * sin(radian);
float yy = y + map(noise(x * noiseScale, frameCount * timeScale, z * noiseScale), 0, 1, -radious / 3, radious / 3);
if (yy > radious) {
yy = radious;
}
float rr = radious * cos(asin(abs(yy / radious)));
float xx = rr * cos(radian);
float zz = rr * sin(radian);
vertex(xx, yy, zz);
}
endShape(CLOSE);
}
}
void mouseClicked () {
Sphere clickedSphere = sun.spheres[0];
float lastd = 10000;
for (Sphere s : sun.spheres) {
float x1 = screenX (s.x, s.y, s.z);
float y1 = screenY (s.x, s.y, s.z);
float d = dist(x1, y1, mouseX, mouseY);
if ( d < lastd) {
lastd = d;
clickedSphere = s;
camera.lookAt(s.x, s.y, s.z);
camera.setDistance (d+200);
}
}
if (lastd <= clickedSphere.radius*1.2) {
selectSphere (clickedSphere);
} else {
backLevel();
camera.lookAt(sun.x, sun.y, sun.z);
camera.setDistance(1400, 400);
}
}
void backLevel() {
println("backLevel");
if (currentSphereCenter != sun) {
selectSphere (currentSphereCenter.sphereCenter);
}
}
void selectSphere (Sphere s) {
println ("planete la plus proche: "+ s.nom);
currentSphereCenter = s;
}
class Sphere {
float theta;
float phi;
float vTheta;
float vPhi;
float r, x, y, z;
float radius;
float radiusSphere;
String nom;
PFont font;
color c;
Sphere[] spheres;
Sphere sphereCenter;
Sphere (float radiusSphere, float rad, float theta, float phi, String s, PFont f, Sphere sC) {
this.theta = theta ;
this.phi = phi;
this.r = radiusSphere;
vTheta =0;
vPhi =0;
x = r * sin(phi) * cos(theta);
y = r * sin(phi) * sin(theta);
z = r * cos(phi);
radius = rad;
c = color(random(200, 255));
nom = s;
font = f;
sphereCenter = sC;
}
String printPos () {
return "x:"+x+ " y:"+y+" z:"+z;
}
void move() {
vTheta = noise (-0.0001, 0.0001);
theta+=vTheta/100;
if (theta < 0||theta > TWO_PI) {
vTheta*= -1;
}
vPhi = noise (-0.0001, 0.0001);
phi+=vPhi/100;
if (phi < 0 ||phi > PI) {
vPhi*= -1;
}
vPhi*=2;
vTheta*=2;
x = r * sin(phi) * cos(theta);
y = r * sin(phi) * sin(theta) ;
z = r * cos(phi);
if (spheres != null) {
for (int i = 0; i < spheres.length; i++) {
spheres[i].move();
}
}
}
void addSatellites (Sphere [] sats) {
spheres= sats;
}
void display () {
//println ("spheres["+i+"]:"+spheres[i].printPos());
textFont(font);
textAlign(CENTER);
pushMatrix();
fill(255);
noStroke();
float[] rotations = camera.getRotations();
translate(x, y - (radius+10), z);
rotateX(rotations[0]);
rotateY(rotations[1]);
rotateZ(rotations[2]);
scale(0.5);
text(nom, 0, 0, 0);
popMatrix();
pushMatrix();
translate(x, y, z);
fill(c);
stroke(c, 100);
getWeird(7, 0.09, radius);
if (spheres != null) {
// lignes qui pointent des spheres vers le sun
for (int i = 0; i < spheres.length; i++) {
float x1 = spheres[i].x;
float y1 = spheres[i].y;
float z1 = spheres[i].z;
strokeWeight(1);
stroke(random (180,225));
line (0, 0, 0, x1, y1, z1);
//line (radius * sin(phi) * cos(theta), radius * sin(phi) * sin(theta), radius * cos(phi), x1, y1, z1);
}
// dessin des lignes entre sphères
for (int i = 0; i < spheres.length; i++) {
float x1 = spheres[i].x;
float y1 = spheres[i].y;
float z1 = spheres[i].z;
int j =1;
for (j+=i; j<spheres.length; j++) {
float x2 = spheres[j].x;
float y2 = spheres[j].y;
float z2 = spheres[j].z;
float d= dist(x1, y1, z1, x2, y2, z2);
if (d<=range) {
float a = constrain((range - d)*4, 0, 225);
strokeWeight(1);
stroke(100, a);
line(x1, y1, z1, x2, y2, z2);
}
}
spheres[i].display();
spheres[i].move();
//println ("spheres["+i+"]:"+spheres[i].printPos());
}
// println("sphere "+ nom +" x: "+x+", y: "+y+", z: "+z+".");
}
popMatrix();
}
void getWeird(float sStep, float tStep, float radius) {
float s = 0;
float t = 0;
float lastx = 0;
float lasty = 0;
float lastz = 0;
while (t < 180) {
s += sStep;
t += tStep;
float radianS = radians(s);
float radianT = radians(t);
float thisx = 0 + (radius * cos(radianS) * sin(radianT)) + noise(random(10)*25);
float thisy = 0 + (radius * sin(radianS) * sin(radianT)) + noise(random(10)*25);
float thisz = 0 + (radius * cos(radianT)) + noise(random(10))*25;
if (lastx != 0) {
line(thisx, thisy, thisz, lastx, lasty, lastz);
}
lastx = thisx;
lasty = thisy;
lastz = thisz;
}
}
}
line 129 only loops over the sun.spheres. you need to also loop over the satellites.
if you make the sun one colour, the spheres another and the satellites another it'll be easier to describe your problem - using 'spheres' to describe things is not great because EVERYTHING is spherical.
Thank you a million times koogs, that makes so much sense! And this time I didn't forget to check the 'answer' buton ;)) Thank you for taking some time to solve my problem, you helped me a lot :)
I work once again on my program with planets and satellites, I try to check out the distance between both and between satellites themselves in order they won't 'coagulate' together ...
I tried to calculate them with the method dist() and then added the result to my variable d, but it doesn't seem to work how should I proceed please? Thanks a lot in advance
Answers
edit post, highlight code, ctrl +o
Sorry couldn't finish my message and it was sent! I face an issue with textSize which copy the same word over and over in diffrenet size, aproblem of
I can't read your code and I don't understand the problem. If you click the icon in the upper right hand corner of the original post you will be able to edit it. Highlight your code and hit ctrl+o. Leave an empty line before and after the code for it to format properly. Then describe your problem and where it occurs.
I repost with a properly edited code. Thanks!
Thank you Eyeorlife! I have a problem to set a random size to my text (String words), it copies my texte several time on the top of the other...
I am still not sure what exactly the problem is, but I can point out that this is problematic:
This should result in error because you are trying to access the array words before it has been declared. And furthermore you are declaring it in every iteration of the loop. Move the array to the top level of the class.
Thank you very much, it may be why the textSize copy the text in every iteration in a different size! I am so dummy. Thank you for your help.
Is the problem that the text "peur du noir" get's drawn instead of any of the other phrases?
Or is it that the size doesn't change?
textSize() doesn't store text, it stores a number. textSize() determines the size of the text that is drawn after it has been called.
that's probably using the global definition of words on line 15. this repetition of that definiton looks wrong - why is it inside the loop? i'd delete line 81
you also need to add a pushMatrix() / popMatrix() in the sphere.display() loop or the translates will accumulate.
and the popStyle should be at the same level as pushStyle, not inside the condition.
Thank you very much Koogs will do that later on. I'm at work now. I'm really a newbe to P5 and I really appreciate your help after I was looking for a solution for hours!
well, does it work?
pushStyle / popStyle should be inside the loop, i think, given that you want all the items to have a separate style.
lines 74 and 75 have errors in them, missing a *?
there are still problems - multiple jittery text for each sphere - but i can't debug it at the moment.
yes, that was the problem I was pointing out multiple jittery text for each sphere! thanks for your quick answer and will check out if it works in a few hours !
The prolem is that each word repeat itself a multiple of times for each sphere
but sphere.display...
you are printing all the text for each of the spheres.
what i think you want is for each sphere to have one word associated with it. so assign that word in the constructor and remove the loop in sphere.display().
in fact, you already pass the word in, as
nom
. and p[i][0..2] are just x, y, zso:
what's the dist() doing? because it looks like everything is always connected to everything else. you might need to tune the values...
yes I need to put the push/pop Style somewhere else that only the lines fade in/out according to the distance between spheres. By the way, what do you mean by assign the word in the constructor?!
Thank you very much and sorry for my very basic skill in Processing ;)
this is the constructor for Sphere. that last argument is copied to 'nom'
when you create the Spheres you use
which gives each sphere a random position and a word from the list. one word is all the Sphere needs. this is good. what you had before was unnecessary.
Hi here is my code, still doesn't work I messed it up I guess thank you very much for your help!
How about this? Is this what you want?
Thank you so much Eeyorelife! I was so stressed I couldn't find a way out. Thank you koogs too, you are both my saviors. It's my 1rst time on the Forum and I am so happy. Thank you for your generosity and the time you spent on my little problem. I hope in few years i'll be able to help someone else too just like you! cu
eeyore coming in there at the 11th hour and getting the 'answered' tick.
I might have known...
Hi Koogs, sorry I didn't pay attention and certainly ticked the'answered' by 'mistake' when eeyore answered me. As I told you then its'my 1rst time on the forum and I may make some mistake. You definitely helped me a lot and I thank you once again for your great help. I ticked the 'answered' everywhere now! Sorry I'll pay more attention to this next time. Best wishes
Hello, I have an issue with selecting object (clickedMouse) and recursivity. I did a kind of solar system, a sun at the center, planets around and satellites around the planets. I manage to slect my planets and zoom towards them, but not to select the satellites!? If someone would take a look at my sketch, I'd be glad ! Thanks in advance.
code doesn't compile...
not a valid statement.
Thanks for your reply koogs, I'll fix the code later on and will send it back, I've sent the wrong version.
Please find my code below. I don't manage to select the satellites, just the spheres (in the mouseClicked method and the selectSphere method). A problem of recursivity I guess. Dont' find a way out ! Thanks in advance for your help.
my code does compile now ;) Found out a way to zoom smoothly with peasy but still haven't found a way to select my satellites! Help!
line 129 only loops over the sun.spheres. you need to also loop over the satellites.
if you make the sun one colour, the spheres another and the satellites another it'll be easier to describe your problem - using 'spheres' to describe things is not great because EVERYTHING is spherical.
Dear Koogs thank you very much for your answer, yes to call them 'spheres' is really dummy!!
I tried to loop over the satellites with this kind of loop but it didnt compile:
I'll change the name and give each group a colour, it will certainly help!Thanks
this works. put it after line 140
the thing is that the satellites are orbiting the spheres, hence the s.x + sat.x stuff.
Thank you a million times koogs, that makes so much sense! And this time I didn't forget to check the 'answer' buton ;)) Thank you for taking some time to solve my problem, you helped me a lot :)
Here is the code with the loop line 30 where the problem occures :
what problem?
is this the same problem as 3 months ago or a new problem?
this doesn't even look like the same code as 3 months ago.
No, sorry Kogs I've pasted this new code in the complete wrong place I apologize... I'll post it in the general a/q dedicated place
Dear koogs, I've just posted a new message regarding minim library, if you have some time I'd be very glad if you can help me ;) thank you very much
Dear Koogs,
I work once again on my program with planets and satellites, I try to check out the distance between both and between satellites themselves in order they won't 'coagulate' together ... I tried to calculate them with the method dist() and then added the result to my variable d, but it doesn't seem to work how should I proceed please? Thanks a lot in advance