#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# I have 2 questions about P3D geometry

edited December 2017

The first is about triangle strips. When I try to draw one it gives me the message: "Only GROUP, PShape.PATH, and PShape.GEOMETRY work with createShape()" for something like:

``````void setup(){
size(1080,720,P3D);
}

void draw(){
stroke(255);
fill(255,0,0);

createShape(TRIANGLE_STRIP);
vertex(-100,0,100);
vertex(-100,0,-100);
vertex(100,0,100);
vertex(100,0,-100);
endShape(CLOSE);
}
``````

The second is about texture mapping. I am trying to put an image onto a sphere but also have other shapes that rely on fill(). I tried putting the fill in pushmatrix and popmatrix but it fills the globe anyway.

``````import peasy.*;

PeasyCam cam;
PImage img;
PShape globe;

void setup(){
cam = new PeasyCam(this,700);
size(1080,720,P3D);
}

void draw(){
pushMatrix();
fill(255,0,0);
popMatrix();

globe=createShape(SPHERE,4000);
globe.setTexture(img);
noStroke();
shape(globe);
}
``````
Tagged:

• edited December 2017 Answer ✓

First

look at reference createShape and beginShape

``````float a;
void setup() {
size(1080, 720, P3D);
background(0);
}

void draw() {
background(0);
lights();

translate(333, 333);
rotateX(a);
a+=.01;
stroke(255);
fill(255, 0, 0);

//createShape(TRIANGLE_STRIP);
createShape();
beginShape(TRIANGLE_STRIP);
vertex(-100, 0, 100);
vertex(-100, 0, -100);
vertex(100, 0, 100);
vertex(100, 0, -100);
endShape(CLOSE);
}
``````

Second

pushMartix/popMatrix doesn't isolate colors, only the Matrix

better define globe in setup()

``````import peasy.*;

PeasyCam cam;
PImage img;
PShape globe;

void setup() {
size(1080, 720, P3D);

cam = new PeasyCam(this, 700);

sphereDetail(44);

background(0);

globe=createShape(SPHERE, 4000);
globe.setFill(false);
globe.setStroke(false);
globe.setTexture(img);
}

void draw() {
background(0);
lights();

shape(globe);

pushMatrix();
noStroke();
fill(255, 0, 0);
sphere(26);
popMatrix();
}
``````