本文整理汇总了C#中OpenSim.Region.Framework.Scenes.Scene.GetEntities方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.GetEntities方法的具体用法?C# Scene.GetEntities怎么用?C# Scene.GetEntities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSim.Region.Framework.Scenes.Scene
的用法示例。
在下文中一共展示了Scene.GetEntities方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetObjectXml
private static string GetObjectXml(Scene scene)
{
string xmlstream = "<scene>";
List<EntityBase> EntityList = scene.GetEntities();
List<string> EntityXml = new List<string>();
foreach (EntityBase ent in EntityList)
{
if (ent is SceneObjectGroup)
{
EntityXml.Add(SceneObjectSerializer.ToXml2Format((SceneObjectGroup)ent, false));
}
}
EntityXml.Sort();
foreach (string xml in EntityXml)
xmlstream += xml;
xmlstream += "</scene>";
return xmlstream;
}
示例2: Reset
void Reset(Scene scene)
{
//Returns all plants to their default size, color
EntityBase[] everyobject = scene.GetEntities();
SceneObjectGroup sog;
foreach (EntityBase entity in everyobject)
{
if (entity is SceneObjectGroup)
{ //make sure it is an object, not an avatar
sog = (SceneObjectGroup)entity;
if (sog.Name.Length > 4)
{ //Avoid an exception on non-plants with short names
string objecttype = sog.Name.Substring(0,5);
if (objecttype == "Spore")
{
Primitive.TextureEntry tex = sog.RootPart.Shape.Textures;
tex.DefaultTexture.RGBA = m_Brown;
sog.RootPart.Scale = m_sporeSize;
sog.RootPart.UpdateTextureEntry(tex.GetBytes());
}
else if (objecttype == "Gamet")
{
Primitive.TextureEntry tex = sog.RootPart.Shape.Textures;
tex.DefaultTexture.RGBA = m_Green;
sog.RootPart.Scale = m_gametSize;
sog.RootPart.UpdateTextureEntry(tex.GetBytes());
}
else if (objecttype == "Sporo")
{
Primitive.TextureEntry tex = sog.RootPart.Shape.Textures;
tex.DefaultTexture.RGBA = m_Green;
sog.RootPart.Scale = m_sporoSize;
sog.RootPart.UpdateTextureEntry(tex.GetBytes());
}
}
}
}
}
示例3: LocusView
void LocusView(Scene scene, int locus)
{
//For a chosen locus, colors plants based on their allele(s)
int locusmask = (int)(Math.Pow(2, locus - 1));
EntityBase[] everyobject = scene.GetEntities();
SceneObjectGroup sog;
foreach (EntityBase entity in everyobject)
{
if (entity is SceneObjectGroup)
{ //make sure it is an object, not an avatar
sog = (SceneObjectGroup)entity;
if (sog.Name.Length > 4)
{ //Avoid an exception on non-plants with short names
string objecttype = sog.Name.Substring(0,5);
if ((objecttype == "Spore") || (objecttype == "Gamet"))
{
int haplo1 = Int32.Parse(sog.Name.Substring(5));
if ((haplo1 & locusmask) == locusmask)
{ // It has the dominant allele
Highlight(sog, m_Red); //highlight it in Red
}
else
{ //It has the recessive allele
Highlight(sog, m_Blue);
}
}
else if (objecttype == "Sporo")
{
int geno = Int32.Parse(sog.Name.Substring(5));
int haplo1 = (m_haplotypes - 1) & geno;
int haplo2 = (geno >> m_loci) & (m_haplotypes - 1);
if ((haplo1 & locusmask) == (haplo2 & locusmask))
{ //It is homozygous...
if ((haplo1 & locusmask) == locusmask)
{ //...dominant
Highlight(sog, m_Red);
}
else
{ //...recessive
Highlight(sog, m_Blue);
}
}
else
{ //It is heterozygous
Highlight(sog, m_Purple);
}
}
}
}
}
}
示例4: LifestageView
void LifestageView(Scene scene, string lifestage)
{
//Show plants at a particular lifestage
EntityBase[] everyobject = scene.GetEntities();
SceneObjectGroup sog;
foreach (EntityBase entity in everyobject)
{
if (entity is SceneObjectGroup)
{ //make sure it is an object, not an avatar
sog = (SceneObjectGroup)entity;
if (sog.Name.Length > 4)
{ //Avoid an exception on non-plants with short names
string objecttype = sog.Name.Substring(0,5);
if (objecttype.ToLower() == lifestage.ToLower())
{
Highlight(sog, m_Blue);
}
}
}
}
}
示例5: HeterozygosityView
void HeterozygosityView(Scene scene)
{
//Show plant using grayscale representing how many loci are heterozygous
EntityBase[] everyobject = scene.GetEntities();
SceneObjectGroup sog;
foreach (EntityBase entity in everyobject)
{
if (entity is SceneObjectGroup)
{ //make sure it is an object, not an avatar
sog = (SceneObjectGroup)entity;
if (sog.Name.Length > 4)
{ //Avoid an exception on non-plants with short names
string objecttype = sog.Name.Substring(0,5);
if (objecttype == "Sporo")
{
float heterozygosity = 0.0f;
int locus = 1;
int geno = Int32.Parse(sog.Name.Substring(5));
int haplo1 = (m_haplotypes - 1) & geno;
int haplo2 = (geno >> m_loci) & (m_haplotypes - 1);
while (locus <= m_loci)
{
int locusmask = (int)(Math.Pow(2, locus-1));
if ((haplo1 & locusmask) != (haplo2 & locusmask))
{ // it is heterozygous
heterozygosity = heterozygosity + (1.0f / m_loci);
}
locus ++;
}
Highlight(sog, new Color4(heterozygosity, heterozygosity, heterozygosity, 1.0f));
}
}
}
}
}
示例6: HaplotypeView
void HaplotypeView(Scene scene, int haplotype)
{
//Show plants with a particular haplotype
EntityBase[] everyobject = scene.GetEntities();
SceneObjectGroup sog;
foreach (EntityBase entity in everyobject)
{
if (entity is SceneObjectGroup)
{ //make sure it is an object, not an avatar
sog = (SceneObjectGroup)entity;
if (sog.Name.Length > 4)
{ //Avoid an exception on non-plants with short names
string objecttype = sog.Name.Substring(0,5);
if ((objecttype == "Spore") || (objecttype == "Gamet"))
{
int haplo1 = Int32.Parse(sog.Name.Substring(5));
if (haplo1 == haplotype)
{
Highlight(sog, m_Blue);
}
}
else if (objecttype == "Sporo")
{
int geno = Int32.Parse(sog.Name.Substring(5));
int haplo1 = (m_haplotypes - 1) & geno;
int haplo2 = (geno >> m_loci) & (m_haplotypes - 1);
if ((haplo1 == haplotype) || (haplo2 == haplotype))
{
Highlight(sog, m_Blue);
}
}
}
}
}
}
示例7: RollbackRegion
/// <summary>
/// Retrieves the latest revision of a region in xml form,
/// converts it to scene object groups and scene presences,
/// swaps the current scene's entity list with the revision's list.
/// Note: Since deleted objects while
/// </summary>
public void RollbackRegion(Scene scene)
{
System.Collections.ArrayList xmllist = null;
SceneObjectGroup temp = null;
System.Collections.Hashtable deleteListUUIDs = new Hashtable();
// Dictionary<LLUUID, EntityBase> SearchList = new Dictionary<LLUUID,EntityBase>();
Dictionary<UUID, EntityBase> ReplacementList = new Dictionary<UUID,EntityBase>();
int revision = m_database.GetMostRecentRevision(scene.RegionInfo.RegionID);
// EntityBase[] searchArray;
xmllist = m_database.GetRegionObjectXMLList(scene.RegionInfo.RegionID, revision);
if (xmllist == null)
{
m_log.Info("[CMMODEL]: Region (" + scene.RegionInfo.RegionID + ") does not have given revision number (" + revision + ").");
return;
}
m_log.Info("[CMMODEL]: Region (" + scene.RegionInfo.RegionID + ") revision number (" + revision + ").");
m_log.Info("[CMMODEL]: Scene Objects = " + xmllist.Count);
m_log.Info("[CMMODEL]: Converting scene entities list to specified revision.");
m_log.ErrorFormat("[CMMODEL]: 1");
foreach (string xml in xmllist)
{
try
{
temp = SceneObjectSerializer.FromXml2Format(xml);
temp.SetScene(scene);
foreach (SceneObjectPart part in temp.Children.Values)
part.RegionHandle = scene.RegionInfo.RegionHandle;
ReplacementList.Add(temp.UUID, (EntityBase)temp);
}
catch (Exception e)
{
m_log.Info("[CMMODEL]: Error while creating replacement list for rollback: " + e);
}
}
//If in scene but not in revision and not a client, remove them
while (true)
{
try
{
foreach (EntityBase entity in scene.GetEntities())
{
if (entity == null)
continue;
if (entity is ScenePresence)
{
ReplacementList.Add(entity.UUID, entity);
continue;
}
else //if (!ReplacementList.ContainsKey(entity.UUID))
deleteListUUIDs.Add(entity.UUID, 0);
}
}
catch(Exception e)
{
m_log.ErrorFormat("[CMMODEL]: " + e);
deleteListUUIDs.Clear();
ReplacementList.Clear();
continue;
}
break;
}
foreach (UUID uuid in deleteListUUIDs.Keys)
{
try
{
// I thought that the DeleteGroup() function would handle all of this, but it doesn't. I'm not sure WHAT it handles.
((SceneObjectGroup)scene.Entities[uuid]).DetachFromBackup();
scene.PhysicsScene.RemovePrim(((SceneObjectGroup)scene.Entities[uuid]).RootPart.PhysActor);
scene.SendKillObject(scene.Entities[uuid].LocalId);
scene.SceneGraph.DeleteSceneObject(uuid, false);
((SceneObjectGroup)scene.Entities[uuid]).DeleteGroup(false);
}
catch(Exception e)
{
m_log.ErrorFormat("[CMMODEL]: Error while removing objects from scene: " + e);
}
}
lock (scene)
{
scene.Entities.Clear();
foreach (KeyValuePair<UUID,EntityBase> kvp in ReplacementList)
{
scene.Entities.Add(kvp.Value);
}
}
//.........这里部分代码省略.........
示例8: EventManager_OnPrimsLoaded
void EventManager_OnPrimsLoaded(Scene s)
{
// let's sniff all the user names referenced by objects in the scene
m_log.DebugFormat("[USER MANAGEMENT MODULE]: Caching creators' data from {0} ({1} objects)...", s.RegionInfo.RegionName, s.GetEntities().Length);
s.ForEachSOG(delegate(SceneObjectGroup sog) { CacheCreators(sog); });
}
示例9: SaveNamedPrimsToXml2
public static void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName)
{
m_log.InfoFormat(
"[SERIALISER]: Saving prims with name {0} in xml2 format for region {1} to {2}",
primName, scene.RegionInfo.RegionName, fileName);
List<EntityBase> entityList = scene.GetEntities();
List<EntityBase> primList = new List<EntityBase>();
foreach (EntityBase ent in entityList)
{
if (ent is SceneObjectGroup)
{
if (ent.Name == primName)
{
primList.Add(ent);
}
}
}
SavePrimListToXml2(primList, fileName);
}
示例10: SavePrimsToXml2
public static void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max)
{
List<EntityBase> EntityList = scene.GetEntities();
SavePrimListToXml2(EntityList, stream, min, max);
}
示例11: GetAssetList
/// <summary>
/// Gets list of assets
/// </summary>
/// <param name="scene">The scene where to get the assets</param>
/// <param name="assetType">Type of the assets to get</param>
/// <returns>Dictinary of assets found</returns>
public static Dictionary<UUID, AssetBase> GetAssetList(Scene scene, int assetType)
{
Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>();
List<EntityBase> entities = scene.GetEntities();
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
Dictionary<UUID, AssetBase> foundObjects = new Dictionary<UUID, AssetBase>();
foreach (EntityBase entity in entities)
{
if (entity is SceneObjectGroup)
{
SceneObjectGroup sceneObject = (SceneObjectGroup)entity;
if (!sceneObject.IsDeleted && !sceneObject.IsAttachment)
sceneObjects.Add((SceneObjectGroup)entity);
}
}
UuidGatherer assetGatherer = new UuidGatherer(scene.AssetService);
if (assetType == 0 || assetType == 1) //do this only for textures and sounds
{
foreach (SceneObjectGroup sceneObject in sceneObjects)
{
assetGatherer.GatherAssetUuids(sceneObject, assetUuids);
}
}
ModrexObjects module = scene.RequestModuleInterface<ModrexObjects>();
if (module != null)
{
foreach (SceneObjectGroup sceneObject in sceneObjects)
{
RexObjectProperties rop = module.GetObject(sceneObject.RootPart.UUID);
AssetBase asset;
switch (assetType)
{
case 1: //sound
if (rop.RexSoundUUID != UUID.Zero)
{
asset = scene.AssetService.Get(rop.RexSoundUUID.ToString());
if (asset != null && !foundObjects.ContainsKey(asset.FullID))
{
foundObjects.Add(asset.FullID, asset);
}
}
break;
case 6: //3d
if (rop.RexMeshUUID != UUID.Zero)
{
asset = scene.AssetService.Get(rop.RexMeshUUID.ToString());
if (asset != null && !foundObjects.ContainsKey(asset.FullID))
{
foundObjects.Add(asset.FullID, asset);
}
}
if (rop.RexCollisionMeshUUID != UUID.Zero)
{
asset = scene.AssetService.Get(rop.RexCollisionMeshUUID.ToString());
if (asset != null && !foundObjects.ContainsKey(asset.FullID))
{
foundObjects.Add(asset.FullID, asset);
}
}
break;
case 0: //texture
foreach (KeyValuePair<uint, RexMaterialsDictionaryItem> kvp in rop.GetRexMaterials())
{
asset = scene.AssetService.Get(kvp.Value.AssetID.ToString());
if (asset != null && (int)asset.Type == assetType && !foundObjects.ContainsKey(asset.FullID))
{
foundObjects.Add(asset.FullID, asset);
}
}
break;
case 41: //Particle
if (rop.RexParticleScriptUUID != UUID.Zero)
{
asset = scene.AssetService.Get(rop.RexParticleScriptUUID.ToString());
if (asset != null && !foundObjects.ContainsKey(asset.FullID))
{
foundObjects.Add(asset.FullID, asset);
}
}
break;
case 45: //Material
foreach (KeyValuePair<uint, RexMaterialsDictionaryItem> kvp in rop.GetRexMaterials())
{
asset = scene.AssetService.Get(kvp.Value.AssetID.ToString());
if (asset != null && (int)asset.Type == assetType && !foundObjects.ContainsKey(asset.FullID))
{
foundObjects.Add(asset.FullID, asset);
//.........这里部分代码省略.........
示例12: CheckForNewEntitiesMissingAuras
/// <summary>
/// Compares the scene's object group list to the list of meta entities. If there is an object group that does not have a corresponding meta entity
/// it is a new part that must have a green aura (for diff mode).
/// Returns list of ContentManagementEntities
/// </summary>
public ArrayList CheckForNewEntitiesMissingAuras(Scene scene)
{
ArrayList missingList = null;
ArrayList newList = new ArrayList();
m_log.Debug("[CONTENT MANAGEMENT] Checking for new scene object parts in scene: " + scene.RegionInfo.RegionName);
//Check if the current scene has groups not included in the current list of MetaEntities
//If so, then the current scene's parts that are new should be marked green.
missingList = m_MetaEntityCollection.CheckForMissingEntities(scene.GetEntities());
foreach (Object missingPart in missingList)
{
if (m_MetaEntityCollection.Auras.ContainsKey(((SceneObjectPart)missingPart).UUID))
continue;
newList.Add(m_MetaEntityCollection.CreateAuraForNewlyCreatedEntity((SceneObjectPart)missingPart));
}
m_log.Info("Number of missing objects found: " + newList.Count);
return newList;
}
示例13: SummarizePopulation
public void SummarizePopulation(Scene m_scene)
{
//Summarize the population data for each scene in scenes
List <String> names = new List <String>();
lock (m_scene)
{
m_regionCount++;
EntityBase[] everyObject = m_scene.GetEntities();
foreach (EntityBase e in everyObject)
{
if (e is SceneObjectGroup) // ignore avatars
{
SceneObjectGroup sog = (SceneObjectGroup)e;
names.Add(sog.Name);
}
}
}
foreach (String name in names)
{
if (name.Length > 4) //avoid an exception on scene objects with short names
{
String objectType = name.Substring(0,5);
if (objectType == "Spore")
{
m_spores++;
int haplo = Int32.Parse(name.Substring(5)); //Parse the haplotype from the object name
m_sporeHaplotypes[haplo]++;
}
else if (objectType == "Gamet")
{
m_gametophytes++;
int haplo = Int32.Parse(name.Substring(5)); //Parse the haplotype from the object name
m_gametHaplotypes[haplo]++;
}
else if (objectType == "Sporo")
{
m_sporophytes++;
int geno = Int32.Parse(name.Substring(5)); //Parse the genotype from the object name
int haplo1 = (m_haplotypes - 1) & geno;
m_sporoHaplotypes[haplo1]++;
int haplo2 = (geno >> m_loci) & (m_haplotypes - 1);
m_sporoHaplotypes[haplo2]++;
int locus = 1;
for(int i = 0; i<m_loci; i++)
{
if ((haplo1 & locus) == (haplo2 & locus))
{
//It is homozygous
if ((haplo1 & locus) == locus)
{
//It is homozygous dominant so it has 2 dominant alleles
m_dominantAlleles[i] = m_dominantAlleles[i] + 2;
}
}
else
{
//It is heterozygous so it has one dominant allele
m_heterozygotes[i]++;
m_dominantAlleles[i]++;
}
locus = locus * 2;
}
}
}
}
}
示例14: SavePrimsToXml
public static void SavePrimsToXml(Scene scene, string fileName)
{
FileStream file = new FileStream(fileName, FileMode.Create);
StreamWriter stream = new StreamWriter(file);
int primCount = 0;
stream.WriteLine("<scene>\n");
List<EntityBase> EntityList = scene.GetEntities();
foreach (EntityBase ent in EntityList)
{
if (ent is SceneObjectGroup)
{
stream.WriteLine(SceneObjectSerializer.ToOriginalXmlFormat((SceneObjectGroup)ent));
primCount++;
}
}
stream.WriteLine("</scene>\n");
stream.Close();
file.Close();
}
示例15: ArchiveOneRegion
private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, sbyte> assetUuids)
{
m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.Name);
EntityBase[] entities = scene.GetEntities();
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
int numObjectsSkippedPermissions = 0;
// Filter entities so that we only have scene objects.
// FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods
// end up having to do this
IPermissionsModule permissionsModule = scene.RequestModuleInterface<IPermissionsModule>();
foreach (EntityBase entity in entities)
{
if (entity is SceneObjectGroup)
{
SceneObjectGroup sceneObject = (SceneObjectGroup)entity;
if (!sceneObject.IsDeleted && !sceneObject.IsAttachment)
{
if (!CanUserArchiveObject(scene.RegionInfo.EstateSettings.EstateOwner, sceneObject, FilterContent, permissionsModule))
{
// The user isn't allowed to copy/transfer this object, so it will not be included in the OAR.
++numObjectsSkippedPermissions;
}
else
{
sceneObjects.Add(sceneObject);
}
}
}
}
if (SaveAssets)
{
UuidGatherer assetGatherer = new UuidGatherer(scene.AssetService, assetUuids);
int prevAssets = assetUuids.Count;
foreach (SceneObjectGroup sceneObject in sceneObjects)
assetGatherer.AddForInspection(sceneObject);
assetGatherer.GatherAll();
m_log.DebugFormat(
"[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets",
sceneObjects.Count, assetUuids.Count - prevAssets);
}
if (numObjectsSkippedPermissions > 0)
{
m_log.DebugFormat(
"[ARCHIVER]: {0} scene objects skipped due to lack of permissions",
numObjectsSkippedPermissions);
}
// Make sure that we also request terrain texture assets
RegionSettings regionSettings = scene.RegionInfo.RegionSettings;
if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1)
assetUuids[regionSettings.TerrainTexture1] = (sbyte)AssetType.Texture;
if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2)
assetUuids[regionSettings.TerrainTexture2] = (sbyte)AssetType.Texture;
if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3)
assetUuids[regionSettings.TerrainTexture3] = (sbyte)AssetType.Texture;
if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
assetUuids[regionSettings.TerrainTexture4] = (sbyte)AssetType.Texture;
Save(scene, sceneObjects, regionDir);
}