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.
IndexProgramming Questions & HelpPrograms › advice about my physics based applet
Page Index Toggle Pages: 1
advice about my physics based applet (Read 704 times)
advice about my physics based applet
Jan 31st, 2009, 12:38am
 
i have many problems with this sketch, and I'm wondering if any pros out there could help out.

first off, there is a problem with 3d picking. I thought I had it sorted out, but apparently not. The basic system is in place but something is just not working quite right.

then there's weird stuff with the text  - I have tried it so many different ways but every one seems to have problems. Right now it's kind of working but ideally it would use textmode(screen) - but when I've tried to implement this I get new problems...like things slow down alot and somethings don't render when they once did. Now I get text in the default mode but sometimes it mysteriously can only be seen from behind.

and then...for some reason my particles are overlapping - actually sitting right atop one another - even though I thought I specified a negative attraction between each one and every other one..doesn't seem to start off working. And while we're at it - how do you do a nested for cycle and not duplicate a function? I have a feeling that just cause I have checked to make sure i is not j, does not mean that I and j aren't being connected over and over again, or at least twice....

I know it's alot to ask. I'm just a bit frustrated right now...so, thanks in advance if anyone has a moment to take a peak. Oh and if this should be put in a different forum, please advise...

thanks

http://www.upsdn.ca/processing/animal_particles_06a/applet/
Re: advice about my physics based applet
Reply #1 - Jan 31st, 2009, 3:42am
 
didnt took a closer look at your code and what your main problems could be. but about the "i+j" problem. Maybe this is doing what you want...

it connects a spring between every particle but not with itself and not twice.

for(int i=0; i<  particle.length; i++){
   for(int j=i+1; j<  particle.length; j++){
     physics.makeAttraction( particle[i], particle[j], -6500, 50 );
   }
 }


Copied it from one of my codes so yo have to adjust it to your needs...
Re: advice about my physics based applet
Reply #2 - Feb 1st, 2009, 5:03am
 
thanks Cedric. that should do it...

any chance I could get advice about why my particles might start off sitting atop one another? it's strange because it happens only in their initialized stated but if you mouse click on the overlapping pairs they separate and do their typical bouncy calculations...

or do you know where i can go for questions about the use of the library? know of any pros?
Re: advice about my physics based applet
Reply #3 - Feb 1st, 2009, 5:50am
 
im not sure, could you upload a zip file with all the files needed and i will take a closer look...
Re: advice about my physics based applet
Reply #4 - Feb 2nd, 2009, 1:28am
 
you can get the sketch here...

www.upsdn.ca/processing/animal_particles_06b-090201a.zip

thanks so much
Re: advice about my physics based applet
Reply #5 - Feb 2nd, 2009, 1:57am
 
hmm, downloaded it, but is not working.
i guess i dont need the CAD plugin, but the OCD plugin is not working either. What version of P5 are you using?
Re: advice about my physics based applet
Reply #6 - Feb 2nd, 2009, 6:59am
 
I am not sure why it's not working. Is it because it just doesn't look like it's working? I'm really no pro and there are lots of problems but it runs fine on my machine with Processing 1.01. Is there a newer version I should be upgrading to?

thanks for trying...I'll see what I can do about getting it going for you. I tried downloading the file I put on that server and it works fins for me...
Re: advice about my physics based applet
Reply #7 - Feb 2nd, 2009, 7:04am
 
your version seems to be ok. im using the same one.
I have some problems with the ocd librarie but i downloaded it but it still wont run... where did you get it from?
http://www.gdsstudios.com/processing/libraries/ocd/download/ this one ?
Re: advice about my physics based applet
Reply #8 - Feb 3rd, 2009, 11:32pm
 
i haven't installed a new ocd library in a while. I presume that if I update it, my sketch will stop working...hmmm, what to do

scratch that - the latest incantation moves back into 2d space, without the need for OCD library and still with the same problem I was having.

You can get it here
www.upsdn.ca/processing/animal_particles_06d-090203a.zip

thanks so much
Re: advice about my physics based applet
Reply #9 - Feb 4th, 2009, 4:17am
 
hmm, I played around with my negative attraction values by implementing your two for loops and it worked quite nicely. Now though, I have noticed all sorts of problems with the positions of my points. When I export their locations many are exactly the same even though they on screen are not overlapping...and when I was trying to calculate their centroid I found that each one's position was being returned at the centre of the screen - which is the position I gave when instantiating each particle. Since my ellipses are based on the particle's positions and since they are moving I assumed I had it all sorted out...So these are two problems but they both probably stem from my poor understanding of the intricate details of oop...
Re: advice about my physics based applet
Reply #10 - Feb 4th, 2009, 5:14am
 
now I sort of kind of figured out a problem but have discovered a new one. Giving the particle a random position upon instantiation helped give them discrete locations which has helped elsewhere, but what I've realised is that my Animal class which creates a child particle when it's created is not updating its position to that of the particle, even though it's supposed to...

within the Animal constructor I have:

this.ps = ps;
this.p = ps.makeParticle(5,random(0,width), random(0,width), 0);
position= new Vector3D(this.p.position().x(),this.p.position().y(),this.p.position().z());

and I thought that would do it, but it isn't...any ideas?
Re: advice about my physics based applet
Reply #11 - Feb 4th, 2009, 5:57am
 
I seem to be having trouble with traer's version of Vector3D not playing nicely with my own Vector3D class....any ideas how to deal with that?

I am getting a message that says cannot convert from Vector3D to Vector3D...I am trying to equate my Animal's position with its particle's position...
Re: advice about my physics based applet
Reply #12 - Feb 4th, 2009, 10:43am
 
oompa_l wrote on Feb 4th, 2009, 5:57am:
I seem to be having trouble with traer's version of Vector3D not playing nicely with my own Vector3D class....any ideas how to deal with that

The simplest methods is either to rename your or to use traer's one...
Otherwise, use fully qualified names, like traer.physics.Vector3D. Not nice.
Re: advice about my physics based applet
Reply #13 - Feb 4th, 2009, 9:13pm
 
it does not allow me to cast from into the other or vice versa...say I want the centroid of all my particles and I have a function that does that takes the generic Vector3D i have create, do I need to make another one that takes traer's?

i wouldn't have this problem if my own class just matched its position to that of the particles like I thought I told it to do...disobedient good for nothings! i think I'm spending too much time with my computer creations...
Page Index Toggle Pages: 1