3
votes

This one is going to be long:

I am struggling with changing dimensions of *.fbx model in XNA 4.0. Let’s assume that I created a simple primitive cube. It has bounding box which coordinates are easy to extract. Here are some example dimensions which are visible in the picture:

BoudningBox

I have also another model which format is *.fbx. Here comes another picture of sample model:

some model

Picture of both of them for better scale (I changed colors for better visibility):

enter image description here

What I want to achieve is putting that cross thing inside blue bindingBox, so it would look like this:

enter image description here

Please note that i didn't rotate cross! I changed it's dimensions in each of three axises (of course scale of resizing in each axis was different).

As you can see I needed to change size of ‘cross’ so it could fit inside binding box. My question is: Can I operate with dimensions of *.fbx model in XNA freely? I did some research on the internet, and I didn’t find any clues how to change appearance of fbx model after it is loaded or at least if is is possibble.

EDIT

I noticed that i can change scale of models in xna like in this example:enter image description here

and than simply dragging one of those axises (in that particular case the red one, which stands for x-axis) i can change model's scale in one axis.

enter image description here

Now, when I know that I'd like to update my question: Can I get control over my content manager in code?

1

1 Answers

1
votes

The answer may be simpler than getting inside the content manager. The first way I would try to accomplish this is to start out with a cross model whose vertices are baked to make it 1 unit wide, 1 unit high, and 1 unit deep. Then a scaling matrix can be applied to it in code that would scale it to however many units the box is for each axis.

To make your original cross in your figure 2 from my idea, you would apply a scaling matrix like this.

Matrix crossWorld = Matrix.CreateScale(6f, 4f, 9f); //now your 1x1x1 cross will render as a 6x4x9 cross (your figure 2) if you apply this to your `Effect.World` matrix

//then, to fit it into your box:
crossWorld = Matrix.CreateScale(10f, 8f, 6f);//now your 1x1x1 cross will render as a 10x8x6 cross and fit perfectly into your box (your figure 1)