Example #1
0
        private static Matrix GetMatrixEyeTranslation(bool isLeftEye, Matrix view)
        {
            float Ipd_2 = 0.2f;

            if (MyOpenVR.Static != null)
            {
                Ipd_2 = MyOpenVR.Ipd_2;
            }

            var invViewMatrix = Matrix.Transpose(view);
            var eyePosition   = (!isLeftEye ? invViewMatrix.Left : invViewMatrix.Right) * Ipd_2;

            return(Matrix.CreateTranslation(eyePosition));
        }
Example #2
0
            internal void StepUpdateProbe()
            {
                if (state == 0)
                {
                    position = MyEnvironment.CameraPosition + Vector3.UnitY * 4;
                }

                if (state < 6)
                {
                    int faceId = state;
                    MyImmediateRC.RC.Context.ClearDepthStencilView(m_cubemapDepth.SubresourceDsv(faceId), DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1, 0);
                    MyImmediateRC.RC.Context.ClearRenderTargetView(workCubemap.SubresourceRtv(faceId), new Color4(0, 0, 0, 0));

                    var localViewProj = Matrix.CreateTranslation(MyEnvironment.CameraPosition - position) * PrepareLocalEnvironmentMatrix(Vector3.Zero, new Vector2I(256, 256), faceId, 40.0f);
                    var viewProj      = MatrixD.CreateTranslation(-position) * localViewProj;

                    AddForwardCamera(ref localViewProj, ref viewProj, new MyViewport(0, 0, 256, 256), m_cubemapDepth.SubresourceDsv(faceId), workCubemap.SubresourceRtv(faceId));

                    ++state;
                    return;
                }
            }
Example #3
0
        internal unsafe void RecordCommands(MyRenderableProxy proxy, VertexBufferId stream, int voxelMatId)
        {
            var          worldMatrix = Matrix.CreateTranslation(-MyEnvironment.CameraPosition);
            MyObjectData objectData  = proxy.ObjectData;

            objectData.LocalMatrix = worldMatrix;

            MyMapping mapping;

            mapping = MyMapping.MapDiscard(RC.Context, proxy.objectBuffer);
            void *ptr = &objectData;

            mapping.stream.Write(new IntPtr(ptr), 0, sizeof(MyObjectData));
            mapping.Unmap();

            RC.SetCB(MyCommon.OBJECT_SLOT, proxy.objectBuffer);

            RC.BindRawSRV(0, MyTextures.GetView(MyTextures.GetTexture(MyVoxelMaterials1.Table[voxelMatId].FoliageArray_Texture, MyTextureEnum.COLOR_METAL, true)));

            RC.SetVB(0, stream.Buffer, stream.Stride);
            Context.DrawAuto();
            RC.Stats.DrawAuto++;
        }
        internal static void DrawBatched()
        {
            bool rebuild = false;

            if (m_group == null || rebuild)
            {
                if (m_group != null)
                {
                    m_group.Clear();
                }

                //m_group = new MyClassicInstancing();
                m_group = new MySoftInstancingGroup2();

                HashSet <string> testModels = new HashSet <string>();
                testModels.Add("Models//Cubes//Large//StoneCube.mwm");
                testModels.Add("Models//Cubes//Large//BattlementAdvancedRoundLarge.mwm");
                testModels.Add("Models//Cubes//large//RoofTileCornerRoundTallFake.mwm");
                testModels.Add("Models//Cubes//Large//StoneSlopeStairs.mwm");
                testModels.Add("Models//Debris//Debris10.mwm");
                testModels.Add("Models//Cubes//small//RotorBlockCogWheel2.mwm");
                testModels.Add("Models//Cubes//Large//BattlementStoneCorner.mwm");
                testModels.Add("Models//Cubes//Large//GeneratedStoneBattlementCorner.mwm");
                testModels.Add("Models//Cubes//Large//HouseStoneRoundedFull.mwm");
                testModels.Add("Models//Cubes//large//RoofTileCornerRoundTallFake.mwm");
                testModels.Add("Models//Cubes//large//StoneBattlementAdvancedRound_5.mwm");
                testModels.Add("Models//Cubes//large//RoofTileSlopeWoodFakeTopRight.mwm");
                testModels.Add("Models//Cubes//Large//CrossRoad.mwm");

                var rnd = new Random();

                for (int i = 0; i < 100; i++)
                {
                    for (int j = 0; j < 100; j++)
                    {
                        for (int k = 0; k < 2; k++)
                        {
                            m_group.AddInstance(testModels.ElementAt(rnd.Next(0, testModels.Count)), Matrix.CreateTranslation(50.0f + i * 4.0f, 150.0f + k * 4.0f, 50.0f + (j + 0) * 4.0f));
                        }
                    }
                }

                m_group.SendToGpu();

                rebuild = false;
            }

            m_group.Draw();
        }