Page 1 of 1

Model Compression Info

Posted: Wed Jul 09, 2014 12:50 am
by XZodia
As I understand it, the bounding box values for a model are not floats as they appear in the meta editor.
Can someone explain how to correctly read these values, to get the world extents of the model?

Re: Model Compression Info

Posted: Wed Jul 09, 2014 1:34 am
by Click16
I would love to know more about Halo 2's model raw. I intend to make a model viewer before my departure of Halo modding and programming.

Re: Model Compression Info

Posted: Wed Jul 09, 2014 1:43 am
by JacksonCougar
That particular thing I handle directly in opengl (directx will do something similar) by making a scaling matrix out of the values in the bounding box reflexive, and streaming the values in the model raw directly as normalized shorts. Then just scale the normalized short in the vertex shader.

Code: Select all

Matrix4 extents_matrix = new Matrix4(
                    new Vector4 (definition.X.Length, 0.0f ,0.0f,0.0f),
                    new Vector4 (0.0f, definition.Y.Length ,0.0f,0.0f),
                    new Vector4 (0.0f, 0.0f ,definition.Z.Length,0.0f),
                    new Vector4(0.0f, 0.0f, 0.0f, 1.0f)
                    );
Those definition values are a range, the length member is just that, the length of the range. It occurs to me just looking at this I will have to change that method to actually use the minimum and maximum value accurately but that gets you the 'scaled' perspective model.

Code: Select all

#version 330

layout(location = 0) in vec4 position;
layout(location = 1) in vec4 diffuse_color;

uniform mat4 object_extents;

uniform mat4 object_matrix;
uniform mat4 view_projection_matrix;

smooth out vec4 frag_diffuse_color;


void inflate (inout vec4 value)
{
	value = object_extents * value;
}

void main()
{
	vec4 normalized_position = position;
	inflate(normalized_position);
    gl_Position = object_matrix * view_projection_matrix * normalized_position;
	frag_diffuse_color = diffuse_color;
}
Otherwise just think of 0 values in the raw equal the minimum value of the bounding box meta, and the 1 values equal the maximum value; the range between those just maps linearly.

Re: Model Compression Info

Posted: Wed Jul 09, 2014 1:55 am
by Click16
Oh jackson, what ever happened to your Sunfish project? https://code.google.com/p/halo2x-sunfish/
I planned on reading some of your source code for this :P

Re: Model Compression Info

Posted: Wed Jul 09, 2014 2:16 am
by JacksonCougar
It turned into another project. I'm at a bit of a standstill with it right now...

Re: Model Compression Info

Posted: Wed Jul 09, 2014 6:42 pm
by XZodia
Out of context that explanation doesn't make much sense...

I'm not actually working with model raw =P
There's an array of bounding box / compression info chunks in the sbsp meta which I was trying to make use of, cause I need to work out which AI Squads are in which bsps...

Re: Model Compression Info

Posted: Wed Jul 09, 2014 7:14 pm
by Click16
I probably shouldn't have posted those in your thread, seeing how its not directly related. When I read the title, it made me think of the model raw, so I just put in a comment about it. And when I said "I could read your source code for this" I was referring to Model raw, because I believe that Jackson wrote an XNA Halo 2 model viewer.