Friday, July 8, 2011

Java3D MouseWheelZoom *Zooming Values*

To be able to track the values everytime you zoom in or zoom out with your mousewheel.
You need to overload the function "transformChanged(Transform3D transform).

Below is a sample snippet.



protected class MyOverloadedMouseWheelZoom extends MouseWheelZoom { public void transformChanged(Transform3D transform) { System.out.println(transform.toString()); } }


And then, in your calling function, you only need to proceed with the followings:



MyOverloadedMouseWheelZoom myMouseWheelZoom = new MyOverloadedMouseWheelZoom(); myMouseWheelZoom.setTransformGroup(objRotate); // my objRotate is a TransformGroup with children myMouseWheelZoom.setSchedulingBounds(bounds); // my bounds is a predefined BoundingSphere objRoot.addChild(myMouseWheelZoom);



Gd lck!



Firefox 4, HTML5 and WebGL: Introduction (how to enable and set up)

Having been in awe with the idea of HTML5 and WEBGL, i have fiddled around with Firefox to get the environment ready.   I have tried with Safari and Chrome, but had no luck.  They all said getting the latest build (nightly build preferably) and usually with a command line " --enable-webgl".

However, if i start developing and distributing little cool apps with html5+webgl.  I certainly cannot ask all my target audience to modify their command line targets.   So, here, i document this 'less-annoying' way such that i could ask my fellow colleagues and research mates to run what i build for them.

Setting Things Up


1) Download and Install Firefox (latest version, as of writing, im using Firefox 5.0.
(http://www.mozilla.com/en-US/firefox/fx/)

2)  Once Firefox is installed, in the address bar, input the following:
about:config

3) then it may prompt for a warning, click "I'll be careful, i promise"  because i will show you what you need to configure without breaking anything

4) in the filter input textbox, input the following:
webgl

5) Double click the row webgl.force-enabled (the corresponding value column would change from false to true)



Testing and Demo

1) To test html5+webgl, i refer you to this website (http://www.html5test.com).  Let it load for a bit, and after its done, scroll to 'webgl'.  Your score should be greater than 20. (In my setting, it gave me 23/25)


2) To see the webgl demo, i refer you to this website (http://www.brummerblogs.com/curvature/work/atomic-orbitals/)  Why? Because it is showing 3D and it has good interactive mouse control!


Good luck, drop me a msg / comment if you need help.

Thursday, July 7, 2011

Spherical Coordinate System

Previously, i was stuck with a very simple geometry question.  My question was simple "How do you take an existing point and map that to a 3D space?"  Why did i have such question?  I have a set of images with annotations.  Now i want to visualize them in 3D.  Note that the set of images were ordered radially.   Hopefully, below illustration would give the reader a better idea.




The dotted red circle and dotted purple circle are there to give a stronger scent of a 3D space and the arrangement of the 2D images(like a fan). It also indicates that each slice is about 1o apart and a legend that'd give you an idea where the z-axis should be.

For peeps who are good at math would immediately recognize what i am trying to do and see the solution.  For a slow learner like me, it took me a while to flash back to basic geometry.

The solution is indeed very simple: Spherical Coordinate System.






Since, formally speaking, what i am trying to do is to convert spherical coordinates to Cartesian coordinates.  The correspoding (x,y,z) can then be expressed by:





x=r \, \sin\theta \, \cos\varphi \quad
y=r \, \sin\theta \, \sin\varphi \quad
z=r \, \cos\theta\quad

I should have known better!

List of Konger's Fruits in English

Growing up with the variety of fruits in HK, i  always wonder either the Chinese word for this or English translation for that.   I tried to google a similar list but had no luck.   So hopefully, this serves as a good reference for you and for me.

(Persimmon)










火龍果 (Pitaya)



山竹 (Mangosteen)

大樹波蘿 (Jackfruit)



番石榴 (Guava)

黃皮 (Chinese Wampi)











哈密瓜 (Hami Melon)



梨花海棠(Malus)

紅毛丹 (Rambutan)







龍眼 (Longan)

蓮子 (Lotus Seed)

楊桃(Starfruit)

無花果(Common Fig)








杏子 (Apricot)






牛油果 (Avocadro)






石榴 (Pomegranate)









布霖 (Plum)








甘蔗 (Sugarcane)










Send me more you know or you don't know!!

Monday, June 27, 2011

re: VTK + VS2010

It turns out to be very simple once you have downloaded CMAKE (http://www.cmake.org).

Select the version of VS you have installed in your computer or would like it to be converted to.  Then, click configure and generate.

Thursday, June 16, 2011

openCL + OSX: Introduction

If you are like me always wander, you might wonder how openCL works in OSX.

Luckily, if you have 10.6 or later, your os is equipped with openCL, no need to fiddle through ./configure make and at the end, a bunch of fiery errors.

And, very fortunately, they have sample codes:
http://developer.apple.com/library/mac/#samplecode/OpenCL_Hello_World_Example/Introduction/Intro.html%23//apple_ref/doc/uid/DTS40008187

ENJOI!