Outerra forum

Anteworld - Outerra Game => Modding: Importer, Tools & Utilities => JavaScript development => Topic started by: SteelRat on January 16, 2016, 11:26:49 am

Title: Object
Post by: SteelRat on January 16, 2016, 11:26:49 am
Hi cameni!

Code: [Select]
var Randomizer = function (val) {
this.v = val || 100;
};

Randomizer.prototype = {
constructor: Randomizer,
get: function () {return Math.round(Math.random()*this.v);}
};

var rnd_1 = new Randomizer();
var rnd_2 = new Randomizer(10000000);

rnd_1.get();
rnd_2.get();

RU: Каждый новый экземпляр объекта Randomizer содержит ссылку на метод get() в объекте Randomizer, или каждый новый экземпляр объекта Randomizer получает свой экземпляр метода get() ?
Translate: Each new instance of Randomizer contains a link to get() method in the object Randomizer, or each new instance of Randomizer gets a copy of the method get() ?
Title: Float32Array
Post by: SteelRat on June 01, 2016, 02:13:12 pm
Hi cameni!

Code: [Select]
ERROR: vehicle::init_chassis: C:/Users/Eduard/Outerra/packages/SteelRat/Test_deform/Ptm/Three/math/Matrix4.js(16): ReferenceError: Float32Array is not defined

How to create an object Float32Array? If this is possible, or is there an alternative?
Title: Re: Object
Post by: cameni on June 02, 2016, 01:22:38 am
I'm not sure if it was supported in Chromium 27 (the version in OT), but maybe it had a different syntax.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array
Title: Matrix
Post by: SteelRat on June 25, 2016, 11:34:10 am
Hi Cameni!

I'm a little confused).
It will be right?

Transformation Matrix

Code: [Select]
[
/*axle_X*/ 1, 0, 0, 0,
/*axle_Y*/ 0, 1, 0, 0,
/*axle_Z*/ 0, 0, 1, 0,
/*pos*/ 0, 0, 0, 1
]

or

Code: [Select]
[
        /*axle_X*/          /*axle_Y*/         /*axle_Z*/         /*pos*/
        1,                  0,                 0,                 0,
        0,                  1,                 0,                 0,
        0,                  0,                 1,                 0,
        0,                  0,                 0,                 1
]
Title: Re: Object
Post by: cameni on July 08, 2016, 01:25:07 am
Right for what?
Title: Re: Object
Post by: DenisJ on July 08, 2016, 01:28:34 am
I believe he asks which format for transformation matrix is correct. Not sure if this is the exact term though...
Title: Re: Object
Post by: cameni on July 08, 2016, 03:24:25 am
Yes but it's just a javascript array, it would depend on the math library used.
Our temporary vector math lib doesn't have matrices. If you are trying to use three.js then it's a question for them ...
Title: Re: Object
Post by: SteelRat on July 08, 2016, 05:23:34 am
Yes but it's just a javascript array, it would depend on the math library used.
Our temporary vector math lib doesn't have matrices. If you are trying to use three.js then it's a question for them ...

I read books about the matrix. And I realized that in a math and programming applies a different format of the matrix organization. However, different sources I met both options described above with respect to programming. That's me and confused).

RU:
Я почитал литературу про матрицы. И понял что в матиматике и программировании применяется разный формат организации матрицы. Но в разных источниках я встретил оба варианта, описанных выше, применительно к программированию. Именно это меня и запутало).
Title: Re: Object
Post by: SteelRat on July 08, 2016, 05:24:32 am
I believe he asks which format for transformation matrix is correct. Not sure if this is the exact term though...

Thank you! You're right.
Title: Re: Object
Post by: cameni on July 09, 2016, 06:50:11 am
Memory layout is implementation specific. OpenGL uses column-major format (sequence of values go by columns), but math libraries may have a different convention. Row-major is more consistent with how we usually write matrices (by rows), but as I can see, three.js uses column-major as well.
Title: Re: Object
Post by: SteelRat on July 09, 2016, 09:41:00 am
Memory layout is implementation specific. OpenGL uses column-major format (sequence of values go by columns), but math libraries may have a different convention. Row-major is more consistent with how we usually write matrices (by rows), but as I can see, three.js uses column-major as well.

Thank you!

"Three.js" I used as a temporary solution.
Over time, I will write the library. I need more experience.)