Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Niflib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Grant Kim
Niflib
Commits
1377fcb4
Commit
1377fcb4
authored
19 years ago
by
Amorilia
Browse files
Options
Downloads
Patches
Plain Diff
Bone matrix calculation function (Blender helper function) fixed.
parent
786ae3ac
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
go.bat
+1
-0
1 addition, 0 deletions
go.bat
nif_math.cpp
+10
-6
10 additions, 6 deletions
nif_math.cpp
nif_math.h
+1
-1
1 addition, 1 deletion
nif_math.h
niflib.h
+1
-1
1 addition, 1 deletion
niflib.h
with
13 additions
and
8 deletions
go.bat
+
1
−
0
View file @
1377fcb4
rem Windows Niflib Python wrapper compilation script (using the Visual C++ Toolkit & SWIG 1.3.27)
rem Windows Niflib Python wrapper compilation script (using the Visual C++ Toolkit & SWIG 1.3.27)
"\Program Files\swigwin-1.3.27\swig.exe"
-c
++
-python -o
py_wrap
.cpp
pyniflib
.i
"\Program Files\swigwin-1.3.27\swig.exe"
-c
++
-python -o
py_wrap
.cpp
pyniflib
.i
cl
/LD /EHsc /I
"\Program Files\Python24\include"
/I
.
/Fe
"_niflib.dll"
niflib
.cpp
docsys_extract
.cpp
NIF_Blocks
.cpp
NIF_IO
.cpp
nif_math
.cpp
py_wrap
.cpp
"\Program Files\Python24\libs\python24.lib"
cl
/LD /EHsc /I
"\Program Files\Python24\include"
/I
.
/Fe
"_niflib.dll"
niflib
.cpp
docsys_extract
.cpp
NIF_Blocks
.cpp
NIF_IO
.cpp
nif_math
.cpp
py_wrap
.cpp
"\Program Files\Python24\libs\python24.lib"
rem cl /EHsc /I. /Fe"test.exe" test.cpp niflib.cpp docsys_extract.cpp NIF_Blocks.cpp NIF_IO.cpp nif_math.cpp
This diff is collapsed.
Click to expand it.
nif_math.cpp
+
10
−
6
View file @
1377fcb4
...
@@ -342,11 +342,15 @@ Matrix44 RotateMatrix44( Vector3 const & axis, float angle) {
...
@@ -342,11 +342,15 @@ Matrix44 RotateMatrix44( Vector3 const & axis, float angle) {
0.0
f
,
0.0
f
,
0.0
f
,
1.0
f
);
0.0
f
,
0.0
f
,
0.0
f
,
1.0
f
);
}
}
Matrix44
BoneToMatrix44
(
Vector3
const
&
bone_
vec
,
float
roll
)
{
Matrix44
BoneToMatrix44
(
Vector3
const
&
bone_
head
,
Vector3
const
&
bone_tail
,
float
roll
,
float
parent_len
)
{
float
theta
;
float
theta
;
Vector3
bone_vec
;
bone_vec
.
x
=
bone_tail
.
x
-
bone_head
.
x
;
bone_vec
.
y
=
bone_tail
.
y
-
bone_head
.
y
;
bone_vec
.
z
=
bone_tail
.
z
-
bone_head
.
z
;
Matrix44
bMatrix
,
rMatrix
,
result
;
Matrix44
bMatrix
,
rMatrix
,
result
;
Vector3
target
(
1.0
f
,
0.0
f
,
0.0
f
);
Vector3
target
(
1.0
f
,
0.0
f
,
0.0
f
);
// X-aligned
Vector3
nor
=
Normalize
(
bone_vec
);
Vector3
nor
=
Normalize
(
bone_vec
);
Vector3
axis
=
CrossProduct
(
target
,
nor
);
Vector3
axis
=
CrossProduct
(
target
,
nor
);
if
(
DotProduct
(
axis
,
axis
)
>
0.0000000000001
)
{
if
(
DotProduct
(
axis
,
axis
)
>
0.0000000000001
)
{
...
@@ -355,7 +359,7 @@ Matrix44 BoneToMatrix44( Vector3 const & bone_vec, float roll ) {
...
@@ -355,7 +359,7 @@ Matrix44 BoneToMatrix44( Vector3 const & bone_vec, float roll ) {
bMatrix
=
RotateMatrix44
(
axis
,
theta
);
bMatrix
=
RotateMatrix44
(
axis
,
theta
);
}
else
{
}
else
{
float
updown
;
float
updown
;
if
(
DotProduct
(
target
,
nor
)
>
0.0
)
updown
=
1.0
f
;
if
(
DotProduct
(
target
,
nor
)
>
0.0
f
)
updown
=
1.0
f
;
else
updown
=
-
1.0
f
;
else
updown
=
-
1.0
f
;
bMatrix
=
Matrix44
(
bMatrix
=
Matrix44
(
updown
,
0.0
f
,
0.0
f
,
0.0
f
,
updown
,
0.0
f
,
0.0
f
,
0.0
f
,
...
@@ -365,8 +369,8 @@ Matrix44 BoneToMatrix44( Vector3 const & bone_vec, float roll ) {
...
@@ -365,8 +369,8 @@ Matrix44 BoneToMatrix44( Vector3 const & bone_vec, float roll ) {
};
};
rMatrix
=
RotateMatrix44
(
nor
,
roll
);
rMatrix
=
RotateMatrix44
(
nor
,
roll
);
result
=
MultMatrix44
(
bMatrix
,
rMatrix
);
result
=
MultMatrix44
(
bMatrix
,
rMatrix
);
result
[
3
][
0
]
=
bone_
vec
.
x
;
result
[
3
][
0
]
=
bone_
head
.
x
+
parent_len
;
// X-aligned
result
[
3
][
1
]
=
bone_
vec
.
y
;
result
[
3
][
1
]
=
bone_
head
.
y
;
result
[
3
][
2
]
=
bone_
vec
.
z
;
result
[
3
][
2
]
=
bone_
head
.
z
;
return
result
;
return
result
;
}
}
This diff is collapsed.
Click to expand it.
nif_math.h
+
1
−
1
View file @
1377fcb4
...
@@ -62,6 +62,6 @@ Vector3 Normalize(Vector3 const & a);
...
@@ -62,6 +62,6 @@ Vector3 Normalize(Vector3 const & a);
float
DotProduct
(
Vector3
const
&
a
,
Vector3
const
&
b
);
float
DotProduct
(
Vector3
const
&
a
,
Vector3
const
&
b
);
Vector3
CrossProduct
(
Vector3
const
&
a
,
Vector3
const
&
b
);
// = MultVector3
Vector3
CrossProduct
(
Vector3
const
&
a
,
Vector3
const
&
b
);
// = MultVector3
float
Angle
(
Vector3
const
&
a
,
Vector3
const
&
b
);
float
Angle
(
Vector3
const
&
a
,
Vector3
const
&
b
);
Matrix44
BoneToMatrix44
(
Vector3
const
&
bone_
vec
,
float
roll
);
Matrix44
BoneToMatrix44
(
Vector3
const
&
bone_
head
,
Vector3
const
&
bone_tail
,
float
roll
,
float
parent_len
);
#endif
#endif
This diff is collapsed.
Click to expand it.
niflib.h
+
1
−
1
View file @
1377fcb4
...
@@ -426,7 +426,7 @@ struct Matrix44 {
...
@@ -426,7 +426,7 @@ struct Matrix44 {
};
};
// Bone calculation helper function from the nif_math module.
// Bone calculation helper function from the nif_math module.
Matrix44
BoneToMatrix44
(
Vector3
const
&
bone_
vec
,
float
roll
);
Matrix44
BoneToMatrix44
(
Vector3
const
&
bone_
head
,
Vector3
const
&
bone_tail
,
float
roll
,
float
parent_len
);
struct
Color
{
struct
Color
{
float
r
,
g
,
b
,
a
;
float
r
,
g
,
b
,
a
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment