Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I want a 3D triangle (e.g., one that can be rotated about an arbitrary 3D axis) with the vertices being red, blue, and green, and the area within the triangle having the interpolated colors. In OpenGL, you can associate a color with a vertex, but I could not find a similar concept in WPF 3D drawing. Any help on how do I do this would be appreciated!

Thanks,
Tom
Posted
Updated 10-Jan-11 6:50am
v2

As far ad I know it is not as simple as in OpenGL, because WPF only offers a limited 3D API, however it is not impossible.

You can create a 3D triangle inside the Viewport3D control and you can use an arbitrary brush to paint the triangle (including DrawingBrush, ImageBrush etc...) - that is enough to create the effect you need.
 
Share this answer
 
Comments
hain 10-Jan-11 13:26pm    
Thanks, Kubajzz. I know how to create the triangle itself, but how would I create a triangle with different vertex colors using a DrawingBrush?

Thanks again,
Tom
Kubajzz 11-Jan-11 8:42am    
DrawingBrush allows you to combine multiple geometric shapes together and paint each of the shapes with a different gradient brush. I believe that is enough to create the texture you need... Both ImageBrush and DrawingBrush are kind of heavy-weight to create such a simple effect, but I'm afraid there is no other way.
Here is a useful link:
http://www.wpftutorial.net/IntroductionTo3D.html[^]

Regards
Espen Harlinn
 
Share this answer
 
Comments
hain 10-Jan-11 13:30pm    
Thanks Espen, but this does not really answer my question. I know how to create the triangle. What I want to know is how to set different colors on the vertices (with interpolation in between). Using an ImageBrush would work, but seems awfully crude (and inefficient).

Tom

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900