Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Simple rotation

4: Adsense

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   

252
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.


#2 phil_t   Members   

8005
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   Members   

1724
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.


Dan Mayor

Professional Programmer & Hobbyist Game Developer

Seeking team for indie development opportunities, see my classifieds post

 


#4 MarlboroKing   Members   

252
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   Members   

1724
Like
0Likes
Like

Posted 09 January 2013 - 12:27 PM

Sometimes it just takes another set of eyes friend.


Dan Mayor

Professional Programmer & Hobbyist Game Developer

Seeking team for indie development opportunities, see my classifieds post

 





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.