rmath3d 1.1.0 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/ChangeLog +26 -0
- data/LICENSE.txt +1 -1
- data/README.md +6 -6
- data/ext/rmath3d/RMath3D.h +3 -3
- data/ext/rmath3d/RMtx2.c +1 -1
- data/ext/rmath3d/RMtx2.h +1 -1
- data/ext/rmath3d/RMtx3.c +1 -1
- data/ext/rmath3d/RMtx3.h +1 -1
- data/ext/rmath3d/RMtx4.c +122 -27
- data/ext/rmath3d/RMtx4.h +14 -6
- data/ext/rmath3d/RQuat.c +1 -1
- data/ext/rmath3d/RQuat.h +1 -1
- data/ext/rmath3d/RType.h +1 -1
- data/ext/rmath3d/RVec2.c +1 -1
- data/ext/rmath3d/RVec2.h +1 -1
- data/ext/rmath3d/RVec3.c +1 -1
- data/ext/rmath3d/RVec3.h +1 -1
- data/ext/rmath3d/RVec4.c +1 -1
- data/ext/rmath3d/RVec4.h +1 -1
- data/ext/rmath3d/rmath3d.c +1179 -1123
- data/lib/rmath3d/rmath3d_plain.rb +270 -139
- data/sample/opengl-bindings/load_matrix.rb +2 -2
- data/sample/opengl2/load_matrix.rb +2 -2
- data/test/test.rb +1 -1
- data/test/test_RMtx4.rb +143 -16
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5dc23938dfb4e458f92a723ca9340b88c8cd9745b2b332c81abf8aef4981e46c
|
4
|
+
data.tar.gz: b23cdf387d8def83bd5310a6666ca83c57b898ee740dee861c804799935d1407
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78dbf7e6ac5f2b5be92247a2ac26100b47df994cd646f25c638e8fc7486f2dbc195a452b88cc28035cc611d87de4778f93ab64a9f94205ff2405005ada383168
|
7
|
+
data.tar.gz: 401b5ab4bb610ea41689276cc96d05bb0c1f4a5b90d579d51781fffb08bde75d8da7140b88a2b8bac8ea223ed64a3cef2f7e1a5d6c667761a096dd6552721eab
|
data/ChangeLog
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
2020-07-23 vaiorabbit <http://twitter.com/vaiorabbit>
|
2
|
+
|
3
|
+
* rmath3d.c, rmath3d_plain.rb (RMtx4): Added lookAtLH, perspectiveLH, etc.
|
4
|
+
|
5
|
+
2020-06-21 vaiorabbit <http://twitter.com/vaiorabbit>
|
6
|
+
|
7
|
+
* rmath3d.c, rmath3d_plain.rb (RMtx4): Added argument 'ndc_homogeneous' for projection matrix APIs.
|
8
|
+
Set true for the environment with Z coordinate ranges from -1 to +1 (OpenGL), and false otherwise (Direct3D, Metal)
|
9
|
+
https://www.slideshare.net/Mark_Kilgard/opengl-32-and-more/26-Direct3D_vs_OpenGL_Coordinate_System
|
10
|
+
https://metashapes.com/blog/opengl-metal-projection-matrix-problem/
|
11
|
+
* rmath3d_plain.rb: Removed Fixnum and Bignum symbols (deprecated and unified into Integer class since Ruby 2.4)
|
12
|
+
|
13
|
+
2017-07-22 vaiorabbit <http://twitter.com/vaiorabbit>
|
14
|
+
|
15
|
+
* Added 'Integer' type for argument type branching (constant ::Fixnum is deprecated since ruby 2.4).
|
16
|
+
|
17
|
+
2015-08-23 vaiorabbit <http://twitter.com/vaiorabbit>
|
18
|
+
|
19
|
+
* rmath3d.c (def ==): Removed control path returning Qnil.
|
20
|
+
* rmath3d_plain.rb (def ==): Removed control path returning Qnil.
|
21
|
+
|
22
|
+
2015-05-02 vaiorabbit <http://twitter.com/vaiorabbit>
|
23
|
+
|
24
|
+
* Ruby 1.9.3 and prior versions are no longer supported. Ref.: https://www.ruby-lang.org/en/news/2015/02/23/support-for-ruby-1-9-3-has-ended/
|
25
|
+
* rmath3d.c: Data_Get_Struct -> TypedData_Get_Struct, etc.
|
26
|
+
|
1
27
|
2015-04-12 vaiorabbit <http://twitter.com/vaiorabbit>
|
2
28
|
|
3
29
|
* RVec2.c|h, RMtx2.c|h: Added.
|
data/LICENSE.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
rmath3d : Ruby math module for 3D Applications
|
2
|
-
Copyright (c) 2008-
|
2
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>
|
3
3
|
|
4
4
|
This software is provided 'as-is', without any express or implied
|
5
5
|
warranty. In no event will the authors be held liable for any damages
|
data/README.md
CHANGED
@@ -4,9 +4,12 @@
|
|
4
4
|
|
5
5
|
rmath3d is a math module for 3D game programming and computer graphics.
|
6
6
|
|
7
|
-
* Last Update:
|
7
|
+
* Last Update: Jul 23, 2020
|
8
8
|
* Since: Jul 20, 2008
|
9
9
|
|
10
|
+
* rmath3d (C Extension Library Implementation) [![Gem Version](https://badge.fury.io/rb/rmath3d.svg)](https://badge.fury.io/rb/rmath3d) [![Gem](https://img.shields.io/gem/dt/rmath3d.svg)](https://rubygems.org/gems/rmath3d)
|
11
|
+
* rmath3d_plain (Pure Ruby Implementation) [![Gem Version](https://badge.fury.io/rb/rmath3d_plain.svg)](https://badge.fury.io/rb/rmath3d_plain) [![Gem](https://img.shields.io/gem/dt/rmath3d_plain.svg)](https://rubygems.org/gems/rmath3d_plain)
|
12
|
+
|
10
13
|
## Features ##
|
11
14
|
|
12
15
|
### Supports frequently-used vector and matrix classes ###
|
@@ -30,11 +33,8 @@ rmath3d is a math module for 3D game programming and computer graphics.
|
|
30
33
|
Notice: This library provides native extension. You must setup develop environment (or DevKit) before installation.
|
31
34
|
|
32
35
|
* Ruby
|
33
|
-
* ruby 2.
|
34
|
-
*
|
35
|
-
* I used: DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe
|
36
|
-
* Unpack the archive -> "> ruby dk.rb init" -> edit config.yml (just add your ruby foldier) -> "> ruby dk.rb install"
|
37
|
-
* Ref.: http://blog.mattwynne.net/2010/10/12/installing-ruby-gems-with-native-extensions-on-windows/
|
36
|
+
* ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x64-mingw32]
|
37
|
+
* Ruby 2.3 and prior versions are no longer supported.
|
38
38
|
|
39
39
|
## Building rmath3d.{so|bundle} ##
|
40
40
|
|
data/ext/rmath3d/RMath3D.h
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#ifndef
|
2
|
-
#define
|
1
|
+
#ifndef RMATH3D_H_INCLUDED
|
2
|
+
#define RMATH3D_H_INCLUDED
|
3
3
|
|
4
4
|
#include "RType.h"
|
5
5
|
#include "RVec2.h"
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
/*
|
16
16
|
RMath : Ruby math module for 3D Applications
|
17
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
17
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>
|
18
18
|
|
19
19
|
This software is provided 'as-is', without any express or implied
|
20
20
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RMtx2.c
CHANGED
@@ -232,7 +232,7 @@ RMtx2Scale( RMtx2* out, const RMtx2* m, rmReal f )
|
|
232
232
|
|
233
233
|
/*
|
234
234
|
RMath : Ruby math module for 3D Applications
|
235
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
235
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>
|
236
236
|
|
237
237
|
This software is provided 'as-is', without any express or implied
|
238
238
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RMtx2.h
CHANGED
@@ -65,7 +65,7 @@ void RMtx2Scale( RMtx2* out, const RMtx2* m, rmReal f );
|
|
65
65
|
|
66
66
|
/*
|
67
67
|
RMath : Ruby math module for 3D Applications
|
68
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
68
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>
|
69
69
|
|
70
70
|
This software is provided 'as-is', without any express or implied
|
71
71
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RMtx3.c
CHANGED
@@ -347,7 +347,7 @@ RMtx3Scale( RMtx3* out, const RMtx3* m, rmReal f )
|
|
347
347
|
|
348
348
|
/*
|
349
349
|
RMath : Ruby math module for 3D Applications
|
350
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
350
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>
|
351
351
|
|
352
352
|
This software is provided 'as-is', without any express or implied
|
353
353
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RMtx3.h
CHANGED
@@ -72,7 +72,7 @@ void RMtx3Scale( RMtx3* out, const RMtx3* m, rmReal f );
|
|
72
72
|
|
73
73
|
/*
|
74
74
|
RMath : Ruby math module for 3D Applications
|
75
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
75
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>
|
76
76
|
|
77
77
|
This software is provided 'as-is', without any express or implied
|
78
78
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RMtx4.c
CHANGED
@@ -436,6 +436,104 @@ RMtx4Scale( RMtx4* out, const RMtx4* m, rmReal f )
|
|
436
436
|
GET_ELEMENT( m, row, col ) * f );
|
437
437
|
}
|
438
438
|
|
439
|
+
/* http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/glu/lookat.html
|
440
|
+
http://msdn.microsoft.com/en-us/library/bb205343.aspx
|
441
|
+
*/
|
442
|
+
void
|
443
|
+
RMtx4LookAtLH( RMtx4* out, const RVec3* eye, const RVec3* at, const RVec3* up )
|
444
|
+
{
|
445
|
+
#define AX(i) RVec3GetElement( &axis_x, i )
|
446
|
+
#define AY(i) RVec3GetElement( &axis_y, i )
|
447
|
+
#define AZ(i) RVec3GetElement( &axis_z, i )
|
448
|
+
|
449
|
+
RVec3 axis_x, axis_y, axis_z;
|
450
|
+
|
451
|
+
RMtx4Identity( out );
|
452
|
+
|
453
|
+
RVec3Sub( &axis_z, at, eye );
|
454
|
+
RVec3Normalize( &axis_z, &axis_z );
|
455
|
+
|
456
|
+
RVec3Cross( &axis_x, up, &axis_z );
|
457
|
+
RVec3Normalize( &axis_x, &axis_x );
|
458
|
+
|
459
|
+
RVec3Cross( &axis_y, &axis_z, &axis_x );
|
460
|
+
|
461
|
+
SET_ELEMENT( out, 0, 0, AX(0) );
|
462
|
+
SET_ELEMENT( out, 0, 1, AX(1) );
|
463
|
+
SET_ELEMENT( out, 0, 2, AX(2) );
|
464
|
+
SET_ELEMENT( out, 0, 3, -RVec3Dot(&axis_x, eye) );
|
465
|
+
|
466
|
+
SET_ELEMENT( out, 1, 0, AY(0) );
|
467
|
+
SET_ELEMENT( out, 1, 1, AY(1) );
|
468
|
+
SET_ELEMENT( out, 1, 2, AY(2) );
|
469
|
+
SET_ELEMENT( out, 1, 3, -RVec3Dot(&axis_y, eye) );
|
470
|
+
|
471
|
+
SET_ELEMENT( out, 2, 0, AZ(0) );
|
472
|
+
SET_ELEMENT( out, 2, 1, AZ(1) );
|
473
|
+
SET_ELEMENT( out, 2, 2, AZ(2) );
|
474
|
+
SET_ELEMENT( out, 2, 3, -RVec3Dot(&axis_z, eye) );
|
475
|
+
|
476
|
+
#undef AX
|
477
|
+
#undef AY
|
478
|
+
#undef AZ
|
479
|
+
}
|
480
|
+
|
481
|
+
void
|
482
|
+
RMtx4PerspectiveLH( RMtx4* out, rmReal width, rmReal height, rmReal znear, rmReal zfar, bool ndc_homogeneous )
|
483
|
+
{
|
484
|
+
RMtx4PerspectiveOffCenterLH( out, -width/2.0f, width/2.0f, -height/2.0f, height/2.0f, znear, zfar, ndc_homogeneous );
|
485
|
+
}
|
486
|
+
|
487
|
+
void
|
488
|
+
RMtx4PerspectiveFovLH( RMtx4* out, rmReal fovy_radian, rmReal aspect, rmReal znear, rmReal zfar, bool ndc_homogeneous )
|
489
|
+
{
|
490
|
+
rmReal top = rmTan(fovy_radian / 2.0f) * znear;
|
491
|
+
rmReal bottom = -top;
|
492
|
+
rmReal right = top * aspect;
|
493
|
+
rmReal left = -right;
|
494
|
+
RMtx4PerspectiveOffCenterLH(out, left, right, bottom, top, znear, zfar, ndc_homogeneous);
|
495
|
+
}
|
496
|
+
|
497
|
+
void
|
498
|
+
RMtx4PerspectiveOffCenterLH( RMtx4* out, rmReal left, rmReal right, rmReal bottom, rmReal top, rmReal znear, rmReal zfar, bool ndc_homogeneous )
|
499
|
+
{
|
500
|
+
rmReal A = (right+left) / (right-left);
|
501
|
+
rmReal B = (top+bottom) / (top-bottom);
|
502
|
+
rmReal C = ndc_homogeneous ? -(zfar+znear) / (zfar-znear) : -zfar / (zfar-znear);
|
503
|
+
rmReal D = ndc_homogeneous ? -(2*znear*zfar) / (zfar-znear) : -(znear*zfar) / (zfar-znear);
|
504
|
+
|
505
|
+
RMtx4Zero( out );
|
506
|
+
SET_ELEMENT( out, 0, 0, 2*znear/(right-left) );
|
507
|
+
SET_ELEMENT( out, 0, 2, -A );
|
508
|
+
SET_ELEMENT( out, 1, 1, 2*znear/(top-bottom) );
|
509
|
+
SET_ELEMENT( out, 1, 2, -B );
|
510
|
+
SET_ELEMENT( out, 2, 2, -C );
|
511
|
+
SET_ELEMENT( out, 2, 3, D );
|
512
|
+
SET_ELEMENT( out, 3, 2, 1.0f );
|
513
|
+
}
|
514
|
+
|
515
|
+
void
|
516
|
+
RMtx4OrthoLH( RMtx4* out, rmReal width, rmReal height, rmReal znear, rmReal zfar, bool ndc_homogeneous )
|
517
|
+
{
|
518
|
+
RMtx4OrthoOffCenterLH( out, -width/2.0f, width/2.0f, -height/2.0f, height/2.0f, znear, zfar, ndc_homogeneous );
|
519
|
+
}
|
520
|
+
|
521
|
+
void
|
522
|
+
RMtx4OrthoOffCenterLH( RMtx4* out, rmReal left, rmReal right, rmReal bottom, rmReal top, rmReal znear, rmReal zfar, bool ndc_homogeneous )
|
523
|
+
{
|
524
|
+
rmReal tx = -(right+left) / (right-left);
|
525
|
+
rmReal ty = -(top+bottom) / (top-bottom);
|
526
|
+
rmReal tz = ndc_homogeneous ? -(zfar+znear) / (zfar-znear) : -znear / (zfar-znear);
|
527
|
+
|
528
|
+
RMtx4Identity( out );
|
529
|
+
SET_ELEMENT( out, 0, 0, 2.0f/(right-left) );
|
530
|
+
SET_ELEMENT( out, 0, 3, tx );
|
531
|
+
SET_ELEMENT( out, 1, 1, 2.0f/(top-bottom) );
|
532
|
+
SET_ELEMENT( out, 1, 3, ty );
|
533
|
+
SET_ELEMENT( out, 2, 2, (ndc_homogeneous ? 2.0f : 1.0f)/(zfar-znear) );
|
534
|
+
SET_ELEMENT( out, 2, 3, tz );
|
535
|
+
}
|
536
|
+
|
439
537
|
/* http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/glu/lookat.html
|
440
538
|
http://msdn.microsoft.com/en-us/library/bb205343.aspx
|
441
539
|
*/
|
@@ -479,37 +577,33 @@ RMtx4LookAtRH( RMtx4* out, const RVec3* eye, const RVec3* at, const RVec3* up )
|
|
479
577
|
}
|
480
578
|
|
481
579
|
void
|
482
|
-
RMtx4PerspectiveRH( RMtx4* out, rmReal width, rmReal height, rmReal znear, rmReal zfar )
|
580
|
+
RMtx4PerspectiveRH( RMtx4* out, rmReal width, rmReal height, rmReal znear, rmReal zfar, bool ndc_homogeneous )
|
483
581
|
{
|
484
|
-
RMtx4PerspectiveOffCenterRH( out, -width/2.0f, width/2.0f, -height/2.0f, height/2.0f, znear, zfar );
|
582
|
+
RMtx4PerspectiveOffCenterRH( out, -width/2.0f, width/2.0f, -height/2.0f, height/2.0f, znear, zfar, ndc_homogeneous );
|
485
583
|
}
|
486
584
|
|
487
|
-
/*
|
585
|
+
/* https://www.scratchapixel.com/lessons/3d-basic-rendering/perspective-and-orthographic-projection-matrix/opengl-perspective-projection-matrix
|
488
586
|
*/
|
489
587
|
void
|
490
|
-
RMtx4PerspectiveFovRH( RMtx4* out, rmReal fovy_radian, rmReal aspect, rmReal znear, rmReal zfar )
|
588
|
+
RMtx4PerspectiveFovRH( RMtx4* out, rmReal fovy_radian, rmReal aspect, rmReal znear, rmReal zfar, bool ndc_homogeneous )
|
491
589
|
{
|
492
|
-
rmReal
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
SET_ELEMENT( out, 1, 1, f );
|
498
|
-
SET_ELEMENT( out, 2, 2, (zfar+znear)/(znear-zfar) );
|
499
|
-
SET_ELEMENT( out, 2, 3, 2*zfar*znear/(znear-zfar) );
|
500
|
-
SET_ELEMENT( out, 3, 2, -1.0f );
|
501
|
-
SET_ELEMENT( out, 3, 3, 0.0f );
|
590
|
+
rmReal top = rmTan(fovy_radian / 2.0f) * znear;
|
591
|
+
rmReal bottom = -top;
|
592
|
+
rmReal right = top * aspect;
|
593
|
+
rmReal left = -right;
|
594
|
+
RMtx4PerspectiveOffCenterRH(out, left, right, bottom, top, znear, zfar, ndc_homogeneous);
|
502
595
|
}
|
503
596
|
|
504
|
-
/*
|
597
|
+
/* https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glFrustum.xml
|
598
|
+
Game Programming in C++ (2018) https://www.oreilly.com/library/view/game-programming-in/9780134598185/
|
505
599
|
*/
|
506
600
|
void
|
507
|
-
RMtx4PerspectiveOffCenterRH( RMtx4* out, rmReal left, rmReal right, rmReal bottom, rmReal top, rmReal znear, rmReal zfar )
|
601
|
+
RMtx4PerspectiveOffCenterRH( RMtx4* out, rmReal left, rmReal right, rmReal bottom, rmReal top, rmReal znear, rmReal zfar, bool ndc_homogeneous )
|
508
602
|
{
|
509
603
|
rmReal A = (right+left) / (right-left);
|
510
604
|
rmReal B = (top+bottom) / (top-bottom);
|
511
|
-
rmReal C = -(zfar+znear) / (zfar-znear);
|
512
|
-
rmReal D = -(2*znear*zfar) / (zfar-znear);
|
605
|
+
rmReal C = ndc_homogeneous ? -(zfar+znear) / (zfar-znear) : -zfar / (zfar-znear);
|
606
|
+
rmReal D = ndc_homogeneous ? -(2*znear*zfar) / (zfar-znear) : -(znear*zfar) / (zfar-znear);
|
513
607
|
|
514
608
|
RMtx4Identity( out );
|
515
609
|
SET_ELEMENT( out, 0, 0, 2*znear/(right-left) );
|
@@ -523,33 +617,34 @@ RMtx4PerspectiveOffCenterRH( RMtx4* out, rmReal left, rmReal right, rmReal botto
|
|
523
617
|
}
|
524
618
|
|
525
619
|
void
|
526
|
-
RMtx4OrthoRH( RMtx4* out, rmReal width, rmReal height, rmReal znear, rmReal zfar )
|
620
|
+
RMtx4OrthoRH( RMtx4* out, rmReal width, rmReal height, rmReal znear, rmReal zfar, bool ndc_homogeneous )
|
527
621
|
{
|
528
|
-
RMtx4OrthoOffCenterRH( out, -width/2.0f, width/2.0f, -height/2.0f, height/2.0f, znear, zfar );
|
622
|
+
RMtx4OrthoOffCenterRH( out, -width/2.0f, width/2.0f, -height/2.0f, height/2.0f, znear, zfar, ndc_homogeneous );
|
529
623
|
}
|
530
624
|
|
531
|
-
/*
|
625
|
+
/* https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glOrtho.xml
|
626
|
+
Game Programming in C++ (2018) https://www.oreilly.com/library/view/game-programming-in/9780134598185/
|
532
627
|
*/
|
533
628
|
void
|
534
|
-
RMtx4OrthoOffCenterRH( RMtx4* out, rmReal left, rmReal right, rmReal bottom, rmReal top, rmReal znear, rmReal zfar )
|
629
|
+
RMtx4OrthoOffCenterRH( RMtx4* out, rmReal left, rmReal right, rmReal bottom, rmReal top, rmReal znear, rmReal zfar, bool ndc_homogeneous )
|
535
630
|
{
|
536
|
-
rmReal tx = (right+left) / (right-left);
|
537
|
-
rmReal ty = (top+bottom) / (top-bottom);
|
538
|
-
rmReal tz = (zfar+znear) / (zfar-znear);
|
631
|
+
rmReal tx = -(right+left) / (right-left);
|
632
|
+
rmReal ty = -(top+bottom) / (top-bottom);
|
633
|
+
rmReal tz = ndc_homogeneous ? -(zfar+znear) / (zfar-znear) : -znear / (zfar-znear);
|
539
634
|
|
540
635
|
RMtx4Identity( out );
|
541
636
|
SET_ELEMENT( out, 0, 0, 2.0f/(right-left) );
|
542
637
|
SET_ELEMENT( out, 0, 3, tx );
|
543
638
|
SET_ELEMENT( out, 1, 1, 2.0f/(top-bottom) );
|
544
639
|
SET_ELEMENT( out, 1, 3, ty );
|
545
|
-
SET_ELEMENT( out, 2, 2, -2.0f/(zfar-znear) );
|
640
|
+
SET_ELEMENT( out, 2, 2, -(ndc_homogeneous ? 2.0f : 1.0f)/(zfar-znear) );
|
546
641
|
SET_ELEMENT( out, 2, 3, tz );
|
547
642
|
}
|
548
643
|
|
549
644
|
|
550
645
|
/*
|
551
646
|
RMath : Ruby math module for 3D Applications
|
552
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
647
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>
|
553
648
|
|
554
649
|
This software is provided 'as-is', without any express or implied
|
555
650
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RMtx4.h
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
#ifndef RMATHMTX4_H_INCLUDED
|
3
3
|
#define RMATHMTX4_H_INCLUDED
|
4
4
|
|
5
|
+
#include <stdbool.h>
|
5
6
|
#include "RType.h"
|
6
7
|
|
7
8
|
struct RVec3;
|
@@ -70,12 +71,19 @@ void RMtx4Sub( RMtx4* out, const RMtx4* m1, const RMtx4* m2 );
|
|
70
71
|
void RMtx4Mul( RMtx4* out, const RMtx4* m1, const RMtx4* m2 );
|
71
72
|
void RMtx4Scale( RMtx4* out, const RMtx4* m, rmReal f );
|
72
73
|
|
74
|
+
void RMtx4LookAtLH( RMtx4* out, const struct RVec3* eye, const struct RVec3* at, const struct RVec3* up );
|
75
|
+
void RMtx4PerspectiveLH( RMtx4* out, rmReal width, rmReal height, rmReal znear, rmReal zfar, bool ndc_homogeneous );
|
76
|
+
void RMtx4PerspectiveFovLH( RMtx4* out, rmReal fovy_radian, rmReal aspect, rmReal znear, rmReal zfar, bool ndc_homogeneous );
|
77
|
+
void RMtx4PerspectiveOffCenterLH( RMtx4* out, rmReal left, rmReal right, rmReal bottom, rmReal top, rmReal znear, rmReal zfar, bool ndc_homogeneous );
|
78
|
+
void RMtx4OrthoLH( RMtx4* out, rmReal width, rmReal height, rmReal znear, rmReal zfar, bool ndc_homogeneous );
|
79
|
+
void RMtx4OrthoOffCenterLH( RMtx4* out, rmReal left, rmReal right, rmReal bottom, rmReal top, rmReal znear, rmReal zfar, bool ndc_homogeneous );
|
80
|
+
|
73
81
|
void RMtx4LookAtRH( RMtx4* out, const struct RVec3* eye, const struct RVec3* at, const struct RVec3* up );
|
74
|
-
void RMtx4PerspectiveRH( RMtx4* out, rmReal width, rmReal height, rmReal znear, rmReal zfar );
|
75
|
-
void RMtx4PerspectiveFovRH( RMtx4* out, rmReal fovy_radian, rmReal aspect, rmReal znear, rmReal zfar );
|
76
|
-
void RMtx4PerspectiveOffCenterRH( RMtx4* out, rmReal left, rmReal right, rmReal bottom, rmReal top, rmReal znear, rmReal zfar );
|
77
|
-
void RMtx4OrthoRH( RMtx4* out, rmReal width, rmReal height, rmReal znear, rmReal zfar );
|
78
|
-
void RMtx4OrthoOffCenterRH( RMtx4* out, rmReal left, rmReal right, rmReal bottom, rmReal top, rmReal znear, rmReal zfar );
|
82
|
+
void RMtx4PerspectiveRH( RMtx4* out, rmReal width, rmReal height, rmReal znear, rmReal zfar, bool ndc_homogeneous );
|
83
|
+
void RMtx4PerspectiveFovRH( RMtx4* out, rmReal fovy_radian, rmReal aspect, rmReal znear, rmReal zfar, bool ndc_homogeneous );
|
84
|
+
void RMtx4PerspectiveOffCenterRH( RMtx4* out, rmReal left, rmReal right, rmReal bottom, rmReal top, rmReal znear, rmReal zfar, bool ndc_homogeneous );
|
85
|
+
void RMtx4OrthoRH( RMtx4* out, rmReal width, rmReal height, rmReal znear, rmReal zfar, bool ndc_homogeneous );
|
86
|
+
void RMtx4OrthoOffCenterRH( RMtx4* out, rmReal left, rmReal right, rmReal bottom, rmReal top, rmReal znear, rmReal zfar, bool ndc_homogeneous );
|
79
87
|
|
80
88
|
#ifdef __cplusplus
|
81
89
|
}
|
@@ -87,7 +95,7 @@ void RMtx4OrthoOffCenterRH( RMtx4* out, rmReal left, rmReal right, rmReal bot
|
|
87
95
|
|
88
96
|
/*
|
89
97
|
RMath : Ruby math module for 3D Applications
|
90
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
98
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>
|
91
99
|
|
92
100
|
This software is provided 'as-is', without any express or implied
|
93
101
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RQuat.c
CHANGED
@@ -344,7 +344,7 @@ RQuatToAxisAngle( const RQuat* in, struct RVec3* axis, rmReal* radian )
|
|
344
344
|
|
345
345
|
/*
|
346
346
|
RMath : Ruby math module for 3D Applications
|
347
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
347
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>
|
348
348
|
|
349
349
|
This software is provided 'as-is', without any express or implied
|
350
350
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RQuat.h
CHANGED
@@ -69,7 +69,7 @@ void RQuatToAxisAngle( const RQuat* in, struct RVec3* axis, rmReal* radian );
|
|
69
69
|
|
70
70
|
/*
|
71
71
|
RMath : Ruby math module for 3D Applications
|
72
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
72
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>
|
73
73
|
|
74
74
|
This software is provided 'as-is', without any express or implied
|
75
75
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RType.h
CHANGED
@@ -53,7 +53,7 @@ typedef double rmReal;
|
|
53
53
|
|
54
54
|
/*
|
55
55
|
RMath : Ruby math module for 3D Applications
|
56
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
56
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>
|
57
57
|
|
58
58
|
This software is provided 'as-is', without any express or implied
|
59
59
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RVec2.c
CHANGED
@@ -144,7 +144,7 @@ RVec2Transform( RVec2* out, const RMtx2* m, const RVec2* in )
|
|
144
144
|
|
145
145
|
/*
|
146
146
|
RMath : Ruby math module for 3D Applications
|
147
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>.
|
147
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>.
|
148
148
|
|
149
149
|
This software is provided 'as-is', without any express or implied
|
150
150
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RVec2.h
CHANGED
@@ -57,7 +57,7 @@ void RVec2Transform( struct RVec2* out, const struct RMtx2* m, const RVec2* i
|
|
57
57
|
|
58
58
|
/*
|
59
59
|
RMath : Ruby math module for 3D Applications
|
60
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
60
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>
|
61
61
|
|
62
62
|
This software is provided 'as-is', without any express or implied
|
63
63
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RVec3.c
CHANGED
@@ -262,7 +262,7 @@ RVec3TransformByQuaternion( RVec3* out, const struct RQuat* q, const RVec3* in )
|
|
262
262
|
|
263
263
|
/*
|
264
264
|
RMath : Ruby math module for 3D Applications
|
265
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>.
|
265
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>.
|
266
266
|
|
267
267
|
This software is provided 'as-is', without any express or implied
|
268
268
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RVec3.h
CHANGED
@@ -66,7 +66,7 @@ void RVec3TransformByQuaternion( RVec3* out, const struct RQuat* q, const RVe
|
|
66
66
|
|
67
67
|
/*
|
68
68
|
RMath : Ruby math module for 3D Applications
|
69
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
69
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>
|
70
70
|
|
71
71
|
This software is provided 'as-is', without any express or implied
|
72
72
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RVec4.c
CHANGED
@@ -192,7 +192,7 @@ RVec4TransformTransposed( RVec4* out, const struct RMtx4* m, const RVec4* in )
|
|
192
192
|
|
193
193
|
/*
|
194
194
|
RMath : Ruby math module for 3D Applications
|
195
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
195
|
+
Copyright (c) 2008-2020 vaiorabbit <http://twitter.com/vaiorabbit>
|
196
196
|
|
197
197
|
This software is provided 'as-is', without any express or implied
|
198
198
|
warranty. In no event will the authors be held liable for any damages
|