aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes
diff options
context:
space:
mode:
authorTeravus Ovares2008-03-22 03:40:38 +0000
committerTeravus Ovares2008-03-22 03:40:38 +0000
commit7854f6f4a296246f4363192a48add1b34804689e (patch)
treee2bcf9edca2604dfdbc72a8f01a4a6ca750b2475 /OpenSim/Region/Environment/Scenes
parentRemove a couple more compiler warnings by commenting unused variables. (diff)
downloadopensim-SC_OLD-7854f6f4a296246f4363192a48add1b34804689e.zip
opensim-SC_OLD-7854f6f4a296246f4363192a48add1b34804689e.tar.gz
opensim-SC_OLD-7854f6f4a296246f4363192a48add1b34804689e.tar.bz2
opensim-SC_OLD-7854f6f4a296246f4363192a48add1b34804689e.tar.xz
* Committing some math to discover the Oriented Bounding Box and decomposing it into planes and normals.
* No obvious functionality difference as the Ray-cast code is incomplete for OBB right now.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs113
1 files changed, 113 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 7fd1963..ea20725 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -933,7 +933,120 @@ namespace OpenSim.Region.Environment.Scenes
933 933
934 return returnresult; 934 return returnresult;
935 } 935 }
936 public EntityIntersection TestIntersectionOABB(Ray iray, Quaternion parentrot)
937 {
938 // In this case we're using a rectangular prism, which has 6 faces and therefore 6 planes
939 // This breaks down into the ray---> plane equation.
940 // TODO: Change to take shape into account
941 Vector3[] vertexes = new Vector3[8];
942
943 Vector3[] FaceA = new Vector3[6];
944 Vector3[] FaceB = new Vector3[6];
945 Vector3[] FaceC = new Vector3[6];
946 Vector3[] FaceD = new Vector3[6];
947
948 Vector3[] normals = new Vector3[6];
949
950 Vector3 AmBa = new Vector3(0, 0, 0);
951 Vector3 AmBb = new Vector3(0, 0, 0);
952
953 LLVector3 pos = GetWorldPosition();
954 LLQuaternion rot = GetWorldRotation();
955 Quaternion AXrot = new Quaternion(rot.W,rot.X,rot.Y,rot.Z);
956
957
958 // Get Vertexes for Faces Stick them into ABCD for each Face
959 #region ABCD Face Vertex Map Comment Diagram
960 // A _________ B
961 // | |
962 // | 4 top |
963 // |_________|
964 // C D
965
966 // A _________ B
967 // | Back |
968 // | 3 |
969 // |_________|
970 // C D
971
972 // A _________ B B _________ A
973 // | Left | | Right |
974 // | 0 | | 2 |
975 // |_________| |_________|
976 // C D D C
977
978 // A _________ B
979 // | Front |
980 // | 1 |
981 // |_________|
982 // C D
983
984 // C _________ D
985 // | |
986 // | 5 bot |
987 // |_________|
988 // A B
989 #endregion
990 vertexes[0] = (AXrot * new Vector3((pos.X - m_shape.Scale.X),(pos.Y - m_shape.Scale.Y),(pos.Z + m_shape.Scale.Z)));
991
992 FaceA[0] = vertexes[0];
993 FaceA[3] = vertexes[0];
994 FaceA[4] = vertexes[0];
995
996 vertexes[1] = (AXrot * new Vector3((pos.X - m_shape.Scale.X), (pos.Y + m_shape.Scale.Y), (pos.Z + m_shape.Scale.Z)));
997
998 FaceB[0] = vertexes[1];
999 FaceA[1] = vertexes[1];
1000 FaceC[4] = vertexes[1];
1001
1002 vertexes[2] = (AXrot * new Vector3((pos.X - m_shape.Scale.X), (pos.Y - m_shape.Scale.Y), (pos.Z - m_shape.Scale.Z)));
1003
1004 FaceC[0] = vertexes[2];
1005 FaceC[3] = vertexes[2];
1006 FaceC[5] = vertexes[2];
936 1007
1008 vertexes[3] = (AXrot * new Vector3((pos.X - m_shape.Scale.X), (pos.Y + m_shape.Scale.Y), (pos.Z - m_shape.Scale.Z)));
1009
1010 FaceD[0] = vertexes[3];
1011 FaceC[1] = vertexes[3];
1012 FaceA[5] = vertexes[3];
1013
1014 vertexes[4] = (AXrot * new Vector3((pos.X + m_shape.Scale.X), (pos.Y + m_shape.Scale.Y), (pos.Z + m_shape.Scale.Z)));
1015
1016 FaceB[1] = vertexes[4];
1017 FaceA[2] = vertexes[4];
1018 FaceD[4] = vertexes[4];
1019
1020 vertexes[5] = (AXrot * new Vector3((pos.X + m_shape.Scale.X), (pos.Y + m_shape.Scale.Y), (pos.Z - m_shape.Scale.Z)));
1021
1022 FaceD[1] = vertexes[5];
1023 FaceC[2] = vertexes[5];
1024 FaceB[5] = vertexes[5];
1025
1026 vertexes[6] = (AXrot * new Vector3((pos.X + m_shape.Scale.X), (pos.Y - m_shape.Scale.Y), (pos.Z + m_shape.Scale.Z)));
1027
1028 FaceB[2] = vertexes[6];
1029 FaceB[3] = vertexes[6];
1030 FaceB[4] = vertexes[6];
1031
1032 vertexes[7] = (AXrot * new Vector3((pos.X + m_shape.Scale.X), (pos.Y - m_shape.Scale.Y), (pos.Z - m_shape.Scale.Z)));
1033
1034 FaceD[2] = vertexes[7];
1035 FaceD[3] = vertexes[7];
1036 FaceD[5] = vertexes[7];
1037
1038 // Get our plane normals
1039 for (int i = 0; i < 6; i++)
1040 {
1041 AmBa = FaceB[i] - FaceA[i];
1042 AmBb = FaceC[i] - FaceA[i];
1043 normals[i] = AmBa.Cross(AmBb);
1044 }
1045
1046 EntityIntersection returnresult = new EntityIntersection();
1047
1048 return returnresult;
1049 }
937 1050
938 /// <summary> 1051 /// <summary>
939 /// 1052 ///