コード例 #1
0
        public override void RenderShape(VisionViewBase view, ShapeRenderMode mode)
        {
            if (TimeOfDay == null)
            {
                return;
            }
            const int iSteps     = 24;
            float     fStep      = 1.0f / (float)iSteps;
            float     fLen       = 200.0f * EditorManager.Settings.GlobalUnitScaling;
            float     fTime      = 0.0f;
            Vector3F  lastCorner = Vector3F.Zero;

            for (int i = 0; i < iSteps; i++, fTime += fStep)
            {
                if (!EditorManager.RendererNodeManager.GetTimeOfDaySnapshot(fTime, daytimeParams))
                {
                    continue;
                }
                Vector3F newCorner = Position + daytimeParams.SunDirection * fLen * 0.75f;
                if (i > 0)
                {
                    view.RenderSolidTriangle(Position, newCorner, lastCorner, VisionColors.Get(daytimeParams.AmbientColor));
                    view.RenderSolidTriangle(Position, lastCorner, newCorner, VisionColors.Get(daytimeParams.AmbientColor));
                }
                Vector3F vEnd = Position + daytimeParams.SunDirection * fLen;
                view.RenderLine(Position, vEnd, VisionColors.Get(daytimeParams.SunColor), 1.0f);
                uint iColor = (i == 12) ? VisionColors.White : VisionColors.Yellow;
                view.WriteText3D(vEnd, i.ToString() + ":00", iColor); // time

                lastCorner = newCorner;
            }
        }
コード例 #2
0
        /// <summary>
        /// overridden function to set/update all specific properties on the engine instance
        /// </summary>
        public override void SetEngineInstanceBaseProperties()
        {
            if (_engineInstance == null)
            {
                return;
            }
            EnginePGroup.BeginUpdateParams();
            EnginePGroup.SetRandomBaseSeed(_uiRandomBaseSeed);
            EnginePGroup.SetEffectFile(_effectFile); // first set the effect...
            base.SetEngineInstanceBaseProperties();  // ...then position etc.
            EnginePGroup.SetVisibleBitmask((uint)_iVisibleBitmask);
            EnginePGroup.SetLightInfluenceBitmask((uint)_iLightInfluenceBitmask);
            EnginePGroup.SetPreferredDirLightKey(_preferredDynamicDirLightKey);
            EnginePGroup.SetLightSamplingOffset(_lightSamplingOffset);
            EnginePGroup.SetAmbientColor(VisionColors.Get(_ambientColor));
            EnginePGroup.SetPaused(_bPaused);
            EnginePGroup.SetHalted(_bHalted);
            EnginePGroup.SetWindSpeed(_windSpeed, _bLocalSpaceWind);
            EnginePGroup.UpdateParticleColors();
            EnginePGroup.SetIntensity(_fIntensity);
            EnginePGroup.SetApplyTimeOfDayLight(_bApplyTimeOfDayLighting);
            EnginePGroup.SetRemoveWhenFinished(_removeWhenFinished);
            UpdateMeshEmitterEntity();

            EnginePGroup.EndUpdateParams();
        }
コード例 #3
0
        /// <summary>
        /// overridden function to render the shape
        /// </summary>
        /// <param name="view">destination view</param>
        /// <param name="mode">render mode</param>
        public override void RenderShape(VisionViewBase view, ShapeRenderMode mode)
        {
            base.RenderShape(view, mode);

            if (_engineInstance != null)
            {
                if (mode == ShapeRenderMode.Selected || (ParentLayer == ParentLayer.ParentScene.ActiveLayer && _bPreview3D))
                {
                    EngineBox.RenderShape(view, mode, VisionColors.Get(_previewColor));
                }
            }
        }
コード例 #4
0
ファイル: HavokAiTest.cs プロジェクト: hxzpily/projectanarchy
        public void TestNavMeshGeneration()
        {
            // Create a nav mesh shape
            EditorManager.GetShapeCreatorPluginByName("Nav Mesh").ExecutePlugin();
            HavokNavMeshShape navMeshShape = (HavokAiEditorPlugin.Shapes.HavokNavMeshShape)EditorManager.Scene.FindFirstShapeOfType(typeof(HavokNavMeshShape), true);

            Assert.IsNotNull(navMeshShape);

            // Build the nav mesh
            ShapeCollection staticGeometries = new ShapeCollection();
            int             numGeometryVertices = 0, numGeometryTriangles = 0, numEntities = 0, numStaticMeshes = 0, numTerrains = 0;
            int             numCarvers = 0, numSeedPoints = 0, numLocalSettings = 0;

            HavokAiPanelDialogs.HavokAiPanel.gatherGeometricShapes(ref staticGeometries, ref numEntities, ref numStaticMeshes, ref numTerrains, ref numCarvers, ref numSeedPoints, ref numLocalSettings);
            bool built = navMeshShape.Build(staticGeometries, ref numGeometryVertices, ref numGeometryTriangles);

            Assert.IsTrue(built);

            // Add Navmesh to world
            navMeshShape.AddNavMeshToWorld();

            // Create a path shape
            EditorManager.GetShapeCreatorPluginByName("Nav Mesh Test Path").ExecutePlugin();
            HavokNavMeshTestPathShape pathShape = (HavokAiEditorPlugin.Shapes.HavokNavMeshTestPathShape)EditorManager.Scene.FindFirstShapeOfType(typeof(HavokNavMeshTestPathShape), true);

            Assert.IsNotNull(pathShape);

            // Verify that a known path exists on the nav mesh
            pathShape.StartPoint      = new Vector3F(-500.0f, 0.0f, 0.0f);
            pathShape.EndPoint        = new Vector3F(500.0f, 0.0f, 0.0f);
            pathShape.CharacterRadius = 20.0f;
            bool foundPath = HavokAiManaged.ManagedModule.ComputeAndDrawPath(EditorManager.ActiveView, pathShape.StartPoint, pathShape.EndPoint, pathShape.CharacterRadius, pathShape.CharacterHeight, 0.08f * pathShape.CharacterHeight, VisionColors.Get(pathShape.PathColor));

            EditorManager.ActiveView.UpdateView(true);
            Assert.IsTrue(foundPath);

            // Create a carver shape
            EditorManager.GetShapeCreatorPluginByName("Nav Mesh Carver").ExecutePlugin();
            HavokNavMeshCarverShape carverShape = (HavokAiEditorPlugin.Shapes.HavokNavMeshCarverShape)EditorManager.Scene.FindFirstShapeOfType(typeof(HavokNavMeshCarverShape), true);

            Assert.IsNotNull(carverShape);

            // Make the carver block the previous path and test by rebuilding the nav mesh and verifying the path is blocked
            carverShape.BoxSizeX = 300.0f;
            carverShape.BoxSizeY = 2000.0f;
            carverShape.BoxSizeZ = 200.0f;
            built = navMeshShape.Build(staticGeometries, ref numGeometryVertices, ref numGeometryTriangles);
            Assert.IsTrue(built);

            // Add Navmesh to world
            navMeshShape.AddNavMeshToWorld();

            foundPath = HavokAiManaged.ManagedModule.ComputeAndDrawPath(EditorManager.ActiveView, pathShape.StartPoint, pathShape.EndPoint, pathShape.CharacterRadius, pathShape.CharacterHeight, 0.08f * pathShape.CharacterHeight, VisionColors.Get(pathShape.PathColor));
            EditorManager.ActiveView.UpdateView(true);
            Assert.IsFalse(foundPath);

            // Resize the carver again, this time so that only character's of a certain radius can traverse the path
            carverShape.BoxSizeY = 1400.0f;
            built = navMeshShape.Build(staticGeometries, ref numGeometryVertices, ref numGeometryTriangles);
            Assert.IsTrue(built);

            // Add Navmesh to world
            navMeshShape.AddNavMeshToWorld();

            foundPath = HavokAiManaged.ManagedModule.ComputeAndDrawPath(EditorManager.ActiveView, pathShape.StartPoint, pathShape.EndPoint, pathShape.CharacterRadius, pathShape.CharacterHeight, 0.08f * pathShape.CharacterHeight, VisionColors.Get(pathShape.PathColor));
            EditorManager.ActiveView.UpdateView(true);
            Assert.IsFalse(foundPath);
            pathShape.CharacterRadius = 10.0f;
            foundPath = HavokAiManaged.ManagedModule.ComputeAndDrawPath(EditorManager.ActiveView, pathShape.StartPoint, pathShape.EndPoint, pathShape.CharacterRadius, pathShape.CharacterHeight, 0.08f * pathShape.CharacterHeight, VisionColors.Get(pathShape.PathColor));
            EditorManager.ActiveView.UpdateView(true);
            Assert.IsTrue(foundPath);

            // Save NavMesh to file
            bool saved = navMeshShape.SaveNavMeshesToFile();

            Assert.IsTrue(saved);
        }
コード例 #5
0
        /// <summary>
        /// Updates the fog in the engine. Optionally redraws the view
        /// </summary>
        /// <param name="bRedraw"></param>
        public void Update(bool bRedraw)
        {
            EditorManager.EngineManager.SetLinearDepthFog(_bEnabled, _fStartDist, _fStartEnd, VisionColors.Get(_color));
            if (bRedraw)
            {
                EditorManager.ActiveView.UpdateView(false);
            }

            // update the dependedncies
            V3DLayer parentLayer = (V3DLayer)OwnerSceneObject;

            if (parentLayer != null)
            {
                // update the current renderer
                //parentLayer.Renderer.Update();
            }
        }
コード例 #6
0
        public override void RenderShape(VisionViewBase view, ShapeRenderMode mode)
        {
            if (FinalVisibleState == true && EditorManager.Scene.AllShapesOfType(typeof(HavokAiEditorPlugin.Shapes.HavokNavMeshShape)).Count != 0)
            {
                HavokAiManaged.ManagedModule.ComputeAndDrawPath(view, _vStartPoint, _vEndPoint, _fCharacterRadius, _fCharacterHeight, _fpathDisplayOffset * _fCharacterHeight, VisionColors.Get(_pathColor));
            }

            base.RenderShape(view, mode);
        }