• Advertisement
Sign in to follow this  

Coord Transformation problem

This topic is 4271 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 ? 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) thanks a lot Killan

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement