Skip to main content
deleted 317 characters in body
Source Link
codymanix
  • 364
  • 1
  • 9

If was trying to set the correct position of my sun billboard in my 3d game. I tried long until it worked correctly, but I wonder why this code must be so complicated:

sun.sprite.Position = Vector3.Transform(Vector3.Transform(-sun.lightDir, 
Quaternion.Inverse(world.Rotation)), Quaternion.Inverse(myRelativeRotation));

Can I simplify this expression? I tried changing it at least to this:

sun.sprite.Position = Vector3.Transform(-sun.lightDir,
Quaternion.Inverse(world.Rotation) * Quaternion.Inverse(myRelativeRotation)) 

But this is giving me different results, so the sun is at the wrong position.

EDIT

In the end, I made it even simpler:

sun.sprite.Position = Vector3.Transform(-sun.lightDir, 
    Quaternion.Inverse(myRelativeRotation * world.Rotation));

Because according to this explanation is:

A^-1 * B^-1 = (B * A)^-1

If was trying to set the correct position of my sun billboard in my 3d game. I tried long until it worked correctly, but I wonder why this code must be so complicated:

sun.sprite.Position = Vector3.Transform(Vector3.Transform(-sun.lightDir, 
Quaternion.Inverse(world.Rotation)), Quaternion.Inverse(myRelativeRotation));

Can I simplify this expression? I tried changing it at least to this:

sun.sprite.Position = Vector3.Transform(-sun.lightDir,
Quaternion.Inverse(world.Rotation) * Quaternion.Inverse(myRelativeRotation)) 

But this is giving me different results, so the sun is at the wrong position.

EDIT

In the end, I made it even simpler:

sun.sprite.Position = Vector3.Transform(-sun.lightDir, 
    Quaternion.Inverse(myRelativeRotation * world.Rotation));

Because according to this explanation is:

A^-1 * B^-1 = (B * A)^-1

If was trying to set the correct position of my sun billboard in my 3d game. I tried long until it worked correctly, but I wonder why this code must be so complicated:

sun.sprite.Position = Vector3.Transform(Vector3.Transform(-sun.lightDir, 
Quaternion.Inverse(world.Rotation)), Quaternion.Inverse(myRelativeRotation));

Can I simplify this expression? I tried changing it at least to this:

sun.sprite.Position = Vector3.Transform(-sun.lightDir,
Quaternion.Inverse(world.Rotation) * Quaternion.Inverse(myRelativeRotation)) 

But this is giving me different results, so the sun is at the wrong position.

added 315 characters in body
Source Link
codymanix
  • 364
  • 1
  • 9

If was trying to set the correct position of my sun billboard in my 3d game. I tried long until it worked correctly, but I wonder why this code must be so complicated:

sun.sprite.Position = Vector3.Transform(Vector3.Transform(-sun.lightDir, 
Quaternion.Inverse(world.Rotation)), Quaternion.Inverse(myRelativeRotation));

Can I simplify this expression? I tried changing it at least to this:

sun.sprite.Position = Vector3.Transform(-sun.lightDir,
Quaternion.Inverse(world.Rotation) * Quaternion.Inverse(myRelativeRotation)) 

But this is giving me different results, so the sun is at the wrong position.

EDIT

In the end, I made it even simpler:

sun.sprite.Position = Vector3.Transform(-sun.lightDir, 
    Quaternion.Inverse(myRelativeRotation * world.Rotation));

Because according to this explanation is:

A^-1 * B^-1 = (B * A)^-1

If was trying to set the correct position of my sun billboard in my 3d game. I tried long until it worked correctly, but I wonder why this code must be so complicated:

sun.sprite.Position = Vector3.Transform(Vector3.Transform(-sun.lightDir, 
Quaternion.Inverse(world.Rotation)), Quaternion.Inverse(myRelativeRotation));

Can I simplify this expression? I tried changing it at least to this:

sun.sprite.Position = Vector3.Transform(-sun.lightDir,
Quaternion.Inverse(world.Rotation) * Quaternion.Inverse(myRelativeRotation)) 

But this is giving me different results, so the sun is at the wrong position.

If was trying to set the correct position of my sun billboard in my 3d game. I tried long until it worked correctly, but I wonder why this code must be so complicated:

sun.sprite.Position = Vector3.Transform(Vector3.Transform(-sun.lightDir, 
Quaternion.Inverse(world.Rotation)), Quaternion.Inverse(myRelativeRotation));

Can I simplify this expression? I tried changing it at least to this:

sun.sprite.Position = Vector3.Transform(-sun.lightDir,
Quaternion.Inverse(world.Rotation) * Quaternion.Inverse(myRelativeRotation)) 

But this is giving me different results, so the sun is at the wrong position.

EDIT

In the end, I made it even simpler:

sun.sprite.Position = Vector3.Transform(-sun.lightDir, 
    Quaternion.Inverse(myRelativeRotation * world.Rotation));

Because according to this explanation is:

A^-1 * B^-1 = (B * A)^-1

edited body
Source Link
codymanix
  • 364
  • 1
  • 9

If was trying to set the correct position of my sun billboard in my 3d game. I tried long until it worked correctly, but I wonder why this code must be so complicated:

sun.sprite.Position = Vector3.Transform(Vector3.Transform(-sun.lightDir, 
Quaternion.Inverse(world.Rotation)), Quaternion.Inverse(myRelativeRotation));

Can I simplify this expression? I tried changing it at least to this:

sun.sprite.Position = Vector3.Transform(-sun.lightDir,
Quaternion.Inverse(world.Rotation) * Quaternion.Inverse(myRelativeRotation)) 

But this is giving myme different results, so the sun is at the wrong position.

If was trying to set the correct position of my sun billboard in my 3d game. I tried long until it worked correctly, but I wonder why this code must be so complicated:

sun.sprite.Position = Vector3.Transform(Vector3.Transform(-sun.lightDir, 
Quaternion.Inverse(world.Rotation)), Quaternion.Inverse(myRelativeRotation));

Can I simplify this expression? I tried changing it at least to this:

sun.sprite.Position = Vector3.Transform(-sun.lightDir,
Quaternion.Inverse(world.Rotation) * Quaternion.Inverse(myRelativeRotation)) 

But this is giving my different results, so the sun is at the wrong position.

If was trying to set the correct position of my sun billboard in my 3d game. I tried long until it worked correctly, but I wonder why this code must be so complicated:

sun.sprite.Position = Vector3.Transform(Vector3.Transform(-sun.lightDir, 
Quaternion.Inverse(world.Rotation)), Quaternion.Inverse(myRelativeRotation));

Can I simplify this expression? I tried changing it at least to this:

sun.sprite.Position = Vector3.Transform(-sun.lightDir,
Quaternion.Inverse(world.Rotation) * Quaternion.Inverse(myRelativeRotation)) 

But this is giving me different results, so the sun is at the wrong position.

Source Link
codymanix
  • 364
  • 1
  • 9
Loading