OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Border.cs
Go to the documentation of this file.
1 /*
2  * Copyright (c) Contributors, http://opensimulator.org/
3  * See CONTRIBUTORS.TXT for a full list of copyright holders.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the OpenSimulator Project nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 using System;
29 using System.Collections.Generic;
30 using System.Text;
31 using OpenMetaverse;
32 
33 namespace OpenSim.Region.Framework.Scenes
34 {
35  public class Border
36  {
40  public Vector3 BorderLine = Vector3.Zero;
41 
45  public Cardinals CrossDirection = Cardinals.N;
46  public uint TriggerRegionX = 0;
47  public uint TriggerRegionY = 0;
48 
49  public Border()
50  {
51  }
52 
74  public Border(float lineStart, float lineEnd, float triggerCoordinate, uint triggerRegionX,
75  uint triggerRegionY, Cardinals direction)
76  {
77  BorderLine = new Vector3(lineStart,lineEnd,triggerCoordinate);
78  CrossDirection = direction;
79  TriggerRegionX = triggerRegionX;
80  TriggerRegionY = triggerRegionY;
81  }
82 
87  public bool TestCross(Vector3 position)
88  {
89  bool result = false;
90  switch (CrossDirection)
91  {
92  case Cardinals.N: // x+0, y+1
93  if (position.X >= BorderLine.X && position.X <= BorderLine.Y && position.Y > BorderLine.Z)
94  {
95  return true;
96  }
97  break;
98  case Cardinals.NE: // x+1, y+1
99  break;
100  case Cardinals.E: // x+1, y+0
101  if (position.Y >= BorderLine.X && position.Y <= BorderLine.Y && position.X > BorderLine.Z)
102  {
103  return true;
104  }
105  break;
106  case Cardinals.SE: // x+1, y-1
107  break;
108  case Cardinals.S: // x+0, y-1
109  if (position.X >= BorderLine.X && position.X <= BorderLine.Y && position.Y < BorderLine.Z)
110  {
111  return true;
112  }
113  break;
114  case Cardinals.SW: // x-1, y-1
115  break;
116  case Cardinals.W: // x-1, y+0
117  if (position.Y >= BorderLine.X && position.Y <= BorderLine.Y && position.X < BorderLine.Z)
118  {
119  return true;
120  }
121  break;
122  case Cardinals.NW: // x-1, y+1
123  break;
124  }
125 
126  return result;
127  }
128 
129  public float Extent
130  {
131  get
132  {
133  switch (CrossDirection)
134  {
135  case Cardinals.N:
136  break;
137  case Cardinals.S:
138  break;
139  case Cardinals.W:
140  break;
141  case Cardinals.E:
142  break;
143  }
144  return 0;
145  }
146  }
147  }
148 }
bool TestCross(Vector3 position)
Tests to see if the given position would cross this border.
Definition: Border.cs:87
Border(float lineStart, float lineEnd, float triggerCoordinate, uint triggerRegionX, uint triggerRegionY, Cardinals direction)
Creates a Border. The line is perpendicular to the direction cardinal. IE: if the direction cardinal ...
Definition: Border.cs:74