• Advertisement
Sign in to follow this  

my texture dissaper

This topic is 4593 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 would save my mesh file in an arraylist that contain a structure with some dtas and a mesh object. When i try loading a mesh and set it to this struct object and i try to render it works fine, but if i resize the mindow the mesh became all black and textuire disappera. Why?
				Directory.SetCurrentDirectory(Application.StartupPath + @"\");

				device.RenderState.ZBufferEnable = true;
				device.RenderState.Ambient = System.Drawing.Color.White;
		
				ExtendedMaterial[] materials = null;

				Directory.SetCurrentDirectory(Application.StartupPath + @"\");

				XFileObject temp = new XFileObject();
				temp.xMesh = Mesh.FromFile(path, MeshFlags.SystemMemory, device, out materials);
				temp.Name = path.Substring(0, path.Length - 2);

				if(meshTextures == null)
				{
					meshTextures = new Texture[materials.Length];
					meshMaterials = new Direct3D.Material[materials.Length];
					for(int i=0; i<materials.Length; i++)
					{
						meshMaterials = materials.Material3D;
						meshMaterials.Ambient = meshMaterials.Diffuse;
						meshTextures = TextureLoader.FromFile(device, materials.TextureFilename);
					}
				}
				
				x_file_list.Add(temp);

Share this post


Link to post
Share on other sites
Advertisement
ok i've solved.
The problem are these two rows:

device.RenderState.ZBufferEnable = true;
device.RenderState.Ambient = System.Drawing.Color.White;

i had to put in onResetDevice.
Now i would to understand why?
Why these rows are needed?

Share this post


Link to post
Share on other sites
Quote:
Original post by Say
ok i've solved.
The problem are these two rows:

device.RenderState.ZBufferEnable = true;
device.RenderState.Ambient = System.Drawing.Color.White;

i had to put in onResetDevice.
Now i would to understand why?
Why these rows are needed?

When a device reset, its state is lost - that includes render states. They're reset to whatever the default is. Most probably, your textures are appearing black because after the reset "Ambient" was set to black, and you had no active lights, so the mesh came out black.

Share this post


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

  • Advertisement