Welcome to my Programming Blog...

I am currently working on a couple of projects: An original game called "Implosion" which I am porting from Flash to the iPad, and a remake of Q*bert in Python (pygame), as part of the class I am teaching. Please feel free to use the "Labels" (at right) to follow a specific project or theme. If you are one of my Python students, I recommend that you check out the Python thread.

Saturday, May 8, 2010

It's always the little things....

As you may know, I am trying to teach myself two things at once for this iPhone App I am working on - blender, and the SIO2 code library that lets me put blender objects on the iPhone screen. (Actually, I'm aiming for the iPad.)

I've been wanting to make my 4-square selector shapes be translucent - that is, I'd like for them to have an Alpha level of about 50% or so. They will mostly appear behind the Chips, but when a chip drops, I'd like it to be seen, and there may be some artwork behind the chips that is important, also.

I watched the SIO2 tutorial #4 several times, and I even found a correction to the tutorial online since the tutorial hasn't kept up with a few updates. But even though I was doing what the tutorial said, I couldn't get objects to show up with any kind of transparency. I'd create an object that was opaque, and it would show up fine. I'd switch the color blending mode in blender to "Value" or (the new version) "Color," and it would disappear when I tried to view it in the iPhone simulator. What gives?

I was just about to start complaining that the Tutorial didn't work, the support forums weren't very helpful and the only book on SIO2 wasn't much help, when I realized that I hadn't actually looked in the book for this... sure enough, a quick peek in the index led me to a page that indicated the problem wasn't in Blender - it was a one line change I needed to make in my code in XCode. I was only rendering solid objects - I needed to tell it to render the solid objects and the objects with alpha transparency. I needed to change:

sio2ResourceRender( sio2->_SIO2resource, sio2->_SIO2window, 
                        sio2->_SIO2camera,
                        SIO2_RENDER_SOLID_OBJECT |
                        SIO2_RENDER_LAMP);

to

sio2ResourceRender( sio2->_SIO2resource, sio2->_SIO2window, 
                        sio2->_SIO2camera,
                        SIO2_RENDER_SOLID_OBJECT |
                        SIO2_RENDER_ALPHA_TESTED_OBJECT |
  SIO2_RENDER_TRANSPARENT_OBJECT|
    SIO2_RENDER_LAMP);

and everything instantly started working. Sigh.

No comments:

Post a Comment