GeometryBatchFactory picking problem

Hi

I’m having a problem with GeometryBatchFactory after it optimises my mesh into a single object. The mesh is lots of duplicated primitive shapes. The problem is raycasting picking (using hello picking code) - as after optimising the raycasting works almost everywhere, except on some of my objects’ faces. Before optimising it works 100% okay, but of course it’s a lot of node objects and not very efficient.

I’m trying locate the source of the problem specifically and if it’s something in my code which is the problem, but just wondering if anyone else has had similar problems and that it might be a bug in jme.

Thanks.

You have to update the mesh collision data with mesh.createCollisionData()

Hi Normen,

I tried what you suggested but I’m still having the same problem.

I’ve managed to isolate the problem a little,

My scene comprises of nodes, each representing a grid chunk. These grid chunks have the duplicated primitives I’m using the optimise on.

So each node, after optimising has only 1 mesh. As the player moves around, these nodes are loaded/unloaded onto the rootnode around the immediate vicinity of the player.

The piece of geometry I’m having a problem with lies on the edge of this area. It actually works sometimes when it’s the very last visible node. But if I move forward a little to bring up another node behind it, the raycasting bi-passes this piece and hits the geometry behind it (which is very close to it).

So the problem seems to happen on the very edge of my node chunks.

actually just seems quite random,



will try write my own optimising code and see if i get the same problem… will report back…

have solved the problem - it’s a bit strange…



the problem only affected about 10% of the duplicated geometries when I done the raycasting test from above onto faces facing directly up.



But when I rotated these faces around Z axis by 0.0000001 or FastMath.PI*2 (making it non zero essentially) - the collision detection works.



strange. but at least it works.

Perhaps you can post a test case? This sounds like a really odd problem

1 Like

it’s a big project with a lot of code sorry…



geometrybatchfactory has a few issues anyway - for example it crashes if you use any deep cloned objects with it.

xp61 said:
it's a big project with a lot of code sorry..
geometrybatchfactory has a few issues anyway - for example it crashes if you use any deep cloned objects with it.

Uh, who told you to deepClone anything? Afaik deepClone is bugged and will probably be deprecated.

that was a much older issue for me anyway, can’t remember why, think i needed deepclone to duplicate geometries with their individual tex coords in tact.

okay i’m still having a few issues,

the problem now is that the raycasting seems to go right through certain single points on my geometry, at fairly random places, although only a small amount of the time.

as I was saying - it works 100% before I use geometrybatchfactory, which seems to mess things up.

i tried using createcollsiondata at every point where I change the geometry, but has no effect.



I know how to create my own optimization code to create a single object out of many duplicates, but the bit I don’t know how to do is getting the absolute vertex positions of an object after scaling/transforms. If i can manag this then I know how to weld all the vertex/index/tex buffers into a single object.



will appreciate any further help, thanks.

You can use Spatial.localToWorld to get the vertex position in world space

1 Like

yes was looking at that - will try it tomorrow, thanks…

okay I understand how localtoworld works, but what if I have geometry that is part of a hierarchy of nodes - and those have transformations that need applied also?



For example if I have a box which is a child of a node which has scaling applied, and which further is a child of another node which has some translation applied - localtoworld doesn’t seem to take these into account, just the immediate transformations made to geometry.

Is there an easy way cumulate all the transformations in a hierarchy into world space?

1 Like

it’s okay, I’m just altering the geometry and using localtoworld every time I do a translation, rather than trying to do it all in one go by adding up multiple translations in a hierarchy.

Make sure to update from SVN … Recently there was an issue related to localToWorld

1 Like

Hi - I just done that - but get an ‘error in scene - java.lang.IllegalArgumentException’ error when I now run jme3



and now my scene isn’t showing at all!



here’s the stack trace



java.lang.IllegalArgumentException

at com.jme3.bounding.BoundingBox.setYExtent(BoundingBox.java:902)

at com.jme3.renderer.Camera.setGuiBounding(Camera.java:1105)

at com.jme3.renderer.Camera.onViewPortChange(Camera.java:1093)

at com.jme3.renderer.Camera.resize(Camera.java:385)

at com.jme3.renderer.RenderManager.notifyReshape(RenderManager.java:231)

at com.jme3.app.Application.reshape(Application.java:354)

at com.jme3.system.lwjgl.LwjglCanvas.runLoop(LwjglCanvas.java:188)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:206)

[catch] at java.lang.Thread.run(Thread.java:680)



I’m using my own viewport with an outputted framebuffer which is redrawn onto a quad - but isn’t showing anything, so the problem is around here i think… looking into it now…

okay i did a fresh reinstall and updated everything to latest builds/svn, and got rid of that first error.

but my scene is still not rendering.



objects on rootnode show up fine,

but because i’m using my own viewport and framebuffer and drawing this into a quad, nothing is showing up anymore, just wondering what recent changes in svn might be affecting this.

i managed to get some new test geometry showing up,



so it’s probably something to do with deprecated ways of creating my old geometry, material definitions etc… looking at it all now.

xp61 said:
okay i did a fresh reinstall and updated everything to latest builds/svn, and got rid of that first error.
but my scene is still not rendering.

objects on rootnode show up fine,
but because i'm using my own viewport and framebuffer and drawing this into a quad, nothing is showing up anymore, just wondering what recent changes in svn might be affecting this.


maybe try to temporarily undo this fix:
https://code.google.com/p/jmonkeyengine/source/detail?r=7291
and see if that changes anything