パーティクルシステムを回転しようとすると問題が発生します。まず、エミッタの位置を回転させようとすると、各パーティクルを回転させてエフェクトを強化しようとしていません。例えば、私が0,0,0にエミッタ位置を持っていて、x軸とz軸の両方に粒子-5と5を放出すると、ワールド軸に沿った正方形で放出するパーティクルに終わります。私は何をしたいのですか?これを回転させて、まったく同じですがエミッタポイントの周りを回転させることです。上記パーティクルシステムを回転させてワールド軸を回転させない方法
// Each particle point is converted to a quad (two triangles)
[maxvertexcount(4)]
void mainGSDraw
(
point VS_VertIn inParticle[1], // One particle in, as a point
inout TriangleStream<GS_VertOut> outStrip // Triangle stream output, a quad containing two triangles
)
{
// Camera-space offsets for the four corners of the quad from the particle centre
// Will be scaled depending on distance of the particle
const float3 Corners[4] =
{
float3(-1, 1, 0),
float3(1, 1, 0),
float3(-1, -1, 0),
float3(1, -1, 0),
};
// Texture coordinates for the four corners of the generated quad
const float2 UVs[4] =
{
float2(0,1),
float2(1,1),
float2(0,0),
float2(1,0),
};
const float3x3 RotY =
{
cos(rotationAngle),0,sin(rotationAngle),
0,1,0,
-sin(rotationAngle),0,cos(rotationAngle)
};
GS_VertOut outVert; // Used to build output vertices
// Output the four corner vertices of a quad centred on the particle position
[unroll]
for (int i = 0; i < 4; ++i)
{
// Use the corners defined above and the inverse camera matrix to calculate each world
// space corner of the quad
float3 corner = Corners[i] * inParticle[0].Scale; // scale first
float3 worldPosition;
worldPosition = mul(inParticle[0].Position + mul(corner, (float3x3)InvViewMatrix), RotY) ; // face the camera
// Transform to 2D position and output along with an appropriate UV
outVert.ViewportPosition = mul(float4(worldPosition, 1.0f), ViewProjMatrix);
outVert.TexCoord = UVs[i];
outStrip.Append(outVert);
}
outStrip.RestartStrip();
} 私のジオメトリシェーダの描画関数のコードで、ポイントなどの粒子が入って来と、クワッドに拡大スケーリングし、その後、世界の位置が計算されます。パーティクルシステムが原点にある場合、回転計算は間違っています。システムを正確に回転させますが、移動すると、原点を中心に回転するので、エミッタの原点を中心にこの回転を行う方法があります世界はゼロではない?コードが縮小されているため、このコードが機能しない可能性のある返信は必要ありません。
あなたはその種の計算を行う必要があります: 1 - 放出点を世界軸に平行移動します。 2 - その軸を中心に回転しますか? 3 - 元の位置に戻します。 これは一般的な方法です。 0の位置以外の場所で何かをする方法がわからないときは、ただ変換し、計算して翻訳し直します。私はあなたにそれについての信頼できる正確な詳細を与えることができないので、インターネットを検索する必要があります。 – Morwenn