• Advertisement
Sign in to follow this  

Problems displaying .x file

This topic is 2774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


I am trying to display in my game a
metallic ball. I am using 3ds max 2011
to create a spherical model with a chrome
material. I use Panda plugin to write
a .x file. When 3ds max renders the sphere it
looks great - very shiny/relective.
When I view the .x file using the directx viewer
it appears as a greyscale sphere.

I coded my app to read .x files.
My app is c++ using microsoft 2008 express.
My app is able to properly display the tiger.x
file supplied with the mesh tutorial. However
when I display my metallic sphere
it appears as a white circle.

Changing in the debugger the material attributes such
as diffuse or ambient does not alter the display of the sphere.

When I edit the .x file (it is saved in text format)
to include a texture in the material description
(otherwise no texture is specified):

TextureFilename {
"cedar.jpg";
}

the texture is properly applied to the sphere in
my app.

Does anybody have any ideas what I am doing incorrectly?
It appears that I have an issue in how the .x file is created.
To render a metallic ball does the .x file need a texture to
be specified?

Share this post


Link to post
Share on other sites
Advertisement
It needs a material. This would need to be saved inside the X file most likely and than you need to tell Direct X to use that material. Otherwise it just assumes that all vertexes and lighting are white, I guess.

Share this post


Link to post
Share on other sites
an excerpt from the .x file:

Material Chrome {
0.803922;0.803922;0.803922;1.000000;;
18.240000;
0.909000;0.909000;0.909000;;
0.000000;0.000000;0.000000;;
}


MeshMaterialList {
1;
960;
0,
.
.
.
{ Chrome }
}

So I do have a material defined.
When this .x file is displayed the sphere is colored gray.
There are no metallic qualities displayed.
Is this because I do not have proper lighting defined in my app?

Share this post


Link to post
Share on other sites
Quote:
Is this because I do not have proper lighting defined in my app?

Probably. The material for Chrome you posted has a specular power and specular color (take a look at the docs for x-file templates: Material).

It's specular highlights that make materials look "shiny."

To render specular color, both the material and the light have to have specular components set, and you have to set the device renderstate D3DRS_SPECULARENABLE set to TRUE (at least during rendering of an object with specular material components). The default value is FALSE.

Obviously, you also have to have lighting enabled.

Material Chrome {
0.803922;0.803922;0.803922;1.000000;; // light gray face color - that's what you're seeing
18.240000; // specular power
0.909000;0.909000;0.909000;; // specular color - whiter than the face color, "highlights"
0.000000;0.000000;0.000000;; // emissive - chrome doesn't "glow," it "shines"
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement