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

Pages: 1 ... 11 12 [13] 14 15 16
181
Support / Rotate an object to match another object's rotation matrix
« on: October 20, 2011, 09:43:32 am »
I have two Matrices;

1) object3D1: The source Object3D rotational matrix (getRotationMatrix())
2) object3D2: The destination Object3D rotational matrix (getRotationMatrix())

I would like to slowly rotate the source object to match the rotation matrix of the destination object frame by frame, so both rotations are exactly the same (both objects are facing the same way).

I'm guessing I can use object3D1.getZAxis() and object3D2.rotateAxis() but how do you do the calculations?

Or can I use Matrix.interpolate()?


182
Support / Re: multiple worlds and clipping planes
« on: October 17, 2011, 01:14:15 am »
If you change the FOV does that make a difference?

Are you changing the origins of the objects or translating everything from 0,0,0?

183
Support / Re: Flipping Phone causes Weird Translation
« on: October 15, 2011, 03:57:23 pm »
Yes, because jPCT isn't thread safe.

Yep I learned that the hard way  :P

184
Support / Re: Aligning bullets/projectiles from player location
« on: October 15, 2011, 03:47:00 pm »
Thanks, the code changes have fixed the problem, plus the projectile collision detection works much better now.

Appreciate the help, I'm still trying to get my head around all the 3D math and concepts :P

ps. The sensor orientation is set to Tablet landscape orientation so it spins incorrectly on a portrait phone. The xyz variables just need to be toggled I believe (I'll fix that up later).

185
Support / Re: Flipping Phone causes Weird Translation
« on: October 15, 2011, 06:52:29 am »
I can confirm that if translations/rotations are changed outside of the rendering thread, the objects can sometimes render in the wrong location at random frames.

Use variables to store the orientation in OnSensor(), and do all camera/object translations and rotations in onFrame() using those variables.

186
Support / Re: Aligning bullets/projectiles from player location
« on: October 15, 2011, 06:44:24 am »
Egon, I've sent you an example app via email. If you have a spare moment and figure out why there is an offset when facing X, that would be great. Thanks.

187
Support / Re: Aligning bullets/projectiles from player location
« on: October 15, 2011, 04:54:55 am »
I tried that code and it helped centering the projectile to the players center, but the projectiles were all facing/shooting towards -X.
So I added "bullet[n].setRotationPivot(player.getZAxis())" to fix that, but the projectile is still offset depending on the YAxis of the player. (Same as before)

If I point the player towards:
+Y = OK
-Y = OK
+Z = OK
-Z = OK
+X = The projectiles are slightly offset to the left of the object
-X = The projectiles are slightly offset to the right of the object

Current code:
Code: [Select]
bullet[n].clearTranslation();
bullet[n].translate(player.getTransformedCenter()); // getTranslation doesn't work properly
bullet[n].getRotationMatrix().setTo(player.getRotationMatrix());
bullet[n].setRotationPivot(player.getZAxis()); // Added because the projectiles were pointing towards -X
//bullet[n].setRotationPivot(player.getRotationPivot()); // No good. All projectiles point to -Z


I am rotating the player per frame using just rotateAxis which is working well. (not using Object3D.rotateY etc..)

// Horz
player.rotateAxis(player.getYAxis(), (fSenseYaw*0.1f)*fDiv);
// Vert
player.rotateAxis(player.getXAxis(), (fSensePitch*0.1f)*fDiv);


I am moving the projectile per frame using:
// Move in its direction
SimpleVector sv = bullet[n].getRotationPivot(); //sv = bullet[n].getZAxis(); (getZ doesnt work properly)
sv.scalarMul(10.0f);
bullet[n].translate(sv);



Thinking the object was off center, I tried correcting it by translating the mesh (Z ways) and then calling translateMesh() but that didn't help. The object itself became way off the camera's center depending on the Rotational Axis.

I also tried replacing the object with a simple cube primitive (loading it with just two lines of code), with no pre translation or rotation:
player = Primitives.getCube(1);
world.addObject(player);
But the projectiles are still offset when point towards -X or +X

I can't figure out why that is happening. I guess I could correct it on the fly by translating Z depending on the XAxis.x value, but I would like to avoid that kind of correction if possible.

188
Support / Aligning bullets/projectiles from player location
« on: October 14, 2011, 06:52:42 pm »
Is there an 'official' way of aligning/rotating projectiles shot from a 3D Object?

I've managed to whip up the following code:

Code: [Select]
SimpleVector sv = new SimpleVector();
sv = player.getZAxis();
bullet[n].clearTranslation();
bullet[n].clearRotation();
bullet[n].setRotationPivot(sv);
bullet[n].align(player);
sv = player.getTranslation();
sv.y += 6f; // Adjust offset
sv.x -= 2f; // Adjust offset
bullet[n].translate(sv);

Which works ok but the bullet is shot with a slight translation offset depending on the axis of the player.
I realize that sv.y+=6f and sv.x-=2f; is probably the cause, but I was wandering if there is a concrete solution for projecting projectiles from a 3D object.

189
Support / Re: checkForCollisionEllipsoid() framerate drop
« on: October 10, 2011, 08:56:40 am »
Installed the Beta and it made a huge improvement!

The Ellipsoid function barely causes a framerate drop now (if at all), plus overall rendering performance has more than doubled. I even tried placing 128 objects in the scene and the frame rate is surprisingly maxing out at 60FPS most of the time.

That's the performance I was looking for, thanks :)

190
Support / Re: checkForCollisionEllipsoid() framerate drop
« on: October 10, 2011, 01:29:11 am »
Yes 90% of the objects are cloned using Object3D.cloneObject() after loading the original ones from 3DS files.

I will try that beta version later today, thanks.


Edit: I'd like to add that the framedrop seems to happen mostly at the (0,0,0) world location so perhaps the bounding boxes of cloned objects are not being translated or updated.

191
Support / Re: Scale around a center point?
« on: October 09, 2011, 04:05:10 pm »
One option would be to move the camera to the location of the initial pinch, or translate/move the object at every frame aligned in ratio to the pinch origin.

Or if you want the object pre-translated, you can load the object, translate it into position, then call rotateMesh to update the meshes translation. Not 100% sure if that would work but I imagine it would.


192
Support / Re: checkForCollisionEllipsoid() framerate drop
« on: October 09, 2011, 02:52:30 pm »
I'm using the latest version (1.23) on a 1GHz Tegra 2 Tablet.

The frame drop happens on a DesireHD as well. With 20 objects in range (only 2 close by), I get these framerates:

23FPS No collision
20FPS Sphere
15FPS Ellipsoid

193
Support / Re: Calculate rotation angle from movement (translation)
« on: October 09, 2011, 02:42:24 pm »
Hmm I guess I could place the Move variables into a simpleVector then scaleMul it to generate a destination. I'll use that technique if I need Y movement :)

194
Support / Re: Calculate rotation angle from movement (translation)
« on: October 09, 2011, 02:10:10 pm »
The problem is that the destination vector is unknown since the object is moved on the fly or by random.

I created an algorithm myself which works fine, I was hoping there was a pre-existing function to do the math.


Here's the code if anyone needs it for something.
Code: [Select]
float fCombined = 0;
if(xMove  < 0) fCombined = -xMove;
else           fCombined =  xMove;
if(zMove  < 0) fCombined += -zMove;
else           fCombined +=  zMove;


float fAngle = fPI;
if(zMove > 0) fAngle = fPIhalf*3;
else          fAngle = fPIhalf*1;


if(zMove > 0) // 270
{
if(xMove > 0) fAngle += (xMove/fCombined) * fPI/2;
else          fAngle -= (-xMove/fCombined) * fPI/2;
}
else // 90
{
if(xMove > 0) fAngle -= (xMove/fCombined) * fPI/2;
else          fAngle += (-xMove/fCombined) * fPI/2;

}

                                myobject.clearRotation();
                                myobject.RotateY(fAngle)


195
Support / Calculate rotation angle from movement (translation)
« on: October 09, 2011, 10:58:07 am »
I'm trying to rotate an object so it's facing the way it's moving.

Is there a function in jPCT or Java that can calculate the rotation angle based on an object's translation movement?


If the object is travelling up Z using translation(0,0,2), the angle would be 270 degrees.
If the object is travelling down Z  using translation(0,0,-2), the angle would be 90 degrees (or PI/2).
If the object is travelling up X  using translation(2,0,0), the angle would be 0 degrees.
If the object is travelling down X  using translation(-2,0,0), the angle would be 180 degrees (or PI).
If the object is travelling down X and up Z using translation(-2,0,2), the angle would be 225 (270-180).

Pages: 1 ... 11 12 [13] 14 15 16