The proposed solution is not natively supported and may not work in all scenarios and versions.
Requires Eyeshot >= 9.0.457
Here's an example of how to override the Line or Circle class in order to draw a curve with textured vertices by deriving the Line and Circle classes.
class MyLine : Line
{
public MyLine(Line another) : base(another)
{
}
public TextureBase texture;
//
// 1D texture coordinates.
//
public Point2D TextureCoordinates { get; set; }
public override void Draw(DrawParams data)
{
data.RenderContext.EndDrawBufferedLines();
data.RenderContext.SetShader(shaderType.Texture1DNoLights);
data.RenderContext.SetTexture(texture);
data.RenderContext.DrawLine(StartPoint, EndPoint, TextureCoordinates);
data.RenderContext.EndDrawBufferedLines();
}
}
class MyCircle : Circle
{
public MyCircle(Circle another) : base(another)
{
}
public TextureBase texture;
//
// 1D texture coordinates.
//
public float[] TextureCoordinates { get; set; }
protected override void DrawWireEntity(RenderContextBase context, object myParams)
{
context.DrawLineStrip(Vertices, TextureCoordinates);
}
public override void Draw(DrawParams data)
{
data.RenderContext.SetShader(shaderType.Texture1DNoLights);
data.RenderContext.SetTexture(texture);
base.Draw(data);
}
}
Then use them as shown below.
Remember to Dispose of the texture object when it's no longer needed.
// Create a texture with a colormap
var texture = design1.RenderContext.CreateTexture1D(new Color[] { Color.Red, Color.Green, Color.Blue, Color.Yellow },
textureFilteringFunctionType.Nearest, textureFilteringFunctionType.Nearest, false, false);
var myL = new MyLine(new Line(0, 0, 100, 100));
myL.TextureCoordinates = new Point2D(0, 1);
myL.texture = texture;
design1.Entities.Add(myL);
var myCirc = new MyCircle(new Circle(new Point3D(10, 10, 0), 20));
myCirc.texture = texture;
// Regenerate it in order to compute the vertices
myCirc.Regen(0.1);
myCirc.TextureCoordinates = new float[myCirc.Vertices.Length];
for (int i = 0; i < myCirc.Vertices.Length; i++)
{
myCirc.TextureCoordinates[i] = (float)i / (myCirc.Vertices.Length - 1);
}
design1.Entities.Add(myCirc);
Comments
Please sign in to leave a comment.