Jump to content


meshes as in the dxviewer


  • You cannot reply to this topic
2 replies to this topic

#1 kopi_b

    New Member

  • Members
  • Pip
  • 3 posts

Posted 16 March 2006 - 08:36 AM

hi!

i've a problem with my meshes
in dxviewer it looks nearly how it should be:
Posted Image

but in my program the shading isn't like in the dxviewer (e.g. the lots are missing):
Posted Image

here are my parameters and my renderstates:

parameters.Windowed = true;

parameters.SwapEffect = SwapEffect.Discard;

parameters.EnableAutoDepthStencil = true;

parameters.AutoDepthStencilFormat = DepthFormat.D16;


dev = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, parameters);

dev.RenderState.ZBufferEnable = true;

dev.RenderState.Lighting = true;

dev.RenderState.CullMode = Cull.None;

dev.RenderState.Ambient = System.Drawing.Color.White;

dev.RenderState.SourceBlend = Blend.SourceAlpha;

dev.RenderState.DestinationBlend = Blend.InvSourceAlpha;

dev.RenderState.ZBufferWriteEnable = true;

dev.RenderState.AlphaBlendEnable = false;

dev.Lights[0].Type = LightType.Directional;

dev.Lights[0].Diffuse = System.Drawing.Color.White;

dev.Lights[0].Direction = new Vector3(-2.0f, -2.0f, -2.0f);

dev.Lights[0].Enabled = true;

dev.Lights[1].Type = LightType.Directional;

dev.Lights[1].Diffuse = System.Drawing.Color.White;

dev.Lights[1].Direction = new Vector3(2.0f, 2.0f, 2.0f);

dev.Lights[1].Enabled = true;

dev.RenderState.Ambient = System.Drawing.Color.FromArgb(0x202020);


loading of the mesh:
mesh = Mesh.FromFile(filename, MeshFlags.SystemMemory, dev, out materials);

meshMaterials = new Material[materials.Length];

for (int i = 0; i < materials.Length; i++)

{

meshMaterials[i] = materials[i].Material3D;

meshMaterials[i].Ambient = meshMaterials[i].Diffuse;

}


what do i have to do to view my mesh as in the dxviewer?

kopi_b

#2 geon

    Senior Member

  • Members
  • PipPipPipPip
  • 893 posts

Posted 16 March 2006 - 05:32 PM

Light seems to come from the wrong direction, at exactly 45 degrees against the thing in the front. That would make the shading dissapear. Move the light around a bit.

#3 kopi_b

    New Member

  • Members
  • Pip
  • 3 posts

Posted 16 March 2006 - 06:01 PM

thx!!!
changing the direction of the light makes it much better
it still looks better in the dxviewer but that's not so important

kopi_b





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users