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

Pages: [1]
1
Support / Re: Tank rotations out of control
« on: April 27, 2007, 02:55:38 am »
Thanks. I know i was asking a little too much, but i don't want to offend your programming style. I found a method that i'm about to implemment. It basically makes the terrain predictable and set the locations of the tires in the calculated spots. Yay, its not exact. I don't think any method will be exact. But it will be consistant. Nice talking to ya.

2
Support / Re: Tank rotations out of control
« on: April 24, 2007, 03:26:10 am »
The rotation doesn't change the tire distances (sorry if i wrote that). But when calculating the car's angle,
{Imagine a right triange the horizontal leg is A, the vertical leg is B , and the hyp. is C}
A is set to 16 and B is set to the current difference in height. Since A doesn't represent the width/length of the car the angle desired is not the correct one. The tire of the car will end in a spot short of where the ray intersected the ground. The tire locations might then be on a different heights compare to the predicted ones related to the ground. I would like to find a rotation that will stick at least three of the four tires on the field  (My current method does not work). If this is too difficult I will try to smooth the current method.

I sorry if I am too confusing. :) I am still working on writing my thoughts in an understandable way.

3
Support / Re: Collision modes
« on: April 22, 2007, 08:16:12 pm »
Opps, sorry. My careless mistake. Thanks.

4
Support / Re: Tank rotations out of control
« on: April 22, 2007, 08:15:20 pm »
You understand it correctly. In the car example, the new positions for the wheels are set with so that the horizontal distance is always the same by using atan. That causes the length/width of the car to change slightly when placed. I used asin to keep the distance from the center to the ends of the tire the same, but by keeping the distances the same, rotating and translating doesn't put them where they were calculated to be. Depending on the angle the ends do not reach the rays intersection.
 _____________________________________
 |                        |                               |
 |                       /| (Intersction)             |
 |                      / |                               |
 |                     /  |                               |
 |                    /   |                               |
 |                   /    |                               |
 |                  /     |                               |
 |                 /      |                               |
 |                /       |                               |
 |    (Does   /         |                              |
 |      not              |                              |
 |      reach)          |                              |
 |                         |                              |
 |   (Intersection     |                              |
---- with field)
(Hopefully you get the idea) ;)


The inaccuracy causes it to wobble.
(How do you insert an image? I trying to show you an image but when I insert it and try to preview the reply, the location of my image adds "http://" to the front.)

5
Support / Collision modes
« on: April 22, 2007, 01:50:44 am »
Hello. I can get my collision checks to work when the source object mode is only ...SELF and the target is only ...OTHER. Why can't setting the mode to (...SELF&...OTHER) for the objects work?

6
Support / Re: Tank rotations out of control
« on: April 22, 2007, 01:10:43 am »
I figured out the problem with my method. Once it calculates the angle to rotate the tank and then moves downward based on the center, the newly made angles will not be correct, depending on the ground below they usually are close to correct. This inacurracy becomes more accurate if the tank stays still and the place method is called repeatingly. I know of no way to improve my current method to make it accurate since i would have to select specific points on the field. Does anyone know of an accuracte method?

7
Support / Re: Tank rotations out of control
« on: April 10, 2007, 02:15:18 am »
I found another problem with my code. After finding the angles, I move the tank directly down instead of in the direction the base of the tank was facing, so I fixed that. Now the tank moves better over the map, but it wobbles at times when it is not supposed to and on a flat surface in certain positions the tank rotates again out of control and gets stuck with its face in the ground.

Here's the improved code
maxVertDis is the max ascention the tank may take
Code: [Select]
public boolean place(Object3D ground) {
//get bottom direction
Object3D o = new Object3D(3);
o.addTriangle(getFrontTireRight().getTransformedCenter(),
getBackTireLeft().getTransformedCenter(),
getFrontTireLeft().getTransformedCenter());
o.calcNormals();
SimpleVector v = o.getPolygonManager().getTransformedNormal(0);
v = v.normalize();
float dis = 300f;
boolean good = false;
Object3D body = getBody();
//move up based on tank pos for ascension
body.translate(v.x*-maxVertDis,v.y*-maxVertDis,v.z*-maxVertDis);
float disFrontLeftBottom  = getTireLeft().rayIntersectsAABB(
getFrontTireLeft().getTransformedCenter(),v,true);
float disFrontRightBottom = getTireRight().rayIntersectsAABB(
getFrontTireRight().getTransformedCenter(),v,true);
float disBackLeftBottom   = getTireLeft().rayIntersectsAABB(
getBackTireLeft().getTransformedCenter(),v,true);
float disBackRightBottom  = getTireRight().rayIntersectsAABB(
getBackTireRight().getTransformedCenter(),v,true);
float disCenterBottom     = getTireLeft().rayIntersectsAABB(
getTireInsideLeft().getTransformedCenter(),v,true);
SimpleVector vFrontLeft  = new SimpleVector(
getFrontTireLeft().getTransformedCenter());
SimpleVector vFrontRight = new SimpleVector(
getFrontTireRight().getTransformedCenter());
SimpleVector vBackLeft   = new SimpleVector(
getBackTireLeft().getTransformedCenter());
SimpleVector vBackRight  = new SimpleVector(
getBackTireRight().getTransformedCenter());
SimpleVector vBody       = new SimpleVector(
getBody().getTransformedCenter());
vFrontLeft.add(new SimpleVector(v.x*-disFrontLeftBottom,
v.y*-disFrontLeftBottom,v.z*-disFrontLeftBottom));
vFrontRight.add(new SimpleVector(v.x*-disFrontRightBottom,
v.y*-disFrontRightBottom,v.z*-disFrontRightBottom));
vBackLeft.add(new SimpleVector(v.x*-disBackLeftBottom,
v.y*-disBackLeftBottom,v.z*-disBackLeftBottom));
vBackRight.add(new SimpleVector(v.x*-disBackRightBottom,
v.y*-disBackRightBottom,v.z*-disBackRightBottom));
vBody.add(new SimpleVector(v.x*-disCenterBottom,
v.y*-disCenterBottom,v.z*-disCenterBottom));
float tireFrontLeft  = ground.calcMinDistance(vFrontLeft,v,dis*10);
float tireFrontRight = ground.calcMinDistance(vFrontRight,v,dis*10);
float tireBackLeft   = ground.calcMinDistance(vBackLeft,v,dis*10);
float tireBackRight  = ground.calcMinDistance(vBackRight,v,dis*10);
float bodyDis        = ground.calcMinDistance(vBody,v,dis*10);
if(tireFrontLeft !=Object3D.COLLISION_NONE&&
   tireFrontRight!=Object3D.COLLISION_NONE&&
   tireBackLeft  !=Object3D.COLLISION_NONE&&
   tireBackRight !=Object3D.COLLISION_NONE&&
   bodyDis       !=Object3D.COLLISION_NONE){
good = true;
//Vert Balance, rotation on X
double angleFront=((tireFrontRight+tireFrontLeft)/2-bodyDis);
    double as=(angleFront/(bodyDisToFront))%1;
    angleFront=Math.asin(as);
    double angleRear=-((tireBackRight+tireBackLeft)/2-bodyDis);
        as=(angleRear/(bodyDisToBack))%1;
        angleRear=Math.asin(as);
    float rot=(float) ((angleFront+angleRear)/2);
        body.rotateX(rot);
       
    //Hori Balance, rotation on Z
        double angleLeft=((tireFrontLeft+tireBackLeft)/2-bodyDis);
        as=(angleLeft/(bodyDisToLeft))%1;
        angleLeft=Math.asin(as);
    double angleRight=-((tireBackRight+tireFrontRight)/2-bodyDis);
        as=(angleRight/(bodyDisToRight))%1;
        angleRight=Math.asin(as);
    rot=(float) ((angleLeft+angleRight)/2);
        body.rotateZ(rot);
       
        //move based on new
        body.translate(v.x*bodyDis,v.y*bodyDis,v.z*bodyDis);
        saveToLastLoc();
}else
{
resetToLastLoc();
}

return good;
}

8
Support / Tank rotations out of control
« on: April 08, 2007, 03:33:12 am »
I am working on a simple tank game, move around in tank and shoot stuff. I based my move rotation on the car example (the tilting based on ground), but I am having problems. The tank moves correctly for a while on the hills i made, but it soon rotates out of control and flies upward. Any help?

Code: [Select]
public boolean place(Object3D ground) {
//get bottom direction
Object3D o = new Object3D(3);
o.addTriangle(getFrontTireRight().getTransformedCenter(),
getBackTireLeft().getTransformedCenter(),
getFrontTireLeft().getTransformedCenter());
o.calcNormals();
SimpleVector v = o.getPolygonManager().getTransformedNormal(0);
float dis = 300f;
boolean good = false;
Object3D body = getBody();
//move up in case of vertical ascending
body.translate(0,-150,0);
float disFrontLeftBottom  = getTireLeft().rayIntersectsAABB(
getFrontTireLeft().getTransformedCenter(),v,false);
float disFrontRightBottom = getTireRight().rayIntersectsAABB(
getFrontTireRight().getTransformedCenter(),v,false);
float disBackLeftBottom   = getTireLeft().rayIntersectsAABB(
getBackTireLeft().getTransformedCenter(),v,false);
float disBackRightBottom  = getTireRight().rayIntersectsAABB(
getBackTireRight().getTransformedCenter(),v,false);
float disCenterBottom     = getTireLeft().rayIntersectsAABB(
getTireInsideLeft().getTransformedCenter(),v,false);
SimpleVector vFrontLeft  = new SimpleVector(
getFrontTireLeft().getTransformedCenter());
SimpleVector vFrontRight = new SimpleVector(
getFrontTireRight().getTransformedCenter());
SimpleVector vBackLeft   = new SimpleVector(
getBackTireLeft().getTransformedCenter());
SimpleVector vBackRight  = new SimpleVector(
getBackTireRight().getTransformedCenter());
SimpleVector vBody       = new SimpleVector(
getBody().getTransformedCenter());
vFrontLeft.add(new SimpleVector(0,-disFrontLeftBottom,0));
vFrontRight.add(new SimpleVector(0,-disFrontRightBottom,0));
vBackLeft.add(new SimpleVector(0,-disBackLeftBottom,0));
vBackRight.add(new SimpleVector(0,-disBackRightBottom,0));
vBody.add(new SimpleVector(0,-disCenterBottom,0));
float tireFrontLeft  = ground.calcMinDistance(vFrontLeft,v,dis*10);
float tireFrontRight = ground.calcMinDistance(vFrontRight,v,dis*10);
float tireBackLeft   = ground.calcMinDistance(vBackLeft,v,dis*10);
float tireBackRight  = ground.calcMinDistance(vBackRight,v,dis*10);
float bodyDis        = ground.calcMinDistance(vBody,v,dis*10);
if (tireFrontLeft !=Object3D.COLLISION_NONE&&
tireFrontRight!=Object3D.COLLISION_NONE&&
tireBackLeft  !=Object3D.COLLISION_NONE&&
tireBackRight !=Object3D.COLLISION_NONE) {
good = true;

//Vert Balance, rotation on X
double angleFront=((tireFrontRight+tireFrontLeft)/2-bodyDis);
    double as=(angleFront/(bodyDisToFront))%1;
    angleFront=Math.asin(as);
    double angleRear=-((tireBackRight+tireBackLeft)/2-bodyDis);
        as=(angleRear/(bodyDisToBack))%1;
        angleRear=Math.asin(as);
    float rot=(float) ((angleFront+angleRear)/2);
        body.rotateX(rot);
       
    //Hori Balance, rotation on Z
        double angleLeft=((tireFrontLeft+tireBackLeft)/2-bodyDis);
        as=(angleLeft/(bodyDisToLeft))%1;
        angleLeft=Math.asin(as);
    double angleRight=-((tireBackRight+tireFrontRight)/2-bodyDis);
        as=(angleRight/(bodyDisToRight))%1;
        angleRight=Math.asin(as);
    rot=(float) ((angleLeft+angleRight)/2);
        body.rotateZ(rot);
       
        //move
        body.translate(0,bodyDis,0);
                     return good;
}

Pages: [1]