FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Programs
(Moderators: fry, REAS)
   3D object renderer... suggestions?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: 3D object renderer... suggestions?  (Read 827 times)
Jerronimo

WWW
3D object renderer... suggestions?
« on: Aug 29th, 2003, 4:25am »

Okay, so I have this sketch:
 
    http://www.cis.rit.edu/~jerry/Software/p5/flatware_view/
 
hit 1-6 to change the object, move the mouse to rotate, click and drag to bring it closer.
 
I need suggestions though on a few things.  If you look at the sketch code:
 
    http://www.cis.rit.edu/~jerry/Software/p5/flatware_view/flatware_view.pd e
 
Beware: It is huge and gross.  It makes the Processing sketchpad painful to use on my computer (Powerbook G4 500mhz, OS X 10.2.6)  I noticed it slowing down as i added more and more code.
 
So what I'd like suggestions on are:
 
is there a better way to store the objects?  Should I parse them in from a file on the fly?  (the original simple file format for these objects can be seen here: http://www.cis.rit.edu/~jerry/Software/projects/mujaki/mujaki/demo/3/ )  I wrote a perl script to convert these into the lines of P5 seen in the sketch... i can just as easily convert them into another format for P5.
 
Is there a better way to get more definition in the 3d renders themselves?
 
Do any of you have any suggestions to get the code to be better organized?
 
I know that the code is gross, and there's more than likely a better way to do this, but I've only been using the language for about 2 days now, and I'm pretty inexperienced... I'm wide open to any suggestions at all.
 
(although it says something about the language in that I was able to make a 3-d renderer after only having looked at the language for 2 days!   )
 
Glen Murphy

WWW Email
Re: 3D object renderer... suggestions?
« Reply #1 on: Aug 29th, 2003, 11:00am »

Quote:

Is there a better way to get more definition in the 3d renders themselves?  

You could turn the lights() on.
 
Collin Allen
Guest
Email
Re: 3D object renderer... suggestions?
« Reply #2 on: Sep 21st, 2003, 4:30am »

Is there an easier way to create 3d polygons other than doing it manually?
 
I created a fairly simple polygon in 3ds max 5 and exported it as an ASCII Scene, and there are vertices in that file you can format for Processing, but it has issues with the order in which they are given.  If I use the points without modification, the two main faces of the object are correct, but the smaller edges are gone except for one side where an "X" has formed (where the Z jumpts to the other face).  
 
If I reorder the vertices and put each face in its own beginShape(), it works fine.  What a pain, though.  Any ideas?
 
elout

12747371274737 WWW
Re: 3D object renderer... suggestions?
« Reply #3 on: Sep 21st, 2003, 12:32pm »

I made also a simple .ase reader although, although I had to clean it up a bit. (getting rid of all the tabs, and extra unneeded information)
 
http://proce55ing.net/discourse/yabb/board_Tools_action_display__num_1063823160.html
http://www.xs4all.nl/~elout/proce55ing/meshtest02/
 
The other thing is if you want to add different lights, put this in your setup.
 
Code:

lights();
  //set-up the lights
  for (int i=0;i<5;i++)
  {
    g.lightR[i] = 1.0f;
    g.lightG[i] = 1.0f;
    g.lightB[i] = 1.0f;
    g.lightX[i]= 0.0f;
    g.lightY[i]= 0.0f;
    g.lightZ[i]= 0.0f;
    g.lightKind[i] = DIFFUSE;
  }  

 
I guess light[0] is the default light, and can`t be changed I guess. the rest of the lights can, I guess up to 10 different lights are supported.
lightning example;
http://www.xs4all.nl/~elout/proce55ing/loise/
 
I noticed as well when smooth(); turned on you get wierd gaps/edges on your faces.
 
elout

12747371274737 WWW
Re: 3D object renderer... suggestions?
« Reply #4 on: Sep 21st, 2003, 2:17pm »

I found out today you can do texturemapping as well.
 
Code:

BImage a;
 
void setup()  
{
  size(550,550);
  background(0, 0, 0);  
  //a 200*200 pixel size image - in your data folder.
  a = loadImage("florence03.jpg");  
}
void loop()  
{
  translate(width/2, height/2, mouseY);
  rotateX(mouseX/10.0);  
  rotateY(mouseY/10.0);  
  rotateZ(mouseY-mouseX/10.0);  
  beginShape(QUADS);  
   textureImage(a);
   vertexTexture(0,0);
   vertex(0,0,0);
   vertexTexture(200,0);    
   vertex(100,0,0);
   vertexTexture(200,200);    
   vertex(100,100,0);
   vertexTexture(0,200);    
   vertex(0,100,0);
  endShape();
}
 
Koenie

170825270170825270koeniedesign WWW Email
Re: 3D object renderer... suggestions?
« Reply #5 on: Sep 21st, 2003, 2:28pm »

Where did you find that texture mapping thing? I have made a sketch that does the same kinda thing, only it's so much slower: http://koeniedesign.com/?k=6
 
Koenie
 

http://koeniedesign.com
elout

12747371274737 WWW
Re: 3D object renderer... suggestions?
« Reply #6 on: Sep 21st, 2003, 3:43pm »

to be honest,  
 
I decompiled some of the class files too figure if there were any other 'secret' commands like the light stuff. And then I stumbled onto the texture thing, among several other interesting stuff.
 
After that I remembered arielm did some 3D texture stuff, and he uses it as well.
 
(I hope processing gets opensource in the near-future)
 
mKoser

WWW Email
Re: 3D object renderer... suggestions?
« Reply #7 on: Sep 21st, 2003, 5:25pm »

nice hacking elout!...
 
i just gave your texture-mapping example a try (nice and clean example btw!) ... i ended up doing a calaidoscopic cheesy sketch, but nevertheless a small step into exploring texture-mapping!
 
http://proce55ing.beyondthree.com/?chapter=sketch&project=texturemap ping
 
+ mikkel
 
UPDATE / woops
hmm, i guess this post doesn't really belong here. (sorry!)
I guess I'll play more with textures and re-post in Responsive Form and Games!
« Last Edit: Nov 5th, 2003, 4:36pm by mKoser »  

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
Collin Allen
Guest
Email
Re: 3D object renderer... suggestions?
« Reply #8 on: Sep 21st, 2003, 9:30pm »

Slick! I'll give ASE loading and texture mapping a shot.  *still waiting for my password conf email....*
 
fry


WWW
Re: 3D object renderer... suggestions?
« Reply #9 on: Sep 21st, 2003, 10:04pm »

on Sep 21st, 2003, 3:43pm, elout wrote:
to be honest,  
 
I decompiled some of the class files too figure if there were any other 'secret' commands like the light stuff. And then I stumbled onto the texture thing, among several other interesting stuff.
 
After that I remembered arielm did some 3D texture stuff, and he uses it as well.
 
(I hope processing gets opensource in the near-future)

we don't intend to keep any of the commands secret, it's just that things that are in flux (or are considered 'advanced' features) aren't documented as well just yet. lights qualify for both of those criteria, since they'll be changing soon (rev 61, prolly). i've made some posts elsewhere on the bboard about how they work (with more info and caveats).
 
and believe me, i hope p5 gets open source soon too.. right now we're only held up by the licensing people at MIT. hopefully it's just a formality but we have to get a rubber stamp for releasing the code. unfortunately these things move slowly and so it'll likely be several weeks before we get the green light.
 
fry


WWW
Re: 3D object renderer... suggestions?
« Reply #10 on: Sep 22nd, 2003, 4:40am »

the lighting posts are linked from the 'technotes' section of the site. (http://proce55ing.net/reference/technotes/)
 
http://proce55ing.net/discourse/yabb/board_Proce55ing_Software__action_display_num_1039496510.html
http://proce55ing.net/discourse/yabb/board_Syntax_action_displa_y_num_1057115468.html
 
elout

12747371274737 WWW
Re: 3D object renderer... suggestions?
« Reply #11 on: Sep 23rd, 2003, 11:14pm »

thx fry;
 
next time I put in my code a command wich p5-version I used,
the same 'simple' texture mapping thing now in v.0060
 
Code:

// source compiled with p5 - v.0060
BImage a;
 
void setup()  
{
  size(550,550);
 
  //load a 200*200 pixel size image  
  //put this image in your data folder!
  a = loadImage("arch.jpg");  
}
void loop()  
{
  //clear screen
  background(0, 0, 0);  
   
  //rotation with mouse
  translate(width/2, height/2, mouseY);
  rotateX(mouseX/10.0);  
  rotateY(mouseY/10.0);  
  rotateZ(mouseY-mouseX/10.0);  
   
  //draw texture
  beginShape(QUADS);  
   texture(a);
   //vertex - x,y,z, u,v
   //x,y,z is position |  u/v is texture-image position
   vertex(0,0,0,  0,0);
   vertex(100,0,0, 200,0);
   vertex(100,100,0,  200,200);
   vertex(0,100,0,  0,200);
  endShape();
}  

 
anyway, started working on this -alpha-; 'gestures'  
shift=flip hands random | mouseclick change lightning  
http://www.xs4all.nl/~elout/fingers/
« Last Edit: Sep 23rd, 2003, 11:56pm by elout »  
arielm

WWW
Re: 3D object renderer... suggestions?
« Reply #12 on: Sep 24th, 2003, 3:34am »

on Sep 23rd, 2003, 11:14pm, elout wrote:
anyway, started working on this -alpha-; 'gestures'  
shift=flip hands random | mouseclick change lightning  
http://www.xs4all.nl/~elout/fingers/

kraftwerk!!!
 
 
(btw, pressing 5 times the shift key on win2k is bringing the system "sticky keys" popup)
 

Ariel Malka | www.chronotext.org
Pages: 1 

« Previous topic | Next topic »