Outerra forum
Anteworld - Outerra Game => Modding: Importer, Tools & Utilities => JavaScript development => Topic started by: SteelRat on May 12, 2015, 02:57:32 pm
-
Hi Cameni!
/*
file: hero.js
*/
"use strict";
$include("scripts/config.js");
$include("scripts/functions.js");
function initialize(reload)
{
this.set_character_model("outerra/mercenary/mercenary");
addWeapon(this, "AK_74M");
}
...
/*
file: functions.js
*/
function addWeapon(unit, weapon) {
var cfgWpn = cfgWeapons[weapon];
if (cfgWpn.scope) {
var cfgWpnBase = cfgWeapons[cfgWpn.base];
unit.set_weapon_model(cfgWpnBase.pack); // model is created
var wpn = unit.get_geomob(1);
for (var meshIdx in cfgWpnBase.meshes) {
if (cfgWpn.meshes.indexOf(cfgWpnBase.meshes[meshIdx]) < 0) {
// operations on arrays are correct
try {
wpn.set_mesh_visible(cfgWpnBase.meshes[meshIdx], false); // Error
} catch(e) {
unit.log_err("PTM: set_mesh_visible: " + e);
}
}
}
}
}
ERROR: PTM: set_mesh_visible: TypeError: Cannot call method 'set_mesh_visible' of null
ERROR: PTM: set_mesh_visible: TypeError: Cannot call method 'set_mesh_visible' of null
ERROR: PTM: set_mesh_visible: TypeError: Cannot call method 'set_mesh_visible' of null
...
What am I doing wrong?
And yet, it's correctly?
var wpn = unit.set_weapon_model(cfgWpnBase.pack);
-
Now when i look at the functions.js ... if ya want to hide a mesh, you have to define its id´s -- ( this.illumfp002_id = this.geom.get_mesh_id('002'); ) ... not sure, but id say you just try to hide them based on the meshes names itself, but it probably needs the "_id" (all the meshes ID´s defined) part on the end and then --- ( this.geom.set_mesh_visible_id(this.illumfp002_id, false); ) ...
-
Now when i look at the functions.js ... if ya want to hide a mesh, you have to define its id´s -- ( this.illumfp002_id = this.geom.get_mesh_id('002'); ) ... not sure, but id say you just try to hide them based on the meshes names itself, but it probably needs the "_id" (all the meshes ID´s defined) part on the end and then --- ( this.geom.set_mesh_visible_id(this.illumfp002_id, false); ) ...
Тут проблема другого характера, в созданном объекте "wpn" отсутствует метод "set_mesh_visible()".
-
The problem is solved.
And the result of me not impressed (
The result has killed my idea!
-
The problem is solved.
And the result of me not impressed (
The result has killed my idea!
... why ? ( could you share the files ? )
-
The problem is solved.
And the result of me not impressed (
The result has killed my idea!
... why ? ( could you share the files ? )
One more thing that should be checked, then share.
-
Hi cameni!
var $sketch = this.$query_interface("ot::js::sketch.get");
this.grp = $sketch.create_group();
// These two methods I understand
this.img = $sketch.load_image("ui/basic.imgset/airspeed");
this.img2 = $sketch.load_image2("ui/airspeed.dds");
$sketch.make_group_active(this.grp);
$sketch.attach_to_element(this.geom.get_inst_id(), true);
$sketch.set_xray_mode(true);
this.canvas = $sketch.create_canvas(this.grp, {x:-1,y:1,z:1});
// I do not understand the meaning of having two methods of implementing the same result
$sketch.draw_image(this.img, {x:0,y:0}, {x:60,y:60}, 0xffffffff);
$sketch.draw_image2(this.img2, {x:0,y:0}, {x:60,y:60}, 0xffffffff);
-
// I do not understand the meaning of having two methods of implementing the same result
$sketch.draw_image(this.img, {x:0,y:0}, {x:60,y:60}, 0xffffffff);
$sketch.draw_image2(this.img2, {x:0,y:0}, {x:60,y:60}, 0xffffffff);
Me neither :D
For some reason Angrypig mixed two interface versions into one. Expect it to change soon.
-
I understood :)
thanks
-
Hi cameni!
function update_frame(dt, engine, brake, steering)
{
...
var speed = Math.round(this.speed()*3.6);
var txt = "" + "Speed: " + speed;
this.sketch.make_group_active(this.grp);
this.sketch.draw_text({x:0,y:0}, 0xffffffff, txt);
}
The result on the screen
Speed: (white squares instead of numbers)
Tried so, the result is the same.
var speed = this.speed().toString();
How to?
And the associated question of how to format text?
-
Hi,
the sketch API is not finished yet we are constantly adding new features and modding existing functions. Once we will have it ready we will release documentation for it. Probably in next update...
-
Hi,
the sketch API is not finished yet we are constantly adding new features and modding existing functions. Once we will have it ready we will release documentation for it. Probably in next update...
I can not understand where the catch.
If I passed to this argument
var txt = "" + "Speed 2: " + (1 + 2 + 3 + 4 + 5.6789);
That data is displayed correctly.
-
:facepalm: :)
The correct version
function update_frame(dt, engine, brake, steering)
{
...
if (this.canvas != undefined)
this.sketch.delete_canvas(this.canvas);
this.canvas = this.sketch.create_canvas(this.grp, {x:0,y:2,z:0});
var speed = Math.round(this.speed()*3.6);
var txt = "";
txt += "Speed: " + speed + "\n";
this.sketch.draw_text({x:0,y:0}, 0xffffffff, txt);
}
Dear developers, do not forget about the method
this.sketch.clear_canvas(this.canvas);
-
Hi cameni!
// Ground vehicle
function init_chassis(){
...
this.add_weapon(); // arguments?
}
-
It's a placeholder function, does nothing yet.
-
It's a placeholder function, does nothing yet.
I'm understood, thank you.
-
Hi cameni!
this.geom = this.get_geomob(0);
var bone = this.geom.get_joint("bone_1");
var angle = Math.random()*3.14;
this.geom.rotate_joint_orig(bone, angle, {x:0,y:1,z:0});
var boneAngle = // How get rotate joint "bone"?
-
PS
Will update this page?
http://xtrac.outerraworld.com/wiki/geomob
getOwnPropertyNames: geomob(0)
get_pos,
get_rot,
get_inst_id,
get_pos_offset,
get_scale,
set_scale,
set_pos,
move,
set_rot,
add_rot,
remove_from_scene,
get_obb_offset,
get_obb_hvec,
get_eid,
set_custom_data,
get_custom_data,
get_joint,
get_mesh_id,
set_joint_visible,
reset_joint,
rotate_joint,
rotate_joint_orig,
move_joint,
move_joint_orig,
set_mesh_visible,
set_mesh_visible_id,
get_joint_model_pos,
get_joint_local_pos,
deselect,
load_animation,
set_animate_mode,
animate,
set_skeleton_weight,
get_animation_stack,
set_visible,
set_visible_on_slave,
is_visible,
is_ready,
get_bone_model_tm,
get_bone_local_tm,
get_bone_bind_pose_tm,
get_meshes,
get_lods,
get_collision_meshes,
get_mesh_flags,
attach_to,
get_world_transform,
dump_geom_info,
$query_interface,
$rebind_events,
$ctx
-
Hi cameni!
this.geom = this.get_geomob(0);
var bone = this.geom.get_joint("bone_1");
var angle = Math.random()*3.14;
this.geom.rotate_joint_orig(bone, angle, {x:0,y:1,z:0});
var boneAngle = // How get rotate joint "bone"?
this.geom = this.get_geomob(0);
var bone = this.geom.get_joint("bone_1");
this.geom.rotate_joint_orig(bone, Math.random()*3.14, {x:0,y:1,z:0});
...
var bone_$ret = this.geom.get_bone_local_tm(bone).$ret;
this.log_inf("get_bone_local_tm: $ret: " + JSON.stringify(bone_$ret));
// get_bone_local_tm: $ret: true
var bone_pos = this.geom.get_bone_local_tm(bone).pos;
this.log_inf("get_bone_local_tm: pos: " + JSON.stringify(bone_pos));
// get_bone_local_tm: pos: {"x":0.04446744918823242,"y":0.3633822202682495,"z":1.1257092952728271}
var bone_rot = this.geom.get_bone_local_tm(bone).rot;
this.log_inf("get_bone_local_tm: rot: " + JSON.stringify(bone_rot));
// get_bone_local_tm: rot: {"x":0,"y":0.585388720035553,"z":0,"w":-0.8107527494430542}
PS
RU
Грустно всё это :(
Возвращаемый методом результат статичен, не учитываются внесённые изменения позиции и углов поворота кости.
-
Hi cameni!
var mtm = this.geom.get_bone_model_tm(this.point_gun_l_fire);
var firePos = mtm.pos;
var fireDir = // how to convert mtm.rot -> float3 dir - model-space direction of firing;
this.fire(firePos, fireDir, 800, 0.23, {x:1,y:.8});
-
rot is a quaternion, and if you want the direction of +y axis (the forward axis in model space), then you'd multiply rot * float3(0,1,0), which can be simplified in JS to:
fireDir = {
x: 2 * (rot.x*rot.y - rot.w*rot.z),
y: 1 - 2*(rot.x*rot.x + rot.z*rot.z),
z: 2 * (rot.y*rot.z + rot.w*rot.x)}
-
Thank you!
-
Hi cameni!
this.get_wheel_param();
this.set_wheel_param();
arguments?
-
//@param wheel wheel id
//@param name one of suspension_max, suspension_min, suspension_stiffness, damping_compression, damping_relaxation, slip, slip_lateral_coef
//@return wheel param value
float get_wheel_param( int wheel, stringtoken name ) const;
//@param wheel wheel id, -1 all wheels, -2 first two wheels
//@param name one of suspension_max, suspension_min, suspension_stiffness, damping_compression, damping_relaxation, slip, slip_lateral_coef
//@param value value to set
void set_wheel_param( int wheel, stringtoken name, float value );
-
//@param wheel wheel id
//@param name one of suspension_max, suspension_min, suspension_stiffness, damping_compression, damping_relaxation, slip, slip_lateral_coef
//@return wheel param value
float get_wheel_param( int wheel, stringtoken name ) const;
//@param wheel wheel id, -1 all wheels, -2 first two wheels
//@param name one of suspension_max, suspension_min, suspension_stiffness, damping_compression, damping_relaxation, slip, slip_lateral_coef
//@param value value to set
void set_wheel_param( int wheel, stringtoken name, float value );
Thanks!
RU
Теперь я понял причину не удачи, ход моей мысли был правильный.
Но я запрашивал параметр radius, мне возвращался NULL. Мне стоило опросить другие параметры).
Но такое положение завело меня в тупик, мне нужно управлять параметром radius, что бы решить эту задачу.
https://youtu.be/afP5KML9zD0
PS
I have an idea! How to solve.
-
I saw a problem similar to this when looking at some stuff about Bullet boat physics. It had a suggestion about invisible attachments that had specific weight and gravity parameters to keep an object at a predetermined angle..... (not sure if that helps)
-
I saw a problem similar to this when looking at some stuff about Bullet boat physics. It had a suggestion about invisible attachments that had specific weight and gravity parameters to keep an object at a predetermined angle..... (not sure if that helps)
Like today operates a ground vehicle simulations. That is, the wheel itself should not be a mesh.
-
PS
I have an idea! How to solve.
RU
Моя идея оказалась верной, но принесла с собой другую проблему.
Я понимаю что можно создать дубли сеток колёс, и в зависимости от состояния шасси скрывать одни и показывать другие.
Но по мне такая реализация выглядит как костыли(medical term), и мне совсем не нравятся подобные реализации.
https://youtu.be/IwzrpiBwyj8
-
Hi cameni!
this.geom.attach_to()
arguments?
-
Another geom object and a bone id to attach to.
-
Another geom object and a bone id to attach to.
Thanks!
PS
detach?
PS_2
You can use the method attach_to() to the geometry of the different objects?
https://youtu.be/EdV3Adw6FMc
Last created box disappears.
If you apply
var pos = this.geom.get_pos();
var rot = this.geom.get_rot();
var dist = 6;
var box;
var dirs = [0, 45, 90, 135, 180, 225, 270, 315];
for (var i = 0; i < dirs.length; i++) {
box = $world.create_instance("PytonPago/AmmoBox_Wood_23x152mm_63pc/AmmoBox_Wood_23x152mm_63pc_BZT", relative_pos(pos, rot, dist, dirs[i]), rot, false);
}
box.geom = box.get_geomob(0);
box.geom.attach_to(this.geom, this.TurVal);
-
Hi cameni!
I already broke my forehead!)
Can it is necessary for more than two arguments?
https://youtu.be/2YC8Ca2c_1Q
-
If you send us FBX files for both models I could look into it.
-
If you send us FBX files for both models I could look into it.
These models are created PytonPago, I asked him to send you the source models.
Ural-4320-31_6x6_CHASIS
AmmoBox_Wood_23x152mm_63pc
ZS-23-2
https://onedrive.live.com/redir?resid=BA7B7E2655BF556D!6930&authkey=!ALpuEGhfxsU0JwI&ithint=file%2czip
-
What I have done here is not so! I do not understand!)
https://youtu.be/AZJx-V7EftY
-
If you send us FBX files for both models I could look into it.
... damn, havent seen this topic ... here are the FBXs AngryPig :
https://drive.google.com/file/d/0B3ZscF0ox2AGQVAyQUlFM2tURnc/view?usp=sharing (https://drive.google.com/file/d/0B3ZscF0ox2AGQVAyQUlFM2tURnc/view?usp=sharing)
-
Hi cameni!
this.geom.attach_to()
arguments?
I understood the reason for the failures in the application of this method.
Cause I do not think a lot of strange, but do not judge me).
To object to which the method of attach_to() , has taken the correct position relative to the parent, the slave must be created on the same coordinates as the parent object.
https://youtu.be/bNuPS3CHlwM
-
Hi cameni!
RU
Как я могу сделать проверку, управляет юзер объектом или нет?
Мне это нужно для того, что бы блокировать не востребованную логику в функции "update_frame()".
Translate
How can I do a background check, the user operates the object or not?
I need it in order to block that are not in demand in the logic function "update_frame ()".
-
Hmm probably via get_camera_mode(). 0 is FPS mode, 1/2/3 TPS modes, and without user it should be a higher number.
-
Thanks!
-
Hmm probably via get_camera_mode(). 0 is FPS mode, 1/2/3 TPS modes, and without user it should be a higher number.
PS
It works great. Thanks again.
-
Hi cameni!
What is it?
// this.get_inv_mass()
{
"$ret":0.01666666753590107,
"inv_inertia":{
"col":[
{"x":5795.962890625,"y":1.54741370677948,"z":-54203176},
{"x":1.3173075914382935,"y":0.000012145993423473556,"z":1.284999966621399},
{"x":0,"y":0,"z":0}
]
}
}
-
1/mass and inverse inertia tensor as returned from Bullet physics.
-
1/mass and inverse inertia tensor as returned from Bullet physics.
RU
Со второй частью я ещё не скоро выпью на брудершафт :facepalm: :)
https://en.wikipedia.org/wiki/Tensor
Thanks!
-
Hi cameni!
RU:
После применения к созданному объекту метода "attach_to()", на позиции создания объекта остаётся "Коллизия" этого объекта.
Я не придавал этому значения пока не столкнулся со странным(избирательным) поведением "Коллизии".
На данный момент у меня есть возможность решить эту проблему?
Translate:
After applying to the created object method "attach_to()", the position of the object creation remains a "Сollision" of the object.
I did not attach any importance to this until he encountered a strange(electoral) behavior "Collision".
At the moment, I have the opportunity to solve this problem?
https://youtu.be/-HzmW9UOjqY
PS
I do not understand what's going on! :)
http://forum.outerra.com/index.php?topic=3360.msg39958#msg39958
-
... i just thought ... could you do he same white the collision meshes visible on both the magazine and the gun ? .... its moving like it would insert the magazies collision mesh box underneath the gun fixet to that position, whyle the gun just jumped on it and then slid off of it during fire ....
-
Hi Cameni!
// basic canvas API example
this.cnv = this.$query_interface("ot::js::canvas.create", "main", true);
this.fnt = this.cnv.load_font("ui/default.fnt");
this.cnv.fill_rect(100, 100, 200, 200, 0x80808080);
this.cnv.draw_text(
this.fnt,
100, 100,
200, 200,
0x02 | 0x20,
"Lorem ipsum dolor sit amet, consectetur\n"
+"adipiscing elit. Nam vestibulum enim quis\n"
+"nisi tincidunt rhoncus. In hac habitasse\n"
+"platea dictumst. Vivamus rutrum posuere\n"
+"dui ut scelerisque.",
0xffffffff,
0x00000000); // ERROR: ground_vehicle::update_frame: D:/Program_data/Outerra_data/packages/SteelRat/Test_truck/functions/ptm_fnc.js(149): SyntaxError: Wrong number of arguments
Where is the problem?
-
Some of these functions are from new API or testing stuff which is not accessible in public version yet. This new API is using freetype2 library for fonts
-
Some of these functions are from new API or testing stuff which is not accessible in public version yet. This new API is using freetype2 library for fonts
That is, I can not use it?
-
It will be fully released in one of the major updates.
Скоро будет доступно и вам.
-
Ok. Thanks!
-
Hi Cameni!
I am faced with a situation that does not call it a problem, but!
I create the visual effect of inertia camera in a vehicle.
The code block
/// camera
if (this.get_camera_mode() == 0) {
var seatBone = this.player.points[this.player.seatCam].seatBone;
// lateral inertia
var inertiaY = clamp(
interpolate(velocity.angular.y, -Math.PI, Math.PI, -1, 1) + interpolate(velocity.linear.x, -6, 6, -1, 1),
-1, 1
);
this.geom.rotate_joint_orig(seatBone, -.35 * inertiaY, {x:0, y:1, z:0});
//this.geom.rotate_joint_orig(seatBone, -.35 * inertiaY, {y:1}); // so I also tried
// inertia acceleration and braking
var inertiaX = clamp(
interpolate_table(velocity.linear.y * (-brake || engine), [-4, 0, 4], [-.15, 0, .075]),
-.15, .075
);
this.geom.rotate_joint_orig(seatBone, inertiaX, {x:1, y:0, z:0});
//this.geom.rotate_joint_orig(seatBone, inertiaX, {x:1});
}
Running a block of code "inertia acceleration and braking" cancels the changes made by the "lateral inertia" in the code block.
I understand what you can do X and Y their bones, it seems to me not very profitable.
Maybe it makes sense to slightly change the algorithm of the method?
var valX = expression;
var valY = expression;
var valZ = expression;
this.geom.rotate_joint_orig(bone, {x:valX, y:valY, z:valZ});
Or so.
Change their values only listed axis.
this.geom.rotate_joint_orig(bone, value, {x:1});
-
rotate_joint_orig means "rotate from original position"
rotate_joint means adding on top of the current rotation.
-
rotate_joint_orig means "rotate from original position"
rotate_joint means adding on top of the current rotation.
I understood. Thank you!
-
Hi cameni!
this.geom.get_bone_model_tm_offset(bone_id, arg2);
1) I can not understand that this method returns?
2) What type of argument arg2, and that it determines?
-
A typical Angrypig's undocumented function :)
But the second argument is "offset", so I assume it's an offset in model space.
It returns an object that contains pos and rot members, rot is a quaternion.
-
A typical Angrypig's undocumented function :)
But the second argument is "offset", so I assume it's an offset in model space.
It returns an object that contains pos and rot members, rot is a quaternion.
Ok. Thanks!
-
:facepalm: :)
The correct version
function update_frame(dt, engine, brake, steering)
{
...
if (this.canvas != undefined)
this.sketch.delete_canvas(this.canvas);
this.canvas = this.sketch.create_canvas(this.grp, {x:0,y:2,z:0});
var speed = Math.round(this.speed()*3.6);
var txt = "";
txt += "Speed: " + speed + "\n";
this.sketch.draw_text({x:0,y:0}, 0xffffffff, txt);
}
Dear developers, do not forget about the method
this.sketch.clear_canvas(this.canvas);
Wow!!!
Only today said that added :)
this.sketch.clear_canvas()
Many thanks! :)
-
Hi Cameni!
INFO: get_bone_model_dq:
{
"$ret":true,
"rot":{"x":3.0616174623351647e-17,"y":-5.960463766996327e-8,"z":3.515645981781436e-17,"w":1.0000001192092896},
"dual":{"x":0.050012435764074326,"y":0.6886845231056213,"z":1.227365493774414,"w":4.845940893005718e-8} // <-- What is it?
}
-
http://cs.gmu.edu/~jmlien/teaching/cs451/uploads/Main/dual-quaternion.pdf
-
Thanks!