Ejemplo n.º 1
0
        public void fpsLook(Vec3f lookpos, Vec3f lookrot)
        {
            IntPtr p = CustomMarshal.Alloc(typeof(FloatVector));
            IntPtr f = CustomMarshal.Alloc(typeof(FloatVector));
            IntPtr r = CustomMarshal.Alloc(typeof(FloatVector));

            isarc    = false;
            parampos = new Vec3f(lookpos);
            paramrot = new Vec3f(lookrot);

            var ps = new FloatVector(lookpos);
            var rt = new FloatVector(lookrot);

            Maths_CameraFPSLook(ref ps, ref rt, p, f, r);

            pos   = new Vec3f((FloatVector)CustomMarshal.PtrToStructure(p, typeof(FloatVector), false));
            fwd   = new Vec3f((FloatVector)CustomMarshal.PtrToStructure(f, typeof(FloatVector), false));
            right = new Vec3f((FloatVector)CustomMarshal.PtrToStructure(r, typeof(FloatVector), false));

            CustomMarshal.Free(p);
            CustomMarshal.Free(f);
            CustomMarshal.Free(r);
        }
Ejemplo n.º 2
0
        public void fpsLook(Vec3f pos, Vec3f rot)
        {
            IntPtr p = CustomMarshal.Alloc(typeof(FloatVector));
            IntPtr f = CustomMarshal.Alloc(typeof(FloatVector));
            IntPtr r = CustomMarshal.Alloc(typeof(FloatVector));

            isarc = false;
            parampos = new Vec3f(pos);
            paramrot = new Vec3f(rot);

            var ps = new FloatVector(pos);
            var rt = new FloatVector(rot);

            Maths_CameraFPSLook(ref ps, ref rt, p, f, r);

            pos = new Vec3f((FloatVector)CustomMarshal.PtrToStructure(p, typeof(FloatVector), false));
            fwd = new Vec3f((FloatVector)CustomMarshal.PtrToStructure(f, typeof(FloatVector), false));
            right = new Vec3f((FloatVector)CustomMarshal.PtrToStructure(r, typeof(FloatVector), false));

            CustomMarshal.Free(p);
            CustomMarshal.Free(f);
            CustomMarshal.Free(r);
        }
Ejemplo n.º 3
0
        public void Arcball(float dist, Vec3f rot)
        {
            IntPtr p = CustomMarshal.Alloc(typeof(FloatVector));
            IntPtr f = CustomMarshal.Alloc(typeof(FloatVector));
            IntPtr r = CustomMarshal.Alloc(typeof(FloatVector));

            isarc      = true;
            parampos.x = dist;
            parampos.y = 0.0f;
            parampos.z = 0.0f;
            paramrot   = new Vec3f(rot);

            var rt = new FloatVector(rot);

            Maths_CameraArcball(dist, ref rt, p, f, r);

            pos   = new Vec3f((FloatVector)CustomMarshal.PtrToStructure(p, typeof(FloatVector), false));
            fwd   = new Vec3f((FloatVector)CustomMarshal.PtrToStructure(f, typeof(FloatVector), false));
            right = new Vec3f((FloatVector)CustomMarshal.PtrToStructure(r, typeof(FloatVector), false));

            CustomMarshal.Free(p);
            CustomMarshal.Free(f);
            CustomMarshal.Free(r);
        }
Ejemplo n.º 4
0
        public void Arcball(float dist, Vec3f rot)
        {
            IntPtr p = CustomMarshal.Alloc(typeof(FloatVector));
            IntPtr f = CustomMarshal.Alloc(typeof(FloatVector));
            IntPtr r = CustomMarshal.Alloc(typeof(FloatVector));

            isarc = true;
            parampos.x = dist;
            parampos.y = 0.0f;
            parampos.z = 0.0f;
            paramrot = new Vec3f(rot);

            var rt = new FloatVector(rot);

            Maths_CameraArcball(dist, ref rt, p, f, r);

            pos = new Vec3f((FloatVector)CustomMarshal.PtrToStructure(p, typeof(FloatVector), false));
            fwd = new Vec3f((FloatVector)CustomMarshal.PtrToStructure(f, typeof(FloatVector), false));
            right = new Vec3f((FloatVector)CustomMarshal.PtrToStructure(r, typeof(FloatVector), false));

            CustomMarshal.Free(p);
            CustomMarshal.Free(f);
            CustomMarshal.Free(r);
        }
Ejemplo n.º 5
0
        private void checkerBack_Click(object sender, EventArgs e)
        {
            var defaults = new TextureDisplay();

            darkBack = m_TexDisplay.darkBackgroundColour = defaults.darkBackgroundColour;
            lightBack = m_TexDisplay.lightBackgroundColour = defaults.lightBackgroundColour;

            backcolorPick.Checked = false;
            checkerBack.Checked = true;

            m_Core.Renderer.BeginInvoke(RT_UpdateAndDisplay);

            if (m_Output == null)
            {
                render.Invalidate();
                pixelContext.Invalidate();
            }
        }
Ejemplo n.º 6
0
        private void backcolorPick_Click(object sender, EventArgs e)
        {
            var result = colorDialog.ShowDialog();

            if (result == DialogResult.OK || result == DialogResult.Yes)
            {
                darkBack = lightBack = m_TexDisplay.darkBackgroundColour =
                    m_TexDisplay.lightBackgroundColour = new FloatVector(
                        ((float)colorDialog.Color.R) / 255.0f,
                        ((float)colorDialog.Color.G) / 255.0f,
                        ((float)colorDialog.Color.B) / 255.0f);

                backcolorPick.Checked = true;
                checkerBack.Checked = false;
            }

            m_Core.Renderer.BeginInvoke(RT_UpdateAndDisplay);

            if (m_Output == null)
            {
                render.Invalidate();
                pixelContext.Invalidate();
            }
        }
Ejemplo n.º 7
0
 private void ApplyPersistData(PersistData data)
 {
     onloadLayout = data.panelLayout;
     darkBack = data.darkBack;
     lightBack = data.lightBack;
 }
Ejemplo n.º 8
0
 public Vec3f(FloatVector v)
 {
     x = v.x; y = v.y; z = v.z;
 }
Ejemplo n.º 9
0
 public Vec3f(FloatVector v) { x = v.x; y = v.y; z = v.z; }
Ejemplo n.º 10
0
        private FloatVector GetPosition(UIState ui, int rowidx)
        {
            if (rowidx >= 0 && rowidx < ui.m_Rows.Length)
            {
                uint offset = 0;
                foreach (var el in ui.m_Input.BufferFormats)
                {
                    if (el.name.ToUpper() == "POSITION" || el.name.ToUpper() == "SV_POSITION")
                    {
                        Stream stream = new MemoryStream(ui.m_RawData);
                        BinaryReader reader = new BinaryReader(stream);

                        uint offs = (uint)(ui.m_RawStride * rowidx + offset);

                        uint numComps = Math.Min(el.format.compCount, 4);

                        if (offs > ui.m_RawData.Length || offs + sizeof(float) * numComps > ui.m_RawData.Length)
                            return new FloatVector();

                        stream.Seek(offs, SeekOrigin.Begin);

                        var ret = new FloatVector();

                        if (el.format.compByteWidth == 4)
                        {
                            for (int i = 0; i < numComps; i++)
                            {
                                if (i == 0) ret.x = reader.ReadSingle();
                                if (i == 1) ret.y = reader.ReadSingle();
                                if (i == 2) ret.z = reader.ReadSingle();
                                if (i == 3) ret.w = reader.ReadSingle();
                            }
                        }
                        else if (el.format.compByteWidth == 2)
                        {
                            for (int i = 0; i < numComps; i++)
                            {
                                ushort data = reader.ReadUInt16();
                                if (i == 0) ret.x = el.format.ConvertFromHalf(data);
                                if (i == 1) ret.y = el.format.ConvertFromHalf(data);
                                if (i == 2) ret.z = el.format.ConvertFromHalf(data);
                                if (i == 3) ret.w = el.format.ConvertFromHalf(data);
                            }
                        }

                        return ret;
                    }

                    offset += el.ByteSize;
                }
            }

            return new FloatVector();
        }
Ejemplo n.º 11
0
 private static extern void Maths_CameraFPSLook(ref FloatVector lookpos, ref FloatVector rot, IntPtr pos, IntPtr fwd, IntPtr right);
Ejemplo n.º 12
0
 private static extern void Maths_CameraArcball(float dist, ref FloatVector rot, IntPtr pos, IntPtr fwd, IntPtr right);
Ejemplo n.º 13
0
 private static extern void Maths_CameraFPSLook(ref FloatVector lookpos, ref FloatVector rot, IntPtr pos, IntPtr fwd, IntPtr right);
Ejemplo n.º 14
0
 private static extern void Maths_CameraArcball(float dist, ref FloatVector rot, IntPtr pos, IntPtr fwd, IntPtr right);