# Box creation and rotation

This topic is 3880 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am creating a box as six different meshes rather then one mesh. I am creating the box like the follow Side one = (0, 0, 0, width, height) - Front Side one rotation = (0, 0, 0) Side two = (0, 0, 0, depth, height) - Left Side two rotation = (0, -90, 0) Side three = (0, 0, depth, width, height) - Back Side three rotation = (0, 0, 0) Side four = (width, 0, 0, depth, height) - Right Side four rotation = (0, -90, 0) Side five = (0, height, 0 width, depth) - Top Side five rotation = (90, 0, 0) Side six = (0, 0, 0, width, depth) - Bottom Side six rotation = (90, 0, 0). When I render everything without a box rotation, it will render just fine. However, if I render with a box rotation, all the rotations go wrong. When applying a box rotation I do ApplyMatrix = box.matrix * box.sides.matrix Is this the way it should be done or is there anything way?

##### Share on other sites
It's a little difficult to tell from what you posted.

However, try:

ApplyMatrix = box.sides.matrix * box.matrix;

instead. (reverse the order of the transform multiplication)

The reason for doing that is that you want to position and rotate the sides of the box first, before you apply additional rotations.

##### Share on other sites
Thank you, that is exactly what I was looking for. I have been trying for hours and tried about half a dozen different ways but never tried that one.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 9
• 34
• 16
• ### Forum Statistics

• Total Topics
634124
• Total Posts
3015659
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!