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
1f2498e5
Commit
1f2498e5
authored
19 years ago
by
Amorilia
Browse files
Options
Downloads
Patches
Plain Diff
Extract action names for 2.0.0.0b KFM files.
MergeActions: read NIF file and all KF files (TODO: merge them as well).
parent
2cad2154
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
niflib.cpp
+39
-1
39 additions, 1 deletion
niflib.cpp
niflib.h
+34
-2
34 additions, 2 deletions
niflib.h
with
73 additions
and
3 deletions
niflib.cpp
+
39
−
1
View file @
1f2498e5
...
@@ -1088,6 +1088,20 @@ unsigned int Kfm::Read( istream & in ) {
...
@@ -1088,6 +1088,20 @@ unsigned int Kfm::Read( istream & in ) {
unk_int3
=
ReadUInt
(
in
);
unk_int3
=
ReadUInt
(
in
);
for
(
vector
<
KfmAction
>::
iterator
it
=
actions
.
begin
();
it
!=
actions
.
end
();
it
++
)
it
->
Read
(
in
,
version
);
for
(
vector
<
KfmAction
>::
iterator
it
=
actions
.
begin
();
it
!=
actions
.
end
();
it
++
)
it
->
Read
(
in
,
version
);
};
};
// Retrieve action names
if
(
version
>=
VER_KFM_2_0_0_0b
)
{
string
model_name
=
nif_filename
.
substr
(
0
,
nif_filename
.
length
()
-
4
);
// strip .nif extension
for
(
vector
<
KfmAction
>::
iterator
it
=
actions
.
begin
();
it
!=
actions
.
end
();
it
++
)
{
string
action_name
=
it
->
action_filename
.
substr
(
0
,
it
->
action_filename
.
length
()
-
3
);
// strip .kf extension
if
(
action_name
.
find
(
model_name
+
"_"
)
==
0
)
action_name
=
action_name
.
substr
(
model_name
.
length
()
+
1
,
string
::
npos
);
if
(
action_name
.
find
(
master
+
"_"
)
==
0
)
action_name
=
action_name
.
substr
(
master
.
length
()
+
1
,
string
::
npos
);
it
->
action_name
=
action_name
;
};
};
return
version
;
return
version
;
};
};
...
@@ -1105,4 +1119,28 @@ void Kfm::Write( ostream & out, uint version ) {
...
@@ -1105,4 +1119,28 @@ void Kfm::Write( ostream & out, uint version ) {
else throw runtime_error("Cannot write KFM file of this version.");
else throw runtime_error("Cannot write KFM file of this version.");
};
};
};
};
*/
*/
\ No newline at end of file
blk_ref
Kfm
::
MergeActions
(
string
const
&
path
)
{
// Read NIF file
cout
<<
path
+
'\\'
+
nif_filename
<<
endl
;
blk_ref
nif
=
ReadNifTree
(
path
+
'\\'
+
nif_filename
);
// Read Kf files
vector
<
blk_ref
>
kf
;
for
(
vector
<
KfmAction
>::
iterator
it
=
actions
.
begin
();
it
!=
actions
.
end
();
it
++
)
{
string
action_filename
=
path
+
'\\'
+
it
->
action_filename
;
// Check if the file exists.
// Probably we should check some other field in the Kfm file to determine this...
bool
exists
=
false
;
fstream
fin
;
fin
.
open
(
action_filename
.
c_str
(),
ios
::
in
);
if
(
fin
.
is_open
()
)
exists
=
true
;
fin
.
close
();
// Import it, if it exists.
if
(
exists
)
kf
.
push_back
(
ReadNifTree
(
action_filename
)
);
};
// TODO: merge everything into the nif file
return
nif
;
}
This diff is collapsed.
Click to expand it.
niflib.h
+
34
−
2
View file @
1f2498e5
...
@@ -3409,7 +3409,7 @@ struct Kfm {
...
@@ -3409,7 +3409,7 @@ struct Kfm {
* unsigned int ver = kfm.Read( "test_in.kfm" );
* unsigned int ver = kfm.Read( "test_in.kfm" );
* if ( ver == VER_UNSUPPORTED ) cout << "unsupported" << endl;
* if ( ver == VER_UNSUPPORTED ) cout << "unsupported" << endl;
* else if ( ver == VER_INVALID ) cout << "invalid" << endl;
* else if ( ver == VER_INVALID ) cout << "invalid" << endl;
* else cout << "Describes keyframes for NIF file " << kfm.nif_file
_
name << "." << endl;
* else cout << "Describes keyframes for NIF file " << kfm.nif_filename << "." << endl;
*
*
* \endcode
* \endcode
*
*
...
@@ -3422,11 +3422,43 @@ struct Kfm {
...
@@ -3422,11 +3422,43 @@ struct Kfm {
* elif ( ver == VER_INVALID ):
* elif ( ver == VER_INVALID ):
* print "invalid"
* print "invalid"
* else:
* else:
*
print "Describes keyframes for NIF file %s."%kfm.nif_file
_
name
* print "Describes keyframes for NIF file %s."%kfm.nif_filename
* \endcode
* \endcode
*/
*/
unsigned
int
Read
(
string
const
&
file_name
);
// returns Kfm version
unsigned
int
Read
(
string
const
&
file_name
);
// returns Kfm version
unsigned
int
Read
(
istream
&
in
);
// returns Kfm version
unsigned
int
Read
(
istream
&
in
);
// returns Kfm version
/*!
* Reads the NIF file and all KF files referred to in this KFM, and returns the root block of the resulting NIF tree.
* \param path The file path; usually, this should be the directory where the KFM file was read from.
* \return The root block of the NIF tree.
*
* <b>Example:</b>
* \code
* Kfm kfm;
* unsigned int ver = kfm.Read( "test_in.kfm" );
* if ( ver == VER_UNSUPPORTED ) cout << "unsupported" << endl;
* else if ( ver == VER_INVALID ) cout << "invalid" << endl;
* else {
* blk_ref root = kfm.MergeActions(".");
* cout << root << endl;
* };
*
* \endcode
*
* <b>In Python:</b>
* \code
* kfm = Kfm()
* ver = kfm.Read( "test_in.kfm" )
* if ( ver == VER_UNSUPPORTED ):
* print "unsupported"
* elif ( ver == VER_INVALID ):
* print "invalid"
* else:
* print kfm.MergeActions(".")
* \endcode
*/
blk_ref
Kfm
::
MergeActions
(
string
const
&
path
);
//void Write( string const & file_name, unsigned int version );
//void Write( string const & file_name, unsigned int version );
//void Write( ostream & out, unsigned int version );
//void Write( ostream & out, unsigned int version );
};
};
...
...
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