Anteworld - Outerra Game > Modding: Importer, Tools & Utilities

ray casting tests

<< < (2/2)

fly77:
Thank you. Indeed it works by deleting the group.

fly77:
I managed to attach a gunsight to the abrams gun using sketch API.
Unfortunately I couldn't do it the straigthforward way. First I tried to attach the sketch to the muzzle. I tried as below but the sketch doesn't move with the muzzle, whatever I use as arguments in  this.geometry.get_joint_local_pos or this.geometry.get_joint_model_pos
I also tried to attach a 3D gunsight geometry to the muzzle.
this.geometry.attach_geom( "outerra/gunsight/gunsight",'muzzle', {x:0,y:0.1,z:0}, unitquat);
I indeed can attach it as needed but as I zoom adjusting this.set_fps_camera_fov(fov_cockpit_zoom)
of course the 3D model gets viewed too big (no more hairline but big rods) and obstructs the view. So I discarded also this solution.


--- Code: ---  var muzzle_pos = this.geometry.get_joint_local_pos(this.muzzle_id);
    // var muzzle_pos = this.geometry.get_joint_model_pos('muzzle');
     $sketch.set_position ({x:muzzle_pos.x ,y:muzzle_pos.y+1,  z:muzzle_pos.z});
     $sketch.draw_line({x:muzzle_pos.x,     y:muzzle_pos.y+1,  z:muzzle_pos.z},true);
     $sketch.draw_line({x:muzzle_pos.x+2, y:muzzle_pos.y+1 , z:muzzle_pos.z});
     $sketch.draw_line({x:muzzle_pos.x-2,  y:muzzle_pos.y+1,  z:muzzle_pos.z});
     $sketch.draw_line({x:muzzle_pos.x,     y:muzzle_pos.y+1,  z:muzzle_pos.z},true);
     $sketch.draw_line({x:muzzle_pos.x,     y:muzzle_pos.y+1,  z:muzzle_pos.z+2});
     $sketch.draw_line({x:muzzle_pos.x,     y:muzzle_pos.y+1,  z:muzzle_pos.z-2});
--- End code ---

So a workaround that I found to make it work for the moment is to set the "draw origin" to  sketch.set_position(raytest impact point)
That is draw a scaled gunsight at the impact point so that I am sure to point at the impact point.  Viewed from the tank it looks as if it were part of the tank anyway. Another way is to sketch.set_position(raytest some point along the ray) eventually close to the muzzle.

In the first case I need to set x-ray mode on $sketch.set_xray_mode(true) since the lines will typically intersect with either terrain or objects;
I have noticed that any segment of line inisde an object or terrain is always white and so often hard to see...
(see image)

I managed to change the color of the segment that is "not inside any object or terrain" by
$sketch.set_group_color(0xffff00ff);
or
$sketch.set_color(0xff0000ff)
but the segment that is inside an object or inside terrain (x-ray) is always white.
Is it possible to change this "x-ray color ?" or is it supposed to be white ?

fly77:
hmm..probably easiest way is to use canvas API and set the cross just in the middle of the screen and attach the fps camera to the gun.

Navigation

[0] Message Index

[*] Previous page

Go to full version