<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with directionallight() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=directionallight%28%29</link>
      <pubDate>Sun, 08 Aug 2021 17:52:41 +0000</pubDate>
         <description>Tagged with directionallight() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggeddirectionallight%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>HE Mesh Parameters</title>
      <link>https://forum.processing.org/two/discussion/28078/he-mesh-parameters</link>
      <pubDate>Tue, 17 Jul 2018 20:06:05 +0000</pubDate>
      <dc:creator>vjjv</dc:creator>
      <guid isPermaLink="false">28078@/two/discussions</guid>
      <description><![CDATA[<p>hello! im using the hemesh library to construct 3D meshes, but ive a problem when i want to change the values of a constructor.. how can i change them? here in the example, i want to change the radius according mouseX position, but it doesnt do anything. i see hemeshve modifiers but i dont find any to change the radius or this parameters, like steps, or points.</p>

<pre><code>import wblut.nurbs.*;
import wblut.hemesh.*;
import wblut.core.*;
import wblut.geom.*;
import wblut.processing.*;
import wblut.math.*;



WB_Render render;
WB_BSpline C;
WB_Point[] points;
HE_Mesh mesh;
HEC_SweepTube creator;

void setup() {
  size(1000,1000,P3D);
  smooth(8);
  // Several WB_Curve classes are in development. HEC_SweepTube provides
  // a way of generating meshes from them.

  //Generate a BSpline
  points=new WB_Point[11];
  for (int i=0;i&lt;11;i++) {
    points[i]=new WB_Point(5*(i-5)*(i-5), -200+40*i, random(100));
  }
  C=new WB_BSpline(points, 4);

  creator=new HEC_SweepTube();

  creator.setCurve(C);//curve should be a WB_BSpline
  creator.setSteps(40);
  creator.setFacets(8);
  creator.setCap(true, true); // Cap start, cap end?
  mesh=new HE_Mesh(creator); 
  //HET_Diagnosis.validate(mesh);
  render=new WB_Render(this);
}

void draw() {
   creator.setRadius(mouseX);


  background(55);
  directionalLight(255, 255, 255, 1, 1, -1);
  directionalLight(127, 127, 127, -1, -1, 1);
  translate(width/2,height/2);
  rotateY(mouseX*1.0f/width*TWO_PI);
  rotateX(mouseY*1.0f/height*TWO_PI);
  stroke(0);
  render.drawEdges(mesh);
  noStroke();
  render.drawFaces(mesh);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Help with p5.js solar system sketch</title>
      <link>https://forum.processing.org/two/discussion/27973/help-with-p5-js-solar-system-sketch</link>
      <pubDate>Mon, 14 May 2018 22:05:58 +0000</pubDate>
      <dc:creator>Mojo</dc:creator>
      <guid isPermaLink="false">27973@/two/discussions</guid>
      <description><![CDATA[<p>Hey everyone,
I am doing this sketch which is following up dan's shiffman tutorial in processing, however I am doing it in p5.js
for some reason I can's seem to do the final step and I think it has to do with the vectors.
If anyone can help me, I would really appreciate it.
Here is the code in processing:</p>

<pre><code>import peasy.*;
Planet sun;

PeasyCam cam;

void setup() {
  size(600, 600, P3D);
  cam = new PeasyCam(this, 500);
  sun = new Planet(50, 0, 0);
  sun.spawnMoons(4, 1);
}

void draw() {
  background(0);
  lights();
  sun.show();
  sun.orbit();
}
</code></pre>

<p>// planet class</p>

<pre><code>class Planet {
      float radius;
      float distance;
      Planet[] planets;
      float angle;
      float orbitspeed;
      PVector v;

      PShape globe;

      Planet(float r, float d, float o) {

    v = PVector.random3D();

    radius = r;
    distance = d;
    v.mult(distance);
    angle = random(TWO_PI);
    orbitspeed = o;
  }

  void orbit() {
    angle = angle + orbitspeed;
    if (planets != null) {
      for (int i = 0; i &lt; planets.length; i++) {
        planets[i].orbit();
      }
    }
  }

  void spawnMoons(int total, int level) {
    planets = new Planet[total];
    for (int i = 0; i &lt; planets.length; i++) {
      float r = radius/(level*2);
      float d = random((radius + r), (radius+r)*2);
      float o = random(-0.1, 0.1);
      planets[i] = new Planet(r, d, o);
      if (level &lt; 2) {
        int num = int(random(0, 3));
        planets[i].spawnMoons(num, level+1);
      }
    }
  }

  void show() {
    pushMatrix();
    noStroke();
    PVector v2 = new PVector(1, 0, 1);
    PVector p = v.cross(v2);
    rotate(angle, p.x, p.y, p.z);
    stroke(255);
    //line(0, 0, 0, v.x, v.y, v.z);
    //line(0, 0, 0, p.x, p.y, p.z);

    translate(v.x, v.y, v.z);
    noStroke();
    fill(255);
    sphere(radius);
    //ellipse(0, 0, radius*2, radius*2);
    if (planets != null) {
      for (int i = 0; i &lt; planets.length; i++) {
        planets[i].show();
      }
    }
    popMatrix();
  }
}
</code></pre>

<p>And this is the p5.js code</p>

<pre><code>var easycam;

function setup() {
    createCanvas(windowWidth,windowHeight,WEBGL);
    easycam = createEasyCam();
    sun = new Planet(20, 0, 0, random(TWO_PI));
    sun.spawnMoons(2, 1);
}

function draw() {
    background(0);
    cursor(HAND);

    sun.show();
    sun.orbit();
}
</code></pre>

<p>//planet class</p>

<pre><code>        class Planet {
            constructor(radius, distance, orbitspeed, angle,mass) {
            this.radius = radius;
            this.distance = distance;
            this.orbitspeed = orbitspeed;
            this.angle = angle;
            this.planets = [];
            this.mass=mass;

            // this should be correct
            // this is the vector coming out of the planet itself.

            this.v = createVector();
            this.v = p5.Vector.random3D();
            this.v. mult(this.distance);
            // park this for now.
            // this.v = createVector();
            // this.v = p5.Vector.random3D();
            // this.v.mult(this.distance);
            // var v = new p5.Vector.random3D();
            // v. mult(this.distance);


        }


    orbit() {
        this.angle += this.orbitspeed/this.mass;
        for (let i in this.planets) {
            this.planets[i].orbit();
        }
    }


    spawnMoons(total, level) {
        for (let i = 0; i &lt; total; i++) {
            let r = this.radius/(level*2);
            let d = random(50, 150);
            let o = random(-0.1, 0.1);
            let a = random(TWO_PI);
            this.planets.push(new Planet(r, d/level, o, a));
            if (level &lt; 1) {
                let num = Math.floor(random(0, 4));
                this.planets[i].spawnMoons(num, level+1);
            }
        }
    }


    show() {
      push();
      noStroke(0)
      // fill(255);
      // let v2 = createVector(1,0,1);
      // let p = createVector(v.cross);
      // this.v2 = createVector(0, 0, 1);
      // this. p = this.v.cross(this.v2);
      // rotateY(this.angel);
      // translate(v.x,v.y,v.z);
      this.v2= createVector(1,0,1);
      this.p= this.v.cross(this.v2);
      rotate(this.angel,this.p.x,this.p.y,this.p.z);
      translate(this.v.x,this.v.y,this.v.z);
      //lights
          ambientLight(5,100);
          directionalLight(255, 255, 255, 0.2, 0.2, 0.7);
          specularMaterial(255);
          sphere(this.radius);

        for (let i in this.planets) {
            this.planets[i].show();
        }
        pop();
    }

}
</code></pre>

<p>I would really really appreciate some help, its quite difficult to find references on vectors in p5.js.</p>

<p>Thanks loads in advance</p>
]]></description>
   </item>
   <item>
      <title>Help with spheres bouncing off each other</title>
      <link>https://forum.processing.org/two/discussion/27948/help-with-spheres-bouncing-off-each-other</link>
      <pubDate>Wed, 09 May 2018 21:26:56 +0000</pubDate>
      <dc:creator>Mojo</dc:creator>
      <guid isPermaLink="false">27948@/two/discussions</guid>
      <description><![CDATA[<p>Hey everyone, 
I created this sketch for a bunch of emojis orbiting around one emoji and I am trying to make them bounce off each other when they touch, can someone please help me on how to do that?
Here is the code I am using:</p>

<pre><code>// importing the Peasy Cam library
import peasy.*;
import peasy.org.apache.commons.math.*;
import peasy.org.apache.commons.math.geometry.*;

// declaring the main emoji
Planet sun;
//declairing the Peasy Cam 
PeasyCam cam;
// declaring the PImage function
PImage img;
// declairing the the texture
PImage[] textures = new PImage[7];
// declaring the particle system

void setup() {

  size(displayWidth, displayHeight, P3D);


  img = loadImage("1.jpg");
  textures[0]= loadImage("2.jpg");
  textures[1]= loadImage("3.jpg");
  textures[2]= loadImage("4.jpg");
  textures[3]= loadImage("5.jpg");
  textures[4]= loadImage("6.jpg");
  textures[5]= loadImage("7.jpg");
  cam = new PeasyCam(this, 500);
  sun = new Planet (100, 0, 0, img);
  sun.spawnMoons(10, 4);
}

void draw() {

  background(0);
  lights();
  ambientLight(129, 62, 0);
  //translate(displayWidth, displayHeight);
  noFill();
  stroke(255);
  strokeWeight(1);
  //rotateY(frameCount/200.0);
  box(4000);

  lights();
  ambientLight(129, 62, 0);
  directionalLight(51, 102, 126, 0, -1, 0);
  spotLight(255, 0, 0, width/2, height/2, 400, 0, 0, -1, PI/4, 2);

  sun.show();
  sun.orbit();
}

class Planet {
  float radius;
  float angle;
  float distance;
  Planet [] planets;
  float orbitSpeed;
  PVector v;
  PShape globe;
  float mass=1;


  Planet(float r, float d, float o, PImage img ) {
    v = PVector. random3D();
    radius = r;
    angle = random(20);
    distance= d;
    v.mult(distance);
    orbitSpeed = o;

    noStroke();
    noFill();
    globe = createShape(SPHERE, radius);
    globe.setTexture(img);
  }
  void spawnMoons(int total, int level) {
    planets = new Planet[total];
    for (int  i = 0; i&lt;planets.length; i++) {

      float r= random(level*10);

      float d = random(100, 1000);

      float o = random (-0.01, 0.02);

      int index = int(random (textures.length));
      planets[i]= new Planet (r, d, o, textures[index]);

      if (level&lt;1) {
        int num = int(random(0, 5));
        planets[i].spawnMoons(num, level+1);
      }
    }
  }

  void orbit() {
    angle =  angle + orbitSpeed/mass;
    if (planets !=null) {
      for (int  i = 0; i&lt;planets.length; i++) {
        planets[i].orbit();
      }
    }
  }
  void show() {
    pushMatrix();
    noStroke();
    PVector v2 = new PVector(1, 0, 1);
    PVector p = v.cross(v2);
    rotate (angle, p.x, p.y, p.z);

    translate(v.x, v.y, v.z);
    shape(globe);
    if (planets !=null) {
      for (int  i = 0; i&lt;planets.length; i++) {
        planets[i].show();
      }
    }
    popMatrix();
  }
  void bounce() {
  }
}
</code></pre>

<p>I would really appreciate your help
Thanks</p>
]]></description>
   </item>
   <item>
      <title>Shadow effect in a PShape?</title>
      <link>https://forum.processing.org/two/discussion/27895/shadow-effect-in-a-pshape</link>
      <pubDate>Tue, 01 May 2018 20:45:51 +0000</pubDate>
      <dc:creator>mromarcoder</dc:creator>
      <guid isPermaLink="false">27895@/two/discussions</guid>
      <description><![CDATA[<p>Hello to everyone.
I was wondering if it's possible to make a shadow effect to a PShape. For example, if the sunlight is coming from east, make the shadow appear in the west, or in the other way, if the sunlight is coming form west make the shadow appear in the east.</p>
]]></description>
   </item>
   <item>
      <title>Why is lights() not lighting sphere in a class?</title>
      <link>https://forum.processing.org/two/discussion/18352/why-is-lights-not-lighting-sphere-in-a-class</link>
      <pubDate>Fri, 30 Sep 2016 03:56:18 +0000</pubDate>
      <dc:creator>GLV</dc:creator>
      <guid isPermaLink="false">18352@/two/discussions</guid>
      <description><![CDATA[<p>Why is lights() not lighting sphere in a class in this example?</p>

<pre><code>float th_6 = 0; 
Orbital Orb_3;

void setup()
  {
  size(1280, 1024, P3D);

//Class initialization
  Orb_3 = new Orbital();
  }

void draw()
  {   
  background(0); 
  lights();
  noStroke();
  translate(width/2, height/2, 0);
  sphere(20); //lights work on this!
  th_6=th_6+TWO_PI/360;
  seq_D();
  }

class Orbital
  {
  int A = 200; //diameter
  float x, y, z;
  float th = 0;

 void Circle()
    {
    for(th=0;th&lt;TWO_PI;th+=TWO_PI/360)
      {
      x=A*cos(th);  
      y=A*sin(th);
      point(x, y, 0);
      }
    }  

   void Traj()
    {
    x = A*cos(th_6);  
    y = A*sin(th_6);
    translate(x,y);
    }       
  }         

void seq_D()
  {
  strokeWeight(2);
  rotateY(th_6);
  stroke(255, 0, 255);
  Orb_3.Circle();
  Orb_3.Traj();
  sphere(20);       //lights DO NOT work on this!
  } 
</code></pre>
]]></description>
   </item>
   <item>
      <title>lights and Shapes3D library</title>
      <link>https://forum.processing.org/two/discussion/25211/lights-and-shapes3d-library</link>
      <pubDate>Sun, 26 Nov 2017 17:27:26 +0000</pubDate>
      <dc:creator>GLV</dc:creator>
      <guid isPermaLink="false">25211@/two/discussions</guid>
      <description><![CDATA[<p>lights() adds light to the opposite side expected on the tubes I create with shapes3D.
The box and sphere have the expected light.</p>

<p>If I add scale(-1, 1, 1); to the tubes, the light appears correct except for the end caps (you must observe each end cap to see this).</p>

<p>Can someone please help with this? <a href="/two/profile/quark">@quark</a></p>

<p><a rel="nofollow" href="http://lagers.org.uk/s3d4p/index.html">lagers.org.uk/s3d4p/index.html</a></p>

<pre><code>// Requires the Shapes3D library.

import shapes3d.utils.*;
import shapes3d.animation.*;
import shapes3d.*;

Tube tube02;
Tube tube01;

float angleX, angleY, angleZ;

void setup() 
  {
  size(1000, 1000, P3D);

  tube01 = new Tube(this, 4, 50);
  tube01.setSize(50, 50, 50, 50, 400);
  tube01.fill(color(255, 255, 0));
//  tube01.fill(#FFFF00, S3D.BOTH_CAP);
  tube01.drawMode(S3D.SOLID);
  tube01.visible(false, S3D.BOTH_CAP);

  tube02 = new Tube(this, 4, 50);
  tube02.setSize(50, 50, 50, 50, 400);
  tube02.fill(color(255, 255, 0));
  tube02.fill(#FFFF00, S3D.BOTH_CAP);
  tube02.drawMode(S3D.SOLID);
  tube02.visible(true, S3D.BOTH_CAP);
  }

void draw() 
  {
  background(0);    
  //  scale(1, 1, 1);
  translate(width/2, height/2);
  //  lights();
  ambientLight(128, 128, 128);                  //default
  //  directionalLight(128, 128, 128, 0, 0, -1);    //default
  directionalLight(128, 128, 128, -1, 0, 0);    //custom
  lightFalloff(1, 0, 0);                        //default 
  lightSpecular(0, 0, 0);                       //default

//  translate(width/2, height/2);

  pushMatrix();  
  noStroke();
  strokeWeight(0);
  fill(color(255, 255, 0));
  angleX += PI/1000;
  angleY += PI/1000;
  angleZ += PI/1000;
  rotateX(angleX);
  rotateY(angleY);
  rotateZ(angleZ);

  pushMatrix();
  translate(-300,0, 0);
  fill(255, 255, 0);
  sphere(50); 
  popMatrix();

  pushMatrix();
  translate(300, 0, 0);
  fill(255, 255, 0);
  box(100, 400, 100);  
  popMatrix();

  pushMatrix();
  translate(100, 0, 0);
//  scale(-1, 1, 1);
  tube01.draw();
  popMatrix();

  pushMatrix();
  translate(-100, 0, 0);
//  scale(-1, 1, 1);
  tube02.draw();
  popMatrix(); 
  popMatrix();
  } 
</code></pre>
]]></description>
   </item>
   <item>
      <title>I have a problem with 3D and 2D things using peasycam</title>
      <link>https://forum.processing.org/two/discussion/24982/i-have-a-problem-with-3d-and-2d-things-using-peasycam</link>
      <pubDate>Mon, 13 Nov 2017 01:48:25 +0000</pubDate>
      <dc:creator>tiwis</dc:creator>
      <guid isPermaLink="false">24982@/two/discussions</guid>
      <description><![CDATA[<p>Hello guys, with the help of Chrisir i'm developing a program that you have a 3D shape and it's allows you to click on the parts of the shape and each part shows you some information.
The problem is that I want the info to appear static and in 2D but I can't, it's affected and I saw it in 3D.</p>

<p>I tried putying the code that calls the text with the info between beginHUD(); and endHUD(); but it crashes the program.</p>

<p>Here is the code.</p>

<pre><code>    import peasy.*;

    PeasyCam cam;

PShape ammonite; 
PImage fondo, titulo, titulo2; 
String estado; 
PFont helvetica, nexa;

// invisible PGraphics
PGraphics pg;

//define hot spots 
PVector[] hotSpotsPosition=new PVector[4]; 
color[] hotSpotsColor =new color [hotSpotsPosition.length]; 
String[] hotSpotsText = new String [hotSpotsPosition.length];
PImage[] hotSpotsImg = new PImage [hotSpotsPosition.length]; 
boolean [] hotSpotsRightSide = new boolean [hotSpotsPosition.length];

int undefined=-1; 
int hotSpotFound=undefined; // when undefined no text is displayed

void setup() { 
  fullScreen(P3D);

  imageMode(CENTER); 
  textAlign(CENTER);

  cam = new PeasyCam(this, 100); 
  cam.setMinimumDistance(110); 
  cam.setMaximumDistance(500);

  ammonite = loadShape("ammonite.obj");
  println ("just loaded ammonite");
  println( ammonite.getChildCount() +" child count");

  // define the hot spots in parallel arrays
  // the first hot spot is defined in hotSpotsPosition[0] and hotSpotsColor[0] and hotSpotsText[0] 
  // positions:
  hotSpotsPosition[0] = new PVector(-15, -20, 0);
  hotSpotsPosition[1] = new PVector(-5, -5, -25); 
  hotSpotsPosition[2] = new PVector(-20, -10, 3); 
  hotSpotsPosition[3] = new PVector(-25, -10, 15);
  //colors: colors are not visible but must be unique!!!!!! 
  hotSpotsColor[0] = color(255, 0, 0); 
  hotSpotsColor[1] = color(100, 0, 0); 
  hotSpotsColor[2] = color(110, 0, 0); 
  hotSpotsColor[3] = color(120, 0, 0); 
  // texts 
  hotSpotsText[0] = "embudo"; 
  hotSpotsText[1] = "caparazon"; 
  hotSpotsText[2] = "ojos"; 
  hotSpotsText[3] = "tentaculos";
  //images
  // use different file names here 
  hotSpotsImg[0] = loadImage ("top shell color.JPG"); 
  hotSpotsImg[1] = loadImage ("top shell color.JPG"); 
  hotSpotsImg[2] = loadImage ("top shell color.JPG");  
  hotSpotsImg[3] = loadImage ("top shell color.JPG");
  // whether we display the spot left or right 
  hotSpotsRightSide[0] = false; 
  hotSpotsRightSide[1] = true;
  hotSpotsRightSide[2] = true; 
  hotSpotsRightSide[3] = true;

  for (PImage img : hotSpotsImg)
    img.resize(100, 0); 

  fondo = loadImage("fondo.jpg"); 
  titulo = loadImage("titulo.png"); 
  titulo2 = loadImage("conociendo.png");

  estado = "inicio";

  helvetica = createFont("HelveticaWorld-Regular.ttf", 30); 
  nexa = createFont("Nexa Bold.otf", 50);

  pg = createGraphics(width, height, P3D);

  fondo.resize(width, height); 
  image(fondo, width/2, height/2);
}//func

void draw() {

  avoidClipping(); // so the graphic AMMONITE is not cut when rotating

  if (estado.equals("inicio")) { 
    //-----------Stopping peasy ------ 
    cam.beginHUD(); 
    image(fondo, width/2, height/2); 
    textFont(nexa); 
    text("AMMONITE", width/2, height/6 - 50); 
    text("EL ANCESTRO MARINO", width/2, height/6); 
    textFont(helvetica); 
    text("Toca para comenzar", width/2, height/2 + 300); 
    cam.endHUD(); //--------------------------------
  }//if 
  // --------------------- next estado !!!! -------- 
  else if ( estado.equals("modelo")) {

    doEstadoModelo(); // most important
  }//else if
  // --------------------- EROR - NO estado - program error !!!! --------
  else { 
    println ("--------------- EROR - NO estado in draw() !!!! --------"); 
    exit(); 
    return;
  }//else
}//func draw()

//------------------------------------------------------------------------

void mousePressed() { 
  if (estado.equals("inicio")) {
    // start screen
    estado = "modelo";
  } 
  // --------------------- next estado !!!! -------- 
  else if ( estado.equals("modelo")) {
    //
    color colorFromMouse = pg.get(mouseX, mouseY);
    int oldHotSpotFound=hotSpotFound; 
    // hotSpotFound=undefined; // reset 
    for (int i=0; i&lt;hotSpotsPosition.length; i++) { 
      if (colorFromMouse==hotSpotsColor[i]) {
        if (i==oldHotSpotFound)
          hotSpotFound=undefined; // reset
        else 
        hotSpotFound=i; // set
        break;
      }//if
    }//for 
    //---
  }//else if 
  // --------------------- EROR - NO estado !!!! -------- 
  else { 
    println ("--------------- EROR - NO estado in mousePressed() !!!! --------"); 
    exit(); 
    return;
  }//else
}//func

void doEstadoModelo() {

  makeInternalPGraphics();

  // HUD ----
  cam.beginHUD(); 
  image(fondo, width/2, height/2, width, height); 
  textFont(nexa); 
  fill(255); 
  text("CONOCIENDO AL AMMONITE", width/2, height/6 - 50);   


  // show Ammonite 
  pushMatrix(); 
  spotLight(255, 255, 255, 80, 20, 40, -1, 0, 0, PI/2, 2); 
  directionalLight(255, 255, 255, width/2, height/2, 20); 
  scale(20); 
  shape(ammonite); 
  popMatrix();

  // spheres
  for (int i=0; i&lt;hotSpotsPosition.length; i++) {
    PVector pv = hotSpotsPosition[i];
    pushMatrix(); 
    translate(pv.x, pv.y, pv.z); 
    noStroke(); 
    // use any color your want here
    fill(255, 2, 2, 50); 
    if (i==hotSpotFound) {
      fill(2, 255, 2, 50);
    }
    sphere(7); 
    popMatrix();
  }

  // if a hot spot has been clicked:
  if (hotSpotFound!=undefined) {

    if (hotSpotsRightSide[hotSpotFound]) {
      // show rect with text 
      // on right side
      pushMatrix();
      translate(hotSpotsPosition[hotSpotFound].x, 
        hotSpotsPosition[hotSpotFound].y, 
        hotSpotsPosition[hotSpotFound].z);
      scale(0.5);
      fill(250, 250, 35); 
      rect(0, 0, 100, 100); 
      fill(0); 
      textFont(helvetica);
      textSize(9);
     textMode(SHAPE); 
      translate(0, 0, 0.2); 
      text(hotSpotsText[hotSpotFound], 4, 4, 90, 92);
      if (hotSpotsImg[hotSpotFound]!=null) {
        translate(100+hotSpotsImg[hotSpotFound].width/2, 0, 0);
        image(hotSpotsImg[hotSpotFound], 0, 0);
      }
      popMatrix();
    } else
    {
      // show rect with text 
      // on left side
      pushMatrix();
      translate(hotSpotsPosition[hotSpotFound].x-50, 
        hotSpotsPosition[hotSpotFound].y, 
        hotSpotsPosition[hotSpotFound].z);
      //  translate(-50, 0, 0);
      fill(250, 250, 35);
      scale(0.5);
      rect(0, 0, 100, 100); 
      fill(0); 
      textFont(helvetica);
      textSize(9);
      textMode(SHAPE); 
      translate(0, 0, 0.2); 
      text(hotSpotsText[hotSpotFound], 4, 4, 90, 92);
      if (hotSpotsImg[hotSpotFound]!=null) {
        translate(-25-hotSpotsImg[hotSpotFound].width/4, hotSpotsImg[hotSpotFound].height/2, 0);
        image(hotSpotsImg[hotSpotFound], 0, 0);
      }
      popMatrix();
      cam.endHUD(); // ----
    }//else
  }//if
}//func

void makeInternalPGraphics() { 
  pg.beginDraw(); 
  pg. perspective(PI/3.0, (float) width/height, 1, 1000000); 
  pg.setMatrix(getMatrix()); // replace the PGraphics-matrix
  pg.background(0); 
  pg.noLights(); 
  for (int i=0; i&lt;hotSpotsPosition.length; i++) { 
    PVector pv=hotSpotsPosition[i]; 
    pg.pushMatrix(); 
    pg.translate(pv.x, pv.y, pv.z); 
    pg.noStroke(); 
    pg.fill(hotSpotsColor[i]); 
    pg.sphere(7); 
    pg.popMatrix();
  }//for 
  pg.endDraw();
}//func

void avoidClipping() {
  // avoid clipping :
  // https : // // forum.processing.org/two/discussion/4128/quick-q-how-close-is-too-close-why-when-do-3d-objects-disappear 
  perspective(PI/3.0, (float) width/height, 1, 1000000);
}//func //
</code></pre>

<p>Any help or advice will be so helpful, thanks!</p>
]]></description>
   </item>
   <item>
      <title>I need help using peasy cam library</title>
      <link>https://forum.processing.org/two/discussion/24920/i-need-help-using-peasy-cam-library</link>
      <pubDate>Wed, 08 Nov 2017 23:01:21 +0000</pubDate>
      <dc:creator>tiwis</dc:creator>
      <guid isPermaLink="false">24920@/two/discussions</guid>
      <description><![CDATA[<p>Hello, i'm developing an app in which i want a 3D object to be moved, i have this 
import peasy.*;</p>

<p>PeasyCam cam;
PShape ammonite;</p>

<p>public void setup() {
  fullScreen(P3D);
  ammonite = loadShape("ammonite.obj");
  cam = new PeasyCam(this, 100);
  cam.setWheelScale(0.01); // 1.0 by default
  cam.setMinimumDistance(60);
  cam.setMaximumDistance(500);
}
public void draw() {
  background(120, 120, 200);
  spotLight(255, 255, 255, 80, 20, 40, -1, 0, 0, PI/2, 2);
  directionalLight(255, 255, 255, width/2, height/2, 20);
  rotateX(-.2);
  rotateY(-.2);
  scale(20);
  shape(ammonite);
  pushMatrix();
  translate(0, 0, 20);
  popMatrix();
}</p>

<p>and it works perfectly, but when I want to use that code in my application with background, the functions that I want to use on my 3D model, applies to all the app and it's a disaster, anyone has used that library using backgrounds and other objects?</p>

<p>How should I write the code in order to make it work?</p>

<p>This is a screen of the app that works</p>

<p><img src="https://k60.kn3.net/8/8/8/8/3/A/F8E.png" alt="" /></p>

<p>And this happens when I try to put that code on my app and I move the mouse</p>

<p><img src="https://k60.kn3.net/6/7/0/B/C/F/AD8.png" alt="" /></p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Applying a texture to an imported *.obj file?</title>
      <link>https://forum.processing.org/two/discussion/15764/applying-a-texture-to-an-imported-obj-file</link>
      <pubDate>Wed, 30 Mar 2016 12:44:32 +0000</pubDate>
      <dc:creator>lmeeken</dc:creator>
      <guid isPermaLink="false">15764@/two/discussions</guid>
      <description><![CDATA[<p>I'm playing around with 3D models, and trying to apply textures to them. I'm finding that setTexture() doesn't work with PShapes created from imported obj files, though it seems to work fine with PShapes created from primitives.</p>

<p>Here is some example code, where I load in a model, and create a sphere, and apply the same texture to both. In this case, only the sphere has a texture.</p>

<pre><code>PShape model;
PShape globey;
PImage pizza;

void setup() {
  size(500, 500, P3D);
  pizza = loadImage("pizza.jpg"); // load the texture
  model = loadShape("mammoth.obj");
  model.setTexture(pizza); //this does not work, the model is just black
  globey = createShape(SPHERE, 1000);
  globey.setTexture(pizza); //this DOES work. The sphere has a texture from pizza.jpg
  globey.setStroke(false);
}

void draw() {
    lights();
    directionalLight(51, 102, 126, -1, 0, 0);
    directionalLight(255, 0, 100, 1, 0, 0);
  scale(.1);
  shape(globey);
  shape(model);
}
</code></pre>

<p>Here is the result:</p>

<p><img src="https://cloud.githubusercontent.com/assets/6827480/14128140/15aae202-f5ec-11e5-89b7-7044ad1729b0.png" alt="" /></p>

<p>I'm trying to get the same texture to be applied to the mammoth skeleton, but it will only apply itself to the sphere, and I'm not sure why.</p>
]]></description>
   </item>
   <item>
      <title>Drawing the human silhouette with bezier</title>
      <link>https://forum.processing.org/two/discussion/18544/drawing-the-human-silhouette-with-bezier</link>
      <pubDate>Fri, 14 Oct 2016 18:00:46 +0000</pubDate>
      <dc:creator>Jose_Aparecido</dc:creator>
      <guid isPermaLink="false">18544@/two/discussions</guid>
      <description><![CDATA[<p>Hello guys,</p>

<p>Sorry but I will try to ask something complicated again ... (laughs) ...</p>

<p>Below are two code snippets in the first example has a "silhouette" human, designed with bezier, the example I took in OpenProcessing.</p>

<p>Then there is another code, which like to do something similar, ie have the outline of the human body, but only in 3D, with proscene library could to facilitate rotacionamento, I got an example here in the forum.</p>

<p>Someone would know where I FIND tips on how to facilitate to mount coordinated the human body? (Build the mesh ...) to make these contours in 3D?</p>

<p>If anyone can help me with any tips, I thank the attention.</p>

<p>Thank you very much</p>

<p>first Program</p>

<pre><code>int neckThick, headShape, shoulderSize, armSize, hipSize, lowerSize, upperSize, thighSize, handSize, legSize, footSize; 

void setup() {
  size(displayWidth, displayHeight, P3D);
  smooth();
  strokeWeight(2);
  noFill();
  stroke(10,50,255,80);

  atualizaPontos();
}

void draw() {
  background(255);
  desenhaCorpo();;
}

void atualizaPontos(){
  neckThick    = 3;
  headShape    = 0;
  shoulderSize = 5;
  armSize      = -1;
  hipSize      = -3;
  lowerSize    = -5;
  upperSize    = 2;
  thighSize    = -5;
  handSize     = 15;
  legSize      = 0;
  footSize     = 14;
}

void desenhaCorpo() {
  head(headShape);
  neck(neckThick);
  shoulders(shoulderSize); 
  upperArms(armSize);
  hips(hipSize); 
  lowerBody(lowerSize); 
  upperBody(upperSize);  
  thighs(thighSize); 
  kneecaps();
  hands(handSize);  
  legs(legSize); 
  feet(footSize);
}

void head(int headSize) { 
  bezier(300, 70, 308, 30, 372, 30, 385, 70); //scalp
  bezier(300, 70, 300-headSize, 120, 315-headSize, 135, 320, 140); //side
  bezier(385, 70, 385+headSize, 120, 370+headSize, 135, 365, 140); //side
  bezier(320, 140, 340, 155, 345, 155, 365, 140); //chin
}
void neck(int neckWidth) {
  bezier(320, 140, 325-neckWidth, 170, 320-neckWidth, 180, 315, 180); //left neck
  bezier(365, 140, 355+neckWidth, 170, 365+neckWidth, 180, 365, 180); //right neck
}
void shoulders(int shoulderWidth) {
  bezier(210, 200, 305, 190-shoulderWidth, 310, 185-shoulderWidth, 315, 180); //left trapezius
  bezier(365, 180, 370, 190-shoulderWidth, 380, 195-shoulderWidth, 480, 200); //right trapezius
  bezier(210, 200, 205, 205, 205, 205, 200, 220); // left shoulder
  bezier(480, 200, 485, 205, 485, 205, 490, 220); // right shoulder
} 
void upperBody(int upperWidth) {
  bezier(240, 250, 245-upperWidth, 300+upperWidth, 250-upperWidth, 325+upperWidth, 275, 325); //left pectoral 
  bezier(450, 250, 450+upperWidth, 300+upperWidth, 430+upperWidth, 325+upperWidth, 415, 325); //right pectoral
  bezier(330, 300, 325, 320, 320, 320, 300, 325); //inner boob
  bezier(360, 300, 370, 320, 375, 320, 390, 325); //inner boob
}
void lowerBody(int lowerWidth) {
  bezier (260, 320, 260-lowerWidth, 350+lowerWidth/2, 270-lowerWidth, 380+lowerWidth/2, 265, 415); // left side 
  bezier (430, 320, 430+lowerWidth, 350+lowerWidth/2, 420+lowerWidth, 380+lowerWidth/2, 425, 415); // right side
}
void hips(int hipWidth) {
  bezier(265, 410, 265-hipWidth, 430, 255-hipWidth, 435, 260, 450); //left hip 
  bezier(425, 410, 425+hipWidth, 430, 435+hipWidth, 435, 430, 450); //left hip
}
void thighs(int thighWidth) {
  bezier(260, 450, 240-thighWidth, 500, 250-thighWidth, 525, 270, 650); //left thigh side
  bezier(335, 480, 340+thighWidth, 500, 330+thighWidth, 525, 320, 650); //right thigh side
  bezier(430, 450, 445+thighWidth, 500, 440+thighWidth, 525, 420, 650); //left thigh side
  bezier(360, 480, 355-thighWidth, 500, 355-thighWidth, 525, 370, 650); //right thigh side
  bezier(335, 480, 340, 483, 340, 483, 360, 480);
}
void kneecaps() {
  bezier(270, 650, 270, 655, 265, 655, 270, 690); // left kneecap side 
  bezier(320, 650, 320, 655, 325, 655, 320, 690); // right kneecap side
  bezier(420, 650, 420, 655, 425, 655, 420, 690); // left kneecap side 
  bezier(370, 650, 370, 655, 365, 655, 370, 690); // right kneecap side
}
void upperArms(int armWidth) {
  bezier(200, 220, 190-armWidth, 300, 200-armWidth, 310, 200, 350); // left forearm side 
  bezier(200, 350, 180-armWidth, 425, 200-armWidth, 500, 200, 500); // left arm side 
  bezier(240, 250, 240+armWidth, 300, 235+armWidth, 310, 235, 350); // left forearm inside 
  bezier(235, 350, 240+armWidth, 425, 230+armWidth, 450, 225, 500); // left arm inside 
  bezier(490, 220, 500+armWidth, 300, 490+armWidth, 310, 490, 350); // right forearm 
  bezier(490, 350, 510+armWidth, 425, 490+armWidth, 500, 490, 500); // right arm 
  bezier(450, 250, 450-armWidth, 300, 455-armWidth, 310, 455, 350); // right forearm inside
  bezier(455, 350, 460-armWidth, 425, 455-armWidth, 450, 465, 500); // right arm inside
}
void hands(int handWidth) {
  bezier(200, 500, 210-handWidth, 530, 175-handWidth, 560, 220, 575); // left hand 
  bezier(220, 575, 225+handWidth, 575, 220+handWidth, 560, 225, 500); // left hand 
  bezier(490, 500, 480+handWidth, 530, 500+handWidth, 560, 490, 575); // right hand 
  bezier(465, 500, 460-handWidth, 575, 455-handWidth, 560, 490, 575); // right hand
}
void legs(int legWidth) {
  bezier(270, 690, 255-legWidth, 775, 265-legWidth, 800, 275, 850); //left calf 
  bezier(320, 690, 320+legWidth, 775, 300+legWidth, 800, 300, 850); //left calf 
  bezier(420, 690, 435+legWidth, 775, 415+legWidth, 800, 405, 850); //right calf 
  bezier(370, 690, 370-legWidth, 775, 380-legWidth, 800, 380, 850); //left calf
}
void feet(int footWidth) {
  bezier(275, 850, 250-footWidth, 900+footWidth, 280-footWidth, 900+footWidth, 300, 850); // left foot 
  bezier(405, 850, 430+footWidth, 900+footWidth, 400+footWidth, 900+footWidth, 380, 850); // left foot
}
</code></pre>

<p>second program</p>

<pre><code>import remixlab.proscene.*;

Scene scene;
float px[], py[], mesh[][][];

void setup() {
  size(displayWidth, displayHeight, P3D);
  smooth(); //Suavição de Contorno
  lights(); //Inicia Luzes no ambiente

  //Inicia ambiente para Cena
  scene = new Scene(this);
  scene.setAxesVisualHint(false);
  scene.setGridVisualHint(false);
  scene.showAll();

  //Cria Matriz para a malha 
  px = new float[40];
  py = new float[40];
  float t = 0;

  for(int i = 0; i &lt; px.length; i++) {
    px[i] = bezierPoint(50, 130, 130, 50, t);
    py[i] = bezierPoint(450, 350, 150, 50, t);
    //px[i] = bezierPoint(300, 308, 370, 300, t);
    //py[i] = bezierPoint(70, 30, 30, 70, t);
    t += (1.0/(float)(px.length-1));
    ellipse(px[i], py[i], 5, 5);
    println(t);
  }

  //Cria Malha
  mesh = createMesh(px,py,20, -60,60);
  //mesh = createMesh(px,py,170, -360,360);

  scene.startAnimation();
}

void draw() {
  background(0);
  ambientLight(128, 128, 128);
  directionalLight(255, 255, 255, 0, 1, -100);

  //head(-3);
  stroke(255);
  //noStroke();
  //fill(255,120,0);
  drawMesh(mesh);
}

void head(int headSize) { 
  fill(255);
  bezier(300, 70, 30, 308, 30, 30, 372, 30, 30, 385, 70, 30); //scalp
  bezier(300, 70, 30, 300-headSize, 120, 30, 315-headSize, 135, 30, 320, 140, 30); //side
  bezier(385, 70, 30, 385+headSize, 120, 30, 370+headSize, 135, 30, 365, 140, 30); //side
  bezier(320, 140, 30, 340, 155, 30, 345, 155, 30, 365, 140, 30); //chin
}

//Desenha Malha
void drawMesh(float mesh[][][]) {
  //println(mesh.length+" "+mesh[0].length+" "+mesh[0][0].length);
  for(int i = 0; i &lt; mesh.length-1; i++) {
    beginShape(QUAD_STRIP);
    for(int j = 0; j &lt; mesh[0].length; j++) {
      vertex(mesh[i][j][0], mesh[i][j][1], mesh[i][j][2]);
      vertex(mesh[i+1][j][0], mesh[i+1][j][1], mesh[i+1][j][2]);
    }
    endShape();
  }
}

//Cria malha
float [][][] createMesh(float px[],float py[],int numrot, float startDeg,float endDeg) {
  float deg, x, z;
  double cosval, sinval, tmp1, tmp2;

  float [][][] mesh = new float[numrot][px.length][3];
  endDeg -= startDeg;

  for(int i = 0; i &lt; numrot; i++) {
    deg = radians(startDeg + (endDeg/(float)(numrot-1)) * (float)i);
    for(int j = 0; j &lt; px.length; j++) {
      x = px[j];
      z = 0;
      cosval = Math.cos(deg);
      sinval = Math.sin(deg);
      tmp1   = x * cosval - z * sinval;
      tmp2   = x * sinval + z * cosval;
      mesh[i][j][0] = (float) tmp1;
      mesh[i][j][1] = py[j];
      mesh[i][j][2] = (float) tmp2;
    }
  }
  return mesh;
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Check amount of light from directionalLight() on quad/Shape</title>
      <link>https://forum.processing.org/two/discussion/16414/check-amount-of-light-from-directionallight-on-quad-shape</link>
      <pubDate>Tue, 03 May 2016 20:48:04 +0000</pubDate>
      <dc:creator>illpack</dc:creator>
      <guid isPermaLink="false">16414@/two/discussions</guid>
      <description><![CDATA[<p>Is it possible to check the amount of light (directionalLight()) that hits a surface so we can use that values?
I am trying to implement a simple shaded wireframe view and I want to be able to colour my lines the same colour the Shapes get when hit by my directionalLight. It seems to me that should be very easy, since Processing is already calculating the normals of all surfaces and interpolating along the surface to colour it... I only need the colour at the vertices.</p>

<p>Any ideas?
Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Can't use the method lights() or directionalLight() in my drawing.</title>
      <link>https://forum.processing.org/two/discussion/15765/can-t-use-the-method-lights-or-directionallight-in-my-drawing</link>
      <pubDate>Wed, 30 Mar 2016 13:42:10 +0000</pubDate>
      <dc:creator>MagnoVJ</dc:creator>
      <guid isPermaLink="false">15765@/two/discussions</guid>
      <description><![CDATA[<p>All the time I try to use some light releted method like lights() or directionalLight() the console is returning to me the error FATAL EXCEPTION: GLThread 10295
java.lang.NullPointerException. Can someone tell me what could it be?</p>

<p>the drawing method:</p>

<pre><code>void draw(){

    background(0);

    lights(); //because of the method the error happens...

    float tempOrientation = (float) ((int) (accelerometerY * 1000)) / 1000;

    camera(width/2.0 + tempOrientation * width/10, height/2.0, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0, height/2.0, 0, 0, 1, 0);

    pointLight(200, 200, 200, width/2, height/2, 200);

    centerLine();
    drawBall();
    drawPlayer();
    drawEnemy();
    scoreText();

    println("-------");
    println("X: " + accelerometerX);
    println("Y: " + accelerometerY);
    println("Z: " + accelerometerZ);
    println("-------");
}
</code></pre>

<p>the error in console:</p>

<pre><code>FATAL EXCEPTION: GLThread 10295
java.lang.NullPointerException
FATAL EXCEPTION: GLThread 10295
java.lang.NullPointerException
    at processing.opengl.PGL.loadVertexShader(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.getPolyShader(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.flushPolys(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.flush(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.endDraw(Unknown Source)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.opengl.PGLES$AndroidRenderer.onDrawFrame(Unknown Source)
    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1524)
    at processing.opengl.PGL.loadVertexShader(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.getPolyShader(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.flushPolys(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.flush(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.endDraw(Unknown Source)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.opengl.PGLES$AndroidRenderer.onDrawFrame(Unknown Source)
    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1524)
    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)
    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)
</code></pre>
]]></description>
   </item>
   <item>
      <title>Render a 3D Map w/Buildings in Processing</title>
      <link>https://forum.processing.org/two/discussion/15292/render-a-3d-map-w-buildings-in-processing</link>
      <pubDate>Sat, 05 Mar 2016 06:00:25 +0000</pubDate>
      <dc:creator>sirianth</dc:creator>
      <guid isPermaLink="false">15292@/two/discussions</guid>
      <description><![CDATA[<p>like so: <a href="https://mapzen.com/projects/tangram/" target="_blank" rel="nofollow">https://mapzen.com/projects/tangram/</a></p>

<p>anyone have any ideas? I've been messing with unfolding maps, but can't figure out how to do it</p>

<p>it has this object:</p>

<p>public abstract class AbstractMapTileUrlProvider
extends AbstractMapProvider
Handles tiles from URLs, such as web map services, etc.</p>

<p>which theoretically could handle any map, but I can't figure out how to use it and/or I don't know if it can import 3D maps</p>

<p>link to the project I'm working on is here: <a href="https://www.instagram.com/p/BBeDQXkiuN-/?taken-by=saitogroup" target="_blank" rel="nofollow">https://www.instagram.com/p/BBeDQXkiuN-/?taken-by=saitogroup</a></p>
]]></description>
   </item>
   <item>
      <title>Methods affecting other methods</title>
      <link>https://forum.processing.org/two/discussion/14618/methods-affecting-other-methods</link>
      <pubDate>Tue, 26 Jan 2016 02:36:14 +0000</pubDate>
      <dc:creator>georgia</dc:creator>
      <guid isPermaLink="false">14618@/two/discussions</guid>
      <description><![CDATA[<p>Hi there,</p>

<p>I have two methods, neither of which are in any classes, that seem to be affecting each other. One of them creates a sphere in the center of the screen and continuously rotates it. The other creates a text field in the upper left side of the screen. I call both of these methods in draw(). For some reason, the text field is being drawn near the sphere and rotated. When I comment out the sphere function, the textfield works perfectly. Any idea what's going on here? I've included my code below for reference. Thanks!</p>

<p>import g4p_controls.*;
import controlP5.*;</p>

<p>PImage bg;
PImage planet; 
PShape globe;
Table t2;
celestialObject C1;
float a=0.0;
PFont f; 
String textValue = "";</p>

<p>void setup(){
  size(1024, 576, P3D);
  globe= createShape(SPHERE, 110);
}</p>

<p>void draw() {
  noStroke(); 
  background(bg);
  buildGraphics();
  buildSphere();
}</p>

<p>void buildSphere(){
  float dirY = (mouseY / float(height) - 0.5) * 2;
  float dirX = (mouseX / float(width) - 0.5) * 2;
  colorMode(HSB, 100);
  directionalLight(0, 0, 99, -dirX, -dirY, -1); 
  translate(width/1.75, height/2, 0);
    //how fast the object rotates.
    a += 0.005;
  if(a &gt; TWO_PI) { 
    a = 0.0; 
  }
 rotateY(a * 2.0);
  shape(globe);
}
void buildGraphics(){</p>

<p>ControlP5 cp5 = new ControlP5(this);
  cp5.addBang("clear")
     .setPosition(180,150)
     .setSize(40,20)
     .getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER)
     ;<br />
        cp5.addTextfield("Search for a celestial body")
     .setPosition(20,100)
     .setSize(200,40)</p>

<pre><code> .setFocus(true)
 .setColor(color(255,0,0))
 ;
 text(cp5.get(Textfield.class,"Search for a celestial body").getText(), 360,130);
</code></pre>

<p>text(textValue, 360,180);
}</p>
]]></description>
   </item>
   <item>
      <title>Load image as background of sphere</title>
      <link>https://forum.processing.org/two/discussion/14542/load-image-as-background-of-sphere</link>
      <pubDate>Tue, 19 Jan 2016 22:13:28 +0000</pubDate>
      <dc:creator>georgia</dc:creator>
      <guid isPermaLink="false">14542@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to make a sphere of size 30 with an image as the background. How do I do this? I'm using the directionalLight() method, so I think I need to incorporate the image somewhere in there. Anything helps!</p>
]]></description>
   </item>
   <item>
      <title>fill() in P3D mode leads to some weird behavior.</title>
      <link>https://forum.processing.org/two/discussion/4537/fill-in-p3d-mode-leads-to-some-weird-behavior</link>
      <pubDate>Sat, 19 Apr 2014 15:39:58 +0000</pubDate>
      <dc:creator>billautomata</dc:creator>
      <guid isPermaLink="false">4537@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to wrap my head around lights and materials for a blog post that I am doing, and I can't seem to figure out what exactly is going on when I use <code>fill()</code> in <code>P3D</code> mode.</p>

<pre><code>void setup(){
  size(800,800,P3D);
  smooth(8);
}
void draw(){

  noStroke();

  background(0);

  ambientLight(128, 128, 128);

  lightSpecular(128,128,128);
  directionalLight(128,128,128, 0, 1, -1);

  pushMatrix();
    translate(width * 0.5, height * 0.5, 0);

    ambient(128,128,128);

    specular(255,255,0);  // yellow specular light
    shininess(10.0);

    sphere(width * 0.2);

  popMatrix();

}
</code></pre>

<p>produces...</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/912/3INDG0XZIBGU.png" alt="ambient" title="ambient" /></p>

<p>If I replace the call to <code>ambient(128,128,128);</code> with <code>fill(128,128,128);</code> I get this:</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/570/2CZEUXANWCNR.png" alt="fill" title="fill" /></p>

<p>Calling <code>fill</code> seems to nullify other settings like <code>shininess</code>.  What exactly is going on in <code>P3D</code> mode when I am calling <code>fill</code>?  Thanks!</p>
]]></description>
   </item>
   </channel>
</rss>