cyuczieekc said:
@normen:
====
I wonder what's @xp61 doing, I really am :) I'm kind of bidding my time waiting... (not to imply any obligations though)
i wouldn't hold your breath, might be a few days ;)
cyuczieekc said:
@normen:
====
I wonder what's @xp61 doing, I really am :) I'm kind of bidding my time waiting... (not to imply any obligations though)
okay i’ve narrowed down the problem (i’ve also updated all plugins/nightly build),
the geometry i had been using was a hexagonal shape imported from blender constructed like so,
http://www.geometryatlas.com/entries/187
when i merge duplicates of these into a single object, the collision problems happen.
i tried replacing the hexagonal shape with a simple quad for testing, and there doesn’t seem to be a problem.
so there’s something in the construction of my hexagon shapes, or something in blender, which is screwing with raycasting when all the shapes are merged into a single object. (but they work fine when not merged…)
well i reconstructed my own hexagon shape internally (not imported) - and the problem persists,
depending on how i scale/translate things before optimizing seems to be the problem,
so transformations seem to be screwing with collision detection on objects that have been optimised into a single mesh.
trying now to locate specific instance of the problem…
if you could isolate that into a simple testcase that we can also run, it may actually save you some time, just copy paste around some code and maybe make a testcase? up to you, but really I believe it may save time… with a testcase we’d be like 3 people trying to track down the problem, not to mention it’s simpler than what you have due to it being a testcase as opposed to your entire project
Please consider taking the time to make one…
yeah i’ll see what i can do, thanks.
mmmmmm may have got to the source of the problem…
it seems if i do a complete 360 rotation of my geometry in all directions before applying any further transformations, the problems go away
like so
hex.rotate((FastMath.PI * 2),(FastMath.PI * 2),(FastMath.PI * 2));
will double check this further…
that is somewhat odd…
does it work if you replace that rotation with
[java]hex.getWorldTranslation(); [/java]
which calls checkDoTransformUpdate();
cyuczieekc said:
that is somewhat odd...
does it work if you replace that rotation with
[java]hex.getWorldTranslation(); [/java]
which calls checkDoTransformUpdate();
i’m afraid i’m back to square one,
i noticed that as i moved away from the world origin vertically(y), the problem starts up again, although seems fine when i move around just horizontally (x,z).
i’ll put together a test case…
okay here’s my test case - it’s a full main.java file…
when you run it move the camera forward and look down to see the blue tiles,
then keep shooting with space/click to place the red marker,
you need to keep repeating this about 10 / 20 times , and on different blue tiles, before the raycasting misses one.
[java]
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Sphere;
import com.jme3.scene.Node;
import com.jme3.scene.Mesh;
import com.jme3.math.Vector3f;
import com.jme3.math.Vector2f;
import com.jme3.util.BufferUtils;
import java.nio.FloatBuffer;
import com.jme3.scene.VertexBuffer;
import com.jme3.scene.VertexBuffer.Type;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.math.Ray;
import com.jme3.input.KeyInput;
import com.jme3.font.BitmapText;
import com.jme3.collision.CollisionResult;
import com.jme3.collision.CollisionResults;
import com.jme3.math.Quaternion;
import jme3tools.optimize.GeometryBatchFactory;
/**
I tried this, I’m not sure, but I kinda tried like 80 times, every time hit… maybe I’m not doing it right?
can you give me your camera location (pressing key C) and camera rotation from where you shoot at them? or even better when it missed
I used jme3 r7301
there we go, I replaced action with analog and added cam pos&rotation where there is a miss
just keep the left mouse button pressed when you move to see blinking where misses occur, but basically if you can keep the mouse steady at the start of the program and just left click you see it misses!
code below
Hi-
Thanks very much for your efforts
I’m confused though - the new code I tried and I’m still having the same problems,
here’s a screenshot of when it ‘missed’ with cam location,
sorry, i guess at this stage you’re just showing the problem much better by having continuous analog testing,
yes you can see the blinking and missing much better…
now what
yeah…at this stage, just showing that you are right, I didn’t have time to test it more then, to get to the root of the problem, trying more now…
well like i was saying, if i do a 360 rotation on the objects - it seems to work fine - (below)
but in my project, if i moved vertically away from the world origin, the problem seems to return…
[java]
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Sphere;
import com.jme3.scene.Node;
import com.jme3.scene.Mesh;
import com.jme3.math.Vector3f;
import com.jme3.math.Vector2f;
import com.jme3.util.BufferUtils;
import java.nio.FloatBuffer;
import com.jme3.scene.VertexBuffer;
import com.jme3.scene.VertexBuffer.Type;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.AnalogListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.math.Ray;
import com.jme3.input.KeyInput;
import com.jme3.font.BitmapText;
import com.jme3.collision.CollisionResult;
import com.jme3.collision.CollisionResults;
import com.jme3.math.Quaternion;
import jme3tools.optimize.GeometryBatchFactory;
import com.jme3.math.FastMath;
/**
and the problem is nothing to do with geometrybatchfactory specifically as i originally thought…
it can sometimes reappear when i use it - sometimes not,
it’s a very random problem…
so far, it seems to me the collision is not detected in com.jme3.bounding.BoundingBox.collideWithRay(Ray, CollisionResults)
that is, the collision of the ray with the boundingbox of each of the hexagonz
I tried your last code, if I just keep LMB pressed and move away with the camera (ie. key S only) then it does detect lack of collisions, seems like the rotations didn’t have any effect… well maybe from the same cam location&rotation while it initially doesn’t detect collision, after you do your rotations it does detect it, but the “bug” is still there really, just have to get a different ray angle I think
basically if I change line 746 in com.jme3.bounding.BoundingBox.collideWithRay(Ray, CollisionResults):
[java]
return 0;[/java]
to:
[java] System.out.println(“no collision”);
return 0;[/java]
I can see that when no collision happens there are 9 “no collision” lines instead of 8 when it does happen, meaning , that method is the one that doesn’t detect it
EDIT: well I mean it could be that the bound is off, I mean, it doesn’t mean this method is bugged
interesting, thanks for that…
at a wild guess i’m wondering is it something to do with internal floating point precision problems don’t picking up the collisions depending on where you are in world space…
i’m out of my depth on this, just a guess…
looks like the same thing happens for Quad`s that have a 0 or very close to 0 height
here’s a sample code (note that I only show the bounding box of the Quad, rest is well invisible?)
also cam pos&rot is already set to the point of no collision detected
also note that if I replace:
[java] Quad m = new Quad(1f, 0.0000000000001f);[/java]
with
[java]Quad m = new Quad(1f, 0.1f);[/java]
there are always collisions
but if I replace it with
[java]Quad m = new Quad(1f, 0.000001f);[/java]
I can easily get some missed collisions by simply aiming the camera at a quad (well it’s boundingbox really) and only moving camera backward with S (keeping LMB pressed) - the red sphere will blink [just in case someone didn’t read prev posts xD]
It might be a float precision issue? I wonder what @momoko_fan or @normen think
[java]package org.jme3.forum2;
import com.jme3.app.SimpleApplication;
import com.jme3.bounding.BoundingBox;
import com.jme3.bounding.BoundingVolume;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Quad;
import com.jme3.scene.shape.Sphere;
import com.jme3.scene.Node;
import com.jme3.scene.Mesh;
import com.jme3.scene.Spatial;
import com.jme3.math.Vector3f;
import com.jme3.math.Vector2f;
import com.jme3.util.BufferUtils;
import java.io.IOException;
import java.nio.FloatBuffer;
import com.jme3.scene.VertexBuffer;
import com.jme3.scene.VertexBuffer.Type;
import com.jme3.scene.control.Control;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.AnalogListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.math.Ray;
import com.jme3.input.KeyInput;
import com.jme3.export.JmeExporter;
import com.jme3.export.JmeImporter;
import com.jme3.font.BitmapText;
import com.jme3.collision.CollisionResult;
import com.jme3.collision.CollisionResults;
import com.jme3.math.Quaternion;
import jme3tools.optimize.GeometryBatchFactory;
/**