Jump to content

Joh

Members
  • Posts

    474
  • Joined

  • Last visited

Posts posted by Joh

  1. We need to reproduce this on Leadwerks.

     

    propulsion.JPG

     

    We try with particle and it can work for smaller ship, but it absolutely not good for bigger ship (wich a propulsion radius of 50 meters), partcile will drain too many fps for it.

     

    Any technical art advice that could help us will be really appreciate.

  2. mmm well in some way it have to do with UPS (Update per Second) check this:

     

    C: TVec3 CalcBodyVelocity( TBody body, TVec3 &position, flt smoothing=1 )

    Lua: CalcVelocity:TVec3( position, smoothing )

    Calculates the velocity required to make the body reach the specified position in one second, with no damping. This can be used for precise control of body movement.

     

    Also in the example he use Flip (1) and use 60 (flip 1 should fix the UPS to 60)

    SetBodyVelocity(body,t.scale(60.0))

    So i am pretty sure it have something to do with it..

     

    Anyway i'll check your way too.

  3. Well my question is:

    When a new updates come out how could we update the engine?

    I have that SDK 2.3 updater and i did the update from 2.28 to 2.3 (or 2.3.1 don't mind), but now when i try to check the update (re-launch that updater it say password incorrect..

     

    Maybe i wrong something i don't know..

  4. I am sorry but how this could help me?

    If i set the velocity to 50 it will move 50 in one second so exactly 50/UPS()..

    How this appspeed can help me in this way? I'll need to know how much the entity is moving in a loop.

  5. Anyway for who need it more clear here there is the whole code.

    This code need to be converted on Leadwers.

     

    #include <iostream>
    #include <cmath>
    
    typedef double Real;
    
    struct Vector3D {
     Real x, y, z;
     Vector3D(Real x, Real y, Real z) : x(x), y(y), z(z) {
     }
    
    };
    
    std::ostream &operator<<(std::ostream &os, Vector3D const &v) {
     return os << '(' << v.x << ',' << v.y << ',' << v.z << ')';
    }
    
    Vector3D operator+(Vector3D const &v1, Vector3D const &v2) {
     return Vector3D(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z);
    }
    
    Vector3D operator-(Vector3D const &v1, Vector3D const &v2) {
     return Vector3D(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z);
    }
    
    Vector3D operator*(Real s, Vector3D const &v) {
     return Vector3D(s*v.x, s*v.y, s*v.z);
    }
    
    Real dot_product(Vector3D const &v1, Vector3D const &v2) {
     return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
    }
    
    struct Point3D {
     Real x, y, z;
     Point3D(Real x, Real y, Real z) : x(x), y(y), z(z) {
     }
    };
    
    Vector3D operator-(Point3D const &p1, Point3D const &p2) {
     return Vector3D(p1.x-p2.x, p1.y-p2.y, p1.z-p2.z);
    }
    
    Real largest_root_of_second_degree_equation(double a, double b, double c) {
     return (-b+std::sqrt(b*b-4*a*c))/(2*a);
    }
    
    Vector3D shooting_direction(Point3D const &target_position,
    		    Vector3D const &target_velocity,
    		    Point3D const &shooter_position,
    		    Vector3D const &shooter_velocity,
    		    Real bullet_speed) {
     Vector3D P = target_position - shooter_position;
     Vector3D V = target_velocity - shooter_velocity;
    
     Real a = bullet_speed*bullet_speed - dot_product(V,V);
     Real b = -2*dot_product(P,V);
     Real c = -dot_product(P,P);
    
     Real t = largest_root_of_second_degree_equation(a,b,c);
    
     return target_position + t*V;
    }
    
    int main() {
     Point3D target(0,0,4);
     Vector3D target_velocity(3,0,0);
     Point3D O(0,0,0);
     Vector3D my_velocity(0,0,0);
     Real bullet_speed = 5;
    
     std::cout << shooting_direction(target,
    			  target_velocity,
    			  O,
    			  my_velocity,
    			  bullet_speed) << '\n';
    }
    

  6. mmm did i wrote incorrectly? In second post i said i found.

    Anyway in the way you suggest the projectile won't be precise.. Just immagine the target is moving far to you on right.. You'll never hit in that way.

    Anyway i found the solution (second post) should i write solved on title? How?

    Sorry i am pretty new on this forum.

  7. You misunderstood i should predict WHERE to hit.. It's for Ai agent, as projectile is not fast as a gun (you fire, and it will hit few millisecs later) i should predict where the target will be to be able to hit it.

  8. Never mind, found it.

     

    distance_to_origin(P+t*V) = s*t

    dot_product(P+t*V,P+t*V) = s^2*t^2

    dot_product(P,P)+2*dot_product(P,V)*t+dot_product( V,V)*t^2 = s^2*t^2

    dot_product(P,P)+2*dot_product(P,V)*t+(dot_product (V,V)-s^2)*t^2 = 0

  9. Hi,

    i did a prediction algorithm but it's not good enough for me, do you know some good prediction algorithm?

     

    In my project the projectile is slower then a gunshoot, so i need to predict where it will be the target and where i should aim to hit it.

    What i did is predicting good but is not so fast as i expected so did you have any good one?

     

    Thx.

×
×
  • Create New...