本文整理汇总了C#中PhysicsScene类的典型用法代码示例。如果您正苦于以下问题:C# PhysicsScene类的具体用法?C# PhysicsScene怎么用?C# PhysicsScene使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PhysicsScene类属于命名空间,在下文中一共展示了PhysicsScene类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestScene
public TestScene(
RegionInfo regInfo, AgentCircuitManager authen, PhysicsScene physicsScene,
SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService,
IConfigSource config, string simulatorVersion)
: base(regInfo, authen, physicsScene, sceneGridService, simDataService, estateDataService,
config, simulatorVersion)
{
}
示例2: Create
public Simulation Create(PhysicsProcessor sceneProcessor, PhysicsEngineFlags flags = PhysicsEngineFlags.None)
{
var scene = new PhysicsScene { Processor = sceneProcessor, Simulation = new Simulation(flags) };
lock (this)
{
scenes.Add(scene);
}
return scene.Simulation;
}
示例3: Initialize
public void Initialize()
{
IConfigSource openSimINI = new IniConfigSource();
IConfig startupConfig = openSimINI.AddConfig("Startup");
startupConfig.Set("physics", "OpenDynamicsEngine");
startupConfig.Set("DecodedSculptMapPath", "j2kDecodeCache");
Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
//PhysicsScene pScene = physicsPluginManager.GetPhysicsScene(
// "BulletSim", "Meshmerizer", openSimINI, "BSTestRegion", regionExtent);
RegionInfo info = new RegionInfo();
info.RegionName = "ODETestRegion";
info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize;
OpenSim.Region.Framework.Scenes.Scene scene = new OpenSim.Region.Framework.Scenes.Scene(info);
//IMesher mesher = new OpenSim.Region.PhysicsModules.Meshing.Meshmerizer();
//INonSharedRegionModule mod = mesher as INonSharedRegionModule;
//mod.Initialise(openSimINI);
//mod.AddRegion(scene);
//mod.RegionLoaded(scene);
pScene = new OdeScene();
Console.WriteLine("HERE " + (pScene == null ? "Null" : "Not null"));
INonSharedRegionModule mod = (pScene as INonSharedRegionModule);
Console.WriteLine("HERE " + (mod == null ? "Null" : "Not null"));
mod.Initialise(openSimINI);
mod.AddRegion(scene);
mod.RegionLoaded(scene);
// Loading ODEPlugin
//cbt = new OdePlugin();
// Getting Physics Scene
//ps = cbt.GetScene("test");
// Initializing Physics Scene.
//ps.Initialise(imp.GetMesher(TopConfig), null, Vector3.Zero);
float[] _heightmap = new float[(int)Constants.RegionSize * (int)Constants.RegionSize];
for (int i = 0; i < ((int)Constants.RegionSize * (int)Constants.RegionSize); i++)
{
_heightmap[i] = 21f;
}
pScene.SetTerrain(_heightmap);
}
示例4: PhysicalSpriteUV
public PhysicalSpriteUV(TextureInfo textureInfo, PhysicsScene physicsScene, bool circle = false)
: base(textureInfo)
{
// Texture Setup
Quad.S = TextureInfo.TextureSizef;
Pivot = new Vector2(TextureInfo.Texture.Width / 2f, TextureInfo.Texture.Height / 2f );
// Physics Setup (get the indicies we will be using
PhysicsScene = physicsScene;
ShapeIndex = PhysicsScene.NumShape;
BodyIndex = PhysicsScene.NumBody;
JointIndex = -1;
// Create shapes (will want to let the programmer pass in things like friction and rotation at some point, AND SPECIFY CIRCLE OR SQUARE SHAPE)
PhysicsShape shape;
if(!circle)
{
shape = new PhysicsShape(new Vector2(textureInfo.Texture.Width/2, textureInfo.Texture.Height/2));
}
else
{
shape = new PhysicsShape(textureInfo.Texture.Width/2);
}
// Why 100?
PhysicsBody body = new PhysicsBody(shape, 100);
body.ShapeIndex = (uint)ShapeIndex;
PhysicsScene.sceneShapes[ShapeIndex] = shape;
PhysicsScene.sceneBodies[BodyIndex] = body;
//PhysicsScene.sceneBodies[BodyIndex].Rotation = 0.1f;
//PhysicsScene.sceneBodies[BodyIndex].AirFriction = 0.01f;
PhysicsScene.NumShape++;
PhysicsScene.NumBody++;
}
示例5: Scene
public Scene(RegionInfo regInfo, AgentCircuitManager authen, PhysicsScene physicsScene,
SceneCommunicationService sceneGridService,
ISimulationDataService simDataService, IEstateDataService estateDataService,
IConfigSource config, string simulatorVersion)
: this(regInfo, physicsScene)
{
m_config = config;
MinFrameTime = 0.089f;
MinMaintenanceTime = 1;
SeeIntoRegion = true;
Random random = new Random();
m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4);
m_authenticateHandler = authen;
m_sceneGridService = sceneGridService;
m_SimulationDataService = simDataService;
m_EstateDataService = estateDataService;
m_regionHandle = RegionInfo.RegionHandle;
m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
m_asyncSceneObjectDeleter.Enabled = true;
m_asyncInventorySender = new AsyncInventorySender(this);
#region Region Settings
// Load region settings
// LoadRegionSettings creates new region settings in persistence if they don't already exist for this region.
// However, in this case, the default textures are not set in memory properly, so we need to do it here and
// resave.
// FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new
// region is set up and avoid these gyrations.
RegionSettings rs = simDataService.LoadRegionSettings(RegionInfo.RegionID);
m_extraSettings = simDataService.GetExtra(RegionInfo.RegionID);
bool updatedTerrainTextures = false;
if (rs.TerrainTexture1 == UUID.Zero)
{
rs.TerrainTexture1 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_1;
updatedTerrainTextures = true;
}
if (rs.TerrainTexture2 == UUID.Zero)
{
rs.TerrainTexture2 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_2;
updatedTerrainTextures = true;
}
if (rs.TerrainTexture3 == UUID.Zero)
{
rs.TerrainTexture3 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_3;
updatedTerrainTextures = true;
}
if (rs.TerrainTexture4 == UUID.Zero)
{
rs.TerrainTexture4 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_4;
updatedTerrainTextures = true;
}
if (updatedTerrainTextures)
rs.Save();
RegionInfo.RegionSettings = rs;
if (estateDataService != null)
RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false);
#endregion Region Settings
//Bind Storage Manager functions to some land manager functions for this scene
EventManager.OnLandObjectAdded +=
new EventManager.LandObjectAdded(simDataService.StoreLandObject);
EventManager.OnLandObjectRemoved +=
new EventManager.LandObjectRemoved(simDataService.RemoveLandObject);
RegisterDefaultSceneEvents();
// XXX: Don't set the public property since we don't want to activate here. This needs to be handled
// better in the future.
m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts;
PhysicsEnabled = !RegionInfo.RegionSettings.DisablePhysics;
m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")";
#region Region Config
// Region config overrides global config
//
if (m_config.Configs["Startup"] != null)
{
IConfig startupConfig = m_config.Configs["Startup"];
StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance);
UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup);
if (!UseBackup)
//.........这里部分代码省略.........
示例6: UnCombine
// Unhook all the combining that I know about.
public void UnCombine(PhysicsScene pScene)
{
// Just like ODE, for the moment a NOP
DetailLog("{0},BSTerrainManager.UnCombine", BSScene.DetailLogZero);
}
示例7: MainScene_PostStep
void MainScene_PostStep( PhysicsScene scene )
{
if( mainBody != null && !mainBody.Sleeping )
UpdateRotation( false );
}
示例8: SceneHelpers
public SceneHelpers(CoreAssetCache cache)
{
SceneManager = new SceneManager();
m_assetService = StartAssetService(cache);
m_authenticationService = StartAuthenticationService();
m_inventoryService = StartInventoryService();
m_gridService = StartGridService();
m_userAccountService = StartUserAccountService();
m_presenceService = StartPresenceService();
m_inventoryService.PostInitialise();
m_assetService.PostInitialise();
m_userAccountService.PostInitialise();
m_presenceService.PostInitialise();
m_cache = cache;
m_physicsScene = StartPhysicsScene();
SimDataService
= OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
}
示例9: Combine
// This routine is called two ways:
// One with 'offset' and 'pScene' zero and null but 'extents' giving the maximum
// extent of the combined regions. This is to inform the parent of the size
// of the combined regions.
// and one with 'offset' as the offset of the child region to the base region,
// 'pScene' pointing to the parent and 'extents' of zero. This informs the
// child of its relative base and new parent.
public void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
{
m_worldOffset = offset;
m_worldMax = extents;
MegaRegionParentPhysicsScene = pScene;
if (pScene != null)
{
// We are a child.
// We want m_worldMax to be the highest coordinate of our piece of terrain.
m_worldMax = offset + DefaultRegionSize;
}
DetailLog("{0},BSTerrainManager.Combine,offset={1},extents={2},wOffset={3},wMax={4}",
BSScene.DetailLogZero, offset, extents, m_worldOffset, m_worldMax);
}
示例10: BSTerrainManager
public BSTerrainManager(BSScene physicsScene)
{
PhysicsScene = physicsScene;
m_terrains = new Dictionary<Vector3,BSTerrainPhys>();
// Assume one region of default size
m_worldOffset = Vector3.Zero;
m_worldMax = new Vector3(DefaultRegionSize);
MegaRegionParentPhysicsScene = null;
}
示例11: AddPhysicsStats
public virtual void AddPhysicsStats(UUID RegionID, PhysicsScene scene)
{
lock (m_currentPhysicsStats)
{
PhysicsStats stats;
if (!m_currentPhysicsStats.TryGetValue(RegionID, out stats))
{
stats = new PhysicsStats();
stats.StatAvatarUpdatePosAndVelocity = scene.StatAvatarUpdatePosAndVelocity;
stats.StatCollisionOptimizedTime = scene.StatCollisionOptimizedTime;
stats.StatPhysicsMoveTime = scene.StatPhysicsMoveTime;
stats.StatPhysicsTaintTime = scene.StatPhysicsTaintTime;
stats.StatPrimUpdatePosAndVelocity = scene.StatPrimUpdatePosAndVelocity;
stats.StatSendCollisionsTime = scene.StatSendCollisionsTime;
stats.StatUnlockedArea = scene.StatUnlockedArea;
stats.StatFindContactsTime = scene.StatFindContactsTime;
stats.StatContactLoopTime = scene.StatContactLoopTime;
stats.StatCollisionAccountingTime = scene.StatCollisionAccountingTime;
}
else
{
stats.StatAvatarUpdatePosAndVelocity += scene.StatAvatarUpdatePosAndVelocity;
stats.StatCollisionOptimizedTime += scene.StatCollisionOptimizedTime;
stats.StatPhysicsMoveTime += scene.StatPhysicsMoveTime;
stats.StatPhysicsTaintTime += scene.StatPhysicsTaintTime;
stats.StatPrimUpdatePosAndVelocity += scene.StatPrimUpdatePosAndVelocity;
stats.StatSendCollisionsTime += scene.StatSendCollisionsTime;
stats.StatUnlockedArea += scene.StatUnlockedArea;
stats.StatFindContactsTime += scene.StatFindContactsTime;
stats.StatContactLoopTime += scene.StatContactLoopTime;
stats.StatCollisionAccountingTime += scene.StatCollisionAccountingTime;
}
m_currentPhysicsStats[RegionID] = stats;
PhysicsStats ProfilerStats = new PhysicsStats();
ProfilerStats.StatAvatarUpdatePosAndVelocity = scene.StatAvatarUpdatePosAndVelocity;
ProfilerStats.StatCollisionOptimizedTime = scene.StatCollisionOptimizedTime;
ProfilerStats.StatPhysicsMoveTime = scene.StatPhysicsMoveTime;
ProfilerStats.StatPhysicsTaintTime = scene.StatPhysicsTaintTime;
ProfilerStats.StatPrimUpdatePosAndVelocity = scene.StatPrimUpdatePosAndVelocity;
ProfilerStats.StatSendCollisionsTime = scene.StatSendCollisionsTime;
ProfilerStats.StatUnlockedArea = scene.StatUnlockedArea;
ProfilerStats.StatFindContactsTime = scene.StatFindContactsTime;
ProfilerStats.StatContactLoopTime = scene.StatContactLoopTime;
ProfilerStats.StatCollisionAccountingTime = scene.StatCollisionAccountingTime;
//Add the stats to the profiler
Profiler p = ProfilerManager.GetProfiler();
p.AddStat("CurrentStatAvatarUpdatePosAndVelocity " + RegionID,
ProfilerStats.StatAvatarUpdatePosAndVelocity);
p.AddStat("CurrentStatCollisionOptimizedTime " + RegionID,
ProfilerStats.StatCollisionOptimizedTime);
p.AddStat("CurrentStatPhysicsMoveTime " + RegionID,
ProfilerStats.StatPhysicsMoveTime);
p.AddStat("CurrentStatPhysicsTaintTime " + RegionID,
ProfilerStats.StatPhysicsTaintTime);
p.AddStat("CurrentStatPrimUpdatePosAndVelocity " + RegionID,
ProfilerStats.StatPrimUpdatePosAndVelocity);
p.AddStat("CurrentStatSendCollisionsTime " + RegionID,
ProfilerStats.StatSendCollisionsTime);
p.AddStat("CurrentStatUnlockedArea " + RegionID,
ProfilerStats.StatUnlockedArea);
p.AddStat("CurrentStatFindContactsTime " + RegionID,
ProfilerStats.StatFindContactsTime);
p.AddStat("CurrentStatContactLoopTime " + RegionID,
ProfilerStats.StatContactLoopTime);
p.AddStat("CurrentStatCollisionAccountingTime " + RegionID,
ProfilerStats.StatCollisionAccountingTime);
}
}
示例12: BSTerrainManager
public BSTerrainManager(BSScene physicsScene)
{
PhysicsScene = physicsScene;
m_heightMaps = new Dictionary<Vector2,BulletHeightMapInfo>();
m_terrainModified = false;
// Assume one region of default size
m_worldOffset = Vector3.Zero;
m_worldMax = new Vector3(DefaultRegionSize);
MegaRegionParentPhysicsScene = null;
}
示例13: Combine
public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
{
m_worldOffset = offset;
WorldExtents = new Vector2(extents.X, extents.Y);
m_parentScene = pScene;
}
示例14: UnCombine
public override void UnCombine(PhysicsScene pScene)
{
IntPtr localGround = IntPtr.Zero;
// float[] localHeightfield;
bool proceed = false;
List<IntPtr> geomDestroyList = new List<IntPtr>();
lock (OdeLock)
{
if (RegionTerrain.TryGetValue(Vector3.Zero, out localGround))
{
foreach (IntPtr geom in TerrainHeightFieldHeights.Keys)
{
if (geom == localGround)
{
// localHeightfield = TerrainHeightFieldHeights[geom];
proceed = true;
}
else
{
geomDestroyList.Add(geom);
}
}
if (proceed)
{
m_worldOffset = Vector3.Zero;
WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize);
m_parentScene = null;
foreach (IntPtr g in geomDestroyList)
{
// removingHeightField needs to be done or the garbage collector will
// collect the terrain data before we tell ODE to destroy it causing
// memory corruption
if (TerrainHeightFieldHeights.ContainsKey(g))
{
// float[] removingHeightField = TerrainHeightFieldHeights[g];
TerrainHeightFieldHeights.Remove(g);
if (RegionTerrain.ContainsKey(g))
{
RegionTerrain.Remove(g);
}
d.GeomDestroy(g);
//removingHeightField = new float[0];
}
}
}
else
{
m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data.");
}
}
}
}
示例15: Combine
public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) {}