Gradient fill on 3D objects

Anonymous 10 years ago 0
This discussion was imported from CodePlex

SeanV12 wrote at 2013-06-06 22:46:

How do you go about doing a gradient fill on a tube? My attempts have been unsuccessful and only show the last listed color.
So if anyone can help, how would you give this tube a gradient?

TubeVisual3D tube1 = new TubeVisual3D();
tube1 .Path = new Point3DCollection();
tube1 .Path.Add(new Point3D(0, 0, 0));
tube1 .Path.Add(new Point3D(10, 10, 0));
tube1 .Diameter = 5;

Thanks for reading, and thank you for the toolkit.

objo wrote at 2013-06-07 12:10:

There should be a TextureCoordinates property on the TubeVisual3D. Set the texture coordinates for each point and use a gradient material!
See the StreamLines demo (but this demo uses the MeshBuilder, not the TubeVisual3D).

SeanV12 wrote at 2013-06-08 16:15:

Alright, got it! Thank you very much.

SeanV12 wrote at 2013-06-18 00:22:

Am I correct in understanding that since the TextureCoordinates property only tracks the X values, it's not possible for an object that moves up the Y axis only, with a static X value, to be painted with a gradient?

For reference, what I'm trying to do is to make certain points along a tube's path different colors.

objo wrote at 2013-06-18 22:05:

See MeshBuilder line 1927 where the texture coordinates are defined.
The x-value is set by the specified values (should be normalized 0..1), and the y value corresponds to the position around the tube.

SeanV12 wrote at 2013-06-19 20:37:

Thank you, I will look into this.
Your quick replies are much appreciated, by the way!