Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trying to extract a model, getting garbage TriVert values

45 views
Skip to first unread message

R.Wieser

unread,
Dec 8, 2023, 3:06:17 AM12/8/23
to
Hello all,

After having had some fun extracting and displaying a map I thought I'd try
to add some (static) puppets into it. So, I opened the "PAK0.PAK" file and
tried to extract the "models/scientist.mdl" model.

Alas, although I /think/ I did everything right what comes out in regard to
vertices didn't look at all as the "SCI3_Template_Biped1(Headless_Body)"
model it should be.

So, I looked a bit more carefull at data I was extracting, and noticed that
the "TriVert" records looked odd.

Here are the first three. The values are the Vertex index, Normal index,
XTex and YTex in that order. It should be the first triangle of a triangle
strip :

000C 001A 0006 0021
0000 004B 000A 0023
0000 0000 0000 0021

As you can see the last two Vertex indices are the same, meaning that no
visible triangle will be displayed. :-(

This and the garbage result I see (when outputting all triangles) makes me
think that somewhere, somehow I have missed something - or the filetype
documenation I have is not for my version of half-life (afaik the GoldSrc
one) :

https://github.com/malortie/assimp/wiki/MDL:-Half-Life-1-file-format

Does anyone here have an idea what the problem might be ?

Remark:
As far as I can see where the above webpage mentions "index" the actual
usage is the offset from the start of the extracted "models/scientist.mdl"
block.

Regards,
Rudy Wieser


John Smith

unread,
Dec 8, 2023, 5:24:51 PM12/8/23
to
Maybe I'm missing something, but doesn't that document say that "Two or
more triverts can have the same vertindex"?

R.Wieser

unread,
Dec 9, 2023, 2:43:00 AM12/9/23
to
John,

> Maybe I'm missing something, but doesn't that document say that "Two or
> more triverts can have the same vertindex"?

No, you're not missing anything, I read the same.

Just imagine a square made up outof four (differently textured) triangles.
In the middle is one vertex shared by all four triangles, and on each of the
corners is a vertex shared by two triangles.

IOW, its nothing outof the ordinary to have /different/ triangles share
vertices (even in the same triangle strip).

But its quite different when (what should be) a *single* triangle has two or
more vertices that are the same : you end up with a line or even a(n
invisible) dot.

IOW, unless in very specific circumstances (triangle strip, possibly fan,
related) that should never happen.

--- especially not at the start/end of a triangle strip (where they can be
removed without any effect to the created mesh).

Also, I would have expected that the vertex indices for at least the first
triangle strip would be incremental, and not the random(ish) values as they
appear now (random is /possible/, just not likely)

By the way, after having posted I found other triangle trips in that same
model part starting the same way (with two TriVert vertex indices being
Zero).


Any chance that you might have a document describing what the fileformat of
a model should be, but in a bit more detail ? I found another one myself,
but its quite different (and doesn't match the model file data I have)

https://developer.valvesoftware.com/wiki/MDL_(Source_1)

If you want/need more specific data (like each step towards the TriVert
records) I'm happy to supply it ...

Regards,
Rudy Wieser


R.Wieser

unread,
Dec 17, 2023, 11:30:15 AM12/17/23
to
> Hello all,

> After having had some fun extracting and displaying a map I thought I'd
> try to add some (static) puppets into it. So, I opened the "PAK0.PAK"
> file and tried to extract the "models/scientist.mdl" model.
>
> Alas, although I /think/ I did everything right what comes out in regard
> to vertices didn't look at all as the
> "SCI3_Template_Biped1(Headless_Body)" model it should be.
>
> So, I looked a bit more carefull at data I was extracting, and noticed
> that the "TriVert" records looked odd.

Update: After trying to extract a way smaller and simpler model I found that
I misinterpreted part of the below documentation :

https://github.com/malortie/assimp/wiki/MDL:-Half-Life-1-file-format

I assumed that the "N" in the block starting with "// Triangle strip" was
gotten from the "numtris" field in the record described below it. It turns
out it isn't (and I stil have no idea what its there for).

Also, the "triindex" field below *isn't* "The offset of the first trivert".

It actually points to the "N" as described in the block above the record,
and is *followed* by a number of TriVert records. Rinse-and-repeat until an
"N" of Zero is encountered (something not mentioned in the above document).

After that I was able to successfully extract the above small and simple
model, as well as a few others.


Alas, it still won't work for "models/scientist.mdl" model, and only partial
for the "models/skeleton.mdl" I found a bit below it (some parts look
alright, some appear to be garbage).

Does anyone still visiting this newsgroup have any idea what could have
missed or is omitted from the above mentioned document ?

Regards,
Rudy Wieser


0 new messages