Jump to content
  • Advertisement
Sign in to follow this  
maxino

Draw Different PointSize for particlesystem

This topic is 3008 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

Hi all, I need to draw a particle with different size from the others, how could I do? I search fore vertex type that implement point size but i dind't find in classic vertex type.(device.VertexFormat) I'm using managed directx 9. I read the possibility of use and define own vertex structure, but how can I define and use it? Can i use "drawuserprimitives" method to draw my own particles (I do not need to use an index buffer). Now I'm using this code: // Declaration Private CustomVertex.PositionColored [] vertexArray; //some point here vertexArray = new CustomVertex.PositionColored(new Vector3(x, y, z), Color.FromArgb(255, 255, 255, 100).ToArgb()); // Device settings dev.device.RenderState.Lighting = false; dev.device.RenderState.PointSpriteEnable = true; dev.device.RenderState.PointScaleEnable = true; dev.device.RenderState.PointSize = 1f / / I'll want to Specify size for all my particles, not All The Same size! dev.device.RenderState.PointSizeMin = 0.0f; dev.device.RenderState.PointScaleA = 0.0f; dev.device.RenderState.PointScaleB = 0.0f; dev.device.RenderState.PointScaleC = 1.0F; // Alphablending dev.device.RenderState.AlphaBlendEnable = true; dev.device.RenderState.SourceBlend = Blend.SourceAlpha; dev.device.RenderState.DestinationBlend = Blend.DestinationAlpha; // Render Loop dev.device.Clear (ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1, 0); dev.device.BeginScene (); dev.device.SetTexture (0, particle); dev.device.VertexFormat = CustomVertex.PositionColored.Format; dev.device.DrawUserPrimitives (PrimitiveType.PointList, PARTICLECOUNT, vertexArray); dev.device.EndScene (); dev.device.Present (); How do I change my code to have different particle size? Thanks a lot of attention await your answers Maxino

Share this post


Link to post
Share on other sites
Advertisement
I don't know how this worked in Managed Direct3D. In C++ you can just use D3DFVF_PSIZE as part of the FVF. There's also CreateVertexDeclaration, which is the alternate way to create a declaration.

I'd also suggest you take a look SlimDX for managed Direct3D programming.

Share this post


Link to post
Share on other sites
SOLVED:

//Definition user structure

[StructLayout(LayoutKind.Sequential)]
public struct PositionColoredPointSize
{
//public Vector3 Position;
public float X, Y, Z;
public float PointSize;
public int Color; // 32-bit integer
public PositionColoredPointSize(float xpos, float ypos, float zpos, float psize, int pcolor)
{
X = xpos;
Y = ypos;
Z = zpos;
PointSize = psize;
Color = pcolor;
}
public PositionColoredPointSize(Vector3 pos, float psize, int pcolor)
{
X = pos.X;
Y = pos.Y;
Z = pos.Z;
PointSize = psize;
Color = pcolor;
}
}


//VertexArray
PositionColoredPointSize[] vertexArrayNew;

//render loop

dev.device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1, 0);
dev.device.BeginScene();
dev.device.SetTexture(0, particle);
dev.device.VertexFormat = VertexFormats.Position | VertexFormats.PointSize | VertexFormats.Diffuse;
dev.device.DrawUserPrimitives(PrimitiveType.PointList, PARTICLECOUNT, vertexArrayNew);

it Works! :)
Tanks...for reply...

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!