Hello!
I am having a .x file that I use to load a Mesh. At run-time, the object is very small. I f run with the file with DirectX Viewer, the size is OK.
I am using this method to load a mesh :
private
void LoadMesh(string filename, ref Mesh mesh, ref Material[] meshmaterials, ref Texture[] meshtextures, ref float meshradius){
ExtendedMaterial[] materialarray;mesh =
Mesh.FromFile(filename, MeshFlags.Managed, device, out materialarray); if ((materialarray != null) && (materialarray.Length > 0)){
meshmaterials =
new Material[materialarray.Length];meshtextures =
new Texture[materialarray.Length]; for (int i = 0; i < materialarray.Length; i++){
meshmaterials[ i] = materialarray[ i].Material3D;
meshmaterials[ i].Ambient = meshmaterials[ i].Diffuse;
if ((materialarray[ i].TextureFilename != null) && (materialarray[ i].TextureFilename != string.Empty)){
meshtextures[ i] =
TextureLoader.FromFile(device, materialarray[ i].TextureFilename);}
}
}
mesh = mesh.Clone(mesh.Options.Value,
CustomVertex.PositionNormalTextured.Format, device);mesh.ComputeNormals();
}
How can I resize the mesh
Thanks!

Enlarge a object from a .x file
The Dwarf
- Tweak your camera parameters so you take a closer look at the object (projection and view matrices).
- Scale up the vertices' positions after loading (lock vertex buffer and loop on all vertices to apply a scale transformation).
- Modify the object-to-world transformation matrix so it scales up your object by a convenient value (don't forget to normalize your normals though).
JamesE
saj14saj
Hello!
I`ve read the note but I`m programming in DirectX for 3 days :) and I don`t know how to normalize the normals. The only 2 things that I`ve changed in my code to enlarge the object are :
device.Transform.World =
Matrix.Scaling(scaling, scaling , scaling) * Matrix.RotationX((float)Math.PI / 2);to
device.Transform.World =
Matrix.Scaling(scaling * 50, scaling * 50, scaling* 50) * Matrix.RotationX((float)Math.PI / 2);and the camera position. That`s all!
Thanks!
DavidThi808
Thanks! That did the trick! :)
Insolence
S Wolfe
Hello!
Thanks for the quick answer. I used the 3rd solution :) and now I can see the object .
Now, I have other problem. When I run the .x file with DirectX Viewer, I can see colors on my object but when I run it with my code, I don`t get the colors... my object is white. Why is that
Thanks!