Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
bringfire
bringfire's Profile
2
Posts
3
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
unexpected token: "class name here"
[2 Replies]
02-Aug-2011 05:29 PM
Forum:
Programming Questions
I keep getting the error "unexpected token:" followed by the name of the class that I just created in another tab within Processing 1.5.1.
As far as I can tell I am using the correct syntax.
Any help would be great.
import hypermedia.net.*; //UDP Library
import processing.pdf.*; //PDF Library
import processing.opengl.*; //OPENGL Library
import traer.physics.*; //Physics Library
import peasy.*; //Camera Library
import controlP5.*; //Control Buttons Library
import superCAD.*; //CAD Export Library
PMatrix3D currCameraMatrix; //define Camera Matrix Object
PGraphics3D g3; //define 3D Space detached from PeasyCam for buttons
ControlP5 controlP5; //define the ControlButton Objects
UDP udp; // define the UDP object
ParticleSystem physics; // Physics Universe!
PeasyCam cam; //PeasyCam Object
Coral coral;
ArrayList corals;
int coralIndex = 0;
void setup() {
//size(1000, 1000, P3D);
size(1000, 1000, OPENGL);
hint(ENABLE_OPENGL_4X_SMOOTH);
frameRate(30);
cursor(CROSS);
udp = new UDP( this, 6001);
udp.listen( true );
g3 = (PGraphics3D)g;
coral = new Coral();
corals = new ArrayList();
controlP5 = new ControlP5(this);
//controlP5.addSlider("mySlider", 0, 0, 0, 10, 10, 300, 50).setId(1);
controlP5.addButton("Export_OBJ", 0, 10, 80, 80, 20).setId(2);
controlP5.addButton("newMesh", 0, 10, 170, 80, 20).setId(3);
controlP5.addButton("Export_PDF", 0, 10, 240, 80, 20).setId(4);
controlP5.setAutoDraw(false);
cam = new PeasyCam(this, 500);
cam.setMinimumDistance(100);
cam.setMaximumDistance(1000);
coral.create();
coral.display();
}
void draw() {
for (int i = 0; i < corals.size(); i++)
{
Coral coral= (Coral) corals.get(i);
coral.display();
}
}
void mouseClicked() {
corals.add(new Coral());
Coral coral = (Cape) corals.get(coralIndex);
coral.create();
coralIndex++;
}
and this is the class
Class Coral {
// import hypermedia.net.*; // UDP Library
// import processing.pdf.*; // PDF Library
// import processing.opengl.*; // OPENGL Library
import traer.physics.*; // Physics Library
// import peasy.*; // Camera Library
// import controlP5.*; // Control Buttons Library
// import superCAD.*; // CAD Export Library
// PMatrix3D currCameraMatrix; // define Camera Matrix Object
// PGraphics3D g3; // define 3D Space detached from PeasyCam for buttons
// ControlP5 controlP5; // define the ControlButton Objects
// UDP udp; // define the UDP object
ParticleSystem physics; // Physics Universe!
// PeasyCam cam; // PeasyCam Object
// Particle centerParticle; // Centre node
ArrayList nodes; // ArrayList (of ArrayLists) contains all nodes (particles)
// - - - - - - - - Variables - - - - - - - - //
int[] pattern = {
2, 5
}; // Growth Pattern
int patternCount, startNodes, numGenerations, radius, restLength, buttonValue;
float strength, damping, repulsion, repulsion_minDist, drag, speed, myColor, myAlpha;
boolean record, pdfsave;
String cadSoftware, ext;
Coral() {
patternCount = 0; // Counter for total of growth pattern
startNodes = 4; // Number of nodes in first ring
numGenerations = 4; // Number of generations (rings)
radius = 10; // Starting distance between rings
restLength = 10; // Rest length of springs between nodes
strength = 0.08; // Strength of springs between nodes
damping = 0.05; // Damping of springs between nodes
repulsion = -3; // Repulsion force between nodes
repulsion_minDist = 1; // Distance from node where repulsion force begins to decrease
drag = 0.01; // Physics System drag (friction)
speed = 3; // Physics System speed of simulation update (clock)
buttonValue = 1;
myColor = 100;
myAlpha = 255;
record = false;
pdfsave = false;
}
public void create() {
physics = new ParticleSystem( 0, drag );
nodes = new ArrayList();
for (int i=0; i<pattern.length; i++) {
patternCount = patternCount + pattern[i];
}
float ringMult = (patternCount*1.0)/pattern.length;
int numNodes = startNodes;
int newRadius = radius;
float newAngle;
// - - - - Make Centre Node - - - - //
centerParticle = physics.makeParticle(1.0, 0, 0, 0);
centerParticle.makeFree();
// - - - - Make Rings - - - - //
for (int j=0; j<numGenerations; j++) {
ArrayList ring = new ArrayList();
for (int i=0; i<numNodes; i++) {
newAngle = i*2*PI/numNodes;
// - - Make Nodes - - //
Particle P = physics.makeParticle(1.0, cos(newAngle)*newRadius, sin(newAngle)*newRadius, random(-5, 5));
ring.add(P); //Particles stored in this ArrayList
//transmit();
// - - Make Concentric Springs Between Neighbouring Nodes - - //
if (i>0) {
Particle L = (Particle) ring.get(i-1);
Spring S = physics.makeSpring(P, L, strength, damping, restLength);
if (i == numNodes-1 ) {
Particle M = (Particle) ring.get(0);
Spring T = physics.makeSpring(P, M, strength, damping, restLength);
}
}
}
nodes.add(ring);
numNodes = int(numNodes*ringMult);
newRadius = newRadius + radius;
}
// - - - - Make Radial Springs Between Start Node and First Ring - - - - //
ArrayList firstRing = (ArrayList) nodes.get(0);
for (int i=0; i<firstRing.size(); i++) {
Particle P = (Particle) firstRing.get(i);
Spring S = physics.makeSpring(P, centerParticle, strength, damping, restLength/2);
}
// - - - - Make Radial Springs Between Rings - - - - //
for (int j=0; j<nodes.size()-1; j++) {
ArrayList thisRing = (ArrayList) nodes.get(j);
ArrayList nextRing = (ArrayList) nodes.get(j+1);
int counter = 0;
for (int i=0; i<thisRing.size(); i++) {
Particle P = (Particle) thisRing.get(i);
for (int k=counter; k<counter+pattern[i%pattern.length]; k++) {
Particle L = (Particle) nextRing.get(k%nextRing.size());
L.position().set(L.position().x(), L.position().y(), P.position().z() + random(-1, 1) );
Spring S = physics.makeSpring(P, L, strength, damping, restLength*(j*j+1));
}
counter = counter+pattern[i%pattern.length];
}
}
// - - - - Make Repulsion Forces Between All Nodes - - - - //
for (int p=0; p< physics.numberOfParticles(); p++) {
Particle P = physics.getParticle(p);
for (int q=0; q< physics.numberOfParticles(); q++) {
Particle Q = physics.getParticle(q);
physics.makeAttraction(P, Q, repulsion, repulsion_minDist);
}
}
// - - - - Print Key Variables - - - - //
// println (pattern);
// println ("startNodes = " + startNodes + ", numgen = " + numGenerations);
// println ("patternlength = " + pattern.length + ", patternCount = " + patternCount + ", ringMult = " + ringMult);
// println ("numparticles = " + physics.numberOfParticles());
// println (" ");
}
// - - - - - - - - Draw Surface Geometry - - - - - - - - //
void display() {
physics.tick();
pushMatrix();
fill(myColor, myColor, myColor, myAlpha);
// - - - - Draw Centre - - - - //
ArrayList firstRing = (ArrayList) nodes.get(0);
beginShape(TRIANGLE_FAN);
stroke(255, 255, 255);
//smooth();
vertex(centerParticle.position().x(), centerParticle.position().y(), centerParticle.position().z());
for (int i=0; i<firstRing.size(); i++) {
Particle P = (Particle) firstRing.get(i);
vertex(P.position().x(), P.position().y(), P.position().z());
}
Particle A = (Particle) firstRing.get(0);
vertex(A.position().x(), A.position().y(), A.position().z());
endShape(CLOSE);
// - - - - Draw Between Rings - - - - //
for (int j=0; j<nodes.size()-1; j++) {
ArrayList thisRing = (ArrayList) nodes.get(j);
ArrayList nextRing = (ArrayList) nodes.get(j+1);
int counter = 0;
for (int i=0; i<thisRing.size(); i++) {
Particle P = (Particle) thisRing.get(i);
// - - Draw Between Springs From This Node - - //
for (int k=counter; k<counter+pattern[i%pattern.length]-1; k++) {
Particle L = (Particle) nextRing.get(k%nextRing.size());
Particle M = (Particle) nextRing.get((k+1)%nextRing.size());
beginShape(TRIANGLES);
stroke(255, 255, 255);
//smooth();
vertex(M.position().x(), M.position().y(), M.position().z());
vertex(L.position().x(), L.position().y(), L.position().z());
vertex(P.position().x(), P.position().y(), P.position().z());
endShape(CLOSE);
}
counter = counter+pattern[i%pattern.length];
// - - Draw Between Last Spring From This Node And First Spring From Next Node - - //
Particle O = (Particle) nextRing.get((counter-1)%nextRing.size());
Particle Q = (Particle) nextRing.get(counter%nextRing.size());
Particle N = (Particle) thisRing.get((i+1)%thisRing.size());
beginShape(QUADS);
stroke(255, 255, 255);
//smooth();
vertex(N.position().x(), N.position().y(), N.position().z());
vertex(Q.position().x(), Q.position().y(), Q.position().z());
vertex(O.position().x(), O.position().y(), O.position().z());
vertex(P.position().x(), P.position().y(), P.position().z());
endShape(CLOSE);
}
// - - Patch Hole At End Of Ring - - //
// this bug occurs when pattern length doesnt divide evenly into number of nodes in next ring
// and is caused because number of nodes in a new ring is determined by a multiplier (the average of the pattern)
// rather than each new node being grown directly by the corresponding node in the previous ring as happens in crochet between rows of stiches
if (nextRing.size() % pattern.length > 0) {
Particle R = (Particle) thisRing.get(thisRing.size()-1);
Particle S = (Particle) nextRing.get(nextRing.size()-1);
Particle T = (Particle) nextRing.get(0);
Particle U = (Particle) thisRing.get(0);
beginShape(TRIANGLES);
vertex(U.position().x(), U.position().y(), U.position().z());
vertex(T.position().x(), T.position().y(), T.position().z());
vertex(S.position().x(), S.position().y(), S.position().z());
endShape(CLOSE);
}
}
popMatrix();
}
// - - - - - - - - Regenerate Coral - - - - - - - - //
void newMesh(float theValue) {
background(0);
nodes.clear();
physics.clear();
patternCount = 0;
pattern = new int[] {
int(random(2, 4)), int(random(3, 6))
};
startNodes = 2*int(random(2, 5));
colR = int(random(255));
colG = int(random(255));
colB = int(random(255));
makeCoral();
}
// void Export_OBJ(float theValue) {
// cadSoftware = "ObjFile";
// ext = "obj";
// record = true;
// //println("a button event. "+theValue);
// }
//
// void Export_PDF(float theValue) {
// pdfsave = true;
// }
//void transmit() {
//
// String Message = "";
// for (int i = 0; i < ring.size; i++) {
// Particle transmit = (Particle) ring.get(i);
// Message = Message + String.valueOf(transmit.position().x()) + "," + String.valueOf(transmit.position().y())+ "," + String.valueOf(transmit.position().z())+"|";
// } // message to transmit
// // transmit
// String message = Message; // the message to send
// String ip = "192.168.9.2";
// the remote IP address
// int port = Port ;
// the destination port
// udps.send( message, ip, port );
// Message = "";
//}
}
High Resolution Image Save
[4 Replies]
17-Oct-2010 10:45 PM
Forum:
Contributed Library Questions
Is there any way to save a very high resolution image of the entire window, in any format that supports an alpha channel.
I have tried the TileSaver method posted elsewhere, with fragmented images as the result.
I would like to use the JAVA2D renderer, since OPENGL is much less smooth.
Any suggestions?
Any native Java methods to handle this type of request?
«Prev
Next »
Moderate user : bringfire
Forum