This project is read-only.

IRenderable for my own objects ...

Mar 11, 2015 at 4:59 AM
Hi, I am using HitTestExample and trying to add my own Line object to render it with bounding box. Following is definition for Line class

public class Line : Polygon, IRenderable, IVolumeBound
{
    double[] from = new double[3] { 10.0, 10.0, 0.0 };
    double[] to = new double[3] { 20.0, 20.0, 0.0 };

    override public void Render(OpenGL gl, RenderMode renderMode)
    {
        gl.Color(1.0, 1.0, 0.0);
        gl.Begin(OpenGL.GL_LINES);
            gl.Vertex(from[0], from[1], from[2]);
            gl.Vertex(to[0], to[1], to[2]);
        gl.End();
    }
}
And then I add line object to child as follows

// Create a cube.
        Cube cube = new Cube();
        cube.Transformation.TranslateX = 2;
        cube.Transformation.TranslateY = -2;
        cube.Transformation.RotateZ = 45f;

        Line line = new Line();
        line.Transformation.TranslateX = 2;
        line.Transformation.TranslateY = -2;
        line.Transformation.RotateZ = 45f;

        //  Add them.
        sceneControl1.Scene.SceneContainer.AddChild(line);
        sceneControl1.Scene.SceneContainer.AddChild(sphere);
        sceneControl1.Scene.SceneContainer.AddChild(cube);
        sceneControl1.Scene.SceneContainer.AddChild(cone);
        sceneControl1.Scene.SceneContainer.AddChild(cylinder);
I get crash at " this.toolStripButtonShowBoundingVolumes.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonShowBoundingVolumes.Image")));"

Mostly because the toolstrip element is trying to finding bounding box for line object and didn't get it. How do I implement IBoundVolume to create my own bounding box for line object?

Regards,

Abhijit.
Mar 11, 2015 at 4:01 PM
Hi Abhijit!

Thanks a lot for you question!

Please come to GitHub! We are there! :) There you can ask questions and see the current work.

https://github.com/dwmkerr/sharpgl

The SceneGraph, and your problem in particular, is a point we've discussed a lot in the last weeks. In future versions of SharpGL the SceneGraph will be obsolete, in order to make place for better framework features used to build applications faster and to use newest features from OpenGL (e.g. the shader).

But if you want to implement bounding boxes where it is missing in the SceneGraph, please visit me branch of SharpGL where I've implemented them. I had the same problem some month ago. Maybe my work helps a bit to solve your problem. Zou can find and clone it from here: https://github.com/robinsedlaczek/sharpgl/tree/BoundingVolumesForAll.

Hope that helps! Otherwise, please do not hesitate to contact me!

Robin