jPCT-AE - a 3d engine for Android > Support

Drawing an outline around objects

(1/3) > >>

orsharir:
Hello,

We want to draw an outline / silhouette around selected objects in my scene (see the attachment for example). I've already implemented this effect using pure OpenGL on the iOS version of our app, and now I need to implement it on the Android version that is using jPCT.

How I do this on iOS, is draw the object 4 times:
1) Draw the object with 0 alpha, while disabling the update to the depth mask, and replacing the stencil buffer with ones where the object is painted.
2) Draw a scaled up version of the object with a constant color except where the stencil buffer is 1 (that is, where the actual regular object would be).
3) The same as above but with a scaled down version.
4) Draw the regular object normally.

The effect is quite simple and looks good enough for our use on iOS, but I have no idea how I could implement it using jPCT on Android. I have noticed that I could use IRenderHook to modify the stencil buffer, depth mask etc, so that part is easy. The issue is that I need to control the drawing order, so that I could draw using the above sequence, and I've seen now way to achieve that.

Any help would be greatly appreciated.

[attachment deleted by admin]

EgonOlsen:
The IRenderHook has a method repeatRendering(). It that one returns true, the geometry will be rendered again. You might want to try to add your direct gl calls at that stage and trigger a new rendering with the new setting. Just keep in mind that you have to fiddle around the gl matrices yourself at this stage, because changes in scaling of the Object3D won't be taken into account here.

orsharir:
Thanks, I'm looking into it right now, though I've stumble upon a small issue: Right now we're using OpenGL 2 with jPCT, so how can we modify the modelview matrix that is passed to the built-in default shader that jPCT uses?

Again, many thanks for the help.

EgonOlsen:
In the IRenderHook, you can implement setCurrentObject3D() to store the current object being rendered. Then, in repeatRendering(), you can call getShader() on that Object3D and set your matrix.

orsharir:
I'm sorry, but I see no documentation for "getShader()" in Object3D or anywhere else. Is it available on a newer version of the library?

Navigation

[0] Message Index

[#] Next page

Go to full version