Jump to content
  • Advertisement
Sign in to follow this  
Bosduif

Could anyone take a look at this error please

This topic is 4952 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'm simply trying to get a .x file in my device,according to every tutorial I used,I've done everything correctly,yet everytime my program opens it crashes,with an unhandled exception in this line: Mesh = Mesh.FromFile("tiger.x", MeshFlags.SystemMemory, GraphicsDevice, materials) since everything in the code seems correct,it's really frustrating so could someone please take a look at the solution and see if you got any idea what's causing the error? http://users.pandora.be/snaplet/WindowsApplication3.zip this is the solution thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
You've got the mesh file in the same folder as your project binary, right? (yep - its there) The other problem is that you might have a NULL pointer somewhere; does everything work if you comment out that line?

linkified your link [wink]

Share this post


Link to post
Share on other sites
Have you tried not using the SystemMemory flag? I remember reading about it giving problems somewhere (I think).

Share this post


Link to post
Share on other sites
I tried not using the SystemMemory flag,same result
I don't think I have a null pointer somewhere,what line are you refering to?

Share this post


Link to post
Share on other sites
I took out the setcurrentdirectory line and it didnt crash on me.
The problem is you place the x file and the bmp in the bin subdirectory, and then you set the current dir as startuppath + "\..\..\", so it is looking in 2 parent directories from the bin dir.

Share this post


Link to post
Share on other sites
hmm,I see why it crashed now,must have overlooked that
but the problem remains,the program doesn't load the mesh

lenny,could you please try this
get rid of the setcurrentdirectory line and the Me.OnResetDevice(GraphicsDevice, Nothing) line
then it crashes again,giving an error on this line:

For i = 0 To materials.Length - 1

Share this post


Link to post
Share on other sites
But the OnDeviceReset method is where you load the mesh, if you dont call it, then it will crash with a null pointer exception.

Share this post


Link to post
Share on other sites
hmmm I don't get it,then why doesn't it show the mesh?

also,the C# example says this:

device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);
device.DeviceReset += new System.EventHandler(this.OnResetDevice);
this.OnResetDevice(device, null);

so the middle line converted to VB is

GraphicsDevice.DeviceReset += New System.EventHandler(Me.OnResetDevice)

but then I get these errors,could this be the problem for the direct3d window not showing the mesh?

'Public Event DeviceReset(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

'System.EventHandler' is a delegate type. Delegate construction permits only a single AddressOf expression as an argument list. Often an AddressOf expression can be used instead of a delegate construction.

Share this post


Link to post
Share on other sites
ok i got it, you didnt set all the transforms, add this

GraphicsDevice.Transform.World = Matrix.RotationY(Environment.TickCount / 1000.0F)
GraphicsDevice.Transform.View = Matrix.LookAtLH(New Vector3(0.0F, 0.0F, -3.0F), New Vector3(0.0F, 0.0F, 0.0F), New Vector3(0.0F, 1.0F, 0.0F))
GraphicsDevice.Transform.Projection = Matrix.PerspectiveFovLH(0.7F, 1.0F, 1.0F, 100.0F)



You also need to clear the zbuffer, add this clear too


GraphicsDevice.Clear(ClearFlags.ZBuffer, System.Drawing.Color.White, 1.0F, 0)



usually you use one clear and just use ClearFlags.ZBuffer | ClearFlags.Target, but it didnt work for me, ORs must be different in VB, I use C# sorry.

Share this post


Link to post
Share on other sites
oh,my god
thank you so very much
I didn't think the transforms mattered except for the location of the "camera"

in any case,I can't say how grateful I am,thank you so much

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!