File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Images on a Cube Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Images on a Cube" Watch "Images on a Cube" New topic

Images on a Cube

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 750
Hi there, I've built a rubiks cube using images.
I use AffineTransforms generated from a matrix M that I've specially

This works fine, and the effect is great.
However there is no perspective on this cube.

I understand how to do perspective in general(1 point),
Using a coordinate system, with:
x axis being horizontal,
y axis going into/out of screen(+ve y axis pointing out of screen)
z axis being vertical,

I simply transform any point (x,y,z) to (F'x,y,F'z) where F'=F/(F-y),
and F is focal point out of screen (0,F,0).
When the point is plotted, you ignore the y component.

I've seen an applet with a cube with an image that has perspective,
so I was wondering how I can do this.

I know AffineTransforms can only turn squares into paralellograms,
so I guess an AffineTransform is out of the question.
Many images could be pre-stored at different angles,
but this is not a great way of doing it generally.
The image could be rebuilt using pixel data, and the animation
techinque with MemoryImageSource, but this could be costly on the cpu
when doing so many repaints in a short time.

Is there other options?

Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
I'm pretty sure you can use JAI for this. E.g. here's a PerspectiveTransform class. I believe JOGL also offers a way to do this. Hope that helps...
[ May 28, 2007: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: Images on a Cube
It's not a secret anymore!