Hi guys an’ gals,
Since Codea is built like Processing I started to look not it. I found a nice little sphere program in Processing and tried to fit it into Codea, but ran into problems . He is the
Processing code:
import processing.opengl.*;
float Xpos=0;
float Ypos=0;
float Zpos=0;
float z= 0;
float StepsV =50;
float StepsH=StepsV;
void setup(){
size(600, 600,OPENGL);
background(0);
lights();
stroke(255);
smooth();
}
void draw(){
translate(width/2, height/2,0);
background(0);
//////////////////////////////////////////////////////////////////
camera(mouseX, mouseY, 220.0, // eyeX, eyeY, eyeZ
0.0, 0.0, 0.0, // centerX, centerY, centerZ
mouseX, 1.0, 0.0); // upX, upY, up
/////////////////////////////////////////////////////////////////
stroke(255);
strokeWeight(0.5);
pushMatrix();
for (int i = 1; i<=StepsV;i++){
rotateY(radians(360/StepsV));
for (float a = 90; a < 270; a+=360/StepsV) {
pushMatrix();
float lineLength= width/3;
float Xpos1=Xpos + ( cos(radians(a)) * lineLength );
float Ypos1=Ypos + ( sin(radians(a)) * lineLength );
float Zpos1=Zpos + ( sin(radians(z-HALF_PI) * lineLength) );
stroke(0,255,0);
point(Xpos1,Ypos1,Zpos1);
//ellipse(Xpos1,Ypos1,2,5,2,5);
popMatrix();
}
}
popMatrix();
//endShape();
}
Here is my Codea take on it, I missed out the mouse response links - just aimed for the basic sphere. Bit it don’t work!!!
function setup()
--
displayMode(FULLSCREEN)
-- backingMode(RETAINED)
Xpos = 0
Ypos = 0
Zpos = 0
z = 0
StepsV = 36
StepsH = StepsV
degs = 360/StepsV
midX = WIDTH/2
midY = HEIGHT/2
Polar:init(20)
end
-- This function gets called once every frame
function draw()
translate(midX, midY)
-- This sets a dark background color
background(0, 0, 0, 255)
stroke(23, 255, 0, 255)
smooth()
-- This sets the line thickness
strokeWidth(5)
-- Do your drawing here
pushMatrix()
for i = 1, StepsV, 1 do
rotate(degs,0,1,0)
for a = 90, 270, degs do
pushMatrix()
lineLength = WIDTH/3
Xpos1 = Xpos+(math.cos(math.rad(a))*lineLength)
Ypos1 = Ypos+(math.sin(math.rad(a))*lineLength)
Zpos1 = Zpos+(math.sin(math.rad(z-90)*lineLength))
stroke(0, 251, 0, 255)
-- ellipse(Xpos1, Ypos1,5,5)
point(Xpos1, Ypos1,
popMatrix()
end
end
popMatrix()
end
Any ideas?
Bri_G