We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
dxf out (Read 280 times)
dxf out
Sep 23rd, 2006, 5:14am
 
I've been playing around with the examples from the particle system page but I'm now trying to output one of the forms to a dxf file. it works but when I try to open the file i get an error message does any one know what i'm doing wrong? Thanks for your help.

import traer.physics.*;
import processing.dxf.*;
boolean record;

ParticleSystem physics;
Particle[][] particles;
int gridSize = 10;

void setup()
{
 size(400, 400,P3D);
 fill(0);
 framerate(60);
       
 physics = new ParticleSystem(0, 0,5,0.5);
 
 particles = new Particle[gridSize][gridSize];
 
 float gridStepX = (float) ((width / 2) / gridSize);
 float gridStepY = (float) ((height / 2) / gridSize);
 
 for (int i = 0; i < gridSize; i++)
 {
   for (int j = 0; j < gridSize; j++)
   {
     //Spring makeSpring( Particle a, Particle b, float strength, float damping, float restLength )
     particles[i][j] = physics.makeParticle(0.2, j * gridStepX + (width / 4), i * gridStepY + 20, sin(gridStepY + 20));
     if (j > 0)
     {
       physics.makeSpring(particles[i][j - 1], particles[i][j], 8.0, 0.5, gridStepX);
     }
   }
 }
 
 for (int j = 0; j < gridSize; j++)
 {
   for (int i = 1; i < gridSize; i++)
   {
     physics.makeSpring(particles[i - 1][j], particles[i][j], 8.0, 0.5, tan(gridStepY));
   }
 }
 
 particles[0][0].makeFixed();
 particles[0][gridSize - 1].makeFixed();
 particles[9][gridSize - 1].makeFixed();
 particles[9][gridSize - 10].makeFixed();

}
void keyPressed() {
  // use a key press so that it doesn't make a million files
  if (key == 'r') record = true;
}
void draw()
{
    if (record) {
    beginRaw("processing.dxf.RawDXF", "output.dxf");
  }
 physics.advanceTime(0.1);
 
 if (mousePressed && keyCode == UP)
 {
   particles[0][gridSize - 1].moveTo(mouseX, mouseY, 0);
   particles[0][gridSize - 1].velocity().clear();
 }
 
   if (mousePressed && keyCode == LEFT)
 {
   particles[9][gridSize - 1].moveTo(mouseX, mouseY, 0);
   particles[9][gridSize - 1].velocity().clear();
 }
 
     if (mousePressed && keyCode == RIGHT)
 {
   particles[9][gridSize - 10].moveTo(mouseX, mouseY, 0);
   particles[9][gridSize - 10].velocity().clear();
 }
 
   if (mousePressed && keyCode == DOWN)
 {
   particles[0][0].moveTo(mouseX, mouseY, 0);
   particles[0][0].velocity().clear();
 }
 
 background(255);
 
 for (int i = 0; i < gridSize; i++)
 {
   beginShape( LINE_STRIP );
   curveVertex(particles[i][0].position().x(), particles[i][0].position().y());
   for (int j = 0; j < gridSize; j++)
   {
     curveVertex(particles[i][j].position().x(), particles[i][j].position().y());
   }
   curveVertex(particles[i][gridSize - 1].position().x(), particles[i][gridSize - 1].position().y());
   endShape();
 }
 for (int j = 0; j < gridSize; j++)
 {
   beginShape( LINE_STRIP );
   curveVertex(particles[0][j].position().x(), particles[0][j].position().y());
   for (int i = 0; i < gridSize; i++)
   {
     curveVertex(particles[i][j].position().x(), particles[i][j].position().y());
   }
   curveVertex(particles[gridSize - 1][j].position().x(), particles[gridSize - 1][j].position().y());
   endShape();
 }
}

void mouseReleased()
{
 particles[0][gridSize - 1].setVelocity( (mouseX - pmouseX), (mouseY - pmouseY), 0 );
 
    if (record) {
    endRaw();
    record = false;
  }
}
Re: dxf out
Reply #1 - Sep 23rd, 2006, 6:46am
 
I have also noticed that any camera settings I apply do not cause any changes in perspective. the only effect I can seem to get is that it offsets slightly.
Re: dxf out
Reply #2 - Sep 23rd, 2006, 5:21pm
 
what error message do you get?

as for things not changing based on perspective.. that's because dxf is a 3D file format. perspective has to do with how you map 3D to 2D, which is controlled by whatever application is rendering the 3D.
Page Index Toggle Pages: 1