XNA 4.0. Dynamic resizing model * .fbx

This will be long:

I am struggling with resizing * .fbx model in XNA 4.0. Let's say I created a simple, primitive cube. It has a bounding box whose coordinates are easily retrievable. Here are some approximate dimensions that can be seen in the picture:

BoudningBox

I have another model, which format is * .fbx. Here is another picture of a sample model:

some model

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

enter image description here

What I want to achieve is that it is a crossover thing inside the blue bindBox, so it will look like this:

enter image description here

Please note that I did not rotate the cross! I resized it on each of the three axes (of course, the resize scale on each axis was different).

As you can see, I needed to resize the "cross" to fit inside the box. My question is, can I work with * .fbx model dimensions in XNA freely? I have done some research on the internet and I have not found any hints on how to change the appearance of the fbx model after loading it, or at least if possible.

EDIT

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

and by simply dragging one of those axes (in this particular case, red, which means the x-axis), I can change the scale of the model on one axis .

enter image description here

Now that I know I would like to update my question: Can I take control of my content manager in code ?

+3


source to share


1 answer


The answer may be easier than getting inside the content manager. The first way I would try to do this is to start with a cross model, whose vertices are baked to make it 1 unit wide, 1 height unit and 1 depth unit. Then a scaling matrix can be applied to it in code, which will scale it until the number of units is there for each axis.

To make your original cross in Figure 2 from my idea, you would use 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)

      

+1


source







All Articles