This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Images on a Cube

 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there, I've built a rubiks cube using images.
I use AffineTransforms generated from a matrix M that I've specially
built.

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?

Thanks
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic