本文整理汇总了C#中OpenSim.Region.Framework.Scenes.Scene.AddNewSceneObject方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.AddNewSceneObject方法的具体用法?C# Scene.AddNewSceneObject怎么用?C# Scene.AddNewSceneObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSim.Region.Framework.Scenes.Scene
的用法示例。
在下文中一共展示了Scene.AddNewSceneObject方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadPrimsFromXml
public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset)
{
XmlDocument doc = new XmlDocument();
XmlNode rootNode;
if (fileName.StartsWith("http:") || File.Exists(fileName))
{
XmlTextReader reader = new XmlTextReader(fileName);
reader.WhitespaceHandling = WhitespaceHandling.None;
doc.Load(reader);
reader.Close();
rootNode = doc.FirstChild;
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
{
SceneObjectGroup obj = SceneObjectSerializer.FromOriginalXmlFormat(aPrimNode.OuterXml);
if (newIDS)
{
obj.ResetIDs();
}
//if we want this to be a import method then we need new uuids for the object to avoid any clashes
//obj.RegenerateFullIDs();
scene.AddNewSceneObject(obj, true);
}
}
else
{
throw new Exception("Could not open file " + fileName + " for reading");
}
}
示例2: CreateTestObjects
private void CreateTestObjects(Scene scene, out SceneObjectGroup sog1, out SceneObjectGroup sog2, out UUID ncAssetUuid)
{
SceneObjectPart part1 = CreateSceneObjectPart1();
sog1 = new SceneObjectGroup(part1);
scene.AddNewSceneObject(sog1, false);
AssetNotecard nc = new AssetNotecard();
nc.BodyText = "Hello World!";
nc.Encode();
ncAssetUuid = UUID.Random();
UUID ncItemUuid = UUID.Random();
AssetBase ncAsset
= AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);
m_scene.AssetService.Store(ncAsset);
TaskInventoryItem ncItem
= new TaskInventoryItem { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid };
SceneObjectPart part2 = CreateSceneObjectPart2();
sog2 = new SceneObjectGroup(part2);
part2.Inventory.AddInventoryItem(ncItem, true);
scene.AddNewSceneObject(sog2, false);
}
示例3: AddSceneObject
/// <summary>
/// Add a test object
/// </summary>
/// <param name="scene"></param>
/// <param name="parts">
/// The number of parts that should be in the scene object
/// </param>
/// <param name="ownerId"></param>
/// <param name="partNamePrefix">
/// The prefix to be given to part names. This will be suffixed with "Part<part no>"
/// (e.g. mynamePart1 for the root part)
/// </param>
/// <param name="uuidTail">
/// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
/// will be given to the root part, and incremented for each part thereafter.
/// </param>
/// <returns></returns>
public static SceneObjectGroup AddSceneObject(Scene scene, int parts, UUID ownerId, string partNamePrefix, int uuidTail)
{
SceneObjectGroup so = CreateSceneObject(parts, ownerId, partNamePrefix, uuidTail);
scene.AddNewSceneObject(so, false);
return so;
}
示例4: AddSceneObject
/// <summary>
/// Add a test object
/// </summary>
/// <param name="scene"></param>
/// <param name="name"></param>
/// <returns></returns>
public static SceneObjectPart AddSceneObject(Scene scene, string name)
{
SceneObjectPart part
= new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
part.Name = name;
//part.UpdatePrimFlags(false, false, true);
//part.ObjectFlags |= (uint)PrimFlags.Phantom;
scene.AddNewSceneObject(new SceneObjectGroup(part), false);
return part;
}
示例5: AddSceneObject
/// <summary>
/// Add a test object
/// </summary>
/// <param name="scene"></param>
/// <param name="name"></param>
/// <returns></returns>
public static SceneObjectPart AddSceneObject(Scene scene, string name)
{
SceneObjectPart part = CreateSceneObjectPart(name, UUID.Random(), UUID.Zero);
//part.UpdatePrimFlags(false, false, true);
//part.ObjectFlags |= (uint)PrimFlags.Phantom;
scene.AddNewSceneObject(new SceneObjectGroup(part), false);
return part;
}
示例6: CreateHelloWorldObject
private void CreateHelloWorldObject(Scene scene)
{
// We're going to write HELLO with prims
// SOG represents a linked group of objects, the link sets in SL, with root part and all
List<SceneObjectGroup> prims = new List<SceneObjectGroup>();
// First prim: |
Vector3 pos = new Vector3(120, 128, 30);
SceneObjectGroup sog = new SceneObjectGroup(UUID.Zero, pos, PrimitiveBaseShape.CreateBox());
sog.RootPart.Scale = new Vector3(0.3f, 0.3f, 2f);
prims.Add(sog);
// Second prim: -
pos = new Vector3(120.5f, 128f, 30f);
sog = new SceneObjectGroup(UUID.Zero, pos, PrimitiveBaseShape.CreateBox());
sog.RootPart.Scale = new Vector3(1, 0.3f, 0.3f);
prims.Add(sog);
// Third prim: |
pos = new Vector3(121, 128, 30);
sog = new SceneObjectGroup(UUID.Zero, pos, PrimitiveBaseShape.CreateBox());
sog.RootPart.Scale = new Vector3(0.3f, 0.3f, 2);
prims.Add(sog);
// Fourth prim: |
pos = new Vector3(122, 128, 30);
sog = new SceneObjectGroup(UUID.Zero, pos, PrimitiveBaseShape.CreateBox());
sog.RootPart.Scale = new Vector3(0.3f, 0.3f, 2);
prims.Add(sog);
// Fifth prim: - (up)
pos = new Vector3(122.5f, 128, 31);
sog = new SceneObjectGroup(UUID.Zero, pos, PrimitiveBaseShape.CreateBox());
sog.RootPart.Scale = new Vector3(1, 0.3f, 0.3f);
prims.Add(sog);
// Sixth prim: - (middle)
pos = new Vector3(122.5f, 128, 30);
sog = new SceneObjectGroup(UUID.Zero, pos, PrimitiveBaseShape.CreateBox());
sog.RootPart.Scale = new Vector3(1, 0.3f, 0.3f);
prims.Add(sog);
// Seventh prim: - (low)
pos = new Vector3(122.5f, 128, 29);
sog = new SceneObjectGroup(UUID.Zero, pos, PrimitiveBaseShape.CreateBox());
sog.RootPart.Scale = new Vector3(1, 0.3f, 0.3f);
prims.Add(sog);
// Eighth prim: |
pos = new Vector3(124, 128, 30);
sog = new SceneObjectGroup(UUID.Zero, pos, PrimitiveBaseShape.CreateBox());
sog.RootPart.Scale = new Vector3(0.3f, 0.3f, 2);
prims.Add(sog);
// Ninth prim: _
pos = new Vector3(124.5f, 128, 29);
sog = new SceneObjectGroup(UUID.Zero, pos, PrimitiveBaseShape.CreateBox());
sog.RootPart.Scale = new Vector3(1, 0.3f, 0.3f);
prims.Add(sog);
// Tenth prim: |
pos = new Vector3(126, 128, 30);
sog = new SceneObjectGroup(UUID.Zero, pos, PrimitiveBaseShape.CreateBox());
sog.RootPart.Scale = new Vector3(0.3f, 0.3f, 2);
prims.Add(sog);
// Eleventh prim: _
pos = new Vector3(126.5f, 128, 29);
sog = new SceneObjectGroup(UUID.Zero, pos, PrimitiveBaseShape.CreateBox());
sog.RootPart.Scale = new Vector3(1, 0.3f, 0.3f);
prims.Add(sog);
// Twelveth prim: O
pos = new Vector3(129, 128, 30);
sog = new SceneObjectGroup(UUID.Zero, pos, PrimitiveBaseShape.CreateBox());
sog.RootPart.Scale = new Vector3(2, 0.3f, 2);
prims.Add(sog);
// Add these to the managed objects
scene_prims.Add(scene, prims);
// Now place them visibly on the scene
foreach (SceneObjectGroup sogr in prims)
{
scene.AddNewSceneObject(sogr, false);
}
//
//ScenePresence avatar = scene.GetScenePresence("Test", "User");
//Vector3 location = new Vector3(128, 128, 50);
//avatar.MoveToTarget(location, true, true);
}
示例7: DoCoverview
void DoCoverview(Scene scene)
{
// We're going to place objects in world
displayed = slideCount - 1;
current = slideCount - 1;
for (int x=0;x<=(2*displayed);x++)
{
if (x< displayed)
{
position[x] = x;
updatedPosition[x] = x;
offset[x] = (x - (displayed + 10f)) * spacing;
}
if (x == displayed)
{
position[x] = x;
updatedPosition[x] = x;
offset[x] = 0.0f;
}
if (x > displayed)
{
offset[x] = (x - (displayed - 10f)) * spacing;
}
}
//Place prims in the region
for (int x=0; x<=displayed; x++)
{
Vector3 pos = new Vector3(rootPosition + offset[position[x]], yPosition, zPosition);
SceneObjectGroup sog = new SceneObjectGroup(UUID.Zero, pos, PrimitiveBaseShape.CreateBox());
if (x==displayed)
{
sog.UpdateGroupRotationR(new Quaternion(0,0,1,1));
}
sog.RootPart.Scale = size;
prims.Add(sog);
}
// Now make them visible
foreach (SceneObjectGroup sogr in prims)
{
scene.AddNewSceneObject(sogr, false);
}
}
示例8: SetupMatrix
void SetupMatrix(Scene scene)
{
// We're going to place a torus of dead cells in world
float twoPi = 2f * (float)Math.PI;
float uSpacing = twoPi / m_xCells;
float vSpacing = twoPi / m_yCells;
float uRadians = 0;
float vRadians = 0;
int counter = 0;
for (int y=0; y<m_yCells; y++)
{
for (int x=0; x<m_xCells; x++)
{
//Calculate the cell's position
float xPos = m_xCenter + ((m_aRadius + (m_bRadius *
(float)Math.Cos(vRadians))) *
(float)Math.Cos(uRadians));
float yPos = m_yCenter + ((m_aRadius + (m_bRadius *
(float)Math.Cos(vRadians))) *
(float)Math.Sin(uRadians));
float zPos = m_zCenter + (m_bRadius * (float)Math.Sin(vRadians));
Vector3 pos = new Vector3(xPos, yPos, zPos);
//Set the size, shape, texture, and color of the cell
PrimitiveBaseShape prim = PrimitiveBaseShape.CreateSphere();
//blank texture
prim.Textures = new Primitive.TextureEntry(new UUID("5748decc-f629-461c-9a36-a35a236fe36f"));
SceneObjectGroup sog = new SceneObjectGroup(UUID.Zero, pos, prim);
float size = 0.5f + (Math.Abs(((m_xCells-1) / 2f) - (float)x) / ((m_xCells-1) / 3f));
sog.RootPart.Scale = new Vector3(size, size, size);
Primitive.TextureEntry tex = sog.RootPart.Shape.Textures;
m_cellStatus[counter] = 0;
tex.DefaultTexture.RGBA = m_deadColor;
sog.RootPart.UpdateTexture(tex);
sog.RootPart.UpdatePrimFlags(false, false, true, false);
//Add the cell to the list of managed objects
m_prims.Add(sog);
vRadians = vRadians + vSpacing;
counter++;
}
uRadians = uRadians + uSpacing;
}
//Place the managed objects visibly into the scene
m_running = false;
foreach (SceneObjectGroup sogr in m_prims)
{
scene.AddNewSceneObject(sogr, false);
}
}
示例9: InitializeMatrix
void InitializeMatrix(Scene scene)
{
// We're going to place a grid of objects in world
for (int y=0; y<m_yCells; y++)
{
for (int x=0; x<m_xCells; x++)
{
Vector3 pos = new Vector3(m_xPos + (x * (m_cellSize + m_cellSpacing)),
m_yPos + (y * (m_cellSize + m_cellSpacing)),
m_zPos);
PrimitiveBaseShape prim = PrimitiveBaseShape.CreateBox();
prim.Textures = new Primitive.TextureEntry(new UUID("5748decc-f629-461c-9a36-a35a221fe21f"));
SceneObjectGroup sog = new SceneObjectGroup(UUID.Zero, pos, prim);
sog.RootPart.Scale = new Vector3(m_cellSize, m_cellSize, 0.1f);
Primitive.TextureEntry tex = sog.RootPart.Shape.Textures;
float randomValue = (float)m_random.NextDouble();
Color4 texcolor = new Color4(randomValue, randomValue, randomValue, 1.0f);
m_matrix[y * m_xCells + x] = randomValue;
tex.DefaultTexture.RGBA = texcolor;
sog.RootPart.UpdateTexture(tex);
m_prims.Add(sog);
}
}
//Add these objects to the list of managed objects
//Place the objects visibly on the scene
foreach (SceneObjectGroup sogr in m_prims)
{
scene.AddNewSceneObject(sogr, false);
}
m_isHidden = false;
}