Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing 3D Studio Max DirectX shader in XNA problem
    primarykey
    data
    text
    <p><strong>UPDATE 2:</strong> It now appears this is more of a modelling issue than a programming one. Whoops.</p> <p>I'm new to XNA development, and despite my C# experience, I've been stuck at one spot for going on two days now.</p> <p>The situation: I've created a model in 3D Studio Max 2010 which uses two materials, both are of type DirectX Shader. The model exports to FBX without error and Visual Studio compiles it properly. When I ran the Draw() method initially, it threw an exception on the 'BasicEffect' portion of one of my loops, demonstrating (at least to me) that it was loading the .fx file correctly, which must be embedded in the FBX file or something.</p> <p>The problem: When using the following code</p> <pre><code> foreach (ModelMesh mesh in map.Meshes) { foreach (Effect effect in mesh.Effects) { effect.CurrentTechnique = effect.Techniques["DefaultTechnique"]; effect.Begin(); effect.Parameters["World"].SetValue(Matrix.CreateTranslation(Vector3.Zero)); effect.Parameters["View"].SetValue(ActiveCamera.ViewMatrix); effect.Parameters["Projection"].SetValue(ActiveCamera.ProjectionMatrix); effect.Parameters["WorldViewProj"].SetValue(Matrix.Identity * ActiveCamera.ProjectionMatrix); effect.Parameters["WorldView"].SetValue(Matrix.Identity * ActiveCamera.ViewMatrix); foreach (EffectPass ep in effect.CurrentTechnique.Passes) { ep.Begin(); // something goes here? ep.End(); } effect.End(); } mesh.Draw(); } </code></pre> <p>The only thing that happens is a white box appears covering the bottom half of the screen, regardless of camera position or angle. I got the name of the effect parameters of the default.fx file specified in Max (it's at [program files]\autodesk\3ds Max 2010\maps\fx).</p> <p>I get the feeling I'm setting one or all of these incorrectly. I've tried to look up tutorials and follow their code, however none of it seems to work for my model.</p> <p>Any help or ideas?</p> <p><strong>UPDATE:</strong> By making these changes:</p> <pre><code> effect.Parameters["WorldViewProj"].SetValue(Matrix.CreateTranslation(Vector3.Zero) * ActiveCamera.ViewMatrix * Conductor.ActiveCamera.ProjectionMatrix); effect.Parameters["WorldView"].SetValue(Matrix.CreateTranslation(Vector3.Zero) * ActiveCamera.ViewMatrix); </code></pre> <p>The model was able to draw. However, everything is completely white :(</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload