draw circles or Line

samibelaksamibelak DEMember

Hello everyone..... am using urhosharp game engine from xamarim to develop a cross platform game .... it was really good choice and compatible with wpf but I did not know how to draw shapes , I went through the guide and documentation and did not find a way maybe to draw circles,Rounded Shapes,annulus or any geometric type anyone knows or could help me ... I would be very grateful .... Thanks in advance

I tried this piece of code but no circle appeared in the screen:

              DebugRenderer _debug = new DebugRenderer();
                        _debug.AddCircle(new Vector3(50,50,0),new Vector3(100,25,5),50,Color.Magenta,2 ,true  );
                        scene.AddComponent(_debug);
Tagged:

Answers

  • EgorBoEgorBo BYXamarin Team ✭✭✭

    @samibelak
    You should take a loot at CustomGeometryclass, for example this code creates a gizmo:

        CustomGeometry geom = node.CreateComponent<CustomGeometry>();
        geom.BeginGeometry(0, PrimitiveType.LineList);
        var material = new Material();
        material.SetTechnique(0, CoreAssets.Techniques.NoTextureUnlitVCol, 1, 1);
        geom.SetMaterial(material);
    
        float size = 1;
    
        //x
        geom.DefineVertex(Vector3.Zero);
        geom.DefineColor(Color.Red);
        geom.DefineVertex(Vector3.UnitX * size);
        geom.DefineColor(Color.Red);
        //y
        geom.DefineVertex(Vector3.Zero);
        geom.DefineColor(Color.Green);
        geom.DefineVertex(Vector3.UnitY * size);
        geom.DefineColor(Color.Green);
        //z
        geom.DefineVertex(Vector3.Zero);
        geom.DefineColor(Color.Blue);
        geom.DefineVertex(Vector3.UnitZ * size);
        geom.DefineColor(Color.Blue);
    
        geom.Commit();
    

    you can also draw other primitives this way, see PrimitiveTypeand other methods of CustomGeometryclass.

  • aseelabuaseelabu USMember

    can we add events to CustomGeometry shape ? ?or add geom to a button ? ?

  • aseelabuaseelabu USMember

    @EgorBo can we add event to Custom Geometry? I drew circle using CustomGeometry and I want to add event ? or add it to a button ?or is there another way to add event to CustomGeometry Shapes ?

  • EgorBoEgorBo BYXamarin Team ✭✭✭

    @aseelabu said:
    @EgorBo can we add event to Custom Geometry? I drew circle using CustomGeometry and I want to add event ? or add it to a button ?or is there another way to add event to CustomGeometry Shapes ?

    What do you mean by "event"? Which one?

  • aseelabuaseelabu USMember

    @EgorBo I mean Touch And Click Events on the geometry or add the drawing geometry to the button which has click or touch ,,, ie when Click on the circle show message or show another drawing ???

  • EgorBoEgorBo BYXamarin Team ✭✭✭

    @aseelabu said:
    @EgorBo I mean Touch And Click Events on the geometry or add the drawing geometry to the button which has click or touch ,,, ie when Click on the circle show message or show another drawing ???

    I guess you can use RayCast, take a look at the Decals sample (or Charts) from https://github.com/xamarin/urho-samples/tree/master/FeatureSamples/Core

  • aseelabuaseelabu USMember

    @EgorBo Thank You Very Much I ll try it :) :)

  • aseelabuaseelabu USMember

    @EgorBo The Sample showed RayCast withOctree i Could not use theRaycastSingle with CustomGeometry Is there another way ? to Detect geom and events on geom ? thank u very much :)

  • VugarMiriyevVugarMiriyev USMember
    edited August 2016

    Hi EgorBo, can I use CustomGeometry for drawing free shape by mouse clicking, I mean create vertex when user click on the place and how can I achive that? And please advice how can I visualize the path when user define new vertex?

  • lahellerlaheller USMember ✭✭
    edited June 2018

    @samibelak @EgorBo
    Draw primitves using debug renderer can be done like this:

    var dr = app.Scene.GetOrCreateComponent<DebugRenderer>();
    app.Engine.PostRenderUpdate += (arg4) => {
        app.Renderer.DrawDebugGeometry(false);
    };
    app.Renderer.BeginViewRender += (arg5) => {
        dr.AddBoundingBox(new BoundingBox(-1000, 1000), Color.Blue);
        dr.LineAntiAlias = true;
        dr.AddTriangle(new Vector3(2,0,0), new Vector3(2,1,0), new Vector3(2,0,1), Color.Magenta, false);
        dr.AddCircle(new Vector3(2,0,0), new Vector3(1,1,1), 5.0f, Color.Red);
    };    
    
Sign In or Register to comment.