I posted this in the original stack overflow then realized that a game-dev specific one exists.

I am working on personal project that requires me to have 4 points surrounding an object (1 at each of its furthest points) that will rotate/move when the object does.

These points are represented as simple coordinates (x,y,z) and rotational values (ry,rx,rz). Some other stuff exists in the class but it shouldn't be to relevant.

My object has coordinates in world space and can freely move around on the X and Z axis. The y value of the object and points are calculated elsewhere, separately using the X and Z values obtained by the points.

So Basically What I am asking is How do I attach my points to the Object and have them rotate when it does, move when it does etc. Keeping in mind I need the points coordinates in world space.

My knowledge of DirectX is a bit sketchy and basic concepts (change of coordinate systems, vector/matrix transformations etc) confuse me sometimes.

Any help is greatly appreciated.

This is the Constructor for the object, it initializes the points to areas around the object.

    Object::Object(ID3D10Device *renderingDevice, float mlength, float mwidth)
    pd3dDevice = renderingDevice;
    length = mlength;
    width = mwidth;
    A = new CollisionPoint(width,-length); //Front Left
    B = new CollisionPoint(-width,-length); //Front Right
    C = new CollisionPoint(width,length); //Back left
    D = new CollisionPoint(-width,length); //Back Right


This is the code that is meant to move and rotate the points.

 void Object::doBehaviour()
    //origin required for rotating of collisionbox
    D3DXVECTOR3 origin = D3DXVECTOR3(x,0,z);
    speed *= 0.99;

    //update collisionbox
    A->x = width;
    A->z = -length;

    B->x = -width;
    B->z = -length;
    B->ry = ry;

    C->x = width;
    C->z = length;
    C->ry = ry;

    D->x = -width;
    D->z = length;
    D->ry = ry;


This is the code the collisionPoints use to move and rotate the points, ignore the int wheel bit.

    void CollisionPoint::moveAndRotate(D3DXVECTOR3 origin, int wheel)
    //1 = frontleft //2 = frontright //3 = backleft //4 = backright
    float xR = origin.x + cos(ry) * x - sin(ry) * z;
    float zR = origin.z - sin(ry) * x + cos(ry) * z;

    x = xR;
    z = zR;


void CollisionPoint::doBehaviour1(D3DXVECTOR3 origin, int wheel)
    moveAndRotate(origin, wheel);
    speed *= 0.99;


How do I:

  1. Convert coordinates to Object space.
  2. Rotate these coordinates along with an object based on its RY (rotation on the Y axis) value
  3. Obtain their coordinates in world space.
  • \$\begingroup\$ I strongly recommend getting a book on 3D graphics that covers the basics of transformations. It's a complex subject, but is essential to how 3D graphics systems work. \$\endgroup\$ – Chuck Walbourn Jul 7 '14 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.