Search in sources :

Example 1 with SpaceGraphPhys3D

use of spacegraph.space3d.SpaceGraphPhys3D in project narchy by automenta.

the class DynamicListSpace method show.

/**
 * displays in a window with default force-directed options
 */
@Deprecated
public SpaceGraphPhys3D show(int w, int h, boolean flat) {
    // new SpaceTransform<Term>() {
    // @Override
    // public void update(SpaceGraph<Term> g, AbstractSpace<Term, ?> src, float dt) {
    // float cDepth = -9f;
    // src.forEach(s -> {
    // ((SimpleSpatial)s).moveZ(
    // s.key.volume() * cDepth, 0.05f );
    // });
    // }
    // }
    // new Spiral()
    // //new FastOrganicLayout()
    AbstractSpace ss = flat ? with(new Flatten(0.25f, 0.25f)) : this;
    SpaceGraphPhys3D<X> s = new SpaceGraphPhys3D<>(ss);
    EdgeDirected fd = new EdgeDirected();
    s.dyn.addBroadConstraint(fd);
    fd.attraction.set(fd.attraction.get() * 8);
    // s.ortho(Vis.logConsole(nar, 90, 40, new FloatParam(0f)).opacity(0.25f));
    // Vis.conceptsWindow2D
    // .ortho(logConsole( n, 90, 40, new FloatParam(0f)).opacity(0.25f))
    s.camPos(0, 0, 90).show(w, h);
    return s;
}
Also used : AbstractSpace(spacegraph.space3d.AbstractSpace) Flatten(spacegraph.space2d.container.Flatten) SpaceGraphPhys3D(spacegraph.space3d.SpaceGraphPhys3D) EdgeDirected(spacegraph.space2d.container.EdgeDirected)

Example 2 with SpaceGraphPhys3D

use of spacegraph.space3d.SpaceGraphPhys3D in project narchy by automenta.

the class NAgentX method chart.

public static void chart(NAgent a) {
    NAR nar = a.nar();
    nar.runLater(() -> {
        SpaceGraph.window(grid(new AutoSurface(a), Vis.beliefCharts(nar.dur() * 64, a.actions.keySet(), a.nar()), new EmotionPlot(64, a), grid(// concept query box
        new TextEdit() {

            @Override
            protected void onKeyEnter() {
                String s = text();
                text("");
                try {
                    nar.conceptualize(s);
                } catch (Narsese.NarseseException e) {
                    e.printStackTrace();
                }
                Vis.conceptWindow(s, nar);
            }
        }.surface(), // new WindowButton("log", () -> Vis.logConsole(nar, 80, 25, new FloatParam(0f))),
        new PushButton("dump", () -> {
            try {
                nar.output(Files.createTempFile(a.toString(), "" + System.currentTimeMillis()).toFile(), false);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }), new PushButton("clear", () -> {
            nar.runLater(NAR::clear);
        }), new PushButton("prune", () -> {
            nar.runLater(() -> {
                DoubleHistogram i = new DoubleHistogram(2);
                nar.tasks(true, false, false, false).forEach(t -> i.recordValue(t.conf()));
                float confThresh = (float) i.getValueAtPercentile(25);
                nar.tasks(true, false, false, false).filter(t -> t.conf() < confThresh).forEach(Task::delete);
            });
        }), new WindowToggleButton("top", () -> new ConsoleTerminal(new nars.TextUI(nar).session(10f))), new WindowToggleButton("concept graph", () -> {
            DynamicConceptSpace sg;
            SpaceGraphPhys3D s = new SpaceGraphPhys3D<>(sg = new DynamicConceptSpace(nar, () -> nar.exe.active().iterator(), 128, 16));
            EdgeDirected fd = new EdgeDirected();
            s.dyn.addBroadConstraint(fd);
            fd.attraction.set(fd.attraction.get() * 8);
            s.add(new SubOrtho(// window(
            grid(new AutoSurface<>(fd), new AutoSurface<>(sg.vis))) {
            }.posWindow(0, 0, 1f, 0.2f));
            // ,  400, 400);
            // .pos(0, 0, 0.5f, 0.5f)
            s.camPos(0, 0, 90);
            return s;
        }), a instanceof NAgentX ? new WindowToggleButton("vision", () -> grid(((NAgentX) a).sensorCam.stream().map(cs -> new AspectAlign(new CameraSensorView(cs, a).withControls(), AspectAlign.Align.Center, cs.width, cs.height)).toArray(Surface[]::new))) : grid())), // 
        900, 600);
    });
}
Also used : Bitmap2DSensor(nars.util.signal.Bitmap2DSensor) IntConsumer(java.util.function.IntConsumer) AspectAlign(spacegraph.space2d.container.AspectAlign) Auvent(net.beadsproject.beads.core.Auvent) AutoSurface(spacegraph.space2d.widget.meta.AutoSurface) RealTime(nars.time.RealTime) nars.$.$$(nars.$.$$) DoubleHistogram(org.HdrHistogram.DoubleHistogram) SpaceGraphPhys3D(spacegraph.space3d.SpaceGraphPhys3D) Vis(nars.gui.Vis) Bitmap2D(jcog.signal.Bitmap2D) XoRoShiRo128PlusRandom(jcog.math.random.XoRoShiRo128PlusRandom) Term(nars.term.Term) nars.video(nars.video) ConsoleTerminal(spacegraph.space2d.widget.console.ConsoleTerminal) Loop(jcog.exe.Loop) UGen(net.beadsproject.beads.core.UGen) BufferedImage(java.awt.image.BufferedImage) Util(jcog.Util) FloatArrayList(org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList) Nullable(org.jetbrains.annotations.Nullable) WaveFactory(net.beadsproject.beads.data.WaveFactory) WorkerMultiExec(nars.exe.WorkerMultiExec) SpaceGraph(spacegraph.SpaceGraph) EmotionPlot(nars.gui.EmotionPlot) Tense(nars.time.Tense) net.beadsproject.beads.ugens(net.beadsproject.beads.ugens) Focus(nars.exe.Focus) Surface(spacegraph.space2d.Surface) Function(java.util.function.Function) Supplier(java.util.function.Supplier) nars.$.$(nars.$.$) WindowToggleButton(spacegraph.space2d.widget.meta.WindowToggleButton) SubOrtho(spacegraph.space2d.hud.SubOrtho) Gridding.grid(spacegraph.space2d.container.Gridding.grid) EdgeDirected(spacegraph.space2d.container.EdgeDirected) FloatProcedure(org.eclipse.collections.api.block.procedure.primitive.FloatProcedure) Inperience(nars.op.mental.Inperience) Files(java.nio.file.Files) PushButton(spacegraph.space2d.widget.button.PushButton) DynamicConceptSpace(nars.gui.graph.DynamicConceptSpace) IOException(java.io.IOException) AudioContext(net.beadsproject.beads.core.AudioContext) IntObjectPair(org.eclipse.collections.api.tuple.primitive.IntObjectPair) java.awt(java.awt) TextEdit(spacegraph.space2d.widget.console.TextEdit) BELIEF(nars.Op.BELIEF) ConjClustering(nars.op.stm.ConjClustering) CaffeineIndex(nars.index.term.map.CaffeineIndex) DynamicConceptSpace(nars.gui.graph.DynamicConceptSpace) DoubleHistogram(org.HdrHistogram.DoubleHistogram) IOException(java.io.IOException) SpaceGraphPhys3D(spacegraph.space3d.SpaceGraphPhys3D) EdgeDirected(spacegraph.space2d.container.EdgeDirected) WindowToggleButton(spacegraph.space2d.widget.meta.WindowToggleButton) AspectAlign(spacegraph.space2d.container.AspectAlign) EmotionPlot(nars.gui.EmotionPlot) TextEdit(spacegraph.space2d.widget.console.TextEdit) AutoSurface(spacegraph.space2d.widget.meta.AutoSurface) ConsoleTerminal(spacegraph.space2d.widget.console.ConsoleTerminal) PushButton(spacegraph.space2d.widget.button.PushButton) SubOrtho(spacegraph.space2d.hud.SubOrtho)

Example 3 with SpaceGraphPhys3D

use of spacegraph.space3d.SpaceGraphPhys3D in project narchy by automenta.

the class TestTimeGraphVis method main.

public static void main(String[] args) {
    // NAR n = NARS.threadSafe();
    TestTimeGraphVis cs = new TestTimeGraphVis();
    SpaceGraphPhys3D sg = cs.show(1400, 1000, true);
    sg.add(new SubOrtho(grid(// new AutoSurface<>(sg.dyn.broadConstraints.get(0) /* FD hack */),
    new AutoSurface<>(cs.vis))).posWindow(0, 0, 1f, 0.2f));
    cs.commit(dt());
// {
// MapNodeGraph<Object, Object> h = new MapNodeGraph<>();
// h.addEdge(h.addNode("y"), "yx", h.addNode("x"));
// 
// ObjectGraph o = new ObjectGraph(h);
// cs.commit(o);
// }
}
Also used : AutoSurface(spacegraph.space2d.widget.meta.AutoSurface) SubOrtho(spacegraph.space2d.hud.SubOrtho) SpaceGraphPhys3D(spacegraph.space3d.SpaceGraphPhys3D)

Example 4 with SpaceGraphPhys3D

use of spacegraph.space3d.SpaceGraphPhys3D in project narchy by automenta.

the class OSMTest method main.

public static void main(String[] args) {
    // https://wiki.openstreetmap.org/wiki/API_v0.6
    // http://api.openstreetmap.org/api/0.6/changeset/#id/comment
    // /api/0.6/map?bbox=min_lon,min_lat,max_lon,max_lat (W,S,E,N)
    IRL i = new IRL(User.the());
    i.load(-80.65, 28.58, -80.60, 28.63);
    SpaceGraphPhys3D sg = new SpaceGraphPhys3D(new OsmSpace(i.osm));
    sg.show(800, 800);
    sg.addWindowListener(new WindowAdapter() {

        @Override
        public void windowDestroyed(WindowEvent e) {
            super.windowDestroyed(e);
            System.exit(0);
        }
    });
    sg.add(new SubOrtho(WidgetTest.widgetDemo()).posWindow(0, 0, 0.3f, 1f));
}
Also used : IRL(spacegraph.util.geo.IRL) OsmSpace(spacegraph.space3d.widget.OsmSpace) WindowEvent(com.jogamp.newt.event.WindowEvent) WindowAdapter(com.jogamp.newt.event.WindowAdapter) SubOrtho(spacegraph.space2d.hud.SubOrtho) SpaceGraphPhys3D(spacegraph.space3d.SpaceGraphPhys3D)

Example 5 with SpaceGraphPhys3D

use of spacegraph.space3d.SpaceGraphPhys3D in project narchy by automenta.

the class ExampleStereoTwoViewsOneCamera method main.

public static void main(String[] args) throws InterruptedException {
    ExampleStereoTwoViewsOneCamera e = new ExampleStereoTwoViewsOneCamera();
    new SpaceGraphPhys3D(new SimpleSpatial(e) {

        @Override
        public void renderAbsolute(GL2 gl, int dtMS) {
            for (ColorPoint3D p : e.gui.view.cloud) {
                int cc = p.rgb;
                gl.glColor3f(Bitmap2D.decodeRed(cc), Bitmap2D.decodeGreen(cc), Bitmap2D.decodeBlue(cc));
                Draw.rect(gl, (float) p.x, (float) p.y, 1, 1, (float) p.z);
            }
        }
    }).show(800, 800);
    RayTracer r = RayTracer.raytracer();
    r.update();
    r.renderProgressively();
    r.scene.camera.position.x = 4 - 1;
    // r.scene.camera.direction.x = -0.577 + 0.25f;
    r.update();
    r.renderProgressively();
    e.snap(r.image);
    Thread.sleep(200);
    // new Thread(()->{
    double t = 0;
    // while (true) {
    r.scene.camera.position.x = 4 + 1;
    // r.scene.camera.direction.x = -0.577 - 0.25f;
    r.update();
    if (r.renderProgressively()) {
        r.input.waitForInput();
    }
    // r.scene.camera.position.x += Math.cos(t)*0.2f;
    t += 0.2f;
    // }
    // }).start();
    // new Thread(()->{
    // while (true) {
    e.snap(r.image);
    try {
        Thread.sleep(250);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }
// }
// 
// }).start();
}
Also used : SimpleSpatial(spacegraph.space3d.SimpleSpatial) ColorPoint3D(boofcv.gui.d3.ColorPoint3D) GL2(com.jogamp.opengl.GL2) SpaceGraphPhys3D(spacegraph.space3d.SpaceGraphPhys3D) RayTracer(spacegraph.slam.raytrace.RayTracer) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint)

Aggregations

SpaceGraphPhys3D (spacegraph.space3d.SpaceGraphPhys3D)5 SubOrtho (spacegraph.space2d.hud.SubOrtho)3 EdgeDirected (spacegraph.space2d.container.EdgeDirected)2 AutoSurface (spacegraph.space2d.widget.meta.AutoSurface)2 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)1 ColorPoint3D (boofcv.gui.d3.ColorPoint3D)1 WindowAdapter (com.jogamp.newt.event.WindowAdapter)1 WindowEvent (com.jogamp.newt.event.WindowEvent)1 GL2 (com.jogamp.opengl.GL2)1 java.awt (java.awt)1 BufferedImage (java.awt.image.BufferedImage)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Function (java.util.function.Function)1 IntConsumer (java.util.function.IntConsumer)1 Supplier (java.util.function.Supplier)1 Util (jcog.Util)1 Loop (jcog.exe.Loop)1 XoRoShiRo128PlusRandom (jcog.math.random.XoRoShiRo128PlusRandom)1 Bitmap2D (jcog.signal.Bitmap2D)1