I have two object.the First is player and the second is House.I set both object with BoundingBox(). Because when i set the other ones , i can't get Yextent from it's Bound.
I plant to make player can move to everywhere.BUt when it will pass house it stop. I use WordBound to check intersection. My code like this :
message.setCollitionWith(MessageInput.OBJ_REFRESHING_HOUSE);//message is my own object
With this method, i can detect when player intersect with house. But Unfortunately player always hit house before stop because it need time to play transition animation.So i'd like to stop player before intersect with house.it is used to give time for transition animation from move to stop.So How to calculate distance player location to house Wordbound? :?
i assume that the player is the camera, then the distance to the CENTER OF THE house is:
distNumTmp = camera.getDirection().dot(house.getWorldTranslation());
distNumTmp -= camera.getDirection().dot(camera.getLocation());
distNumTmp /= camera.getDirection().length();
player and house in my game are node.Is it same with camera?
Vector3f has a distance Method:
yes, i know it. But i need to calculate the distance of Node to the outside(border) of WordBound ( ModelBoundingBox) of House(Node). So i can detect collition and stop player before collition happened.
…then subtract the x (or z or y) -extend of the house's boundingBox from the resulting distance between Cam and House.
If the BoundingBox of your House isn't a cube, maybe you have to check from which direction the player is moving towards the house, and choose the corresponding x/y/z-extend of the boundingBox. Consider the edges as well…
Another way is to primary check for bounding intersection… and for more precize results check for collisions with polys.
take a closer look on the jmetest.intersection package.
if your house is made up of walls that correspond to boxes or something at the bounds then you can do a pick with a ray between the 2 centers and figure out the closest wall from the pick results.
Then you can do this and solve for D
performance might not be so good though.
Have you tried BoundingVolume's method: float distanceToEdge(Vector3f point);
Thank for all answering my question. And the end, i try to implement which suggested by renanse. And it can calculate the point to the outside of house worldBound.And it is what i look for.I have got tried with this