Collins1987

Member
  • Content count

    6
  • Joined

  • Last visited

Community Reputation

117 Neutral

About Collins1987

  • Rank
    Newbie
  1. Ive figured it out really was quite simple to be honest.   involved adding the radius of the circle to be rotated around to the objects position, then when the object had been rotated working out the objects current orientation and multiplying that by the radius offset and taking it from the position before adding it the rotated corners.   Here's the code that is being used: D3DXVECTOR2 X(cosf(Rot), sinf(Rot)); D3DXVECTOR2 Y(-sinf(Rot), cosf(Rot)); X *= halfWidth/2; Y *= halfHeight/2; Corner[0] = Centre - X - Y; Corner[1] = Centre + X - Y; Corner[2] = Centre + X + Y; Corner[3] = Centre - X + Y; float offsetX = orientation.x * Offset; float offsetY = orientation.y * Offset; D3DXVECTOR2 offset(offsetX, offsetY); pos -= offset; Corner[0] += pos; Corner[1] += pos; Corner[2] += pos; Corner[3] += pos; Centre += pos; Thanks for all the help! Wouldn't have made it without the pointers in the write direction!
  2. Have tried implementing it this way and its not working still just rotating the bounding boxes into some weird places, would using a matrix transform during drawing of the sprite effect this as directx draws the sprite in the right location but the world only knows the positions without the transform matrix applied to it?   should state that im working with Orientated Bounding Boxes opposed to Axis Aligned Bounding Boxes
  3. Yes that is the type of bounding box I am using just trying to get it placed in the right location for the collision detection to work. I will give it a try and see what happens Thanks
  4. have tried using this formula there is two things wrong with it, first you cant set a 2D vector with just one value and second it creates a bounding box that is massive compared to the actual entity. Also when drawing these bounding boxes to check to see if it has worked the size of them changes dependent on the rotation of the parent object? Any ideas how to solve this or what I have done wrong? D3DXVECTOR3 orientation = Entity.getOrientation(); float Rot = Entity.getRotation(); D3DXVECTOR2 pos = D3DXVECTOR2(Entity.getPosition().x,Entity.getPosition().y); Centre = Entity.getCentre() + pos; D3DXVECTOR2 X(Entity.getPosition().x + (168 * (sinf(Rot))), 0); D3DXVECTOR2 Y(0, Entity.getPosition().y + (168 * (cosf(Rot)))); X.x -= Entity.getWidth()/2; Y.y -= Entity.getHeight()/2; Corner[0] = (Centre - X) - Y; Corner[1] = (Centre + X) - Y; Corner[2] = (Centre + X) + Y; Corner[3] = (Centre - X) + Y; Where entity Position = 496, 200. entity centre = 512, 216 rotation point is = 512, 368
  5. Thanks for that but this is just rotating the box then moving it back to the old position.   I am trying to rotate the bounding box so that its is rotated around a point on a fixed circular distance away from the origin and cannot figure out how to rotate the bounding box to the same position around the circle as the object instead of just rotating around the point where the object was before it was rotated around the fixed point. if that makes any sense?
  6. hey,   Ive been trying to work out how to rotate a bounding box about a position that is not the objects centre and perform collisions based on SAT Collision Dectection. I have the collisions working but i cannot figure out how to rotate the bounding box into the right location as all I seem to be able to manage is to rotate the bounding box around the objects centre position.   This is what i have so far:   float Rot = Entity.getRotation(); D3DXVECTOR2 pos = D3DXVECTOR2(Entity.getPosition().x,Entity.getPosition().y); Centre = Entity.getCentre() + pos; D3DXVECTOR2 X(cosf(Rot), sinf(Rot)); D3DXVECTOR2 Y(-sinf(Rot), cosf(Rot)); X *= Entity.getWidth()/2; Y *= Entity.getHeight()/2; Corner[0] = (Centre - X) - Y; Corner[1] = (Centre + X) - Y; Corner[2] = (Centre + X) + Y; Corner[3] = (Centre - X) + Y; This code rotates about the objects centre position but i cant mange to rotate about a position say 15 pixels in the positive X direction from its own centre.   Any Ideas on how I would accomplish this?