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
Surface library (Read 896 times)
Surface library
Jun 14th, 2008, 1:02pm
 
I'd like to use the surface library mentioned in the Reference library, but unfortunately I get errors when I try to use libraries in Processing.

I'm new in Processing and actually in programming altogether. I sincerely apologize if my questions are actually too easy or silly. I've spend days trying to figure out a program and I really hope your library can help me. But first I guess I'm clumsy with libraries. I asked about this in general in my post http://processing.org/discourse/yabb_beta/YaBB.cgi?board=LibraryProblems ;action=display;num=1213391592;start=0

But now I actually have specific beginner questions for the surface library. I put the unzipped surfaceLib under the directory of libraries in processing-0135. Then I just tried something. For example:


import surface.calculation.*;
import surface.*;
import processing.xml.*;

size(500,500,P3D);
Surface(g, 10, 10, 0, 200, 0, 200, 1, 100);
Sphere(g, 10, 10);


I get the error 'Cannot find a function named "Sphere" with parameters processing.corePGraphics,int,int.

1) The program doesn't do anything. How do I get acces to the library and get for example a surface working?

2) It's also not very clear to me what I should do with i_parameter and i_color. And should the first parameter just be g? Am I wrong with the parameters? Does anyone have example code?

3) And another question: the surface function has x and y locations, but what if I wish to move vertices over the z-axis according to values of an array? Should I create a class or is there a standard solution? This is the idea: I intend to make a grid of vertices (x,y,z). The x and y remain at their positions, but z should vary according to a heightmap. Then I wish to put a texture over the surface. The user looks on top of the surface (in z-direction) so in 3D the areas that are placed higher seem larger on screen. Then when the mouse is dragged, the surface rotates.  

I just copied the source code from http://www.eskimoblood.de/applets/surface/applet3/surface3.pde into Processing and it gave me this error: Cannot parse error text s.setSurface(types[cnt]); Maybe this gives a clue about what's going wrong with my library access?

I thought I might mail this as well, because I imagine that my description of how the library doesn't work is rather vague.  

I really need this program and I've been pondering over these things for days. It's actually for a research project. If you help me, it would be my pleasure to mention your advice in my article. Again, I apologize that these questions probably seem too easy.

I really appreciate your help; it would save my project.
Re: Surface library
Reply #1 - Jun 14th, 2008, 2:12pm
 
there's an example here:

http://www.eskimoblood.de/surfacelib/sphere_class_sphere.htm

Code:

import surface.*;

Sphere s;

void setup(){
size(400,300,P3D);
s=new Sphere(g, 20, 20);
...
}

void draw() {
...
s.draw();
}


you can't just call Sphere, you have to instantiate one.

first parameter is g, yes. which is the global variable set up in processing for the main graphics context. Surface page above explains.
Re: Surface library
Reply #2 - Jun 14th, 2008, 2:35pm
 
The line seems OK syntax wise, it might be a bug in the error reporting code.
The applet you took as example seems old, the current constructors are Surface(s) and Surface(i_g, i_phiSteps, i_thetaSteps, i_minTheta, i_maxTheta, i_minPhi, i_maxPhi, i_parameter, i_colors);

I see an annoying side effect in P5 0141: each time I get your error, Processing opens the changes.html page.
Oh, I see, that's why the old framerate() function is used, instead of frameRate(). Saw that in Processing code, it takes care of old syntax and points to the new one.

Ah, I see, or rather, I don't see setSurface in the API either. The error reporting is a bit odd there. If I deactivate the keyPressed function, I get an error on drawSegment (more understandable) which isn't know of the current API either.

So drop this example, stick to those given in the current API.
Also I am not sure if that library is fitting for your needs... Wink
Re: Surface library
Reply #3 - Jun 14th, 2008, 10:04pm
 
Please note that the linked example (http://www.eskimoblood.de/applets/surface/applet3/surface3.pde)is written with for an older version of the library and so it cant work.
Re: Surface library
Reply #4 - Jun 15th, 2008, 11:23pm
 
I think I'll won't use the library after all for my program, but it was really inspiring to see the great work.

Thank you for your code, koogs!
Thank you for your help, PhiLho, and again for your advice!
I didn't see your program was for an older library, eskimoblood. I'm happy you corrected this. Thanks!
Page Index Toggle Pages: 1