当前位置: 首页>>代码示例>>C#>>正文


C# BoundingBoxD.Translate方法代码示例

本文整理汇总了C#中BoundingBoxD.Translate方法的典型用法代码示例。如果您正苦于以下问题:C# BoundingBoxD.Translate方法的具体用法?C# BoundingBoxD.Translate怎么用?C# BoundingBoxD.Translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BoundingBoxD的用法示例。


在下文中一共展示了BoundingBoxD.Translate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderCellCoordToWorldAABB

 public static void RenderCellCoordToWorldAABB(Vector3D referenceVoxelMapPosition, ref MyCellCoord renderCell, out BoundingBoxD worldAABB)
 {
     RenderCellCoordToLocalAABB(ref renderCell, out worldAABB);
     worldAABB = worldAABB.Translate(referenceVoxelMapPosition);
 }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:5,代码来源:MyVoxelCoordSystems.cs

示例2: QuerySurfaceParameters

        public unsafe void QuerySurfaceParameters(Vector3D localOrigin, ref BoundingBoxD queryBounds, List<Vector3> queries, List<MySurfaceParams> results)
        {
            localOrigin -= Planet.PositionLeftBottomCorner;

            using (Planet.Storage.Pin())
            {
                var bounds = (BoundingBox)queryBounds.Translate(-Planet.PositionLeftBottomCorner);

                Planet.Provider.Shape.PrepareCache();
                Planet.Provider.Material.PrepareRulesForBox(ref bounds);

                if (results.Capacity != queries.Count)
                {
                    results.Capacity = queries.Count;
                }

                fixed (MySurfaceParams* pars = results.GetInternalArray())
                {
                    for (int i = 0; i < queries.Count; ++i)
                    {
                        Planet.Provider.ComputeCombinedMaterialAndSurface(queries[i] + localOrigin, true, out pars[i]);
                        pars[i].Position -= localOrigin;
                    }
                }

                results.SetSize(queries.Count);
            }
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:28,代码来源:MyPlanetEnvironmentComponent.cs

示例3: AddVoxelMesh

        private void AddVoxelMesh(MyVoxelBase voxelBase, IMyStorage storage, Dictionary<Vector3I, MyIsoMesh> cache, float border, Vector3D originPosition, MyOrientedBoundingBoxD obb, List<BoundingBoxD> bbList)
        {
            bool useCache = cache != null;
            if (useCache)
                CheckCacheValidity();

            obb.HalfExtent += new Vector3D(border, 0, border);
            BoundingBoxD bb = obb.GetAABB();            
            int aabbSideSide = (int)Math.Round(bb.HalfExtents.Max() * 2);
            bb = new BoundingBoxD(bb.Min, bb.Min + aabbSideSide);
            bb.Translate(obb.Center - bb.Center);

            // For debug
            bbList.Add(new BoundingBoxD(bb.Min, bb.Max));

            bb = (BoundingBoxD)bb.TransformFast(voxelBase.PositionComp.WorldMatrixInvScaled);
            bb.Translate(voxelBase.SizeInMetresHalf);

            Vector3I min = Vector3I.Round(bb.Min);
            Vector3I max = min + aabbSideSide;
            Vector3I geomMin, geomMax;
            MyVoxelCoordSystems.VoxelCoordToGeometryCellCoord(ref min, out geomMin);
            MyVoxelCoordSystems.VoxelCoordToGeometryCellCoord(ref max, out geomMax);

            var cullBox = obb;
            cullBox.Transform(voxelBase.PositionComp.WorldMatrixInvScaled);
            cullBox.Center += voxelBase.SizeInMetresHalf;
            ProfilerShort.Begin("WOOOORK");

            Vector3I_RangeIterator it = new Vector3I_RangeIterator(ref geomMin, ref geomMax);
            MyCellCoord coord = new MyCellCoord();
            BoundingBox localAabb;
            coord.Lod = NAVMESH_LOD;
            int hits = 0;
            MyIsoMesh gMesh;
            Vector3 offset = originPosition - voxelBase.PositionLeftBottomCorner;

            // Calculate rotation
            Vector3 gravityVector = -Vector3.Normalize(GameSystems.MyGravityProviderSystem.CalculateTotalGravityInPoint(originPosition));
            Vector3 forwardVector = Vector3.CalculatePerpendicularVector(gravityVector);
            Quaternion quaternion = Quaternion.CreateFromForwardUp(forwardVector, gravityVector);
            Matrix rotation = Matrix.CreateFromQuaternion(Quaternion.Inverse(quaternion));

            Matrix ownRotation = voxelBase.PositionComp.WorldMatrix.GetOrientation();

            while (it.IsValid())
            {
                ProfilerShort.Begin("ITERATOR");

                if (useCache && cache.TryGetValue(it.Current, out gMesh))
                {
                    if (gMesh != null)
                    {
                        AddMeshTriangles(gMesh, offset, rotation, ownRotation);
                    }
                    it.MoveNext();
                    ProfilerShort.End();
                    continue;
                }
                    
                coord.CoordInLod = it.Current;
                MyVoxelCoordSystems.GeometryCellCoordToLocalAABB(ref coord.CoordInLod, out localAabb);
                
                if (!cullBox.Intersects(ref localAabb))
                {
                    hits++;
                    it.MoveNext();
                    ProfilerShort.End();
                    continue;
                }
                ProfilerShort.End();

                var debugBB = new BoundingBoxD(localAabb.Min, localAabb.Max).Translate(-voxelBase.SizeInMetresHalf);
                bbList.Add(debugBB);

                ProfilerShort.Begin("Mesh Calc");
                var voxelStart = coord.CoordInLod * MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS - 1;
                var voxelEnd = voxelStart + MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS //- 1
                    + 1 // overlap to neighbor so geometry is stitched together within same LOD
                    + 1; // for eg. 9 vertices in row we need 9 + 1 samples (voxels)

                var generatedMesh = MyPrecalcComponent.IsoMesher.Precalc(storage, NAVMESH_LOD, voxelStart, voxelEnd, false, false, true);
                ProfilerShort.End();

                if (useCache)
                    cache[it.Current] = generatedMesh;

                if (generatedMesh != null)
                {
                    ProfilerShort.Begin("Mesh NOT NULL");
                    AddMeshTriangles(generatedMesh, offset, rotation, ownRotation);
                    ProfilerShort.End();
                }
                it.MoveNext();
            }
            ProfilerShort.End();
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:97,代码来源:MyNavigationInputMesh.cs

示例4: DebugDrawChunk

        public static void DebugDrawChunk(this IMyStorage self, Vector3I start, Vector3I end, Color? c = null)
        {
            if (!c.HasValue) c = Color.Blue;

            var vmaps = MySession.Static.VoxelMaps.Instances.Where(x => x.Storage == self);

            var box = new BoundingBoxD(start, end + 1);

            box.Translate(-((Vector3D)self.Size * .5) - .5);

            foreach (var map in vmaps)
            {
                MyRenderProxy.DebugDrawOBB(new MyOrientedBoundingBoxD(box, map.WorldMatrix), c.Value, 0.5f, true, true);
            }
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:15,代码来源:IMyStorage.cs

示例5: Draw


//.........这里部分代码省略.........
            //    {
            //        Matrix am = Matrix.CreateRotationX(x) * Matrix.CreateRotationZ(y);
            //        am.Translation = genPos - 20 * am.Forward;

            //        if ((am.Translation - genPos).Y >= 0)
            //        {
            //            VRageRender.MyRenderProxy.DebugDrawAxis(am, 2, false);
            //            VRageRender.MyRenderProxy.DebugDrawText3D(am.Translation, k.ToString(), Color.White, 0.5f, false);
            //            k++;
            //        }
            //    }
            //}

            //for (int i = 0; i < viewVectors2.Length; i++)
            //{
            //    viewVectors[i] = Matrix.Identity;
            //}


            
            //for (int i = 0; i < viewVectors2.Length; i++)
            //{
            //    Matrix am = viewVectors[i];
            //    am = am * m_teapotMatrix.GetOrientation();
            //    am.Translation = genPos - 20 * am.Forward;
            //    VRageRender.MyRenderProxy.DebugDrawAxis(am, 2, false);
            //    VRageRender.MyRenderProxy.DebugDrawText3D(am.Translation, i.ToString(), Color.White, 0.5f, false);
            //    //VRageRender.MyRenderProxy.DebugDrawLine3D(m_teapotMatrix.Translation, m_teapotMatrix.Translation + 20 * s_viewVectors[i].Forward, Color.White, Color.Wheat, false);
            //}






            Vector3I vv;
            Vector3 rr;
            Vector3 cdir = Vector3.Normalize((Vector3)(m_teapotMatrix.Translation - MySector.MainCamera.Position));
            Matrix invT = Matrix.Invert(m_teapotMatrix.GetOrientation());
            
            cdir = Vector3.TransformNormal(cdir, invT);
            cdir.Z *= -1;
            //cdir = Vector3.TransformNormal(cdir, Matrix.CreateRotationX(MathHelper.Pi));
            findViews(0, cdir, out vv, out rr);

            VRageRender.MyRenderProxy.DebugDrawText3D(m_teapotMatrix.Translation, vv.ToString() + " " + rr.ToString(), Color.White, 0.5f, false);


            BoundingBoxD bbox = new BoundingBoxD(-new Vector3D(20), new Vector3D(20));
            bbox.Translate(new Vector3D(0, 0, -30));
          //  VRageRender.MyRenderProxy.DebugDrawAABB(bbox, Color.White, 1, 1, false);


            Matrix m = MatrixD.Identity;
            m.Translation = MySector.MainCamera.Position + MySector.MainCamera.ForwardVector * 50;

          //  VRageRender.MyRenderProxy.DebugDrawAxis(m, 100f, false);

            Vector3I vvLight;
            Vector3 rrLight;
            Vector3 ldir = -MySector.DirectionToSunNormalized;
            ldir.Z *= -1;
            //ldir.Y *= -1;
            findViews(0, ldir, out vvLight, out rrLight);

         //   VRageRender.MyRenderProxy.DebugDrawText3D(m_teapotMatrix.Translation, "L: " + vvLight.ToString() + " " + rrLight.ToString(), Color.White, 0.5f, false);
            VRageRender.MyRenderProxy.DebugDrawLine3D(m_teapotMatrix.Translation, m_teapotMatrix.Translation + MySector.DirectionToSunNormalized * 100, Color.Yellow, Color.Yellow, false);


            //VRageRender.MyRenderProxy.SetUvIndices(m_spawnedTree, vv, rr, vvLight, rrLight);
            //VRageRender.MyRenderProxy.SetImpostorMatrices(s_viewVectors);

            return;
            var mat = "WeaponLaser";
            float thickness = 0.05f;

            float spacing = 5;
            int count = 100;
            Vector4 color = Color.White.ToVector4();

            //Vector3 center = MySector.MainCamera.Position + new Vector3(0, -10, 0);
            Vector3 center = Vector3.Zero;
            Vector3 startPos = center - new Vector3(spacing * count / 2, 0, 0);

            for (int i = 0; i < count; i++)
            {
                Vector3D lineStart = startPos + new Vector3(spacing * i, 0, -spacing * count / 2);
                Vector3D lineEnd = startPos + new Vector3(spacing * i, 0, spacing * count / 2);

                Vector3D closestPoint = Vector3.Zero;
                Vector3D campos = MySector.MainCamera.Position;
                closestPoint = MyUtils.GetClosestPointOnLine(ref lineStart, ref lineEnd, ref campos);
                var distance = MySector.MainCamera.GetDistanceFromPoint(closestPoint);

                var lineThickness = thickness * MathHelper.Clamp(distance, 0.1f, 10);

                MySimpleObjectDraw.DrawLine(lineStart, lineEnd, mat, ref color, (float)lineThickness );
            }

        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:101,代码来源:MyPetaDebugInputComponent.cs

示例6: Draw

            public override void Draw()
            {
                base.Draw();

                if (MySession.Static == null) return;

                var ops = MySession.Static.GetComponent<MyVoxelOperationsSessionComponent>();

                if (ops != null)
                {
                    Text("Cache Enabled: {0}", MyVoxelOperationsSessionComponent.EnableCache);

                    Text("Cache Writing: {0}", ops.ShouldWrite ? "Enabled" : "Disabled");
                    Text("Cache Flushing: {0}", ops.ShouldFlush ? "Enabled" : "Disabled");

                    var storages = ops.QueuedStorages.ToArray();

                    if (storages.Length == 0)
                    {
                        Text(Color.Orange, "No queued storages.");
                    }
                    else
                    {
                        Text(Color.Yellow, 1.2f, "{0} Queued storages:", storages.Length);

                        foreach (var storage in storages)
                        {
                            MyStorageBase.WriteCacheStats stats;
                            storage.GetStats(out stats);
                            Text("Voxel storage {0}:", storage.ToString());
                            Text(Color.White, .9f, "Pending Writes: {0}", stats.QueuedWrites);
                            Text(Color.White, .9f, "Cached Chunks: {0}", stats.CachedChunks);

                            if (DisplayDetails)
                            {
                                foreach (var chunk in stats.Chunks)
                                {
                                    var ck = chunk.Value;
                                    Text(Color.Wheat, .9f, "Chunk {0}: {1} hits; pending {2}", chunk.Key, ck.HitCount, ck.Dirty);
                                }
                            }

                            if (DebugDraw)
                            {
                                var vmap = MySession.Static.VoxelMaps.Instances.FirstOrDefault(x => x.Storage == storage);

                                if (vmap == null) continue;

                                foreach (var chunk in stats.Chunks)
                                {
                                    var box = new BoundingBoxD(chunk.Key << MyStorageBase.VoxelChunk.SizeBits, ((chunk.Key + 1) << MyStorageBase.VoxelChunk.SizeBits));

                                    box.Translate(-((Vector3D)storage.Size * .5) - .5);

                                    MyRenderProxy.DebugDrawOBB(new MyOrientedBoundingBoxD(box, vmap.WorldMatrix), GetColorForDirty(chunk.Value.Dirty), 0.1f, true, true);
                                }
                            }
                        }
                    }
                }
            }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:61,代码来源:MyVoxelDebugInputComponent.StorageWriteCache.cs


注:本文中的BoundingBoxD.Translate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。