Author Topic: drawWireframe  (Read 3298 times)

Offline ghidra

  • byte
  • *
  • Posts: 5
    • View Profile
drawWireframe
« on: February 07, 2011, 03:03:32 am »
Hi.

I am new to jPCT. So far I it's been easy to get something basic running. Before I get too deep in, I was looking into rendering a wireframe so I don't have to deal with textures at the moment. I found the method in the docs, but I'm not sure I am applying it right.

Code: [Select]
framebuffer.clear(back);
world.renderScene(framebuffer);
world.draw(framebuffer);
world.drawWireframe(framebuffer, wirecolor );
framebuffer.display();

wire color set to white 255,255,255 and nothing draws. Even without the the first draw call, the wireframe doesn't draw.

Like I said, I'm new and just getting to digging around. I haven't even gotten into shaders yet, maybe a basic phong or lambert with a color might be good too instead of wireframe. Just looking for some basic drawing to get things figured out. Also, about wireframe, sense I have seen it, is there a type of hidden line removal available?

I'm looking forward to learning more about this library and being around in the community.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: drawWireframe
« Reply #1 on: February 07, 2011, 06:51:04 am »
Wire frames are not supported by the AE-version ATM. I was pretty lazy on this, because no one ever complained about them not working. Do you really need them?

Offline ghidra

  • byte
  • *
  • Posts: 5
    • View Profile
Re: drawWireframe
« Reply #2 on: February 07, 2011, 03:25:20 pm »
I don't necessarily need them. I'll just need to research the shaders, and just make myself something simple. I was hoping to build a project with lo-fi style graphics. But I don't mean to make you implement wireframe, I'm sure there are other things I might use a favour for in the future ;)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: drawWireframe
« Reply #3 on: February 07, 2011, 04:24:00 pm »
Which shaders? Shaders aren't supported by jPCT-AE because they are ES 2.0 only and i don't have the hardware and in addition i consider them to be rather pointless on most devices.

Offline ghidra

  • byte
  • *
  • Posts: 5
    • View Profile
Re: drawWireframe
« Reply #4 on: February 07, 2011, 04:44:46 pm »
ah. I apologize for my ignorance. And I thank you for your quick response and help.

So, is the primary option for shaded color on geometry only with an image? And, besides that, is there a way to, say, dial in specular. Or does it all run in kind of a general context?

Again, thanks for your patience. I am going through as much documentation to soak up as much of this as I can.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: drawWireframe
« Reply #5 on: February 07, 2011, 06:11:57 pm »
If you don't assign a texture, a default white one will be used. You can set an additional color that will be added to ambient lighting and the light from the light sources. Polygons will be shaded by using gl's standard gouraud shading. You can enable specular lighting as well, but the results usually aren't very impressive.

Offline Darkflame

  • int
  • **
  • Posts: 55
    • View Profile
Re: drawWireframe
« Reply #6 on: February 09, 2011, 02:45:08 pm »
There are times when I'd have found wireframe usefull - mostly in editing/debugging a scene and wanting to see bits more clearly.

Is it a lot of work to implement in the engine? Or just something you have to copy over or toggle on?

Might be a little retro-thinking of me, but sometimes wireframes can be used nicely in games too. (I've seen it used to add "thin detail" onto objects back when polygon counts were still very restrictive).
But that would be need to be on a per-object base's and not sure how possible that is.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: drawWireframe
« Reply #7 on: February 09, 2011, 05:38:41 pm »
It's not a simply copy and paste job. If it were, i would have ported it already. I've to change some things to support it on Android. Nothing really difficult, i just avoided it because there was no real demand. I'll add it, when i find the time.

Offline Darkflame

  • int
  • **
  • Posts: 55
    • View Profile
Re: drawWireframe
« Reply #8 on: February 09, 2011, 09:05:27 pm »
Ok, not a problem.
Its kinda a bit in the catagory of "lens flares" for me, nice to have as an option but not strictly essential.

Offline luftiguru

  • byte
  • *
  • Posts: 8
    • View Profile
Re: drawWireframe
« Reply #9 on: July 10, 2013, 04:27:13 pm »
It's been a while since the last news on drawWireframe() in jPCT AE.
I'd like to use wireframed 3D overlays in my augmented reality app. Is there any chance, to find the method implemented in jPCT AE soon?
I'd really appreciate any progress in this matter or hints, how to achieve a similar result for my own.
Thanks!  :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: drawWireframe
« Reply #10 on: July 10, 2013, 08:54:26 pm »
It's already implemented. You can choose between points and lines, but there's a drawback: The implementation of lines doesn't create results as you might expect them. That's caused by some design decision on how OpenGL ES does handle line drawing. To fix this, i would have to create a complete new batch of geometry for each object just to render proper lines...and i'm not going to do that. So just give it a try. Depening on the object, it might look good enough. Or maybe point mode is an option.

Offline luftiguru

  • byte
  • *
  • Posts: 8
    • View Profile
Re: drawWireframe
« Reply #11 on: July 19, 2013, 03:40:30 pm »
Thanks for the fast reply. :)
I tried wireframes with the newest version of jPCT AE (July 4, 2013).
First thing, I noticed is the changed API. The method has two additional parameters now:
Code: [Select]
void com.threed.jpct.World.drawWireframe(FrameBuffer buffer, RGBColor color, int size, boolean pointMode)BTW... the online documentation still points to the old API version.

Nevertheless, I tried to use the method with various combinations of "size" and "pointMode". Unfortunately, an exception was thrown at every try:
Code: [Select]
FATAL EXCEPTION: GLThread 1579
java.lang.RuntimeException: Not implemented!
at com.threed.jpct.GL20.glPointSize(GL20.java:1049)
  at com.threed.jpct.GLRenderer.drawWireframe(GLRenderer.java:2244)
  at com.threed.jpct.World.draw(World.java:1349)
  at com.threed.jpct.World.drawWireframe(World.java:1114)
  at myapp.MyRenderer.onDrawFrame(MyRenderer.java:70)
  at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1516)
  at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
Any Idea, why this happens? Will a fix be available soon? :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: drawWireframe
« Reply #12 on: July 19, 2013, 05:33:09 pm »
The online documentation is fine. Make sure that you are looking at the version for jPCT-AE, not the one for desktop jPCT. I'll have a look into the other issue...looks like as if i've forgotten to implement some GL 2.0 related stuff... :o

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: drawWireframe
« Reply #13 on: July 19, 2013, 06:02:00 pm »
OpenGL ES 2.0 obviously doesn't support glPointSize and i haven't added a compatibility layer for this yet. You can try this version: http://jpct.de/download/beta/jpct_ae.jar. It should work (i.e. not crash), but you still can't set a point's in point mode. Points will always be one pixel in size. You can set the width of lines though.

Offline luftiguru

  • byte
  • *
  • Posts: 8
    • View Profile
Re: drawWireframe
« Reply #14 on: July 20, 2013, 11:48:21 am »
Awesome! Thanks for the great support. :)
It works now. The generated wireframes are rendered correctly and are exactly, what I needed so far.