Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - auser

Pages: [1]
1
Support / Re: Collision detection between two points?
« on: December 01, 2011, 01:57:39 pm »
Aha ahokey then i know! i Fixed that. :)

2
Support / Re: Collision detection between two points?
« on: November 30, 2011, 07:19:56 pm »
Soo, now i Think i made it. Thank you for your time!

public SimpleVector GetRayHitPosition(SimpleVector point1, SimpleVector point2)
{
   SimpleVector dir = new SimpleVector(
         point2.x - point1.x,
         point2.y - point1.y,
         point2.z - point1.z);
   
   float hitedRay = RenderEngine.ThisWorld.calcMinDistance(point1, dir, 1000000);
   if(hitedRay == Object3D.COLLISION_NONE) return null;
   
   dir.x = dir.x * hitedRay + point1.x;
   dir.y = dir.y * hitedRay + point1.y;
   dir.z = dir.z * hitedRay + point1.z;
   
   return dir;
}

3
Support / Re: Collision detection between two points?
« on: November 30, 2011, 04:56:21 pm »
I changed to:

RenderEngine.ThisWorld.calcMinDistance(point1, dir, 100000);

It seems to work pretty well, But sometimes the return value is 1.45, should it not be from 0 to 1?
And sometime it is 1.0E12, is that when it doesent hit anything?

4
Support / Re: Collision detection between two points?
« on: November 29, 2011, 09:15:10 pm »
Okej, here i am trying with this own method. I want to get the hit position between their two points:

SimleVector hited = GetRayHitPosition(turretPosition, camPosition);

public SimpleVector GetRayHitPosition(SimpleVector point1, SimpleVector point2)
{
   float viewDistance = Functions.computeAverageDistance(point1, point2);
   
   SimpleVector dir = new SimpleVector();
   dir.add(point2);
   dir.sub(point1);
   float aimToPlayer = RenderEngine.ThisWorld.calcMinDistance(point1, dir, viewDistance);
   
   SimpleVector result = new SimpleVector();
   result.add(point1);
   
   dir.x = dir.x / 1 * aimToPlayer;
   dir.y = dir.y / 1 * aimToPlayer;
   dir.z = dir.z / 1 * aimToPlayer;
   
   result.add(dir);
   
   return result;
}

But it dont work very well, it is hard to explain what the wrong is. Maybe there is somehere who can help me with the code, so i can get the hit position?

5
Support / Re: Collision detection between two points?
« on: November 29, 2011, 07:49:54 pm »
Sorry for my very bad English and it is really hard for me to explain this very simple question.
I can change my question... I want to make a gun, and when i shoot at the wall, how can i get the actual hit position in the world?

I have the SimpleVector position at the gun, and i have a SimpleVector position at the end of the bullet position somewhere in the space. How can i check the SimpleVector position from the bullet hit?

6
Support / Re: Collision detection between two points?
« on: November 28, 2011, 11:24:35 pm »
Hmm i really cant solve this. Right now it works when i use jBullet like this

ClosestRayResultCallback callback = new ClosestRayResultCallback(TurretPosition, PlayerPosition);
DynamicWorld.rayTest(TurretPosition, PlayerPosition, callback);
boolean hited = callback.hasHit();

Then i even can use  callback.hitPointWorld to get the position of the collision point.

But to use jBullet collision i must have both jBullet walls and jpct walls.
I havent much knowledge about collisions, so, there would be very nice if some one have an example code?  :-[

7
Support / Re: Collision detection between two points?
« on: November 28, 2011, 09:13:46 pm »
Oh thanks! But sorry, where can i find that method hehe? :P

8
Support / Collision detection between two points?
« on: November 27, 2011, 09:14:48 pm »
Hi. Im trying to detect collision between two Points.
I have create a small AI turret how is looking for the player. But now the AI can see thought the walls.
So i need to check if there is walls between the AI and the player.

I was trying to use:
SimpleVector collideAtWall = AITurret.checkForCollisionSpherical(playerPosition, 10);

And creating a line between Turret and collideAtWall. But the line points at the player Always anyway. :(

9
Support / Door moving and push the player?
« on: November 16, 2011, 07:48:40 pm »
Hi. I have tried jpct-ae and like it alot! But now i am stuck with the collision.
I have created a player who collide with the World objects. And now i created a door wich act good with the
movement. But now, when the door moves and push the player, the door goes through the player. In some way i need to check when the door hits the player and push the player.
Is there some solution to do that in a good way? Thanks for help :)

Pages: [1]