Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  3 point gradient?  (Read 1859 times)
0 Members and 1 Guest are viewing this topic.
Offline Alrecenk

Junior Newbie




Java games rock!


« Posted 2004-06-24 18:07:00 »

Basically, I'd like to do gouraud shading with triangles in java. I am aware of the 2 point gradient in Graphics2D, but I am not sure what to do for 3 points . Please reply if you know a way to do this or an effective alternative. (I am not using and do not intend to use java3D)
Offline barfy

Junior Member




The evidence of things not seen


« Reply #1 - Posted 2004-06-24 19:47:04 »

Do you want to shade with GradientPaint using 3 color gradients or are you talking about orienting the shading with regards to 3 vertices of your triangle?
Offline Alrecenk

Junior Newbie




Java games rock!


« Reply #2 - Posted 2004-06-25 00:16:41 »

I'd like a gradient based on 3 points each a different color. So, the second one.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 343
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2004-06-25 09:36:26 »

A gourad-shaded triangle, then.

Cas Smiley

Offline barfy

Junior Member




The evidence of things not seen


« Reply #4 - Posted 2004-06-25 12:50:59 »

Quote
A gourad-shaded triangle, then.

Cas Smiley


I'm not aware of any utility class in the java2d library that does gouraud-shading based on 3 non-collinear points. So if you're planning on sticking with java2D to do your shading, then the most straightforward way would be to either:

1. Extend the Paint and PaintContext interfaces with your own GouraudShading class that draws a pixel with a certain color based on the distance between 3 (or more) points. This should be somewhat similar to the method used by java2D's GradientPaint.

2. Forget about extending interfaces in the java2D library and build your own scan-converter/rasterizer that colors a pixel with a certain color based on the distance between 3 or more points. There should be lots of tutorials on the web that shows you how to perform scan-conversion of triangles if you're unsure how.

Are you doing real-time 3D? I recommend you take a look at other user-made OpenGL-based libraries like JOGL or LWJGL or Xith3D. Java2D's no good for that kind of thing (hence "java2D").




Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (25 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (13 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (44 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!