calc object size
parent
d2d9973b0a
commit
15e2bb570b
|
@ -123,7 +123,7 @@ namespace OpenSim.Modules.PathFinding
|
||||||
|
|
||||||
#region Script Funktions
|
#region Script Funktions
|
||||||
|
|
||||||
private bool checkIsPositionBlockedByObjekts(int posX, int posY)
|
private bool drawAllBlocketPositions(ref Bitmap _map)
|
||||||
{
|
{
|
||||||
List<SceneObjectGroup> _objects = m_scene.GetSceneObjectGroups().FindAll(X => X.IsPhantom != true);
|
List<SceneObjectGroup> _objects = m_scene.GetSceneObjectGroups().FindAll(X => X.IsPhantom != true);
|
||||||
|
|
||||||
|
@ -133,17 +133,52 @@ namespace OpenSim.Modules.PathFinding
|
||||||
|
|
||||||
foreach (SceneObjectPart _part in _parts)
|
foreach (SceneObjectPart _part in _parts)
|
||||||
{
|
{
|
||||||
if ((int)_part.AbsolutePosition.X == posX && (int)_part.AbsolutePosition.Y == posY)
|
if(!_part.Description.Contains("ignorepathfinding"))
|
||||||
{
|
{
|
||||||
return true;
|
Vector2 _start = new Vector2(_part.AbsolutePosition.X - ((int)_part.Scale.X / 2), _part.AbsolutePosition.Y - ((int)_part.Scale.Y / 2));
|
||||||
}
|
Vector2 _end = new Vector2(_part.AbsolutePosition.X + ((int)_part.Scale.X / 2), _part.AbsolutePosition.Y + ((int)_part.Scale.Y / 2));
|
||||||
|
|
||||||
|
fillArea(ref _map, _start, _end, Color.Red);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTestImage(String imageName)
|
private bool drawAllAllowedPaths(ref Bitmap _map)
|
||||||
|
{
|
||||||
|
foreach (SceneObjectGroup _object in m_scene.GetSceneObjectGroups())
|
||||||
|
{
|
||||||
|
SceneObjectPart[] _parts = _object.Parts;
|
||||||
|
|
||||||
|
foreach (SceneObjectPart _part in _parts)
|
||||||
|
{
|
||||||
|
if (_part.Description.Contains("allowedpath") || _part.Description.Contains("pathfinding_allow"))
|
||||||
|
{
|
||||||
|
Vector2 _start = new Vector2(_part.AbsolutePosition.X - ((int)_part.Scale.X / 2), _part.AbsolutePosition.Y - ((int)_part.Scale.Y / 2));
|
||||||
|
Vector2 _end = new Vector2(_part.AbsolutePosition.X + ((int)_part.Scale.X / 2), _part.AbsolutePosition.Y + ((int)_part.Scale.Y / 2));
|
||||||
|
|
||||||
|
fillArea(ref _map, _start, _end, Color.Green);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillArea(ref Bitmap _map, Vector2 _start, Vector2 _end, Color _color)
|
||||||
|
{
|
||||||
|
for (int X = (int)_start.X; X < (int)_end.X; X++)
|
||||||
|
{
|
||||||
|
for (int Y = (int)_start.Y; Y < (int)_end.Y; Y++)
|
||||||
|
{
|
||||||
|
_map.SetPixel(X, Y, _color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createPathFindingScene(String imageName)
|
||||||
{
|
{
|
||||||
Bitmap _map = new Bitmap((int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY);
|
Bitmap _map = new Bitmap((int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY);
|
||||||
|
|
||||||
|
@ -151,15 +186,17 @@ namespace OpenSim.Modules.PathFinding
|
||||||
{
|
{
|
||||||
for (int Y = 0; Y < m_scene.RegionInfo.RegionSizeY; Y++)
|
for (int Y = 0; Y < m_scene.RegionInfo.RegionSizeY; Y++)
|
||||||
{
|
{
|
||||||
_map.SetPixel(Y, X, Color.Green);
|
|
||||||
|
|
||||||
float baseheight = (float)m_scene.Heightmap[X, Y];
|
float baseheight = (float)m_scene.Heightmap[X, Y];
|
||||||
|
|
||||||
if (baseheight <= m_scene.RegionInfo.RegionSettings.WaterHeight)
|
if (baseheight <= m_scene.RegionInfo.RegionSettings.WaterHeight)
|
||||||
_map.SetPixel(Y, X, Color.Red);
|
_map.SetPixel(Y, X, Color.Red);
|
||||||
|
|
||||||
if (checkIsPositionBlockedByObjekts(X, Y) == true)
|
if (baseheight > m_scene.RegionInfo.RegionSettings.WaterHeight)
|
||||||
_map.SetPixel(Y, X, Color.Yellow);
|
_map.SetPixel(Y, X, Color.Yellow);
|
||||||
|
|
||||||
|
drawAllBlocketPositions(ref _map);
|
||||||
|
|
||||||
|
drawAllAllowedPaths(ref _map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +207,7 @@ namespace OpenSim.Modules.PathFinding
|
||||||
public string osCreateNewPathFindingScene(UUID hostID, UUID scriptID)
|
public string osCreateNewPathFindingScene(UUID hostID, UUID scriptID)
|
||||||
{
|
{
|
||||||
String imageName = UUID.Random().ToString();
|
String imageName = UUID.Random().ToString();
|
||||||
(new Thread(delegate () { createTestImage(imageName); })).Start();
|
(new Thread(delegate () { createPathFindingScene(imageName); })).Start();
|
||||||
|
|
||||||
return imageName;
|
return imageName;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue