public PhysxPhysicWorld(CoreDescription CoreDescription, SceneDescription SceneDescription, bool connectToRemoteDebugger = false, bool safeAndSlowUpdate = true) { this.safeAndSlowUpdate = safeAndSlowUpdate; UserOutput output = new UserOutput(); this.Core = new Core(CoreDescription, output); Core core = this.Core; core.SetParameter(PhysicsParameter.VisualizationScale, 2.0f); core.SetParameter(PhysicsParameter.VisualizeCollisionShapes, true); core.SetParameter(PhysicsParameter.VisualizeClothMesh, true); core.SetParameter(PhysicsParameter.VisualizeJointLocalAxes, true); core.SetParameter(PhysicsParameter.VisualizeJointLimits, true); core.SetParameter(PhysicsParameter.VisualizeFluidPosition, true); core.SetParameter(PhysicsParameter.VisualizeFluidEmitters, false); // Slows down rendering a bit too much core.SetParameter(PhysicsParameter.VisualizeForceFields, true); core.SetParameter(PhysicsParameter.VisualizeSoftBodyMesh, true); this.Scene = core.CreateScene(SceneDescription); // Connect to the remote debugger if it's there if (connectToRemoteDebugger) core.Foundation.RemoteDebugger.Connect("localhost"); ControllerManager = Scene.CreateControllerManager(); objs = new List<IPhysicObject>(); ctns = new List<IPhysicConstraint>(); TriggerReport = new Physics.TriggerReport(); Scene.UserTriggerReport = TriggerReport; Utilities.ErrorReport = errorReport; }
public EngineScene() { //инит ФизиХ-а var coreDesc = new CoreDescription(); var output = new UserOutput(); Core = new Core(coreDesc, output); Core.SetParameter(PhysicsParameter.ContinuousCollisionDetection, false); Core.SetParameter(PhysicsParameter.ContinuousCollisionDetectionEpsilon, 0.01f); var sceneDesc = new SceneDescription { SimulationType = SimulationType.Software, //Hardware, MaximumBounds = new Bounds3(-1000, -1000, -1000, 1000, 1000, 1000), UpAxis = 2, Gravity = new StillDesign.PhysX.MathPrimitives.Vector3(0.0f, -9.81f * 1.7f, 0.0f), GroundPlaneEnabled = false }; Scene = Core.CreateScene(sceneDesc); //для обработки столкновений Scene.UserContactReport = new ContactReport(MyGame.Instance); _objects = new MyContainer<PivotObject>(100, 10, true); _visibleObjects = new MyContainer<PivotObject>(100, 2); _shadowObjects = new MyContainer<PivotObject>(100, 2); _sceneGraph = new SceneGraph.SceneGraph(this); }
public static void SwitchToMenuMode() { Debug.Assert(!isInitialized || gameMenu.isActiveAndEnabled, "Already in menu mode"); initMenu.gameObject.SetActive(isFirstRun); mainMenu.gameObject.SetActive(!isFirstRun); playMenu.gameObject.SetActive(false); optionsMenu.gameObject.SetActive(false); infoMenu.gameObject.SetActive(false); gameMenu.gameObject.SetActive(false); if (currentMap) { gameInstance.StartCoroutine(AsyncSceneUnloading()); Resources.UnloadUnusedAssets(); currentMap = null; } foreach (Controller player in allPlayers) { player.SetPanel(null); player.SetMode(Controller.Mode.MENU); player.gameObject.SetActive(false); } }
/* Saves all augmentations to disk. Each augmentation is represented by an AugmentationDescription and the entire scene is serialized as a SceneDescription. */ private void SaveScene() { var sceneDescription = new SceneDescription(); foreach (var augmentation in Controller.ActiveModels) { int id = GetAugmentationId(augmentation); if (id == -1) { /* Early return in case we cannot find the ID of an augmentation. */ Debug.LogError("Could not find ID for augmentation " + augmentation.name); return; } else { sceneDescription.Augmentations.Add(new AugmentationDescription(id, augmentation.transform)); } } try { string json = JsonUtility.ToJson(sceneDescription); File.WriteAllText(Application.persistentDataPath + "/InstantScene.json", json); } catch (Exception ex) { InfoMessage.text = "Error saving scene augmentations."; Debug.LogError("Error saving augmentations: " + ex.Message); } }
protected Core iniPhysics() { CoreDescription coreDesc = new CoreDescription(); Core core = new Core(coreDesc, null); core.SetParameter(PhysicsParameter.VisualizationScale, 2.0f); core.SetParameter(PhysicsParameter.VisualizeCollisionShapes, true); core.SetParameter(PhysicsParameter.VisualizeClothMesh, true); core.SetParameter(PhysicsParameter.VisualizeJointLocalAxes, true); core.SetParameter(PhysicsParameter.VisualizeJointLimits, true); core.SetParameter(PhysicsParameter.VisualizeFluidPosition, true); core.SetParameter(PhysicsParameter.VisualizeFluidEmitters, false); // Slows down rendering a bit too much core.SetParameter(PhysicsParameter.VisualizeForceFields, true); core.SetParameter(PhysicsParameter.VisualizeSoftBodyMesh, true); RemoteDebugger debugger = core.Foundation.RemoteDebugger; debugger.Connect("localhost"); if (debugger.IsConnected) { Console.Write("Debugger connected\n"); } SceneDescription sceneDesc = new SceneDescription(); sceneDesc.Gravity = new StillDesign.PhysX.MathPrimitives.Vector3(0, -10.0f, 0); scene = core.CreateScene(sceneDesc); return(core); }
public PhysxPhysicWorld(CoreDescription CoreDescription, SceneDescription SceneDescription, bool connectToRemoteDebugger = false, bool safeAndSlowUpdate = true) { this.safeAndSlowUpdate = safeAndSlowUpdate; UserOutput output = new UserOutput(); this.Core = new Core(CoreDescription, output); Core core = this.Core; core.SetParameter(PhysicsParameter.VisualizationScale, 2.0f); core.SetParameter(PhysicsParameter.VisualizeCollisionShapes, true); core.SetParameter(PhysicsParameter.VisualizeClothMesh, true); core.SetParameter(PhysicsParameter.VisualizeJointLocalAxes, true); core.SetParameter(PhysicsParameter.VisualizeJointLimits, true); core.SetParameter(PhysicsParameter.VisualizeFluidPosition, true); core.SetParameter(PhysicsParameter.VisualizeFluidEmitters, false); // Slows down rendering a bit too much core.SetParameter(PhysicsParameter.VisualizeForceFields, true); core.SetParameter(PhysicsParameter.VisualizeSoftBodyMesh, true); this.Scene = core.CreateScene(SceneDescription); // Connect to the remote debugger if it's there if (connectToRemoteDebugger) { core.Foundation.RemoteDebugger.Connect("localhost"); } ControllerManager = Scene.CreateControllerManager(); objs = new List <IPhysicObject>(); ctns = new List <IPhysicConstraint>(); TriggerReport = new Physics.TriggerReport(); Scene.UserTriggerReport = TriggerReport; Utilities.ErrorReport = errorReport; }
// Main function to be called by GameController. // Passes in a description received over ROS or hardcoded. // LoadScene is responsible for loading all resources and putting them in // place, and attaching callbacks to created GameObjects, where these // callbacks involve functions from SceneManipulatorAPI. public void LoadPage(SceneDescription description) { this.setDisplayMode(description.displayMode); this.resetPanelSizes(); // Load audio. this.audioManager.LoadAudio(description.audioFile); if (description.isTitle) { // Special case for title page. // No TinkerTexts, and image takes up a larger space. this.loadTitlePage(description); } else { // Load image. this.loadImage(description.storyImageFile); // Load all words as TinkerText. Start at beginning of a stanza. this.remainingStanzaWidth = 0; List <string> textWords = new List <string>(description.text.Split(' ')); textWords.RemoveAll(String.IsNullOrEmpty); if (textWords.Count != description.timestamps.Length) { Logger.LogError("textWords doesn't match timestamps length " + textWords.Count.ToString() + " " + description.timestamps.Length.ToString()); } for (int i = 0; i < textWords.Count; i++) { // This will create the TinkerText and update stanzas. this.loadTinkerText(textWords[i], description.timestamps[i]); } // Set end timestamp of last stanza (edge case). this.stanzas[this.stanzas.Count - 1].GetComponent <Stanza>().SetEndTimestamp( this.tinkerTexts[this.tinkerTexts.Count - 1].GetComponent <TinkerText>().audioEndTime); // Load audio triggers for TinkerText. this.loadAudioTriggers(); } // Load all scene objects. foreach (SceneObject sceneObject in description.sceneObjects) { this.loadSceneObject(sceneObject); } // Load triggers. foreach (Trigger trigger in description.triggers) { this.loadTrigger(trigger); } if (this.autoplayAudio) { this.audioManager.PlayAudio(); } }
//---------------------------------------------------------------------------------------------------- void LoadSceneXML(string path) { var serializer = new XmlSerializer(typeof(SceneDescription)); var stream = new FileStream(path, FileMode.Open); xml = serializer.Deserialize(stream) as SceneDescription; stream.Close(); }
public void SetScene(SceneDescription sceneDescription) { Position.Clear(); Position.Scene = sceneDescription; NotifyPropertyChanged("Position"); NotifyPropertyChanged("CanGoFurther"); NotifyPropertyChanged("CanGoBack"); }
// Helper function to wrap together two actions: // (1) loading a page and (2) sending the StorybookPageInfo message over ROS. private void loadPageAndSendRosMessage(SceneDescription sceneDescription) { // Load the page. this.storyManager.LoadPage(sceneDescription); // Send the ROS message to update the controller about what page we're on now. StorybookPageInfo updatedInfo = new StorybookPageInfo(); updatedInfo.storyName = this.currentStory.GetName(); updatedInfo.pageNumber = this.currentPageNumber; updatedInfo.sentences = this.storyManager.stanzaManager.GetAllSentenceTexts(); // Update state (will get automatically sent to the controller. StorybookStateManager.SetStorySelected(this.currentStory.GetName(), this.currentStory.GetNumPages()); // Gather information about scene objects. StorybookSceneObject[] sceneObjects = new StorybookSceneObject[sceneDescription.sceneObjects.Length]; for (int i = 0; i < sceneDescription.sceneObjects.Length; i++) { SceneObject so = sceneDescription.sceneObjects[i]; StorybookSceneObject sso = new StorybookSceneObject(); sso.id = so.id; sso.label = so.label; sso.inText = so.inText; sceneObjects[i] = sso; } updatedInfo.sceneObjects = sceneObjects; // Gather information about tinker texts. StorybookTinkerText[] tinkerTexts = new StorybookTinkerText[this.storyManager.tinkerTexts.Count]; for (int i = 0; i < this.storyManager.tinkerTexts.Count; i++) { TinkerText tt = this.storyManager.tinkerTexts[i].GetComponent <TinkerText>(); StorybookTinkerText stt = new StorybookTinkerText(); stt.word = tt.word; stt.hasSceneObject = false; stt.sceneObjectId = -1; tinkerTexts[i] = stt; } foreach (Trigger trigger in sceneDescription.triggers) { if (trigger.type == TriggerType.CLICK_TINKERTEXT_SCENE_OBJECT) { tinkerTexts[trigger.args.textId].hasSceneObject = true; tinkerTexts[trigger.args.textId].sceneObjectId = trigger.args.sceneObjectId; } } updatedInfo.tinkerTexts = tinkerTexts; // Send the message. if (Constants.USE_ROS) { this.rosManager.SendStorybookPageInfoAction(updatedInfo); } }
/// <summary> /// Allows physics to initialize itself and its parameters /// </summary> public void Initialize(GraphicsDevice graphicsDevice) { this.graphicsDevice = graphicsDevice; _visualizationEffect = new BasicEffect(this.graphicsDevice, null) { VertexColorEnabled = true }; _bCCDEnabled = false; //_visualizationEffect.EnableDefaultLighting(); var coreDesc = new CoreDescription(); var output = new UserOutput(); Core = new Core(coreDesc, output); //#if DEBUG //_core.SetParameter( PhysicsParameter.VisualizationScale, 2.0f ); Core.SetParameter(PhysicsParameter.VisualizationScale, 1.0f); Core.SetParameter(PhysicsParameter.VisualizeCollisionShapes, true); Core.SetParameter(PhysicsParameter.VisualizeClothMesh, true); Core.SetParameter(PhysicsParameter.VisualizeJointLocalAxes, true); Core.SetParameter(PhysicsParameter.VisualizeJointLimits, true); Core.SetParameter(PhysicsParameter.VisualizeFluidPosition, true); Core.SetParameter(PhysicsParameter.VisualizeFluidEmitters, false); // Slows down rendering a bit to much Core.SetParameter(PhysicsParameter.VisualizeForceFields, true); Core.SetParameter(PhysicsParameter.VisualizeSoftBodyMesh, true); Core.SetParameter(PhysicsParameter.DefaultSleepLinearVelocitySquared, 2.0f * 2.0f); Core.SetParameter(PhysicsParameter.DefaultSleepAngularVelocitySquared, 2.0f * 2.0f); Core.SetParameter(PhysicsParameter.VisualizeCollisionFaceNormals, true); //#endif //aLk's Data INIT Core.SetParameter(PhysicsParameter.SkinWidth, 0.01f); Core.SetParameter(PhysicsParameter.VisualizeActorAxes, true); //aLk's Data END var sceneDesc = new SceneDescription { SimulationType = SimulationType.Software, Gravity = new Vector3(0.0f, -9.81f, 0.0f) }; Scene = Core.CreateScene(sceneDesc); ControllerManager = Scene.CreateControllerManager(); //Lesson 05: Materials //Material defaultMat = _scene.Materials[0]; //defaultMat.Restitution = 0.25f; //defaultMat.StaticFriction = 0.5f; //defaultMat.DynamicFriction = 0.5f; //end lesson // Connect to the remote debugger if its there Core.Foundation.RemoteDebugger.Connect("localhost"); Core.SetParameter(PhysicsParameter.ContinuousCollisionDetection, true); }
/// <summary> /// /// </summary> /// <param name="sizex">Image width</param> /// <param name="sizey">Image height</param> /// <param name="scene">Scene description</param> /// <param name="frame">Number of frame rendered</param> /// <param name="quality">Render quality (default: Medium)</param> public RayProcessor(int sizex, int sizey, SceneDescription scene, int frame, RenderQuality quality, string outputPath) { this.sizex = sizex; this.sizey = sizey; this.frame = frame; sceneDescription = scene; this.Quality = quality; this.OutputPath = outputPath; }
private void CreateCoreAndScene(out Core core, out Scene scene) { var coreDesc = new CoreDescription(); core = new Core(coreDesc, null); var sceneDesc = new SceneDescription { SimulationType = SimulationType.Software//todo: ver cual es el lio con hardware }; scene = _wrappedCore.CreateScene(sceneDesc); }
private void CreateScene() { var coreDesc = new CoreDescription(); var core = new Core(coreDesc, null); var sceneDesc = new SceneDescription { Gravity = new NxVector3(0, -9.81f, 0), SimulationType = SimulationType.Software }; _scene = core.CreateScene(sceneDesc); }
public Scene CreateDefaultScene() { SceneDescription sceneDesc = new SceneDescription(); //SimulationType = SimulationType.Hardware, sceneDesc.Gravity = new Vector3(0.0f, -9.81f, 0.0f); sceneDesc.GroundPlaneEnabled = true; //sceneDesc.UserContactReport = new CustomContactReport(this); var scene = Core.CreateScene(sceneDesc); return(scene); }
private void LoadScenes(XmlNode parent) { if (parent.ChildNodes != null) { Scenes.Clear(); } SceneDescription d; foreach (XmlNode node in parent.ChildNodes) { d = new SceneDescription(); // traverse each attribute foreach (XmlAttribute a in node.Attributes) { switch (a.Name) { case XmlAttributeNames.Name: d.Name = a.Value; break; case XmlAttributeNames.Description: d.Description = a.Value; break; case XmlAttributeNames.Column: d.Column = Int32.Parse(a.Value); break; case XmlAttributeNames.TimePosition: d.TimePosition = Int32.Parse(a.Value); break; case XmlAttributeNames.Duration: d.Duration = Int32.Parse(a.Value); break; } } foreach (XmlNode contentNode in node.ChildNodes) { IContent content = new UnrecognizedContent(); foreach (IRiddleHandler h in ContentHandlers) { if (h.CanLoad(contentNode)) { content = h.Load(contentNode); } } d.Pages.Add(content); } Scenes.Add(d); } }
private void x_timeline_show_MouseMove(object sender, MouseEventArgs e) { if (toMove == null) { return; } Point p = e.MouseDevice.GetPosition(x_timeline_show); SceneDescription desc = toMove.DataContext as SceneDescription; desc.Column = (int)p.X / (_width + _margin); desc.TimePosition = Math.Max((int)p.Y, _height + _margin); MoveButton(toMove, desc.TimePosition, desc.Column); }
/// <summary> /// Registers an update receiver by sorting it into its scene root element. /// </summary> /// <param name="ur">Object to be updated.</param> /// <param name="order">Call order.</param> public static void RegisterUpdateReceiver(IUpdateReceiver ur, int order = 0) { var root = ur.Root; var scene = _scenes.SingleOrDefault(x => x.Root == root); if (scene == null) { scene = new SceneDescription { Root = root }; _scenes.Add(scene); } scene.UpdateReceiverOrder[ur] = order; }
public void MaximumBounds() { SceneDescription sceneDesc = new SceneDescription(); try { sceneDesc.MaximumBounds = null; sceneDesc.MaximumBounds = new Bounds3( -10000.0f, -10000.0f, -10000.0f, 10000.0f, 10000.0f, 10000.0f ); sceneDesc.MaximumBounds = new Bounds3( -10000.0f, -10000.0f, -10000.0f, 10000.0f, 10000.0f, 10000.0f ); sceneDesc.MaximumBounds = null; } catch { Assert.Fail( "Setting SceneDescription.MaximumBounds Failed" ); } }
public void MaximumBounds() { SceneDescription sceneDesc = new SceneDescription(); try { sceneDesc.MaximumBounds = null; sceneDesc.MaximumBounds = new Bounds3(-10000.0f, -10000.0f, -10000.0f, 10000.0f, 10000.0f, 10000.0f); sceneDesc.MaximumBounds = new Bounds3(-10000.0f, -10000.0f, -10000.0f, 10000.0f, 10000.0f, 10000.0f); sceneDesc.MaximumBounds = null; } catch { Assert.Fail("Setting SceneDescription.MaximumBounds Failed"); } }
private PhysX() { try { Core = new StillDesign.PhysX.Core(); } catch (Exception exception) { //ScreenManager.Graphics.IsFullScreen = false; //ScreenManager.Graphics.ApplyChanges(); //MessageBox.Show("Error initializing PhysX.\n- Did you install the nVidia PhysX System Software?\n\n" + exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } //Core.SetParameter(PhysicsParameter.SkinWidth, (float)0.01f); Core.SetParameter(PhysicsParameter.VisualizationScale, (float)0f); Core.SetParameter(PhysicsParameter.ContinuousCollisionDetection, false); Core.SetParameter(PhysicsParameter.VisualizeCollisionShapes, true); Core.SetParameter(PhysicsParameter.VisualizeCollisionAxes, false); Core.SetParameter(PhysicsParameter.VisualizeBodyAxes, false); Core.SetParameter(PhysicsParameter.VisualizeContactNormal, false); Core.SetParameter(PhysicsParameter.VisualizeContactForce, false); Core.SetParameter(PhysicsParameter.VisualizeActorAxes, false); SceneDescription sceneDescription = new SceneDescription(); sceneDescription.Gravity = new Vector3(0f, Gravity, 0f); sceneDescription.TimestepMethod = TimestepMethod.Fixed; sceneDescription.Flags = SceneFlag.SimulateSeparateThread; sceneDescription.ThreadMask = 0xfffffffe; Scene = Core.CreateScene(sceneDescription); Scene.UserContactReport = ContactReport.Instance; Scene.UserTriggerReport = TriggerReport.Instance; MaterialDescription description = new MaterialDescription(); description.Restitution = 0.1f; description.DynamicFriction = 0.2f; Scene.DefaultMaterial.LoadFromDescription(description); InitScene(); }
public void InitalizePhysics() { // Construct engine objects this.Camera = new Camera(this); //_visualizationEffect = new BasicEffect(this.Device) //{ // VertexColorEnabled = true //}; //_vertexDeclaration = VertexPositionColor.VertexDeclaration; // Construct physics objects CoreDescription coreDesc = new CoreDescription(); UserOutput output = new UserOutput(); this.Core = new Core(coreDesc, output); Core core = this.Core; core.SetParameter(PhysicsParameter.VisualizationScale, 2.0f); core.SetParameter(PhysicsParameter.VisualizeCollisionShapes, true); core.SetParameter(PhysicsParameter.VisualizeClothMesh, true); core.SetParameter(PhysicsParameter.VisualizeJointLocalAxes, true); core.SetParameter(PhysicsParameter.VisualizeJointLimits, true); core.SetParameter(PhysicsParameter.VisualizeFluidPosition, true); core.SetParameter(PhysicsParameter.VisualizeFluidEmitters, false); // Slows down rendering a bit too much core.SetParameter(PhysicsParameter.VisualizeForceFields, true); core.SetParameter(PhysicsParameter.VisualizeSoftBodyMesh, true); SceneDescription sceneDesc = new SceneDescription() { //SimulationType = SimulationType.Hardware, Gravity = new Vector3(0, -9.81f, 0).AsPhysX(), GroundPlaneEnabled = true }; this.Scene = core.CreateScene(sceneDesc); HardwareVersion ver = Core.HardwareVersion; SimulationType simType = this.Scene.SimulationType; // Connect to the remote debugger if it's there core.Foundation.RemoteDebugger.Connect("localhost"); }
protected override void Update() { if (FlaiInput.IsNewKeyPress(this.LoadFirstSceneKey)) { SceneFader.Fade(SceneDescription.FromIndex(0), Fade.Create(0.75f), Fade.Create(0.75f)); } else if (FlaiInput.IsNewKeyPress(this.ReloadSceneKey)) { SceneFader.Fade(SceneDescription.FromIndex(Application.loadedLevel), Fade.Create(0.15f), Fade.Create(0.15f)); } else if (FlaiInput.IsNewKeyPress(this.PreviousSceneKey)) { SceneFader.Fade(SceneDescription.FromIndex(Application.loadedLevel - 1), Fade.Create(0.15f), Fade.Create(0.15f)); } else if (FlaiInput.IsNewKeyPress(this.NextSceneKey)) { SceneFader.Fade(SceneDescription.FromIndex((Application.loadedLevel == Application.levelCount - 1) ? 0 : Application.loadedLevel + 1), Fade.Create(0.15f), Fade.Create(0.15f)); } }
private void startStory(string story) { this.storyName = story; TextAsset[] textAssets = Resources.LoadAll <TextAsset>("SceneDescriptions/" + story); // Sort to ensure pages are in order. Array.Sort(textAssets, (f1, f2) => string.Compare(f1.name, f2.name)); this.storyPages.Clear(); // Figure out the orientation of this story and tell SceneDescription. this.setOrientation(this.orientations[this.storyName]); SceneDescription.SetOrientation(this.orientation); foreach (TextAsset text in textAssets) { this.storyPages.Add(new SceneDescription(text.text)); } this.setOrientation(this.orientation); this.changeButtonText(this.nextButton, "Begin Story!"); this.hideElement(this.backButton.gameObject); this.storyManager.LoadPage(this.storyPages[this.currentPageNumber]); }
public override void Initialize() { this.Camera = new Camera(this); _visualizationEffect = new BasicEffect(this.Device, null); _visualizationEffect.VertexColorEnabled = true; // CoreDescription coreDesc = new CoreDescription(); UserOutput output = new UserOutput(); this.Core = new Core(coreDesc, output); Core core = this.Core; core.SetParameter(PhysicsParameter.VisualizationScale, 2.0f); core.SetParameter(PhysicsParameter.VisualizeCollisionShapes, true); core.SetParameter(PhysicsParameter.VisualizeClothMesh, true); core.SetParameter(PhysicsParameter.VisualizeJointLocalAxes, true); core.SetParameter(PhysicsParameter.VisualizeJointLimits, true); core.SetParameter(PhysicsParameter.VisualizeFluidPosition, true); core.SetParameter(PhysicsParameter.VisualizeFluidEmitters, false); // Slows down rendering a bit to much core.SetParameter(PhysicsParameter.VisualizeForceFields, true); core.SetParameter(PhysicsParameter.VisualizeSoftBodyMesh, true); SceneDescription sceneDesc = new SceneDescription(); //SimulationType = SimulationType.Hardware, sceneDesc.Gravity = new Vector3(0.0f, -9.81f, 0.0f); sceneDesc.GroundPlaneEnabled = true; this.Scene = core.CreateScene(sceneDesc); HardwareVersion ver = Core.HardwareVersion; SimulationType simType = this.Scene.SimulationType; // Connect to the remote debugger if its there core.Foundation.RemoteDebugger.Connect("localhost"); }
/// <summary> /// 物理ワールドの初期化 /// </summary> public void init(CollisionDispatcher d, IBroadphaseInterface b, IConstraintSolver s, ICollisionConfiguration c) { // Construct physics objects CoreDescription coreDesc = new CoreDescription(); UserOutput output = new UserOutput(); this.Core = new Core(coreDesc, output); Core core = this.Core; // デバッグ描画用の設定 core.SetParameter(PhysicsParameter.VisualizationScale, 2.0f); core.SetParameter(PhysicsParameter.VisualizeForceFields, true); core.SetParameter(PhysicsParameter.VisualizeCollisionShapes, true); core.SetParameter(PhysicsParameter.VisualizeJointLimits, true); /* * core.SetParameter(PhysicsParameter.VisualizeJointLocalAxes, true); * //core.SetParameter(PhysicsParameter.VisualizeJointWorldAxes, true); * core.SetParameter(PhysicsParameter.VisualizeClothMesh, true); * core.SetParameter(PhysicsParameter.VisualizeFluidPosition, true); * core.SetParameter(PhysicsParameter.VisualizeFluidEmitters, false); // Slows down rendering a bit too much * core.SetParameter(PhysicsParameter.VisualizeSoftBodyMesh, true); */ // シーンの設定 SceneDescription sceneDesc = new SceneDescription() { //SimulationType = SimulationType.Hardware, Gravity = new Vector3(0, -9.81f, 0), GroundPlaneEnabled = true }; this.scene = core.CreateScene(sceneDesc); HardwareVersion ver = Core.HardwareVersion; SimulationType simType = this.scene.SimulationType; // Connect to the remote debugger if it's there //core.Foundation.RemoteDebugger.Connect("localhost"); }
// Based on the image and orientation, determine an aspect ratio and decide the display mode. private void setDisplayModeFromSceneDescription(SceneDescription description) { if (description.isTitle) { if (description.orientation == ScreenOrientation.Landscape) { this.setDisplayMode(DisplayMode.Landscape); } else { this.setDisplayMode(DisplayMode.Portrait); } } else { if (description.orientation == ScreenOrientation.Landscape) { // Need to look at aspect ratio to decide between Landscape and LandscapeWide. Texture texture = this.assetManager.GetSprite(description.storyImageFile).texture; // // TODO: this is where we set the display mode. // // For now, just only allow landscape, because otherwise sentences are too // // tall and the text takes up too much space. // float aspectRatio = (float)texture.width / (float)texture.height; // if (aspectRatio > 2.0) { // this.setDisplayMode(DisplayMode.LandscapeWide); // } else { // this.setDisplayMode(DisplayMode.Landscape); // } this.setDisplayMode((DisplayMode.Landscape)); } else if (description.orientation == ScreenOrientation.Portrait) { this.setDisplayMode(DisplayMode.Portrait); } else { // If it's something else, then idk, put it as DisplayMode.Landscape as default. this.setDisplayMode(DisplayMode.Landscape); } } }
// Based on the image and orientation, determine an aspect ratio and decide the display mode. private void setDisplayModeFromSceneDescription(SceneDescription description) { if (description.isTitle) { if (description.orientation == ScreenOrientation.Landscape) { this.setDisplayMode(DisplayMode.Landscape); } else { this.setDisplayMode(DisplayMode.Portrait); } } else { if (description.orientation == ScreenOrientation.Landscape) { // Need to look at aspect ratio to decide between Landscape and LandscapeWide. Texture texture = this.assetManager.GetSprite(description.storyImageFile).texture; float aspectRatio = (float)texture.width / (float)texture.height; if (aspectRatio > 2.0) { this.setDisplayMode(DisplayMode.LandscapeWide); } else { this.setDisplayMode(DisplayMode.Landscape); } } else if (description.orientation == ScreenOrientation.Portrait) { this.setDisplayMode(DisplayMode.Portrait); } else { // If it's something else, then idk, put it as DisplayMode.Landscape as default. this.setDisplayMode(DisplayMode.Landscape); } } }
private void Button_MouseUp(object sender, MouseButtonEventArgs e) { if (toMove == null) { return; } SceneDescription scene = toMove.DataContext as SceneDescription; Point p = e.MouseDevice.GetPosition(x_timeline_show); if (p.Y < _height) { scene.TimePosition = -1; _todos.Add(toMove); } else { MoveButton(toMove, scene.TimePosition, scene.Column); } toMove = null; // in case on of the todos was removed RearrangeTodos(); }
/// <summary> /// Registers an update receiver by sorting it into its scene root element. /// </summary> /// <param name="updateAction">Update action to call.</param> /// <param name="preRenderAction">Render action to call</param> /// <param name="root">Root scene of the update receiver.</param> /// <param name="order">Call order.</param> public static void RegisterUpdateReceiver(Action updateAction, Action preRenderAction, SceneObject root, int order = 0) { var scenes = _instance._scenes; var scene = scenes.SingleOrDefault(x => x.Root == root); if (scene == null) { scene = new SceneDescription { Root = root }; scenes.Add(scene); } if (updateAction != null) { scene.UpdateReceiverOrder[updateAction] = order; } if (preRenderAction != null) { scene.PreRenderReceiverOrder[preRenderAction] = order; } }
private void loadTitlePage(SceneDescription description) { // Load the into the title panel without worrying about anything except // for fitting the space and making the aspect ratio correct. // Basically the same as first half of loadImage() function. string imageFile = description.storyImageFile; GameObject newObj = new GameObject(); newObj.AddComponent <Image>(); newObj.AddComponent <AspectRatioFitter>(); newObj.transform.SetParent(this.titlePanel.transform, false); newObj.transform.localPosition = Vector3.zero; newObj.GetComponent <AspectRatioFitter>().aspectMode = AspectRatioFitter.AspectMode.FitInParent; newObj.GetComponent <AspectRatioFitter>().aspectRatio = this.titlePanelAspectRatio; Logger.Log("loading title page"); newObj.GetComponent <Image>().sprite = this.assetManager.GetSprite(imageFile); newObj.GetComponent <Image>().preserveAspect = true; this.storyImage = newObj; }
private void startStory(string story) { this.storyName = story; DirectoryInfo dir = new DirectoryInfo(Application.dataPath + "/SceneDescriptions/" + story); FileInfo[] files = dir.GetFiles("*.json"); // Sort to ensure pages are in order. Array.Sort(files, (f1, f2) => string.Compare(f1.Name, f2.Name)); this.storyPages.Clear(); // Figure out the orientation of this story and tell SceneDescription. this.setOrientation(this.orientations[this.storyName]); SceneDescription.SetOrientation(this.orientation); foreach (FileInfo file in files) { this.storyPages.Add(new SceneDescription(file.Name)); } this.setOrientation(this.orientation); this.changeButtonText(this.nextButton, "Begin Story!"); this.hideElement(this.backButton.gameObject); this.storyManager.LoadPage(this.storyPages[this.currentPageNumber]); }
protected Core iniPhysics() { CoreDescription coreDesc = new CoreDescription(); Core core = new Core(coreDesc, null); core.SetParameter(PhysicsParameter.VisualizationScale, 2.0f); core.SetParameter(PhysicsParameter.VisualizeCollisionShapes, true); core.SetParameter(PhysicsParameter.VisualizeClothMesh, true); core.SetParameter(PhysicsParameter.VisualizeJointLocalAxes, true); core.SetParameter(PhysicsParameter.VisualizeJointLimits, true); core.SetParameter(PhysicsParameter.VisualizeFluidPosition, true); core.SetParameter(PhysicsParameter.VisualizeFluidEmitters, false); // Slows down rendering a bit too much core.SetParameter(PhysicsParameter.VisualizeForceFields, true); core.SetParameter(PhysicsParameter.VisualizeSoftBodyMesh, true); RemoteDebugger debugger = core.Foundation.RemoteDebugger; debugger.Connect("localhost"); if (debugger.IsConnected) { Console.Write("Debugger connected\n"); } SceneDescription sceneDesc = new SceneDescription(); sceneDesc.Gravity = new StillDesign.PhysX.MathPrimitives.Vector3(0, -10.0f, 0); scene = core.CreateScene(sceneDesc); return core; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // Load saved scene. if (File.Exists(SampleSceneFilePath)) { m_scene = SceneDescription.ReadFromFile(SampleSceneFilePath); } else { // Create a new scene. m_scene = new SceneDescription(); m_scene.Name = "Sample Scene"; // Add some models. m_scene.Add(new SceneDescriptionModelEntry("Sponza", "Models/Sponza/Sponza", Transformation.Identity)); m_scene.Add(new SceneDescriptionModelEntry("Tank1", "Models/tank", Transformation.Identity)); Transformation tank2Transformation = new Transformation(1.0f, Quaternion.Identity, new Vector3(-5, 0, 10)); m_scene.Add(new SceneDescriptionModelEntry("Tank2", "Models/tank", ref tank2Transformation)); Transformation robot1Transformation = new Transformation(1.0f, Quaternion.Identity, new Vector3(5, 3, 10)); m_scene.Add(new SceneDescriptionModelEntry("Robot1", "Models/RobotGame/Yager", ref robot1Transformation)); // Add randomly distributed point lights. { // Point lights Random random = new Random(); for (int i = 0; i < 200; ++i) { Vector3 position = new Vector3( ( float )random.NextDouble() * 200.0f - 100.0f, ( float )random.NextDouble() * 150.0f, ( float )random.NextDouble() * 100.0f - 50.0f); Vector3 diffuseColor = new Vector3( ( float )random.NextDouble(), ( float )random.NextDouble(), ( float )random.NextDouble()); float specularPower = ( float )random.NextDouble() * 10.0f; float attenuationDistance = 10.0f + ( float )random.NextDouble() * 190.0f; float attenuationDistanceExponent = 1.0f + ( float )random.NextDouble() * 99.0f; m_scene.Add(SceneDescriptionLightEntry.CreatePointLight(string.Format("PointLight{0}", i), position, diffuseColor, specularPower, attenuationDistance, attenuationDistanceExponent)); } // Spot lights #if false random = new Random(random.Next()); for (int i = 0; i < 20; ++i) { Vector3 position = new Vector3( ( float )random.NextDouble() * 200.0f - 100.0f, ( float )random.NextDouble() * 150.0f, ( float )random.NextDouble() * 100.0f - 50.0f); Vector3 direction = new Vector3( ( float )random.NextDouble() * 2.0f - 1.0f, ( float )random.NextDouble() * 2.0f - 1.0f, ( float )random.NextDouble() * 2.0f - 1.0f); Vector3 diffuseColor = new Vector3( ( float )random.NextDouble(), ( float )random.NextDouble(), ( float )random.NextDouble()); float specularPower = ( float )random.NextDouble() * 100.0f; float attenuationDistance = ( float )random.NextDouble() * 200.0f; float attenuationDistanceExponent = 100.0f; float attenuationInnerAngle = ( float )random.NextDouble() * MathHelper.PiOver4; float attenuationOuterAngle = attenuationInnerAngle + ( float )random.NextDouble() * MathHelper.PiOver4; float attenuationAngleExponent = 1.0f + ( float )random.NextDouble() * 19.0f; m_scene.Add( string.Format("SpotLight{0}", i), SceneDescriptionLightEntry.CreateSpotLight(position, direction, diffuseColor, specularPower, attenuationDistance, attenuationDistanceExponent, attenuationInnerAngle, attenuationOuterAngle, attenuationAngleExponent)); } #endif } // Add a direction light. m_scene.Add(SceneDescriptionLightEntry.CreateDirectionalLight("SkyLight", new Vector3(0, -1, 0), new Vector3(0.2f, 0.2f, 0.2f), 1.0f)); } base.Initialize(); }
public void Open(string fileName) { FrameDescription frame; using (var frameFile = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { using (var reader = new StreamReader(frameFile)) frame = (FrameDescription)SerializationService.Deserialize(reader.ReadToEnd(), typeof(FrameDescription)); } frame.FrameName = Path.GetFileNameWithoutExtension(fileName); Directory.SetCurrentDirectory(frame.WorkingDir); scn = new SceneDescription(); try { scn.LightOrientation = (int)frame["LightOrientation"]; } catch { scn.LightOrientation = -1.0f; } scn.WorkingDirectory = frame.WorkingDir; scn.SceneName = frame.FrameName; var lights = new List<Lightsource>(); var cameras = new List<Camera>(); foreach (var frameElement in frame.Elements) { switch (frameElement.GetType().Name.ToString()) { case "FrameAreaLightTemplate": var templ = (FrameAreaLightTemplate)frameElement; scn.LightNameTemplate = templ.NameTemplate; scn.LightGain = new Vector3(templ.Gain.c1, templ.Gain.c2, templ.Gain.c3); break; case "FrameLightsource": var lt = (FrameLightsource)frameElement; var light = new Lightsource(); if (lt.LightType == RayDen.Library.Entity.Frames.LightSourceTypes.Area) { var emission = Vector.FromString(lt.Parameters[FrameLightsource.LightsourcePower].ToString().Replace(" ", string.Empty)); light.Type = LightSourceTypes.Area; light.Name = lt.Parameters[FrameLightsource.AreaLightGeometryName].ToString(); light.Emission = new Vector3(emission.x, emission.y, emission.z); } else if (lt.LightType == RayDen.Library.Entity.Frames.LightSourceTypes.EnvironmentMap) { light.Type = LightSourceTypes.EnvironmentMap; light["ImagePath"] = scn.EnvMapPath = lt.Parameters[FrameLightsource.InfiniteLightMapPath].ToString(); } else if (lt.LightType == RayDen.Library.Entity.Frames.LightSourceTypes.Point) { var pos = Vector.FromString(lt.Parameters[FrameLightsource.PointLightPosition].ToString().Replace(" ", string.Empty)); var emission = Vector.FromString(lt.Parameters[FrameLightsource.LightsourcePower].ToString().Replace(" ", string.Empty)); light.Emission = new Vector3(emission.x, emission.y, emission.z); light.Type = LightSourceTypes.Point; light.p0 = new Vector3(pos.x, pos.y, pos.z); } Trace.WriteLine(string.Format("Lightsource {0} {1}", light.Type, light.Name)); lights.Add(light); break; case "FrameCamera": var cam = (FrameCamera)frameElement; //cameras.Add(new Camera() //{ // Fov = cam.Fov > 0f ? cam.Fov : 30f, // Position = new Vector3(cam.Position.x, cam.Position.y, cam.Position.z), // Target = new Vector3(cam.Target.x, cam.Target.y, cam.Target.z), // Up = new Vector3(cam.Up.x, cam.Up.y, cam.Up.z) //}); var camera = new Camera() { Fov = cam.Fov > 0f ? cam.Fov : 30f }; camera.LookAt(new Vector3(cam.Position.x, cam.Position.y, cam.Position.z), new Vector3(cam.Target.x, cam.Target.y, cam.Target.z), new Vector3(cam.Up.x, cam.Up.y, cam.Up.z)); cameras.Add(camera); break; case "FrameObjFileReference": var objFile = (FrameObjFileReference)frameElement; scn.SceneGeo = new GeoGroup() { MatFilePath = frame.WorkingDir + objFile.MtlFilePath, ObjFilePath = frame.WorkingDir + objFile.ObjFilePath }; break; } } scn.Cameras = cameras.ToArray(); Trace.WriteLine(string.Format("{0} cameras", scn.Cameras.Length)); scn.Lights = lights.ToArray(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { base.Initialize(); CoreDescription coreDesc = new CoreDescription(); this.PhysXCore = new Core(coreDesc, new ConsoleOutputStream()); var core = this.PhysXCore; core.SetParameter(PhysicsParameter.VisualizationScale, 2.0f); core.SetParameter(PhysicsParameter.VisualizeCollisionShapes, true); SimulationType hworsw = (core.HardwareVersion == HardwareVersion.None ? SimulationType.Software : SimulationType.Hardware); Console.WriteLine("PhysX Acceleration Type: " + hworsw); SceneDescription sceneDesc = new SceneDescription() { SimulationType = hworsw, Gravity = new Vector3(0.0f, -9.81f, 0.0f) }; this.Scene = core.CreateScene(sceneDesc); // If there's a remote debugger, connect to it. core.Foundation.RemoteDebugger.Connect("localhost"); // Create the camera. _camera = new Camera(this); // Let's create physics objects! InitializeObjects(); }
public DTLPhysXScene() { physicsCore = new Core(); SceneDescription sceneDescription = new SceneDescription() { Gravity = new Vector3(0, 0, -9.81f), GroundPlaneEnabled = true // Disable once terrain is confirmed working. }; physicsScene = physicsCore.CreateScene(sceneDescription); SimulationType simtype = physicsScene.SimulationType; if(simtype == SimulationType.Hardware) { } // Win! }