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
6f55a683
Commit
6f55a683
authored
19 years ago
by
Amorilia
Browse files
Options
Downloads
Patches
Plain Diff
added old NIF version detection, skeletonroot fix, and a few GCC compatibility fixes
parent
2c36c4e6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nif_attrs.h
+13
-6
13 additions, 6 deletions
nif_attrs.h
niflib.cpp
+14
-0
14 additions, 0 deletions
niflib.cpp
with
27 additions
and
6 deletions
nif_attrs.h
+
13
−
6
View file @
6f55a683
...
...
@@ -454,10 +454,10 @@ private:
class
CrossRefAttr
:
public
AAttr
{
public:
CrossRefAttr
(
string
const
&
name
,
IBlock
*
owner
,
unsigned
int
first_ver
,
unsigned
int
last_ver
)
:
AAttr
(
name
,
owner
,
first_ver
,
last_ver
),
link
(
NULL
),
tmp_blk_num
(
-
1
)
{}
CrossRefAttr
(
string
const
&
name
,
IBlock
*
owner
,
unsigned
int
first_ver
,
unsigned
int
last_ver
)
:
AAttr
(
name
,
owner
,
first_ver
,
last_ver
),
tmp_blk_num
(
-
1
)
,
link
(
NULL
)
{}
~
CrossRefAttr
()
{
//cout << endl << "~CrossRefAttr()";
//This attribute is dying, so decr
i
ment the link
//This attribute is dying, so decr
e
ment the link
UpdateLink
(
NULL
);
}
AttrType
GetType
()
const
{
...
...
@@ -474,7 +474,7 @@ public:
void
WriteAttr
(
ostream
&
out
,
unsigned
int
version
)
const
{
//cout << endl << "CrossRefAttr::WriteAttr()";
if
(
link
==
NULL
)
{
WriteUInt
(
-
1
,
out
);
WriteUInt
(
0xFFFFFFFF
,
out
);
}
else
{
WriteUInt
(
link
->
GetBlockNum
(),
out
);
}
...
...
@@ -992,7 +992,8 @@ public:
void
ReadAttr
(
istream
&
in
,
unsigned
int
version
)
{
//The only difference is that there is a boolean before this link group
bool
has_links
=
ReadBool
(
in
,
version
);
//bool has_links =
ReadBool
(
in
,
version
);
//if ( has_links || version >= VER_10_2_0_0 ) {
LinkGroupAttr
::
ReadAttr
(
in
,
version
);
...
...
@@ -1613,6 +1614,12 @@ public:
bone_pars
.
push_front
(
par
);
par
=
par
->
GetParent
();
};
// There is something odd going on with some of the DAoC files:
// all bones would refer to the scene root (see Atlantis/figures/fig03/lbody08_hig_m.nif).
// In this case the skeleton root also refers to the scene root; let's cover this case here.
if
(
bone_pars
.
empty
())
return
blk_ref
(
bones
[
0
]);
// Now do the same with the owner.
block
=
_owner
;
par
=
block
->
GetParent
();
...
...
@@ -1622,8 +1629,8 @@ public:
par
=
par
->
GetParent
();
};
// Now find closest common ancestor.
if
(
owner_pars
.
empty
()
||
bone_pars
.
empty
()
)
throw
runtime_error
(
"
Skinning instance has no common parent with the bones it refers to
(invalid NIF file?). Cannot set skeleton root."
);
if
(
owner_pars
.
empty
()
)
throw
runtime_error
(
"
Owner has no parents
(invalid NIF file?). Cannot set skeleton root."
);
blk_ref
skelroot
;
list
<
blk_ref
>::
const_iterator
bone_par_it
=
bone_pars
.
begin
();
list
<
blk_ref
>::
const_iterator
owner_par_it
=
owner_pars
.
begin
();
...
...
This diff is collapsed.
Click to expand it.
niflib.cpp
+
14
−
0
View file @
6f55a683
...
...
@@ -135,6 +135,20 @@ vector<blk_ref> ReadNifList( istream & in ) {
//--Read Header--//
char
header_string
[
256
];
in
.
getline
(
header_string
,
256
);
string
headerstr
(
header_string
);
// make sure this is a NIF file
if
(
(
headerstr
.
substr
(
0
,
22
)
!=
"NetImmerse File Format"
)
&&
(
headerstr
.
substr
(
0
,
20
)
!=
"Gamebryo File Format"
)
)
throw
runtime_error
(
"Not a NIF file."
);
// detect old versions
if
(
(
headerstr
==
"NetImmerse File Format, Version 3.1"
)
||
(
headerstr
==
"NetImmerse File Format, Version 3.03"
)
||
(
headerstr
==
"NetImmerse File Format, Version 3.0"
)
||
(
headerstr
==
"NetImmerse File Format, Version 2.3"
)
)
throw
runtime_error
(
"Unsupported: "
+
headerstr
);
uint
version
=
ReadUInt
(
in
);
//There is an unknown Byte here from version 20.0.0.4 on
...
...
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