Git Product home page Git Product logo

Comments (28)

zeffii avatar zeffii commented on June 12, 2024 3
from sverchok.nodes.generator.torus import torus_verts, torus_edges, torus_polygons

from svrx.util.geom import vectorize
from svrx.util.smesh import SMesh

@vectorize
def make_torus(R, r, N1, N2, rPhase, sPhase):
    v = torus_verts(R, r, N1, N2, rPhase, sPhase, False)[0]
    e = torus_edges(N1, N2)
    f = torus_polygons(N1, N2)
    return SMesh.from_pydata(v, e, f).as_rxdata

@node_script
def sn_torus(
    R: Float = 2.0, r: Float = 0.6, 
    N1: Int = 22, N2: Int = 15, 
    rPhase: Float = 0.0,
    sPhase: Float = 0.0) -> ([Vertices], [Edges], [Faces]):
    return list(make_torus(R, r, N1, N2, rPhase, sPhase))

hahaha :)

from sverchok.

zeffii avatar zeffii commented on June 12, 2024 1

almost..

from sverchok.nodes.generator.sphere import sphere_verts, sphere_edges, sphere_faces
from svrx.util.geom import vectorize
from svrx.util.mesh import rxdata_from_pydata

@vectorize
def make_sphere(U, V, Radius):
    v = sphere_verts(U, V, Radius, False)
    e = sphere_edges(U, V)
    f = sphere_faces(U, V)
    return rxdata_from_pydata(v, e, f)

@node_script
def sn_sphere(U: Int = 12, V: Int = 10, Radius: Float = 1.0) -> ([Vertices], [Edges], [Faces]):
    return list(make_sphere(U, V, Radius))

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

Absolutely needed.

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

I really need to sort out the generator pattern.

Otherwise I will have a check at it tomorrow.

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

For sn it works quite well to import from Sverchok, nice touch :)

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

I keep getting called away.. can barely finish thoughts :/ but it seems SN is showing Int / Float as property names instead of U..V..Radius.. now?

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

image

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

Most have messed up then. Will take look at that.

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

edges (even though they would be skipped with this example's full polygon count) gives an error

  File "svrx\util\mesh.py", line 47, in bmesh_from_pydata
    if not edges is None and len(edges):
TypeError: object of type 'SvEdges' has no len()

does SvEdges need a def __len__ or what

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

Ok I see what I did, not to clever.

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

Yes for that to work, that len check feels a bit redundant

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

agreed

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

image

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

Fixed the name issue in master

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

a ha!

def rxdata_from_pydata(verts, edges=None, faces=None):
    # v = SvVertices.from_pydata(verts)
    # e = SvEdges.from_pydata(edges)
    # f = SvPolygon.from_pydata(faces)
    # return v, e, f
    rxm = SMesh.from_pydata(verts, edges, faces)
    return rxm.vertices, rxm.edges, rxm.faces

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

how about SMesh.from_pydata(verts, edges, faces).as_rxdata

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

seems to work :) but i'm sure i've not dealt well with the scenario of empty lists...

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

The empty scenario is a tricky scenario...
A property makes sense since it is basically not any heavy computed data but free.

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

we need to be strict with Generators that land in SvRx. They must be numpy only. else it's a scriptnode.

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

or we give them a prefix to the bl_idname/label ..

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

Initially we should be strict with everything while we test out what works and what doesn't.
Tomorrow I will tackle the generator pattern, it feels like a clean solution could be done quite easily.

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

(had copy paste mistake in above snippet)

image

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

OK. that's enough for now. let me know if you want to merge the PR. #34

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

Done

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

I really miss the opengl viewer, thinking about a quick hack to port it.
Or even just abusing the sverchok built in one via import for now...

from sverchok.

zeffii avatar zeffii commented on June 12, 2024

..and indexviewer... but as it was originally made .. not with the extra baking, placing screen text on verts/edges/faces should be its own node.

from sverchok.

nortikin avatar nortikin commented on June 12, 2024

@zeffii @ly29
openGL viewer need to be different, + 2.8 blender will be with other BGL
Maybe to include in new version osl or something. shading+lighting in bgl, as i wanted long ago.
PS
where is 2.8 BGL to see?

from sverchok.

ly29 avatar ly29 commented on June 12, 2024

@nortikin
For 2.8 yes, but it will be some time before that happens. For 2.78b where we are now and 2.79 bgl will still be there.

from sverchok.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.