Sign in to follow this  

Draw Different PointSize for particlesystem

This topic is 2791 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 [i] = 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
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

This topic is 2791 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this