コード例 #1
0
        public static OctData MakeData(string filename)
        {
            OctData data;

            filename = AutocompleteFile(filename);
            string     basename = Path.ChangeExtension(filename, null);
            FileFormat format   = FormatOf(filename);

            if (format == FileFormat.ASDF)
            {
                Trace.WriteLine("Loading from " + filename);
            }
            var raw = OctData.NativeOctData.Generate(filename, format);

            data = new OctData(raw);
            OctData.NativeOctData.Free(raw);
            //else
            //    throw new ArgumentException("Invalid " + Path.GetExtension(filename) + "; can only read .obj or .asdf files.");

            State.buffer_size = (uint)data.Length;
            return(data);

            OctData Sample()
            {
                var children = new Octree[8];

                for (int i = 0; i < 8; i++)
                {
                    var vals = new float[8];
                    for (int j = 0; j < 8; j++)
                    {
                        vals[j] = dist(SdfMath.split(j) + SdfMath.split(i));
                    }
                    children[i] = new Octree(vals);
                }
                var mainvals = new float[8];

                for (int i = 0; i < 8; i++)
                {
                    mainvals[i] = dist(SdfMath.split(i) * 2);
                }
                var t = new Octree(children, mainvals);

                return(new Model(t).Cast());
            }

            float dist(Int3 p) => ((p.Vector - Vector3.One).Length() - 0.6f) * 0.5f;
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.SetOut(Logic.console);
            Trace.Listeners.Add(new TextWriterTraceListener(Logic.console));

            model = Logic.MakeData(args[0]);

            window = Utilities.MakeWindow(720, 720);
            Logic.Init(window);
            window.Resized += Resize;

            FPS fpsCounter = new FPS();

            device = VeldridStartup.CreateGraphicsDevice(window, new GraphicsDeviceOptions(DebugMode, null, false, ResourceBindingModel.Improved));
            CreateResources();
            DateTime start = DateTime.Now;
            TimeSpan delta = TimeSpan.FromSeconds(0);

            Logic.Heading      = Logic.Heading;
            Logic.Position     = Logic.Position;
            window.WindowState = WindowState.Maximized;

            while (window.Exists)
            {
                if (loader != null && loader.IsCompleted)
                {
                    model             = loader.Result;
                    compute["data"]   = model.StructBuffer();
                    compute["values"] = model.ValueTexture();
                    compute.Update(factory);
                    loader = null;
                }
                delta = DateTime.Now - start;
                start = DateTime.Now;

                var input = window.PumpEvents();
                Logic.Update(delta, input);
                Logic.MakeGUI(fpsCounter.Frames);
                Draw();
                fpsCounter.Frame();
            }
            ImGui.DestroyContext();
            DisposeResources();
        }
コード例 #3
0
 internal static void Serialize(OctData data, BinaryWriter writer)
 {
     throw new NotImplementedException();
 }