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 - AGP

Pages: 1 ... 98 99 [100] 101 102 ... 108
1486
Support / Re: Why not add a math class?
« on: September 08, 2008, 06:26:35 pm »
I need the hero to look in the direction of the mouse click. By the way, I could just use the original mouse coordinates which are already in 2D. So shouldn't converting the hero's center and the hero's direction vector (in front of him) to 2D and then calculate that angle make sense? And if you agree, tell me if my changes work and if not please make your own. Thanks a lot.

1487
Support / Re: Why not add a math class?
« on: September 07, 2008, 11:44:44 pm »
OK, now I'm confused. My s1 was the hero's transformed center, and my s2 was the mouse click's position.

The hero''s transformed center is the origin. I have a direction vector for the keyboard that's always directly ahead of the hero, and I have the direction vector of the mouse click. What exactly should I feed into the method and for that matter, what version of the method? Yours?

1488
Support / Re: Why not add a math class?
« on: September 07, 2008, 10:07:28 pm »
OK, but I still think that a Math class with all sorts of operations would be invaluable.

By the way, you know my problem and it didn't work for that one. I also tried the 2D variation that follows. Why doesn't it work?
Code: [Select]
      public float calculateAngle(SimpleVector s1, SimpleVector s2) {
s1=s1.normalize();//TRIED WITH AND WITHOUT THESE
s2=s2.normalize();
SimpleVector p13d = Interact2D.project3D2D(theCamera, buffer, s1);
Point p1 = new Point((int)p13d.x, (int)p13d.y);
SimpleVector p23d = Interact2D.project3D2D(theCamera, buffer, s2);
Point p2 = new Point((int)p23d.x, (int)p23d.y);

float pa=(float)p1.x*(float)p2.x+(float)p1.y*(float)p2.y;

// Inaccuracies may cause NaN...fix this:
if (pa<-1)
pa=-1;
else if (pa>1)
pa=1;
    return (float) Math.acos(pa);
      }

1489
Support / Re: Why not add a math class?
« on: September 06, 2008, 05:48:42 pm »
Thanks a lot. What about my suggestion of adding a Math class? Could be quite useful and wouldn't make jPCT cumbersome in any way.

1490
Support / Re: Why not add a math class?
« on: September 06, 2008, 06:19:21 am »
More specifically, I'm trying to calculate a 2D angle, so this method would only use the x and y components of the SimpleVector class. static float calculateAngle2D(SimpleVector origin, SimpleVector p1, SimpleVector p2) might be a better name!

1491
Support / Why not add a math class?
« on: September 06, 2008, 05:33:30 am »
And include methods like static float calculateAngle(SimpleVector origin, SimpleVector p1, SimpleVector p2)? Until then, if somebody would tell me the code for that I'd be grateful! : -)

1492
Support / Re: Distance between SimpleVectors
« on: September 06, 2008, 05:30:21 am »
While you're at it, why not a calculateAngle(SimpleVector origin, SimpleVector p1, SimpleVector p2)?

1493
Support / Re: Character Moves Towards Mouse Click
« on: August 28, 2008, 10:14:11 pm »
OK, that'll take me a little while. It's a little humbling discussing this with you, dude!

Here's a question: why does the cube translate to the camera's position? And then, why does the camera see something whose center is the same as its?

1494
Support / Re: Character Moves Towards Mouse Click
« on: August 28, 2008, 09:58:10 pm »
Thanks for the solution, my friend. But I don't understand why it is that the collision-detection line makes it work. If I take it out for the plane, it doesn't work on the plane. But if the other objects are still calculating the collision, it works on them. Why is that?

1495
Support / Re: Character Moves Towards Mouse Click
« on: August 28, 2008, 12:56:00 am »
Cool. I await your solution, pal. Thanks.

1496
Support / Re: Character Moves Towards Mouse Click
« on: August 26, 2008, 11:05:06 pm »
I sent you an e-mail with a screenshot. If we find a solution, I will post it on this thread.

As for the picking plane, I expect you mean for me to add destination.z = destination.y; destination.y = 0; again. But if that's not it, please explain. And should I pass any value for z on reproject2D3D() call?

1497
Support / Re: Character Moves Towards Mouse Click
« on: August 26, 2008, 10:30:17 pm »
I guess I misunderstood the documentation, because it says it will assume z to be 1. And the hero should move on the x and z planes. So I figured the z value would instead be placed on the y coordinate (some orientation problem someone with more spacial perception than I would understand!). But you're right, of course, about the delta. It should be calculated on the call to transform (between destination and hero.getTransformedCenter()). The following still doesn't work:
Code: [Select]
SimpleVector heroCenter3D = hero.getTransformedCenter();
SimpleVector destination = Interact2D.reproject2D3D(theCamera, buffer, mousePoint.x, mousePoint.y);
hero.translate(destination.x-heroCenter3D.x, destination.y-heroCenter3D.y, destination.z-heroCenter3D.z);

Note that the hero shouldn't even move in the y axis anyway, but I suppose I would just change the y and z values later (after I at least saw the hero appearing to be in the right place).

1498
Support / Re: Character Moves Towards Mouse Click
« on: August 26, 2008, 09:47:25 pm »
Hah, as opposed to my other overly simple questions? : -)

What's not working is that the translation value is wrong (hero goes somewhere else).

1499
Support / Character Moves Towards Mouse Click
« on: August 26, 2008, 09:17:15 pm »
I'm trying to make an RPG with 2D backgrounds and a 3D hero. When the player clicks on the screen, the hero has to move that way. The following's what I did (for translation, rotation is something else). Is it wrong, because it's not working?
Code: [Select]
SimpleVector heroCenter = Interact2D.project3D2D(theCamera, buffer, hero.getTransformedCenter());
SimpleVector destination = Interact2D.reproject2D3D(theCamera, buffer, mousePoint.x-(int)heroCenter.x, mousePoint.y-(int)heroCenter.y, hero.getTransformedCenter().z);
destination.z = destination.y;
destination.y = 0;
hero.translate(destination);

1500
Support / Re: What does Animation.getSequenceCount() return?
« on: August 21, 2008, 12:48:20 am »
I see. Thanks for the explanation.

Pages: 1 ... 98 99 [100] 101 102 ... 108