• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# VRageMath.Vector3类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中VRageMath.Vector3的典型用法代码示例。如果您正苦于以下问题:C# Vector3类的具体用法?C# Vector3怎么用?C# Vector3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Vector3类属于VRageMath命名空间,在下文中一共展示了Vector3类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: DrawTriangle

        internal static void DrawTriangle(Vector3 v0, Vector3 v1, Vector3 v2, Color color)
        {
            var distance = ((v0 + v1 + v2) / 3f - MyEnvironment.CameraPosition).LengthSquared();
            m_triangleSortDistance.Add(distance);

            m_vertexList.Add(new MyVertexFormatPositionColor(v0, color));
            m_vertexList.Add(new MyVertexFormatPositionColor(v1, color));
            m_vertexList.Add(new MyVertexFormatPositionColor(v2, color));
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:9,代码来源:MyShapesRenderer.cs


示例2: AddBillboardOriented

        internal static void AddBillboardOriented(string material,
            Color color, Vector3D origin, Vector3 leftVector, Vector3 upVector, float radius, int priority = 0, int customViewProjection = -1)
        {
            Debug.Assert(material != null);

            origin.AssertIsValid();
            leftVector.AssertIsValid();
            upVector.AssertIsValid();
            radius.AssertIsValid();
            MyDebug.AssertDebug(radius > 0);

            MyBillboard billboard = SpawnBillboard();
            if (billboard == null)
                return;

            billboard.Priority = priority;
            billboard.CustomViewProjection = customViewProjection;

            MyQuadD quad;
            MyUtils.GetBillboardQuadOriented(out quad, ref origin, radius, ref leftVector, ref upVector);

            CreateBillboard(billboard, ref quad, material, ref color, ref origin);
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:23,代码来源:MyBillboardRenderer.cs


示例3: AddBillboardOriented

        //  Add billboard for one frame only. This billboard isn't particle (it doesn't survive this frame, doesn't have update/draw methods, etc).
        //  This billboard isn't facing the camera. It's always oriented in specified direction. May be used as thrusts, or inner light of reflector.
        //  It's used by other classes when they want to draw some billboard (e.g. rocket thrusts, reflector glare).
        public static void AddBillboardOriented(string material,
            Color color, Vector3D origin, Vector3 leftVector, Vector3 upVector, float radius, int priority = 0, bool colorize = false, int customViewProjection = -1)
        {
            Debug.Assert(material != null);

            if (!IsEnabled) return;

            origin.AssertIsValid();
            leftVector.AssertIsValid();
            upVector.AssertIsValid();
            radius.AssertIsValid();
            MyDebug.AssertDebug(radius > 0);


            MyBillboard billboard = m_billboardOncePool.Allocate();
            if (billboard == null)
                return;

            billboard.Priority = priority;
            billboard.CustomViewProjection = customViewProjection;

            MyQuadD quad;
            MyUtils.GetBillboardQuadOriented(out quad, ref origin, radius, ref leftVector, ref upVector);

            CreateBillboard(billboard, ref quad, material, ref color, ref origin, colorize);

            m_billboardsOnce.Add(billboard);
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:31,代码来源:MyTransparentGeometry.cs


示例4: LoadAnimationData

        public void LoadAnimationData()
        {
            if (m_loadedData) return;

            lock (this)
            {
                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyModel::LoadAnimationData");


                MyLog.Default.WriteLine("MyModel.LoadData -> START", LoggingOptions.LOADING_MODELS);
                MyLog.Default.IncreaseIndent(LoggingOptions.LOADING_MODELS);

                MyLog.Default.WriteLine("m_assetName: " + m_assetName, LoggingOptions.LOADING_MODELS);

                //  Read data from model TAG parameter. There are stored vertex positions, triangle indices, vectors, ... everything we need.
                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Model - load data - import data");

                MyLog.Default.WriteLine(String.Format("Importing asset {0}, path: {1}", m_assetName, AssetName), LoggingOptions.LOADING_MODELS);
                try
                {
                    m_importer.ImportData(AssetName);
                }
                catch
                {
                    MyLog.Default.WriteLine(String.Format("Importing asset failed {0}", m_assetName));
                    throw;
                }
                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Model - load data - load tag data");
                Dictionary<string, object> tagData = m_importer.GetTagData();
                if (tagData.Count == 0)
                {
                    throw new Exception(String.Format("Uncompleted tagData for asset: {0}, path: {1}", m_assetName, AssetName));
                }

                DataVersion = m_importer.DataVersion;

                Animations = (ModelAnimations)tagData[MyImporterConstants.TAG_ANIMATIONS];
                Bones = (MyModelBone[])tagData[MyImporterConstants.TAG_BONES];

                BoundingBox = (BoundingBox)tagData[MyImporterConstants.TAG_BOUNDING_BOX];
                BoundingSphere = (BoundingSphere)tagData[MyImporterConstants.TAG_BOUNDING_SPHERE];
                BoundingBoxSize = BoundingBox.Max - BoundingBox.Min;
                BoundingBoxSizeHalf = BoundingBoxSize / 2.0f;
                Dummies = tagData[MyImporterConstants.TAG_DUMMIES] as Dictionary<string, MyModelDummy>;
                BoneMapping = tagData[MyImporterConstants.TAG_BONE_MAPPING] as VRageMath.Vector3I[];
                if (BoneMapping.Length == 0)
                    BoneMapping = null;

                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

                ModelInfo = new MyModelInfo(GetTrianglesCount(), GetVerticesCount(), BoundingBoxSize);

                m_loadedData = true;

                MyLog.Default.DecreaseIndent(LoggingOptions.LOADING_MODELS);
                MyLog.Default.WriteLine("MyModel.LoadAnimationData -> END", LoggingOptions.LOADING_MODELS);

                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:62,代码来源:MyModel.cs


示例5: GetVertex

 public void GetVertex(int vertexIndex1, int vertexIndex2, int vertexIndex3, out Vector3 v1, out Vector3 v2, out Vector3 v3)
 {
     v1 = GetVertex(vertexIndex1);
     v2 = GetVertex(vertexIndex2);
     v3 = GetVertex(vertexIndex3);
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:6,代码来源:MyModel.cs


示例6: UpdatePointlight

        internal static void UpdatePointlight(LightId light, bool enabled, float range, Vector3 color, float falloff)
        {
            Pointlights[light.Index].Range = range;
            Pointlights[light.Index].Color = color;
            Pointlights[light.Index].Falloff = falloff;
            Pointlights[light.Index].Enabled = enabled;

            
            var proxy = Pointlights[light.Index].BvhProxyId;
            var difference = Vector3D.RectangularDistance(ref Pointlights[light.Index].LastBvhUpdatePosition, ref Lights.Data[light.Index].PositionWithOffset);

            bool dirty = (enabled && ((proxy == -1) || (difference > MOVE_TOLERANCE))) || (!enabled && proxy != -1);

            if(dirty)
            {
                DirtyPointlights.Add(light);
            }
            else
            {
                DirtyPointlights.Remove(light);
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:22,代码来源:MyLight.cs


示例7: MyVertexFormatPositionH4

 internal MyVertexFormatPositionH4(Vector3 position)
 {
     
     Position = VF_Packer.PackPosition(ref position);
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:5,代码来源:MyVertexFormats.cs


示例8: MyVertexFormatPositionColor

 internal MyVertexFormatPositionColor(Vector3 position, Byte4 color)
 {
     Position = position;
     Color = color;
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:5,代码来源:MyVertexFormats.cs


示例9: Draw6FacedConvexZ

        // Assuming engine order (+Z first)
        internal static unsafe void Draw6FacedConvexZ(Vector3* vertices, Color color, float alpha)
        {
            Color c = color;
            c.A = (byte)(alpha * 255);

            DrawQuadClockWise(vertices[0], vertices[1], vertices[2], vertices[3], c);
            DrawQuadClockWise(vertices[4], vertices[5], vertices[6], vertices[7], c);

            /* top left bottom right */
            DrawQuadClockWise(vertices[0], vertices[1], vertices[5], vertices[4], c);
            DrawQuadClockWise(vertices[0], vertices[3], vertices[7], vertices[4], c);
            DrawQuadClockWise(vertices[3], vertices[2], vertices[6], vertices[7], c);
            DrawQuadClockWise(vertices[2], vertices[1], vertices[5], vertices[6], c);
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:15,代码来源:MyPrimitivesRenderer.cs


示例10: UpdateVectors

 static void UpdateVectors()
 {
     MatrixD invertedViewMatrix;
     MatrixD.Invert(ref ViewMatrix, out invertedViewMatrix);
     ForwardVector = (Vector3)invertedViewMatrix.Forward;
     LeftVector = (Vector3)invertedViewMatrix.Left;
     UpVector = (Vector3)invertedViewMatrix.Up;
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:8,代码来源:MyRenderCamera.cs


示例11: DrawNormalGlare

        internal static void DrawNormalGlare(LightId light, ref MyGlareDesc glare, Vector3 L, float distance)
        {
            //if (m_occlusionRatio <= MyMathConstants.EPSILON)
            //    return;

            var intensity = glare.Intensity;
            var maxDistance = glare.MaxDistance;

            //float alpha = m_occlusionRatio * intensity;
            float alpha = intensity;


            const float minGlareRadius = 0.2f;
            const float maxGlareRadius = 10;
            float radius = MathHelper.Clamp(glare.Range * 20, minGlareRadius, maxGlareRadius);

            float drawingRadius = radius * glare.Size;

            if (glare.Type == MyGlareTypeEnum.Directional)
            {
                float dot = Vector3.Dot(L, glare.Direction);
                alpha *= dot;
            }

            if (alpha <= MyMathConstants.EPSILON)
                return;

            if (distance > maxDistance * .5f)
            {
                // distance falloff
                float falloff = (distance - .5f * maxDistance) / (.5f * maxDistance);
                falloff = (float)Math.Max(0, 1 - falloff);
                drawingRadius *= falloff;
                alpha *= falloff;
            }

            if (drawingRadius <= float.Epsilon)
                return;

            var color = glare.Color;
            color.A = 0;

            MyBillboardsHelper.AddBillboardOriented(glare.Material.ToString(), 
                color * alpha, light.Position, MyEnvironment.InvView.Left, MyEnvironment.InvView.Up, drawingRadius);
        }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:45,代码来源:MyLightRendering.cs


示例12: SetViewMatrix

        public void SetViewMatrix(MatrixD value)
        {
            ViewMatrix = value;

            MatrixD.Invert(ref ViewMatrix, out WorldMatrix);
            Position = WorldMatrix.Translation;
            InversePositionTranslationMatrix = MatrixD.CreateTranslation(-Position);

            PreviousPosition = Position;

            ForwardVector = (Vector3)WorldMatrix.Forward;
            UpVector = (Vector3)WorldMatrix.Up;
            LeftVector = (Vector3)WorldMatrix.Left;

            //  Projection matrix according to zoom level
            ProjectionMatrix = MatrixD.CreatePerspectiveFieldOfView(FovWithZoom, ForwardAspectRatio,
                GetSafeNear(),
                FarPlaneDistance);

            ViewProjectionMatrix = ViewMatrix * ProjectionMatrix;

            //  Projection matrix according to zoom level
            float near = System.Math.Min(NearPlaneDistance, NearForNearObjects); //minimum cockpit distance 
            ProjectionMatrixForNearObjects = MatrixD.CreatePerspectiveFieldOfView(FovWithZoomForNearObjects, ForwardAspectRatio,
                near,
                FarForNearObjects);

            float safenear = System.Math.Min(4, NearPlaneDistance); //minimum cockpit distance

            ViewMatrixAtZero = value;
            ViewMatrixAtZero.M14 = 0;
            ViewMatrixAtZero.M24 = 0;
            ViewMatrixAtZero.M34 = 0;
            ViewMatrixAtZero.M41 = 0;
            ViewMatrixAtZero.M42 = 0;
            ViewMatrixAtZero.M43 = 0;
            ViewMatrixAtZero.M44 = 1;

            UpdateBoundingFrustum();

            VRageRender.MyRenderProxy.SetCameraViewMatrix(
                value,
                ProjectionMatrix,
                ProjectionMatrixForNearObjects,
                safenear,
                Zoom.GetFOVForNearObjects(),
                Zoom.GetFOV(),
                NearPlaneDistance,
                FarPlaneDistance,
                NearForNearObjects,
                FarForNearObjects,
                Position);
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:53,代码来源:MyCamera.cs


示例13: MyVertexFormatPositionPackedColor

 internal MyVertexFormatPositionPackedColor(Vector3 position, Byte4 color)
 {
     Position = new HalfVector4(position.X, position.Y, position.Z, 1);
     Color = color;
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:5,代码来源:MyVertexFormats.cs


示例14: DrawQuadRowWise

 internal static void DrawQuadRowWise(Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3, Color color)
 {
     DrawTriangle(v0, v1, v2, color);
     DrawTriangle(v1, v3, v2, color);
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:5,代码来源:MyPrimitivesRenderer.cs


示例15: Translate

 internal void Translate(Vector3 v)
 {
     m_row0.W += v.X;
     m_row1.W += v.Y;
     m_row2.W += v.Z;
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:6,代码来源:MyGbufferPass.cs


示例16: MyVertexFormatPositionTextureH

 internal MyVertexFormatPositionTextureH(Vector3 position, HalfVector2 texcoord)
 {
     Position = position;
     Texcoord = texcoord;
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:5,代码来源:MyVertexFormats.cs


示例17: CreateRenderable

        internal static RenderableId CreateRenderable(EntityId entity, MeshId model, Vector3 keyColor)
        {
            var id = new RenderableId { Index = Renderables.Allocate() };

            Renderables.Data[id.Index] = new MyRenderableInfo
            {
                KeyColor = keyColor,
                ObjectDithering = 0,
                Mesh = model
            };

            EntityDirty.Add(entity);

            RenderableIndex[entity] = id;

            return id;
        }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:17,代码来源:MyRenderableComponent.cs


示例18: UpdateSpotlight

        internal static void UpdateSpotlight(LightId light, bool enabled, 
            Vector3 direction, float range, float apertureCos, Vector3 up,
            Vector3 color, float falloff, TexId reflectorTexture)
        {
            var info = Spotlights[light.Index];

            var gid = light.ParentGID;
            if (gid != -1 && MyIDTracker<MyActor>.FindByID((uint)gid) != null)
            {
                var matrix = MyIDTracker<MyActor>.FindByID((uint)gid).WorldMatrix;
                Vector3.TransformNormal(ref direction, ref matrix, out direction);
                Vector3.TransformNormal(ref up, ref matrix, out up);
            }

            bool aabbChanged = info.Direction != direction || info.Range != range || info.ApertureCos != apertureCos || info.Up != up;

            Spotlights[light.Index].Enabled = enabled;
            Spotlights[light.Index].Direction = direction;
            Spotlights[light.Index].Range = range;
            Spotlights[light.Index].ApertureCos = apertureCos;
            Spotlights[light.Index].Up = up;
            Spotlights[light.Index].Falloff = falloff;
            Spotlights[light.Index].Color = color;
            Spotlights[light.Index].ReflectorTexture = reflectorTexture;

            var proxy = Spotlights[light.Index].BvhProxyId;
            var positionDifference = Vector3D.RectangularDistance(ref Spotlights[light.Index].LastBvhUpdatePosition, ref Lights.Data[light.Index].PositionWithOffset);

            bool dirty = (enabled && ((proxy == -1) || (positionDifference > MOVE_TOLERANCE || aabbChanged))) || (!enabled && proxy != -1);

            if (dirty)
            {
                DirtySpotlights.Add(light);
            }
            else
            {
                DirtySpotlights.Remove(light);
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:39,代码来源:MyLight.cs


示例19: Construct

        internal override void Construct()
        {
            base.Construct();

            Type = MyActorComponentEnum.Renderable;
            //m_mesh = null;
            m_lods = null;
            m_cullProxy = MyProxiesFactory.CreateCullProxy();
            m_btreeProxy = -1;

            Mesh = MeshId.NULL;
            Instancing = InstancingId.NULL;
            
            m_instanceCount = 0;
            m_startInstance = 0;

            m_isRenderedStandalone = true;

            m_keyColor = Vector3.One;
            m_objectDithering = 0;

            m_renderableProxiesForLodTransition = null;

            m_lodTransitionState = 0;
            m_lod = 0;

            m_voxelLod = -1;
            m_additionalFlags = 0;

            ModelProperties = new Dictionary<MyEntityMaterialKey, MyModelProperties>();
        }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:31,代码来源:MyRenderableComponent.cs


示例20: LoadData


//.........这里部分代码省略.........
                    if (maxIndex <= ushort.MaxValue)
                    {
                        // create 16 bit indices
                        m_Indices_16bit = new ushort[indices.Count];
                        for (int i = 0; i < indices.Count; i++)
                        {
                            m_Indices_16bit[i] = (ushort)indices[i];
                        }
                    }
                    else
                    {
                        // use 32bit indices
                        m_Indices = indices.ToArray();
                    }
                }

                if (tagData.ContainsKey(MyImporterConstants.TAG_MODEL_BVH))
                {
                    m_bvh = new MyQuantizedBvhAdapter(tagData[MyImporterConstants.TAG_MODEL_BVH] as GImpactQuantizedBvh, this);
                }

                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Model - load data - other data");

                Animations = (ModelAnimations)tagData[MyImporterConstants.TAG_ANIMATIONS];
                Bones = (MyModelBone[])tagData[MyImporterConstants.TAG_BONES];

                BoundingBox = (BoundingBox)tagData[MyImporterConstants.TAG_BOUNDING_BOX];
                BoundingSphere = (BoundingSphere)tagData[MyImporterConstants.TAG_BOUNDING_SPHERE];
                BoundingBoxSize = BoundingBox.Max - BoundingBox.Min;
                BoundingBoxSizeHalf = BoundingBoxSize / 2.0f;
                Dummies = tagData[MyImporterConstants.TAG_DUMMIES] as Dictionary<string, MyModelDummy>;
                BoneMapping = tagData[MyImporterConstants.TAG_BONE_MAPPING] as VRageMath.Vector3I[];

                if (tagData.ContainsKey(MyImporterConstants.TAG_MODEL_FRACTURES))
                    ModelFractures = (MyModelFractures)tagData[MyImporterConstants.TAG_MODEL_FRACTURES];

                object patternScale;
                if (tagData.TryGetValue(MyImporterConstants.TAG_PATTERN_SCALE, out patternScale))
                {
                    PatternScale = (float)patternScale;
                }

                if (BoneMapping.Length == 0)
                    BoneMapping = null;

                if (tagData.ContainsKey(MyImporterConstants.TAG_HAVOK_COLLISION_GEOMETRY))
                {
                    HavokData = (byte[])tagData[MyImporterConstants.TAG_HAVOK_COLLISION_GEOMETRY];
                    byte[] tagCollisionData = (byte[])tagData[MyImporterConstants.TAG_HAVOK_COLLISION_GEOMETRY];
                    if (tagCollisionData.Length > 0 && HkBaseSystem.IsThreadInitialized)
                    {
                        bool containsSceneData;
                        bool containsDestructionData;
                        List<HkShape> shapesList = new List<HkShape>();
                        if (!HkShapeLoader.LoadShapesListFromBuffer(tagCollisionData, shapesList, out containsSceneData, out containsDestructionData))
                        {
                            MyLog.Default.WriteLine(string.Format("Model {0} - Unable to load collision geometry", AssetName), LoggingOptions.LOADING_MODELS);
                        //Debug.Fail("Collision model was exported in wrong way: " + m_assetName);
                        }

                        if (shapesList.Count > 10)
                            MyLog.Default.WriteLine(string.Format("Model {0} - Found too many collision shapes, only the first 10 will be used", AssetName), LoggingOptions.LOADING_MODELS);

                        if (HavokCollisionShapes != null)
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:67,代码来源:MyModel.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# VRageRender.PixelShaderId类代码示例发布时间:2022-05-26
下一篇:
C# VRageMath.Vector2类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap