Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
I’m trying to render an animation from the commandline but it fails because an “asset is missing”. What’s interesting is that the asset in reference is from the “Studio.lib4d” file located in the “library/browser” subfolder of the Cinema 4D R19 installation directory. I used a material from that preset library in the animation, but it renders fine in the GUI version of C4D, so I don’t understand why it is missing from the commandline version. Here’s my example command:
&"C:\PFxPK2\Cinema 4D R19\Commandline.exe" -render "\\networkdrive\myfolder\heart.c4d"
and here’s the output:
How do I get the commandline version of C4D to recognize the .lib4d library files in the library/browser folder?
@m_magalhaes This worked great, thank you.
I want to change the value of a parameter and then export a .gltf file in C4D R23, and do this over and over again for many values. I'm trying to do it with this code, but it is not working:
import c4d from c4d import documents, plugins import c4d.documents as docs def main(): for ii in range(882): obj = doc.SearchObject("Selector") obj[c4d.ID_USERDATA,1] = ii docs.SaveDocument(c4d.documents.GetActiveDocument(), f'out{ii}.gltf', c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, format=c4d.FORMAT_GLTFEXPORT) c4d.EventAdd() if __name__=='__main__': main()
Unfortunately, I get this error:
How do I fix this? I think I need to specify the gltf export settings somehow, but I don't know how to do this.
@ferdinand Thank you, your example worked great. Now I understand how to use those symbols. Lowering the the degrees from 5 to 1 solved the issue. Thanks!
Example for anyone curious:
spline = c4d.SplineObject(total_points, c4d.SPLINETYPE_CUBIC) spline[c4d.SPLINEOBJECT_INTERPOLATION] = c4d.SPLINEOBJECT_INTERPOLATION_ADAPTIVE spline[c4d.SPLINEOBJECT_ANGLE] = c4d.utils.DegToRad(1.)
Basically, what I'm looking to do is increase the number of intermediate points. It seems like the default is to use "Adaptive" with an angle of 5 degrees. However, I would prefer for it to be lower (such as one degree), but I don't see any documentation on the SplineObject page on how to do this with the Python generator. Any ideas?
I found this page here, but I don't understand how to use that with the SplineObject.
I am using a Python generator to create a spline, and I set the interpolation to cubic. However, when the points of the spline are spread out enough, even with the cubic interpolation, it looks more like piecewise linear when getting closer. To it. Look at this video showing what I'm observing:
https://www.youtube.com/watch?v=_rNVelCUdxE
As you can see, it is certainly smoother than when I set the interpolation to linear, but even when it is cubic, when I zoom in enough, it still looks somewhat jagged, enough to be noticeable. At the end of the video I circle the cursor around the joints on the cubic spline.
Is there some way I can make the cubic interpolation smoother? I would prefer that the cubic interpolation splines doesn't look like a bunch of connected straight line segments.
@ferdinand Your flat UV projection solution worked great! Although I had to change the y to z and subtract the z range mappings from 1 in order to get it to work correctly. I will include a download in case anybody wants to see the details.
Now I just have a few more questions:
But it works when I render it:
Is there any way to get the Python shader to work in the viewport (not be completely black)? Or is it just too slow for that?
The Python shader is very slow to render. If I were to write the shader in C++ and compile it, would you expect a significant speedup? The code would be nearly identical to what I have in the Python "complexShader" code I presented above, but C++ obviously and instead of using Python's "cmath" module I would be using C++'s "std::complex". Would this render noticeably quicker than doing it in Python?
If I wrote a plugin in C++ to generate the geometry instead of doing it in Python, would you expect a significant speedup? I'm thinking so just because, from personal experience, I know nested for loops in Python are quite slow. The code I have written above slows down fast as the "resolution" variable increases. But I'm curious to hear your thoughts.
@m_magalhaes
It seems like there must be more to it or I'm doing something wrong. I added the following right above the return node line of code in the Python generator:
return node
uvwTag = node.MakeVariableTag(c4d.Tuvw, poly_count) c4d.EventAdd() for ii in range(poly_count): q = ii/poly_count uvwTag.SetSlow(ii, c4d.Vector(q,q,0), c4d.Vector(q,q,0), c4d.Vector(q,q,0), c4d.Vector(q,q,0))
But I'm still getting the red error color. I also have the Python plugin print "hi" when it errors, and it is printing "hi". I haven't done the math to correctly set the values for the UV coordinates yet (that "q" number is just a placeholder/test to see if it errors, and it does).
Regardless of what I set the UVW coordinates to be at each point, I shouldn't be getting the error color. So do you know what I'm missing?
@m_magalhaes Thank you, that Python fresnel example was extremely helpful. I got very close with the following:
import os import math import cmath import c4d from c4d import plugins, bitmaps, utils #warning Please obtain your own plugin ID from http://www.plugincafe.com # I didn't PLUGIN_ID=1027090 class complexShader(plugins.ShaderData): def __init__(self): #if a Python exception occurs during the calculation of a pixel colorize this one in red for debugging purposes self.SetExceptionColor(c4d.Vector(1,0,0)) def Output(self, sh, cd): if cd.vd: #if shader is computated in 3d space pi = math.pi u = cd.p[0] v = cd.p[1] tt = cd.t # /28.0 osc = math.sin(2*pi*tt) min_y = -2*pi max_y = 2*pi min_x = -2*pi max_x = 2*pi # to view correctly when applied to a plane in c4d, have x axis pointing right, z axis pointing up, and y axis pointing at the camera x = c4d.utils.RangeMap(u, 0, 1, min_x, max_x, clampval = True) y = c4d.utils.RangeMap(1-v, 0, 1, min_y, max_y, clampval = True) z = x + y*1j out = cmath.exp(z) angle = cmath.phase(out)/pi % 2.0 # wrap it at pi to match Mathematica's color mapping (mathematica: -pi = cyan, 0 = red, pi = cyan) hue = c4d.utils.RangeMap(angle, 0.0, 2.0, 0, 1, clampval = True) colorHSV = c4d.Vector(hue, 1.0, 1.0) colorRGB = c4d.utils.HSVToRGB(colorHSV) return c4d.Vector(colorRGB[0],colorRGB[1],colorRGB[2]) else: #if shader is computated in 2d space return c4d.Vector(0.0) def FreeRender(self, sh): #Free any resources used for the precalculated data from InitRender(). return def RegisterComplexShader(): IDS_COMPLEX_SHADER=10001 #string resource, must be manually defined return plugins.RegisterShaderPlugin(PLUGIN_ID, plugins.GeLoadString(IDS_COMPLEX_SHADER), 0, complexShader, "", 0) if __name__=='__main__': RegisterComplexShader()
This works on a plane. However, when I apply the same material to the Python generator, it returns the error color (red):
I'm assuming this is because the geometry generated in the Python generator doesn't have UVs. Is that correct? If so, what is the proper way to add them? If not, why does it work on the plane but not the Python generator (which contains the same code as my first post).
Here's the sample .c4d file and the .pyp plugin in case anybody wants to test it for themselves. I was testing this on R19: https://drive.google.com/file/d/1UJAsaYsEdKJKwafTau8-LDkLETSzgRNW/view?usp=sharing
I'm struggling to understand exactly what U and V are in the Formula Effector. The documentation states:
d(uvxyzt) This is where you enter the formula for all effects apart from Manual. u and v are parameters that run from 0 to 1 along the horizontal and vertical axes respectively.
But this definition doesn't make it clear how that's different than the y or x axis. If I apply a formula effector to a sphere, here are some results I get:
When I just use "U" in the formula:
When I just use "V" in the formula:
I don't see the relationship between "the horizontal and vertical axes" in this case.
Does somebody have a more precise definition of what u and v represent, specifically in "spherical" mode? What do they range from (is it 0 to 1)?