Hi, next to my post about handling input events, my final objective is to draw Bézier curves, thus, the use of orxDisplay_DrawLine/Circle (from my point of view).
I get my coordinates (thanks to the previous topic) and I can display them when created through orxObject_CreateFromConfig(). I prefer not to store orxOBJECTs, but only the orxVECTORs related to my clicked coordinates to use them with the orxDisplay_Draw* functions.
My problem is that, having my orxVECTOR array and looping on it with orxDisplay_DrawCircle, nothing happen in my windows.
Are there pre-requisites or some initialization steps before using the orxDisplay_Draw* functions ?
Comments
It was a problem at first, but, I found topics on this matter and the correction helped me to display my points through orxOBJECTs.
Would you mind sharing a few examples when you get it going? I notice that the drawing must be done every frame, so it would be nice to see which loop routine you put the redraw into.
all the orxDisplay_* API expects coordinates in screen space. If you're using world space coordinates with it, it's unlikely to work!
Now if you don't want to do the conversion yourself, you can create a dummy orxOBJECT that lives in the world.
Now, that brings me to Sausage's question.
You can then listen for the orxRENDER_EVENT_OBJECT_START event, when you receive it, all the info you'll need to display this object on screen will be in the payload. You can use those information and add your local bezier values to it to finally draw lines/circles where you want. Here's a very simple example that only uses position of an object and will display a yellow circle underneath.
Here's the event handler:
PS: You need the latest from the source repository for this to compile. I recently renamed the payload, it used to be called orxRENDER_EVENT_OBJECT_PAYLOAD instead and had the pstTransform field directly (not ->stObject.pstTransform).
To try it, start orx (bounce) and press 'T'. https://forum.orx-project.org/uploads/legacy/fbfiles/files/bezier.zip
I'll make a routine and post here if anyone is interested.
Thanks Iarwain, I'll check this out. I've also had some success creating bezier waves for aliens. Routine is still underway and will publish if anyone wants it. But hadn't tried drawing beziers.
As I get my coordinates with orxMouse_GetPosition(), I'm already in screen space, so no need for conversion.
I don't mind publishing my code (I have to finish it first
Glad you got it working!
The first draft is finished. It's very basic : you make a polyline and the Beziers curve is drawn accordingly. The source is fair enough for a tutorial, but needs some work to be used in a bigger project.
Now, as sausage wanted examples, here is the source. https://forum.orx-project.org/uploads/legacy/fbfiles/files/beziers_curve.zip
If you want to be able to edit the wiki directly, all you need is to register there and let me know so I can give you write access.