Basic 3d texture question
in
Programming Questions
•
1 year ago
All I'm doing is calling this class's draw + update in an arraylist. The original PNG is a circle but for some reason it's being warped here as you can see. Anyone know how I can fix this? This is my first 3d project. Thanks!
- class Particle
- {
- PVector d_pos;
- PImage d_img;
- int d_size;
- float d_fade;
- Particle( float x, float y, float z)
- {
- d_pos = new PVector( x, y , z);
- d_img = loadImage( "ring1.png" );
- d_size = d_img.width;
- d_fade = 255;
- d_size = 100;
- }
- void draw()
- {
- tint( 255, 150, 255, d_fade );
- noStroke();
- // image(d_img, d_pos.x - d_size/2, d_pos.y - d_size/2, d_pos.z );
- pushMatrix();
- translate(width / 2, height / 2);
- rotateX(PI/3);
- beginShape();
- texture(d_img);
- vertex(-d_size, -d_size, d_pos.z, 0, 0);
- vertex(d_size, -d_size, d_pos.z, 300, 0);
- vertex(d_size, d_size, d_pos.z, 300, 300);
- vertex(-d_size, d_size, d_pos.z, 0, 300);
- endShape();
- popMatrix();
- }
- boolean update()
- {
- d_fade *= .98;
- d_pos.z+=2;
- if( floor( d_fade ) != 0 )
- return true;
- return false;
- }
- }
1