Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
K
kara3D
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Jules LEMARCHAND
kara3D
Validations
13c9711b
Valider
13c9711b
rédigé
3 years ago
par
ultrakatiz
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
shapes can now render with a camera
parent
2e9209e0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
4
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
4 fichiers modifiés
all.lua
+1
-0
1 ajout, 0 suppression
all.lua
camera.lua
+35
-0
35 ajouts, 0 suppression
camera.lua
shape.lua
+15
-6
15 ajouts, 6 suppressions
shape.lua
transform.lua
+23
-1
23 ajouts, 1 suppression
transform.lua
avec
74 ajouts
et
7 suppressions
all.lua
+
1
−
0
Voir le fichier @
13c9711b
...
...
@@ -3,3 +3,4 @@ require("kara3d.matrix")
require
(
"kara3d.quaternion"
)
require
(
"kara3d.transform"
)
require
(
"kara3d.shape"
)
require
(
"kara3d.camera"
)
Ce diff est replié.
Cliquez pour l'agrandir.
camera.lua
0 → 100644
+
35
−
0
Voir le fichier @
13c9711b
require
(
"kara3d.transform"
)
-- ********** DEFINITION AND GENERIC FUNCTIONS **********
camera
=
{
class
=
"camera"
}
camera
.
__index
=
camera
-- Creates a camera at transform t with aspect ratio a, horizontal fov f,
-- near plane distance nd and far plane distance fd
function
camera
.
new
(
t
,
f
,
nd
,
fd
)
local
c
=
{
transform
=
t
,
fov
=
f
or
80
/
180
*
math.pi
,
near
=
nd
or
1
,
far
=
fd
or
1000000000
}
setmetatable
(
c
,
camera
)
return
c
end
-- Clones this camera
function
camera
:
clone
()
return
camera
.
new
(
self
.
transform
,
self
.
fov
,
self
.
near
,
self
.
far
)
end
-- ********** INSTANCE FUNCTIONS **********
-- Returns this camera's projection * view matrix
function
camera
:
matrix
()
local
s
=
1
/
math.tan
(
self
.
fov
/
2
)
local
n
,
f
=
self
.
near
,
self
.
far
local
xres
,
yres
,
_
,
_
=
aegisub
.
video_size
()
local
m
=
matrix
.
new
(
4
,
4
,
{
s
,
0
,
0
,
0
,
0
,
s
,
0
,
0
,
0
,
0
,
(
n
+
f
)
/
(
n
-
f
),
2
*
n
*
f
/
(
n
-
f
),
0
,
0
,
1
/
xres
,
0
})
return
m
*
self
.
transform
:
inv_matrix
(
true
)
end
Ce diff est replié.
Cliquez pour l'agrandir.
shape.lua
+
15
−
6
Voir le fichier @
13c9711b
...
...
@@ -2,6 +2,7 @@ require("kara3d.vector")
require
(
"kara3d.matrix"
)
require
(
"kara3d.quaternion"
)
require
(
"kara3d.transform"
)
require
(
"kara3d.camera"
)
require
(
"utils"
)
-- ********** DEFINITION AND GENERIC FUNCTIONS **********
...
...
@@ -36,37 +37,45 @@ end
-- Generates a line for each face of this shape, with the indicated tags
-- The boolean cull determines if the faces facing away from the screen are
-- drawn or not
function
shape
:
draw
(
subs
,
line
,
tags
,
cull
)
function
shape
:
draw
(
subs
,
line
,
tags
,
cull
,
cam
)
local
l
=
table
.
copy
(
line
)
local
p
=
self
.
transform
:
position
(
true
)
local
r
=
self
.
transform
:
rotation
(
true
)
local
m
=
self
.
transform
:
matrix
(
true
)
local
c
=
vector
.
cardinal
(
4
,
4
)
local
layer
=
line
.
layer
local
pv
=
cam
and
cam
:
matrix
()
or
matrix
.
identity
(
4
,
4
)
local
cam_inv_rot
=
cam
and
cam
.
transform
:
rotation
(
true
):
inv
()
or
quaternion
.
identity
()
local
xres
,
yres
,
_
,
_
=
aegisub
.
video_size
()
local
m
=
pv
*
self
.
transform
:
matrix
(
true
)
for
i
=
1
,
#
self
.
faces
do
local
face
=
self
.
faces
[
i
]
local
n
=
quaternion
.
mul_vector
(
r
,
face
.
normal
)
n
=
quaternion
.
mul_vector
(
cam_inv_rot
,
n
)
if
not
(
cull
and
n
:
z
()
>
0
)
then
local
vs
=
face
.
vertices
local
v
=
matrix
.
mul_vector
(
m
,
vs
[
#
vs
]
+
c
)
-
p
local
v
=
m
*
(
vs
[
#
vs
]
+
c
)
v
=
(
1
/
v
:
w
())
*
v
local
sum
=
vector
.
zero
(
4
)
local
str
=
(
tags
and
"{"
..
tags
..
"}"
or
""
)
..
(
face
.
tags
and
"{"
..
face
.
tags
..
"}"
or
""
)
..
"{\\an7\\pos("
..
p
:
x
(
)
..
", "
..
p
:
y
(
)
..
")\\p1}"
..
"{\\an7\\pos("
..
(
xres
/
2
)
..
", "
..
(
yres
/
2
)
..
")\\p1}"
..
"m "
..
v
:
x
()
..
" "
..
v
:
y
()
..
" "
for
i
=
1
,
#
vs
do
v
=
m
atrix
.
mul_vector
(
m
,
vs
[
i
]
+
c
)
-
p
v
=
m
*
(
vs
[
i
]
+
c
)
sum
=
sum
+
v
v
=
(
1
/
v
:
w
())
*
v
str
=
str
..
"l "
..
v
:
x
()
..
" "
..
v
:
y
()
..
" "
end
l
.
text
=
str
-- layers must be between 0 and 9999999999
l
.
layer
=
500000000
+
math.floor
(
-
(
p
+
sum
):
z
()
/
#
vs
)
l
.
layer
=
500000000
+
math.floor
((
p
+
sum
):
z
()
/
#
vs
)
l
.
effect
=
"fx"
subs
.
append
(
l
)
end
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
transform.lua
+
23
−
1
Voir le fichier @
13c9711b
...
...
@@ -81,9 +81,31 @@ function transform:matrix(global)
0
,
0
,
0
,
1
})
local
m
=
translation
*
rotation
*
scale
if
(
global
and
self
.
parent
~=
nil
)
then
if
(
global
and
self
.
parent
)
then
m
=
self
.
parent
:
matrix
(
true
)
*
m
end
return
m
end
-- Returns the inverse of the transformation matrix of this transform
function
transform
:
inv_matrix
(
global
)
local
translation
=
matrix
.
new
(
4
,
4
,
{
1
,
0
,
0
,
-
self
.
pos
:
get
(
1
),
0
,
1
,
0
,
-
self
.
pos
:
get
(
2
),
0
,
0
,
1
,
-
self
.
pos
:
get
(
3
),
0
,
0
,
0
,
1
})
local
rotation
=
self
.
rot
:
normalized
():
inv
():
to_matrix
()
local
scale
=
matrix
.
new
(
4
,
4
,
{
1
/
self
.
scl
:
get
(
1
),
0
,
0
,
0
,
0
,
1
/
self
.
scl
:
get
(
2
),
0
,
0
,
0
,
0
,
1
/
self
.
scl
:
get
(
3
),
0
,
0
,
0
,
0
,
1
})
local
m
=
scale
*
rotation
*
translation
if
(
global
and
self
.
parent
)
then
m
=
m
*
self
.
parent
:
inv_matrix
(
true
)
end
return
m
end
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter