XNA Creators Club Online
Page 1 of 1 (7 items)
Sort Posts: Previous Next

Problem with particle 3D sample

Last post 2008-09-04 09:54 by Rygaar. 6 replies.
  • 2008-01-17 21:02

    Problem with particle 3D sample

    The error I'm getting is in:
    vertexBuffer.SetData(firstNewParticle * stride, particles,
    firstNewParticle,
    firstFreeParticle - firstNewParticle,
    stride, SetDataOptions.NoOverwrite);

    And it says InvalidOperationException. You may not modify a resource that has been set on a device, or after its been using within a tiling bracket.

    The only changes I made was that its no longer a drawable component, now I manually make the calls for initialize, load, update and draw. The other change I made is creating a class with a List of particle systems that takes care of those calls, as far as I can see neither of those should affect this.

    Im pretty lsot as to what the error can be, hopefully someone can help me out.
  • 2008-01-17 21:34 In reply to

    Re: Problem with particle 3D sample

    That error message means pretty much what it says. You cannot to something like:
    • Set data into buffer
    • Draw using buffer
    • Set other data into buffer

    Instead you must write:

    • Set data into buffer
    • Draw using buffer
    • Unset buffer from the graphics device (by selecting some other buffer, or null)
    • Set other data into buffer

    Perhaps some other code in the sample used to be resetting the VB between one frame and then next, but if you took that code out so you're not drawing anything other than the particles, you could be having the same VB left set from the previous frame? Try resetting it to null at the end of the particle drawing.
    XNA Framework Developer - blog - homepage
  • 2008-01-19 12:47 In reply to

    Re: Problem with particle 3D sample

    Thanks, that worked fine, I actually included another class for terrain and since they both use a vb it kinda fixed itself :P

    Now the problem im having is that when the particles start running the rendering of all objects changes and starts showing with like a like blue color over it, im using a different shader for the rendering of the rest of the objects, and the sample apparently resets the changes it makes to the renderstate of the device

                    // Reset a couple of the more unusual renderstates that we changed,
    // so as not to mess up any other subsequent drawing.
    device.RenderState.PointSpriteEnable = false;
    device.RenderState.DepthBufferWriteEnable = true;


    Im guessing it can only be one of the other changes to the renderstate that is doing this right?
  • 2008-01-19 12:54 In reply to

    Re: Problem with particle 3D sample

    I added a function called UnSetParticleRenderStates and basically reversed everything to how it used to be before the particle system makes the call and now the light blue is gone... only one problem left, I have another model in the scene and for some reason its texture gets streched after I call the particle generation... Im lost on this, any hints? :)

  • 2008-01-20 18:08 In reply to

    Re: Problem with particle 3D sample

    I tried commenting the code that caused this and then discomment line by line and testing and I managed to narrow down the problem, it heppens when the code cycles through the EffectPasses to draw the particles, so im assuming the problem is in the shader.
  • 2008-09-04 02:31 In reply to

    Re: Problem with particle 3D sample

    Hi,

    I have the same issue.  Did you ever work out what the problem was?

    cheers

  • 2008-09-04 09:54 In reply to

    Re: Problem with particle 3D sample

    I worked it out.  The sharder code was setting the following to TextureAddressMode.Clamp.  If you reset to Wrap after the Draw() it fixes things (see below).

      device.SamplerStates[0].AddressU = TextureAddressMode.Wrap;
      device.SamplerStates[0].AddressV = TextureAddressMode.Wrap;

Page 1 of 1 (7 items) Previous Next