3D renderer draws curves always on top

19 views
Skip to first unread message

Viktor Schepik

unread,
Jul 3, 2015, 8:43:32 AM7/3/15
to clj-pro...@googlegroups.com
The 3D renderers :p3d and :opengl draw curves always on top of e.g. rectangles even when they are drawn before the rectangles. When I use the 2d renderers (default and :p2d) everything is right. Is there a way to influence what is drawn on top of what when using a 3d renderer?

I want to use 3d renderers because of the speed. My sketch draws graphs of nodes (rectangles) and edges (curves) and supports drag'n drop of nodes. The graph will be quite large with more than 1000 edges / curves.

I am using quil "2.2.6", clj on OSX 10.10.3 and JDK1.7.

Sample code that demonstrates the problem:

(ns quil-exp.core
  (:require [quil.core :as q]
            [quil.middleware :as m]))

(defn setup []
  (q/frame-rate 30)
  (q/color-mode :hsb)
  (q/rect-mode :radius))

(defn update-state [state]
  state)

(defn rectangles
  []
  (q/rect 100 100 40 40)
  (q/rect 250 100 40 40)
  (q/rect 400 100 40 40))

(defn lines
  []
  (q/curve 100 100 100 100 400 100 400 100))

(defn draw-state [state]
  (q/background 240)
  (lines)
  (rectangles))

(q/defsketch quil-exp
             :size [500 500]
             :setup setup
             :update update-state
             :draw draw-state
             :features [:keep-on-top]
             :middleware [m/fun-mode]
             :renderer :p3d)

Thanks in advance!
  Viktor

Nikita Beloglazov

unread,
Jul 6, 2015, 1:36:32 AM7/6/15
to clj-pro...@googlegroups.com
Hi Victor

I don't know how to workaround this issue properly. As a hack you can try changing z coordinate of drawings. Something like:

(defn draw []
  (q/curve ...)
  (q/with-translation [0 0 1] ; draw with z = 1
     (q/rect ...)))

It draws rect over curve. If you have 2 types of objects like rects and curves it might work, but if you have 100 different shapes and you want each of them to be drawn using unique z-index it might be too messy. 

Thanks,
Nikita

--
You received this message because you are subscribed to the Google Groups "clj-processing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clj-processin...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Viktor Schepik

unread,
Jul 6, 2015, 4:25:43 AM7/6/15
to clj-pro...@googlegroups.com
Hi Nikita,

thank you for your hint. Now the rendering is done the way I need it.

Thanks,
  Viktor
Reply all
Reply to author
Forward
0 new messages