Out of order drawing for 3D / Layered 3D rendering? #2373
-
Hello. I'm trying to build a crude 3D editor, I've been trying to figure out a way to render handles (the little thingys you move objects around with) in front of other geometry. Is there a way to render 3D geometry out of order or into different layers? Note: I'm currently using raylib's drawing functions (DrawCube, DrawLine3D, etc..). I would like to work with meshes later on but a solution that works for these objects would be much appreciated too. What I've tried so far:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Are you rendering big Model at once (which contains meshes)? raylib renders all meshes (from Model) on one drawcall (check rmodels.c -> void DrawModelEx() -function ). Copy that function and modify it to work as you wish. Or load every mesh as one model, and then render them like you wish (then you can control depth and other tests). Get mesh's bounding box, its center, mesh's rotation and then render lines. ...some ideas, hopefully got some ideas. |
Beta Was this translation helpful? Give feedback.
-
So, I think I figured it out following raysan's suggestions in #682. What you need is:
BeginTextureMode(bg);
ClearBackground(RAYWHITE);
BeginMode3D(camera);
// DrawCube() or any other 3D drawing function
EndMode3D();
EndTextureMode();
BeginTextureMode(fg);
BeginMode3D(camera);
ClearBackground(Fade(WHITE, 0.0f));
// Functions to draw some foreground 3D objects
EndMode3D();
EndTextureMode();
BeginDrawing();
DrawTextureRec(bg.texture, {0, 0, screenWidth, -screenHeight}, {0, 0}, WHITE);
DrawTextureRec(fg.texture, {0, 0, screenWidth, -screenHeight}, {0, 0}, WHITE);
// UI/Text drawing functions
EndDrawing(); If you're trying to do this for UI, you can check out raygui or rlImGui. Here's the commit when I added rlImGui and layers. |
Beta Was this translation helpful? Give feedback.
So, I think I figured it out following raysan's suggestions in #682. What you need is:
BeginX()
andEndX()
functions you currently use.You can clear the background with whatever color you want.
You can play with the alpha to get cool effects like dimming the backgroun…