Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Simple rotation


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 MarlboroKing   Members   -  Reputation: 192

Like
0Likes
Like

Posted 09 January 2013 - 10:22 AM

I'm attempting to rotate a code-defined model, however it appears to be moving instead of rotating. I've looked all over, even copy/pasting, but to no avail.

 

Edit- This current code shows me using a custom effect, however, I'm basing all this off my previous edits (that being, using the BasicEffect)!

			m_GraphicsDevice.BlendState = BlendState.Opaque;
			m_GraphicsDevice.DepthStencilState = DepthStencilState.Default;

			m_Effect.Parameters["View"].SetValue( m_Camera.View );
			m_Effect.Parameters["Projection"].SetValue( m_Camera.Projection );
			m_Effect.Parameters["CameraPosition"].SetValue( m_Camera.Position );
			m_Effect.Parameters["Texture1"].SetValue( m_TextureAtlas );
			
			foreach( EffectPass pass in m_Effect.CurrentTechnique.Passes )
			{
				foreach( Item item in m_World.ItemMap.Values )
				{
					if( item == null || !item.BoundingBox.Intersects( frustum ) )
						continue;

					Matrix matWorld = Matrix.CreateRotationY( fRROT );
					m_Effect.Parameters["World"].SetValue( matWorld );
					pass.Apply();

					m_GraphicsDevice.SetVertexBuffer( item.m_VertexBuffer );
					m_GraphicsDevice.Indices = item.m_IndexBuffer;

					m_GraphicsDevice.DrawIndexedPrimitives( PrimitiveType.TriangleList, 0, 0,
						item.m_VertexBuffer.VertexCount, 0, item.m_IndexBuffer.IndexCount / 3 );

I've tried using Matrix.CreateFromAxisAngle which did rotate, just not anywhere near the axis I want - even when defining just that axis.

My other attempt was Matrix.CreateRotationY(..) * Matrix.CreateTranslation(..) and still seemed to move.

 

Further information:

m_VertexBuffer = VertexPositionTexture

m_Effect = BasicEffect

ItemMap only contains 1 value for the time being.

I know Quanternations is better for this since it holds the rotation, but I'd like to avoid that route..


Edited by MarlboroKing, 09 January 2013 - 10:52 AM.


Sponsor:

#2 phil_t   Crossbones+   -  Reputation: 4109

Like
1Likes
Like

Posted 09 January 2013 - 11:07 AM

Are the vertices of your code-defined model centered at (0, 0, 0)?



#3 Dan Mayor   Crossbones+   -  Reputation: 1714

Like
2Likes
Like

Posted 09 January 2013 - 11:25 AM

Using CreateRotationX, CreateRotationY, & CreateRotationZ all apply rotations around the world or global axes. Meaning it causes your object to rotate only around the world/global axes, not your object's local axes.  Using CreateFromAxisAngle allows you to input whatever rotation axis you want, including the models own local axes.


Digivance Game Studios Founder:

Dan Mayor - Dan@Digivance.com
 www.Digivance.com


#4 MarlboroKing   Members   -  Reputation: 192

Like
0Likes
Like

Posted 09 January 2013 - 11:29 AM

Snap. I completely forgot about that..! Time to dig around my previous edits. Thank you both!



#5 Dan Mayor   Crossbones+   -  Reputation: 1714

Like
0Likes
Like

Posted 09 January 2013 - 12:27 PM

Sometimes it just takes another set of eyes friend.


Digivance Game Studios Founder:

Dan Mayor - Dan@Digivance.com
 www.Digivance.com





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS