Closed javismiles closed 4 years ago
splitting this question up into parts that need to be solved individually..
A
, B
A, B
)so far that's in the realm of what can be done easily in Sverchok.
There's no Object
property for fade/opacity, so it would need to be done another way - i haven't rendered much since my main computer died and am not in a position to make a demo file for you, but approaches I would consider is
wonderful thank you very much, forgetting for now about the fading, is there any example somewhere done of this part?
On Tue, Dec 3, 2019, 10:16 AM Dealga McArdle notifications@github.com wrote:
splitting this question up into parts that need to be solved individually..
- generate 100 points
- for each point set
- a start coordinate A,
- end coordinate B
- trajectory (if not linear interpolation between A, B)
so far that's in the realm of what can be done easily in Sverchok. Fade:
There's no Object property for fade/opacity, so it would need to be done another way - i haven't rendered much since my main computer died and am not in a position to make a demo file for you, but approaches I would consider is
- using BmeshViewer Merge on all objects, and assign vertex colors so that black is invisible and white is visible (ie a mix between two shaders), and interpolate over time. depending on complexity i would hesitate to do that
- more? that one is pretty crazy, but seems even more sane than the suggestions i'm going to not add here :)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nortikin/sverchok/issues/2709?email_source=notifications&email_token=AAHUIBGHM7XOMRVVKRHEMLTQWYPVXA5CNFSM4JUTYK62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFYUXXA#issuecomment-561073116, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHUIBCDRFUHJFL7AGYOSCLQWYPVXANCNFSM4JUTYK6Q .
Here is one way to answer your question.
Think of it like DRIVERS for values and SV vectorization (many values calculated) is the coolest thing ever without having to use LOOP.
But then you are thinking of using ScriptNode... so for that you have to convert the nodes into ScriptNode...
Thank u so much, mmm I wonder what's the best way let me explain you what I have so far, so far I have a csv file with coordinates for say 50 points, And I use a python script to create 50 spheres , assign them material and position them in those coordinates, thats all done without sverchok and works all well
But now I wanna animate moving to those positions over time and also what if it's 500 rather than 50 etc
So what's best with sverchok, using nodes like in your last pic or using scriptnode or? ;)
On Tuesday, December 3, 2019, Jimmy Gunawan notifications@github.com wrote:
But then you are thinking of using ScriptNode... so for that you have to convert the nodes into ScriptNode...
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nortikin/sverchok/issues/2709?email_source=notifications&email_token=AAHUIBGZWAVRKJ3TDAPZGRTQWYWS5A5CNFSM4JUTYK62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFY2YCY#issuecomment-561097739, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHUIBCLIBXUFHOWDFOCF2DQWYWS5ANCNFSM4JUTYK6Q .
-- Ideami Studios Augmented A.I / Deep Learning: https://losslandscape.com Augmented Innovation: https://torch4ideas.com Augmented Design: https://posterini.com Augmented Ideami: https://ideami.com
Twitter: https://twitter.com/ideami
Simpler with nodes, I supposed.
ScriptNode might be able to do this too... if you treat it like coding like Processing because you will be dealing with Time, Time Offset, etc. So like basically creating some kind of particles simulation.
Consider also Animation Nodes for Scripting. In general SV is better for 3D modeling and generative.
Here is one way to answer your question.
- You generate 100 points.
- You decide where to travel to. Luckily we have Mix Vectors now. So we can interpolate between the two.
- So what drives those A and B vector positions? Frame? Yes use Frame. Want to randomize Frame Time, just add some random numbers offset. Then use easing if you need to.
so using these kinds of nodes in the image you shared, I should be able to do this you say, reading the coordinates with the text node, and being able to animate them from coordinate a to b, all of the points
simple interpolation bteween two 3D np.array
"""
in numpoints s d=200 n=2
in mix s d=0.0 n=2
out verts v
"""
import numpy as np
import math
# A
X1 = np.linspace(0.0, 3*math.pi, numpoints)
Y1 = np.sin(X1)
Z1 = np.zeros(numpoints)
C1 = np.vstack([X1, Y1, Z1]).T
# B
P2 = np.linspace(0.0, 2*math.pi, numpoints)
X2 = np.sin(P2)
Y2 = np.cos(P2)
Z2 = np.zeros(numpoints)
C2 = np.vstack([X2, Y2, Z2]).T
# C
def np_interp_v3_v3v3(a, b, t=0.5):
if t == 0.0: return a
elif t == 1.0: return b
else:
s = 1.0 - t
return (s * a) + (t * b)
C3 = np_interp_v3_v3v3(C1, C2, mix)
verts.append(C3.tolist())
simple interpolation bteween two 3D np.array
""" in numpoints s d=200 n=2 in mix s d=0.0 n=2 out verts v """ import numpy as np import math # A X1 = np.linspace(0.0, 3*math.pi, numpoints) Y1 = np.sin(X1) Z1 = np.zeros(numpoints) C1 = np.vstack([X1, Y1, Z1]).T # B P2 = np.linspace(0.0, 2*math.pi, numpoints) X2 = np.sin(P2) Y2 = np.cos(P2) Z2 = np.zeros(numpoints) C2 = np.vstack([X2, Y2, Z2]).T # C def np_interp_v3_v3v3(a, b, t=0.5): if t == 0.0: return a elif t == 1.0: return b else: s = 1.0 - t return (s * a) + (t * b) C3 = np_interp_v3_v3v3(C1, C2, mix) verts.append(C3.tolist())
and this would have to be related to the different temporal frames in blender to make it happen over x frames
Simpler with nodes, I supposed.
ScriptNode might be able to do this too... if you treat it like coding like Processing because you will be dealing with Time, Time Offset, etc. So like basically creating some kind of particles simulation.
Consider also Animation Nodes for Scripting. In general SV is better for 3D modeling and generative.
animation nodes are native nodes of blender? but using sv nodes you say it would still be possible to animate them right
@javismiles i'm just using this thread to store some of the intermediate steps that we'd solve to towards the end resolut
@zeffii awesome thank you very much, later today Im gonna try to start putting together some of these steps you are writing and trying them yeah
@zeffii where is the scriptnode, cant find it in the add menus of sverchok ;)
@zeffii scripted node lite, found it
@zeffii , first I created with another script a set of sphere and then I have used your interpolation function mixed with other bits, to animate over 100 frames in this case the movement of the spheres like this:
import bpy
import random
cxa=[0] * 100
cya=[0] * 100
cza=[0] * 100
cxb=[0] * 100
cyb=[0] * 100
czb=[0] * 100
path_to_file="pathToFileWithXYZDestinationCoordinatesOfPoints.csv"
with open(path_to_file, 'r') as f:
c=1
for line in f:
x, y, z = line.split(",")
cxa[c]=float(-15.7)
cya[c]=float(5.5)
cza[c]=float(113.3)
cxb[c]=float(x)*float(100)
cyb[c]=float(y)*float(100)
czb[c]=float(z)*float(100)
c=c+1
def np_interp_v3_v3v3(a, b, t=0.5):
if t == 0.0: return a
elif t == 1.0: return b
else:
s = 1.0 - t
return (s * a) + (t * b)
def my_handler(scene):
print("Frame Change", scene.frame_current)
c=1
for obj in bpy.context.scene.objects:
print(obj.name, obj, obj.type)
if(obj.name[:5]=="sampl"):
f=bpy.context.scene.frame_current
t=float(f)/float(100)
x=np_interp_v3_v3v3(cxa[c],cxb[c],t)
y=np_interp_v3_v3v3(cya[c],cyb[c],t)
z=np_interp_v3_v3v3(cza[c],czb[c],t)
print(x,y,z)
obj.location = (x,y,z)
c=c+1
bpy.app.handlers.frame_change_pre.append(my_handler)
and this works nicely, but now would be nice to add acceleration and a bezier curve and easing etc to the interpolation,
Of course this is pure pythons script, I wish this could be done much easier just with a bunch of sverchok nodes for example
easing can be done very nicely with these equations and it works: https://gist.github.com/th0ma5w/9883420
Cool! ah, yes, we have easing funcs too.. but we could implement them in numpy ..
https://github.com/nortikin/sverchok/blob/b28_prelease_master/utils/sv_easing_functions.py
@zeffii thank you thats great Zeffii, something urgent please, look I have two objects now being shown with Viewer BMesh, the problem I have is that both are positioned at 0,0,0 location and 0,0,0 rotation by viewerBMesh, and the second one I need to have it at Z -200 and rotation -90 in z axis, and when I move it there, every time I change frames, it returns to 0,0,0 in everything, driving me nuts ;) how can I make the created mesh be at a different position and rotation that is not 0,0,0 without the sverchok nodes returning it to 0,0,0 all the time ;)
You have two possibilities:
thank you @vicdoval , but if I disable the node, will the mesh still remain in place? if I use the Matrix in node, I input those locations,rotations into where, into the bottom left matrix thing of the viewerBMesh?
disabling the LIVE button of the ViewerBMesh stops the problem, but this is ok for a single static figure, if I had them changing on each frame I would need something else to compensate all the time an extra x on z, etc
so yeah for a static mesh, disabling the LIVE button solved it perfectly. But when I have a mesh that evolves over the frames, then I will have trouble. The problem is that for this second object, I read the coordinates from a csv file, but I have to then add a displacemente and a rotation to the created mesh, but sverchok will force me to 0,0,0. I cannot disable the node in the case of having movement across the frames, so maybe I have to do that matrix node you say, but where do I plug it let me know please, thank you ;)
btw do you have also equations that interpolate with easing but not on a straight line but doing some kind of a curve?
mixing your own event handler + scripting + sverchok does demand more attention to detail, but it is possible, sometimes even preferable. But so far in your problem statement, i don't see anything that demands that kind of code being executed in an event handler. BMeshViewer has a matrix in, which you can use to pump location/scale/rotation information into the objects. You can even pass BMeshViewer one set of Verts/Faces and hundreds of matrices, and it will act like an instancer.
i think your issue really is "how do i convert this general requirement X into a nodetree, and thus a function that takes a frame number"
if each object gets its own material the fading into visibility could be keyframed, or algorithmically controller via a frame change handler (this is where sverchok is weak out-of-the-box, it's also an area where we don't sink much effort)
here's 3 ngon nodes, each outputting a randomized polygon of 5 vertices.
if ngon 1 is set 'A'
and ngon 2 is set 'THROUGH'
and ngon 3 is set 'B'
we can interpolate between A, B while traveling through THROUGH
.
right now i set the Interpolation node to IntRange, which takes a number of steps to produce, but if you switch that off it will produce one value per "track". This would give you a defined trajectory component.
@zeffii thank you, interesting all that you shared; at the moment with just the raw code its all working great, I think I could continue for now with raw code, but I still need to solve:
when I change the mesh over the frames, I cannot keep the LIVE off, I have to have it on, and then sverchok keeps returning the shape to 0,0,0; how can I avoid that in that case. The Viewer has a matrix input, do I have to input something there to keep position and rotation on a specific place? and how do I enter both into there?
would love find an equation in python to do a curve , similar to these ones but with a curve def easeInOutExpo(t, b, c, d): t /= d/2 if t < 1: return c/2 math.pow( 2, 10 (t - 1) ) + b t -= 1 return c/2 ( -math.pow( 2, -10 t) + 2 ) + b
;)
you might want to read the implementation of BMeshViewer, it will all become a lot less mystic.
if the vertices/topolgy of each object do not change over time you can even set to "fixed verts" setting in the N-Panel, and then only new matrices are passed to the objects. that's a super fast technique. but Live has to be on.
f, I have to have it on, and then sverchok keeps returning the shape to 0,0,0; how can I avoid that in that case.
you need to drop the raw code part that sets the object locations, and do it via nodes instead. You can set of a nodeScript to take an input frame_number, and output rotation and location information, which you then merge into a matrix and pass that to BMeshViewer. Try that at least, don't just read this.
thank you @zeffii , so if I set fixed verts in N panel, with Live on, then that may keep it in place you say, if I pass a matrix with coordinates to the BMeshViewer, ok I have to investigate the parameters of that matrix input of BMeshViewer yes in its documentation thank you ;)
i think this is a problem...
@portnov, we should make this more intuitive..
@zeffii aha, whats that part of, I hadnt seen that example before, so thats how you input position and rotation to the bviewermesh I see
yeah, that's the next step.. but that node isn't working as it should
"Matrix in" was not vectorized as far as I remember...
ah yes. it's not broken, but it works in a lazy way (we like it.. but i can understand this is perceived as weird.. )
https://gist.github.com/126dc0c2cde80fc3a3e4820b457e1ee8
and
and with rotation driven by frame input..
https://gist.github.com/3214cea392de28e41d853c2e6d38e838
@wisarTR - better to discuss this particle issue in a new issue, #2717
Im starting to do experiments with scriptNode, one question, for example say I want to create 100 spheres and position them in specific coordinates which I have in a csv text file. It´s easy to do this with python no probs.
But say that I want that they all begin at a certain coordinate and then over x number of frames move to their final coordinate, and also that they do this starting on different frames. So for example sphere 1 begins on frame 1 and moves to its final coordinate till frame 50. But sphere 2 doesnt appear until frame 5 and then moves to its final coordinate on frame 55, etc
and also that they fade in when they appear, so they don´t appear suddenly but fade in
what would be the optimal way of doing this? using scriptnode combined with? or?
thank you for your help :)