1
\$\begingroup\$

I am creating a voxel-like game in XNA/Monogame. I am trying to create particle effect of which I create by making a list that is populated every frame. My issue is here: I am using a WorldMatrix to help rotate the particles, but I don't see how I can rotate them with a translating because each particle is different. Here is an example:

partEffect.CurrentTechnique = partEffect.Techniques[0];
        partEffect.Parameters["View"].SetValue(camera.viewMatrix);
        partEffect.Parameters["Projection"].SetValue(camera.projectionMatrix);
        Vector3 rotAxis = new Vector3(1,0,0);
        Vector3 rotAxis1 = new Vector3(0, 1, 0);

        rotAxis.Normalize();
        Matrix worldMatrix = Matrix.CreateTranslation(-20.0f / 3.0f, -10.0f / 3.0f, 0);// *Matrix.CreateFromAxisAngle(rotAxis1, camera.HORIZONTAL) * Matrix.CreateFromAxisAngle(rotAxis, camera.VERTICAL);// *Matrix.CreateFromAxisAngle(rotAxis1, camera.HORIZONTAL);//RotateToFace(vertices[0].Position, camera.Position, new Vector3(0, 1, 0));//Matrix.CreateBillboard(vertices[0].Position, camera.Position, new Vector3(0, 1, 0), new Vector3(0,0,0));//Matrix.CreateFromAxisAngle(rotAxis, angle);//Matrix.CreateTranslation(-20.0f / 3.0f, -10.0f / 3.0f, 0) * Matrix.CreateFromAxisAngle(rotAxis, angle);
        partEffect.Parameters["World"].SetValue(worldMatrix);

The next code that I call after that is the actual draw code, but my problem is here: How do I modify that translation when it seems to be static while each particle is different? Here is my draw effect:

foreach (EffectPass pass in partEffect.CurrentTechnique.Passes)
{
pass.Apply();
     GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 1, VertexPositionColor.VertexDeclaration);
}

So as you can see, the Matrix.CreateTranslation is called before I run my actual draw code. I just don't see how I can modify that translation so it works for every particle instead of just the translation for the single particle. Any insight would be greatly appreciated.

\$\endgroup\$
1
  • \$\begingroup\$ I mean I appreciate your response but that doesn't answer my question, I have looked in foreigners tutorials before but he has an effects file that does not compile into MonoGame as my question shows I am using. Therefore that doesn't help me as my question is more so asking how I can do it without the effects file doing it like he does. \$\endgroup\$
    – Jon
    Commented Mar 12, 2015 at 20:31

1 Answer 1

1
\$\begingroup\$

If you ask how rotate particles to camera you can find explanation here.

But if you want rotate particles around normal vector you must do it when you generate vertices. If you do it like in the toturial a privide tnen you can save information about offset of each vertex of plane in that vertex, For example without rotation vertex offset for left top lertex of plane should be (-0.5, -0.5), but if you rotate it clockwise at 45 degrees it become (0, -0.71), for 90 (0.5, -0.5) and so on. Also, for this method you can not use texture coords, and you must add you must create your own vertex declaration with additional field for vertex offsets.

\$\endgroup\$
1
  • \$\begingroup\$ Your link is broken. \$\endgroup\$ Commented Mar 11, 2015 at 21:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .