Archive 17/01/2023.

Creating a new Drawable subclass - how to actually draw

Alan

Hi guys, I asked this on Gitter but I think Discourse would be more appropriate:

I’m making a new Drawable subclass, and it’s working rather fine, however, the way I’m drawing stuff is actually by calling IsInView in the update event and manually drawing, what’s a hacky solution but I couldn’t find any obvious way to properly draw something, there’s no Draw() or OnDraw() or anything like that, and no way I can see to pass the data to be rendered except maybe GetLodGeometry what I don’t think is what I want. How would you do that?

Thank you

1vanK

Minimal template for Drawable that draws triangle: https://github.com/1vanK/Urho3DRuWiki/wiki/Шаблон-графического-компонента-(Drawable)

(sorry, comments on russian)

Alan

Thank you! However, I still didn’t understand something, how does the renderer access the geometry data?

At the moment I’m subscribing a method to E_POSTRENDERUPDATE and calling the drawing function in my component, what I don’t think is ideal. Also, for some reason subscribing to that in the component itself didn’t work, what are the requirements for that event to fire? In any case, I’m not very happy with that solution, I just need to somehow manage aabbs and also submit geometry data (vert and idx buffers) to the render pipeline along with shaders/materials, what that snippet really seems to do except the material part :stuck_out_tongue: .

Thank you very much @1vanK

1vanK

Engine found Drawables which fall into the field of view of the camera, take batches_ from each and render its, so the main task of Drawable is fill batches_ vector

Alan

Got it! Awesome! Thank you @1vanK!