Jump to content
  • Advertisement
Sign in to follow this  

Coord Transformation problem

This topic is 4507 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, i have some trouble with transformation coord it's in shadow volume case, i have an objet in my world with position and rotation i have a light point to générate the shadow volume (it work good) i can modify the position of my objet, it's ok for shadow, i can too made Y rotation, it's ok again but i can't make X and Z rotation i do this to have light position with my object
vecLight = lightpos;
vecLight -= lo.Position;
vecLight.TransformCoordinate(Matrix.RotationX(Geometry.DegreeToRadian(-lo.Rotation.X)) * Matrix.RotationY(Geometry.DegreeToRadian(-lo.Rotation.Y)) * Matrix.RotationZ(Geometry.DegreeToRadian(-lo.Rotation.Z)));


i annulate the deplacement and the rotation (like the object is the center of the world to have light position) it's work good but X and Z not work :s other think to know, the light vector will be modified after like this :
public void MakeShadowVolume(Vector3 lightpos)
	if (!ombreRefaire) return;

	//Matrix mat = Matrix.RotationAxis(new Vector3(1,0,0),Geometry.DegreeToRadian(Rotation.X)) * Matrix.RotationAxis(new Vector3(0,1,0),Geometry.DegreeToRadian(Rotation.Y)) * Matrix.RotationAxis(new Vector3(0,0,1),Geometry.DegreeToRadian(Rotation.Z)) * Matrix.Translation(Position);

	Vector3 lightVector = Vector3.Normalize( -lightpos );
	ombre.BuildFromMesh(ox.OXMesh, lightVector, Matrix.Identity);

	ombreRefaire = false;

and at the end, the vector is modified like :
public void BuildFromMesh(Mesh mesh, Vector3 lightVector, Matrix rotationTransform)
	// transform light vertor by inverse rotation transform used for the shadow volume & the shading mesh
	Vector4 tlv = Vector3.Transform( lightVector, Matrix.Invert(rotationTransform) );
	lightVector = new Vector3( tlv.X, tlv.Y, tlv.Z );


pictures to see the problem with comments : http://tech.daaboo.net/images/060615-p-0.jpg http://tech.daaboo.net/images/060615-p-1.jpg http://tech.daaboo.net/images/060615-p-2.jpg http://tech.daaboo.net/images/060615-b-0.jpg http://tech.daaboo.net/images/060615-b-1.jpg http://tech.daaboo.net/images/060615-b-2.jpg can you help me please ? thanks a lot Killan [Edited by - killan on June 16, 2006 12:30:03 PM]

Share this post

Link to post
Share on other sites
i have make some analyse and test

if only one axis of rotation is defined : it's ok for the shadow

but if more than one are defined : shadow move anormally

maybe it's my formula that's not correcte ? (see previous post)

Share this post

Link to post
Share on other sites
solution, axes order is important too... so simply but so important... grrr

lightposc.TransformCoordinate(Matrix.RotationZ(Geometry.DegreeToRadian(-Rotation.Z)) * Matrix.RotationY(Geometry.DegreeToRadian(-Rotation.Y)) * Matrix.RotationX(Geometry.DegreeToRadian(-Rotation.X)));

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!