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
physics (Read 1292 times)
physics
Aug 31st, 2006, 12:54am
 
I'm trying to learn how to use the trear physics plug in. Just to get myself going I droped the source code from one of the examples in the editor and tried to run the code.

import traer.physics.*;

ParticleSystem physics;

Particle p;
Particle anchor;
Spring s;

void setup()
{
 size( 400, 400 );
 smooth();
 fill( 0 );
 framerate( 24 );
 ellipseMode( CENTER );
       
 physics = new ParticleSystem( 5.0, 0.05 );
       
 p = physics.makeParticle( 1.0, width/2, height/2, 0 );
 anchor = physics.makeParticle( 1.0, width/2, height/2, 0 );
 anchor.makeFixed();
 s = physics.makeSpring( p, anchor, 1.0, 0.1, 100 );
}

void draw()
{
 if ( !mousePressed )
   physics.advanceTime( 1.0 );
 else
 {
   p.moveTo( mouseX, mouseY, 0 );
   p.setVelocity( (mouseX - pmouseX), (mouseY - pmouseY), 0 );  // this is so you can throw it...
 }
   
 background( 255 );
 
 line( p.position().x(), p.position().y(), anchor.position().x(), anchor.position().y() );
 ellipse( anchor.position().x(), anchor.position().y(), 5, 5 );
 ellipse( p.position().x(), p.position().y(), 20, 20 );
}


This is supposed to set up two particles and a spring. However I get the following message.

Semantic Error: No accessible method with signature "position()" was found in type "Particle".

which is supposidly in resonce to this line

 p = physics.makeParticle( 1.0, width/2, height/2, 0 );

however I can't figure out what is wrong. I was wondering if some one with more experiance may be abel to explain this.
Re: physics
Reply #1 - Aug 31st, 2006, 10:40am
 
Hey Frank,

I just copied that code and didn't have a problem running it.


Are you still having the same problem?

tk
Page Index Toggle Pages: 1