This site requires JavaScript, please enable it in your browser!
Greenfoot back
bourne
bourne wrote ...

2011/10/16

Filling a polygon with an image

bourne bourne

2011/10/16

#
Hello, Is there an easy way to draw an image texturing the region of a 4 sided polygon (not a rectangle) ? In so that the corners match that of the corners of the image. Thanks
Builderboy2005 Builderboy2005

2011/10/17

#
As far as I know, there is no built in way to do this. There might be some graphics libraries somewhere that use OpenGL and such, and while they are probably going to be the fastest way to map textures onto polygons, I don't think they are that compatible with Greenfoot. If speed isn't too much of an issue, you can use linear interpolation and draw it pixel by pixel yourself, but this is probably going to be way too slow to do if you have a large number of polygons on the screen. Our of curiosity, are you wanting to implement this for use in a 3D engine? Or other uses for image mapped polygons?
bourne bourne

2011/10/17

#
Alright, I didn't want to complicate things. I started throwing together this scenario that's 2D playing area but has a 3D effect. I've managed to work with GradientPaint which creates the effect but it's not the prettiest =/
Builderboy2005 Builderboy2005

2011/10/17

#
I know I did something akin to 3D display with my Earth/Eye scenario http://www.greenfoot.org/scenarios/990 but I don't know how applicable it would be. Probably the best bet would be to use something like http://lwjgl.org/ to interface directly with OpenGl to get fast 3D graphics, as eventually I think serious games need to graduate themselves past the more beginner oriented Greenfoot.
You need to login to post a reply.