Outerra forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Outerra Tech Demo download. Help with graphics driver issues

Pages: [1] 2 3 4

Author Topic: can we create, place or throw custom made objects that have physics in outerra ?  (Read 13615 times)

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755

I was trying to make a throwable object by following the structure of objdef file of the crate. Created a package of a rock and moved it to the outerra program's packages directory 
C:\Program Files (x86)\Outerra\Anteworld\packages\outerra. However I don't know which keys to press to throw the physical object. So I tried if it can be brought to life by placing it in the editor, but all objects even if they have a mass parameter, when placed by the editor do not seem to move in any way in the game..they are just static. Is there any way to place/throw objects made by us that have physics in outerra, besides creating them as vehicles or planes or boats - as this would require to "enter" each object to bring it to life?

« Last Edit: December 02, 2018, 05:23:22 am by fly77 »
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6721
  • No sense of urgency.
    • outerra.com

Hm, this part isn't completed.

All objects (including vehicles) can be placed as static, it depends on the method used to instantiate them. Throwable objects have to be created as dynamic, but I think scenery editor doesn't recognize them as such and creates them as static ones. It should be using a hybrid mode, where they would be dynamic initially but then static in the final scenery, to avoid wasting cpu cycles on them. But we also need to add ability to wake them up on interaction.

The shortcuts create those few dynamic objects as dynamic ones directly. Currently you'd be able to test if your object works as dynamic probably only though alt+c console (or a script from vehicle) like this:
Code: [Select]
var x = $query_interface("ot::js::dynamic_object.create", "outerra/crate/crate", #pos, #rot);
x.extra_impulse({x:0, y:0, z:0}, {y:10}, false);

Can't test right now because my Vega GPU again corrupts the displays whenever I run OT ...
You may not be able to apply extra impulse until the object is ready (first time pkg loading).
« Last Edit: December 03, 2018, 03:49:59 pm by cameni »
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755

Hmm. I tried

Alt+C

$query_interface("ot::dynamic_object.create", "outerra/crate/crate", {x:0,y:0,z:0}, {x:0,y:0,z:0});

but got error: interfacace creator ot::dynamic_object.create not found
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6721
  • No sense of urgency.
    • outerra.com

I forgot js there: "ot::js::dynamic_object.create"
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755

Thanks a lot !  It works !
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755

Trying to get the right shoot direction for a missile object from an aircraft carrier missile launcher using quaternions..not easy as I struggle to understand how to get the proper quaternion for my missile launcher. For the moment without the commented line of code it shoots to the front of the ship horizontally following the heading of the ship. Also the missile flies OK as the impulse is applied in front of the tip and drags it towards its tip. But: I don't know how to modify the quaternion to allow for pitch of the launcher.  As soon as I start trying some quaternion multiplications  as in the commented line of code the shoot direction doesn't follow any more the ship heading and seems to shoot in crazy direction. What I was trying with the code is to implement    Qpitch * Qship * Conjugate(Qpitch) . Is this what is needed ? Also I am not sure if the definition of Qpitch is ok. Thought it could be  Qpitch = {x:1*Math.sin(missile_pitch/2),y:0,z:0,w:Math.cos(missile_pitch/2)} as cannon normally points to the forward direction of ship (y model axis) and rotation for pitch should be around x model axis. Result however is not as expected. Any hint ? Where is/are the error/s ?

Code: [Select]


function Quatmult(q,p){
var r =[];
    r.x = q.x*p.w + q.y*p.z + q.w*p.x - q.z*p.y;
    r.y = q.z*p.x + q.w*p.y + q.y*p.w - q.x*p.z;
    r.z = q.w*p.z + q.z*p.w + q.x*p.y - q.y*p.x;
    r.w = -(q.y*p.y + q.x*p.x + q.z*p.z - q.w*p.w);
    return r;
}

function QuatConjug(quat){
    var Quat = [];
    Quat.x = -quat.x;
    Quat.y = -quat.y;
    Quat.z = -quat.z;
    Quat.w = quat.w;
    return Quat;
}


function toQuatRot(angle,axxis){
    var Quat = [];
    Quat.x = axxis.x*Math.sin(angle/2);
    Quat.y = axxis.y*Math.sin(angle/2);
    Quat.z = axxis.z*Math.sin(angle/2);
    Quat.w = Math.cos(angle/2);
    return Quat;
}


function update_frame(dt, engine, brake, steering, parking){
   
     shipQuat= this.geom.get_rot(); 

    pitchquat = toQuatRot(missile_pitch,{x:1,y:0,z:0});
     
    tempquat = Quatmult (pitchquat,Quatmult(shipQuat,QuatConjug(pitchquat)));  // trying invane to get pitch for missile launch direction
     
     cannonQuat = tempquat;

$throw = this.$query_interface("ot::js::dynamic_object.create", "outerra/missile/missile", ecef,  cannonQuat);
$throw.extra_impulse( {x:0, y:10, z:0}, {x: 0 ,y: 10000, z:0 }, false);

}

« Last Edit: February 06, 2019, 06:27:55 pm by fly77 »
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6721
  • No sense of urgency.
    • outerra.com

Quaternions aren't easy to work with, and one has to realize they just define rotations around a vector. Here it means that quaternion is used to transform from default orientation (y+ forward, z+ up) in ECEF space to the desired one.

Take a look at these functions that compute quaternion from provided fwd & up vectors.

Their JS versions are actually in lib/vectors.js. In theory you could $include("/lib/vector.js") and then do something like ot.vectors.Quaternion ...
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755

Thank you very much cameni for the suggestion. I will try it.
Hmmm i tried   $include("/lib/vector.js")

and got

Error: error opening file C:/Program Files (x86)/Outerra/Anteworld/lib/vector.js
« Last Edit: February 07, 2019, 12:08:45 pm by fly77 »
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6721
  • No sense of urgency.
    • outerra.com

Hm it's possible there was a recently fixed error in $include from vehicle scripts (if the path is ok). For now you could try extracting it into your directory, getting rid of the wrapper js magic ...
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755

you mean using the functions from https://github.com/Outerra/anteworld/blob/c7727033c4f64574baa04e2e03d2b955b2454d1e/include/ot/glm/glm_ext.h#L456
and getting rid of all the  stuff like "inline detail::"  or  "template<..."   so to get a clean javascript code ? is this what you mean by wrapper ? If so how can I achieve this ? unfortunately I am not very fluent in all this. I have the impression that's a bit over my capacities.

By the way also on airplane models js files I get error opening file if i try $include("/lib/vector.js"). The vectors file however is indeed in the path C:/Program Files (x86)/Outerra/Anteworld/lib/
Also trying $include("C:/Program Files (x86)/Outerra/Anteworld/lib/vector.js"); gives same error.

maybe I'll just try to understand the code you mention and reproduce it or some of it by myself. Anyway thanks !
« Last Edit: February 07, 2019, 01:03:40 pm by fly77 »
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755

Hmm.. by fiddling around with code, trying different quaternion multiplication ordering,  apparently I got the missile launcher pitch working now ! What I have done is  performing the simple quaternion multiplication  Qship * Qpitch, that is do the pitch rotation first (I reasoned that as the reference orientation (starting orientation) is the one with the model aligned with its x,y,z axes parallel to the  ECEF x,y,z axes probably the rotation around x for the pitch should be done first and then apply the ship orientation. Also there seems to be no need for the Q*P*conj(Q) formula here. Just multiply two quaternions to get the two rotations combined...  :)
Now it fires at the desired pitch angle while keeping aligned with the ship heading which is what I wanted. By the way also works for azimuth (Quaternion rotation around z). I simply did the multiplications in the order: Qship * Qazimuth*Qpitch. Wow !

The "last" thing that is missing now is  to get a "splash" or an "explosion" when the object falls into water or lands on ground. Would also be used for thrown bomb objects from a plane.  I tried to throw a "vehicle" (that might have a script to trigger a splash or explosion when low above ground ) but it gives an error. For the missile fortunately it seems I can fire a "plasma-thing" in the same direction and with same speed as the thrown object. I also  set "bounce" to 0 and "rolling_friction" to 1 in the physics parameters for the missile object so that hopefully it won't move too far from the impact location. Unfortuntaly it still bounces away quite a lot. Is there another physics parameter I could set to get it "stuck" where it falls ? kind of "stickiness" ?


Code: [Select]

function update_frame(dt, engine, brake, steering, parki
 pitchquat = toQuatRot(missile_pitch,{x:1,y:0,z:0}); 
 shipQuat = this.geom.get_rot(); 
 shipQuat = Quatmult(shipQuat,pitchquat);
}
« Last Edit: February 08, 2019, 11:45:07 am by fly77 »
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755

I found that I can reduce  bouncing my adding a very high value of rolling_friction and using a (spherical?) collision box for the missile , plus setting bounce to very large negative value. Still it bounces but less. A trick to get the missile stuck in the crater seems to be to shoot the plasma-thing ahead of the missile so that he crater is made first and then hoping that the missile flies exactly into the crater. I hope I can get the tuning right.  =|
« Last Edit: February 08, 2019, 05:29:40 pm by fly77 »
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755

I tried the command "launch_tracer" from explosions.h as it seems to allow for another way to drag an object (missile) along a plasma thingy (tracer?) . At least this is what I understand from the documentation on github (" //@param entid object id to be dragged by tracer" ). I tried as follows from a plane (mig29) but while no error occured and I can hear my missile launch sound I could not see any plasma thing nor my missile object nor any visual effect (no light flash) anywhere. I also tried with "outerra/crate/crate" but nothing happens. What is wrong ? Is the command "active"?

Code: [Select]

var $explosions;
var bomb_flag =  0;

function initialize(reload){
...
  this.register_event("air/controls/eject", function(v){ bomb_flag ^= 1; }); 

  $explosions=this.$query_interface("ot::js::explosions.get");
}


function update_frame(dt){

if (bomb_flag ==1){

  $explosions.launch_tracer( {x:10, y:20, z:-10}, {x:0, y:300, z:0}, 3, {x:1,y:1, z:0},      0.5, 0.2, 0,    0, "outerra/missile/missile");
   
  this.snd.play(missile_sound_src,missile_sound,false,false); 

  bomb_flag = 0;

  }

}

« Last Edit: February 09, 2019, 04:54:18 pm by fly77 »
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6721
  • No sense of urgency.
    • outerra.com

The parameter has to be an id of existing object (get_eid), not a name.
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755

Still stuck  with the "launch_tracer". I still could not figure out how to get the  id of my missile object .... that I want to shoot from the carrier vehicle..whatever I used for get_eid() I get error "has no method get_eid"...for instance I tried   $throw.get_eid()  or   with obj as defined below    obj.get_eid() but get the same error. I get no error if I do this.geom = this.get_geomob(0)  this.geom.get_eid()     it gives me a number (apparently the   id of the carrier but how to get that of the missile ?)

  world = this.$query_interface("ot::js::world.get");
   obj = world.create_instance("outerra/missile/missile" , pos, rot, false);            creates an apparently static missile
   $throw = this.$query_interface("ot::js::dynamic_object.create", "outerra/missile/missile", ecef2, shipQuat);       OK creates a dynamic missile but don't know how to get_eid()

Another trial that gave no error but still no moving missile was the following:

tracer = this.fire(mdc, {x:plasmaquat.x, y:plasmaquat.y, z:plasmaquat.z}, 100, 30, {x:1,y:1, z:0});
pos = this.geom.get_world_pos_offset(mdc);
bullet = world.create_instance("outerra/missile/missile", pos, shipQuat, false);     
$explosions.launch_tracer( mdc, {x:0, y:1000000, z:0}, 3, {x:1,y:1, z:0},      0.5, 0.2, 0,    0,  tracer , bullet , 0 );

It created the missile at right spot and orientation, gave no error, but the missile is a static one and remains in place. IF i try the same with   $throw.id()  again no error, the missile is dynamic and $throw.id() increases by 1 with each shoot but the missile is not deagged along with the tracer....by the way what is a tracer ?? is it the plasma-thing ?

Also if I try  the following I get no error and even    bullet.id() is a number that changes with every shoot but missile remains static

$explosions.launch_tracer( mdc, {x:0, y:1000000, z:0}, 3, {x:1,y:1, z:0},      0.5, 0.2, 0,    0,  tracer , bullet.id() , 0 );
« Last Edit: February 16, 2019, 05:47:32 pm by fly77 »
Logged
Pages: [1] 2 3 4