Model Compression Info

Post Reply
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Model Compression Info

Post 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?
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
Click16
Posts: 1941
Joined: Mon Dec 31, 2007 4:36 am
Location: United States

Re: Model Compression Info

Post 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.
Image
User avatar
JacksonCougar
Huurcat
Posts: 2460
Joined: Thu Dec 06, 2007 11:30 pm
Location: Somewhere in Canada

Re: Model Compression Info

Post 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.
User avatar
Click16
Posts: 1941
Joined: Mon Dec 31, 2007 4:36 am
Location: United States

Re: Model Compression Info

Post 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
Image
User avatar
JacksonCougar
Huurcat
Posts: 2460
Joined: Thu Dec 06, 2007 11:30 pm
Location: Somewhere in Canada

Re: Model Compression Info

Post by JacksonCougar »

It turned into another project. I'm at a bit of a standstill with it right now...
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: Model Compression Info

Post 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...
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
Click16
Posts: 1941
Joined: Mon Dec 31, 2007 4:36 am
Location: United States

Re: Model Compression Info

Post 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.
Image
Post Reply