Announcement

Collapse
No announcement yet.

a little understanding problem TRay.IntersectCubevolume

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • a little understanding problem TRay.IntersectCubevolume

    Hi again.
    ​Making progress with my editor and I am now able to draw cubes into my scenes.
    Next step would be a mouse detection for them so I tested out IntersectCubeVolume. I know that the framework has additional helper classes for handling models and mouse detection and stuff but for now I would like to do it manually.

    So I wondered how I enter the size of the cube volume first to check. Looked up again how 4x4 matrixes are build up (im still not that used to them ) and tested:

    aWorld.Data[0,0] := 100;
    aWorld.Data[1,1] := 50;
    aWorld.Data[2,2] := 50;
    Mouseray.IntersectCubeVolume(aWorld,aDistance);

    And that worked so far and correctly detected a cube volume with the size of 100x50x50 around the center of the worldspace.
    So I thought cool, thats seems to be it.

    But when I now try to move that cube around by for example:

    aWorld.Data[0,0] := 100;
    aWorld.Data[1,1] := 50;
    aWorld.Data[2,2] := 50;
    aWorld := aWorld * TMatrix4f.Translate (Vector3f(200,0,0));
    Mouseray.IntersectCubeVolume(aWorld,aDistance);​

    It is still only detected around the center of the worldspace. The translation seems to be ignored. DO I have to specify more stuff in the matrix first? Sorry, if this is something I should know by now. Matrixes are still confusing me ^^
    Attached Files

  • #2
    OK.. apparently Data [3,3] has to be 1. I simply saw that when I searched for matrixes that the value a44 is always 1 so I tried that and that worked ^^

    Comment


    • #3
      I would recommend trying to leverage framework's hierarchical object model system, which handles visibility and intersection very efficiently.

      However, your manual approach should also work. IntersectCubeVolume expects a "volume", which implies using "unity cube" (a cube with all dimensions set to one). Therefore, to use a 100x50x50 cube, you can use a scale matrix, multiplied by rotation and translation matrices. You can also write data directly to matrix values as you have done, but it is less intuitive.

      Comment

      Working...
      X