latex2blender icon indicating copy to clipboard operation
latex2blender copied to clipboard

Update object without creating a new one

Open tobiasBora opened this issue 2 years ago • 7 comments

First, thanks a lot for this great addon. I would like to animate latex expressions (notably visibility, scale, position), unfortunately, once the animation is done, I can't easily update it: creating "Compile Latex Code" always create a new object.

For now, one solution is to create (and animate) a new Geometry Node that uses Object info to refer to the old object, but it would be cool to have a more direct solution in Latex2blender directly, replacing the current object and keeping the animations on it.

Also, it could be cool to pre-fill the text with the formula used for the current node (made possible for instance by storing it in a custom property). For now, as far as I see, one must retype everything.

EDIT A workaround for the first issue is to create a new object (so you still have to retype the whole expression from scratch), and then copy/paste the mesh data into the original animated object:

image

But it does not solve the second issue: I still need to type again the whole expression.

tobiasBora avatar Mar 15 '22 08:03 tobiasBora

Hi! The way latex2blender works at the moment, it would be difficult to make the TeX of the mesh editable. In particular, latex2blender inserts the object as a mesh that, once in blender, no longer remembers the underlying TeX from which it is generated. I would recommend animating an empty object and then linking the TeX object to it. Then, if you want to change the TeX, you can just create a new mesh and all your animation data is still on the empty object. I agree, though, that this would require you to retype the expression. Perhaps at a later date, we can look into adding this feature.

ghseeli avatar Mar 29 '22 15:03 ghseeli

Thanks for your answer. To remember the text, wouldn't it be possible to insert the original expression inside a Custom Property linked with the object? I guess it would allow us to remember easily the underlying TeX (and it would even be copy/pastable easily).

If I've some time in the coming months, I may give it a try.

tobiasBora avatar Mar 29 '22 18:03 tobiasBora

I updated latex2blender to add a custom property called "Original LaTeX Code" that stores the typed latex code. I have not yet made a new release, but the updated latex2blender.py file has the update.

peterkj1 avatar Jun 27 '22 18:06 peterkj1

Really cool, thanks a lot! I guess changing this property does not change the mesh?

tobiasBora avatar Jun 30 '22 19:06 tobiasBora

That's right. It doesn't change the mesh. It just stores the original LaTeX code used to compile the text.

peterkj1 avatar Jul 02 '22 17:07 peterkj1

Shouldn't we keep this issue opened? The last fix is great, but being able to change easily the shape would be even more awesome ;-) (in particular to preserve the modifiers, position, animation…) For now we can combine your solution with the above workaround, but it still requires a few unnecessary steps.

tobiasBora avatar Jul 03 '22 20:07 tobiasBora

This feature would be really awesome. I envision it as follows:

  • If no LaTeX object is selected, show the usual view in the latex2blender panel, i.e. where you can enter a command and compile it to a mesh.
  • If a LaTeX object is selected, show instead the LaTeX command that was used to generate the mesh inside that panel. From here, users might edit it. The button changes to Recompile as Mesh.

Difficulties

  • How to detect that an object was generated via your plugin? Maybe a simple boolean custom property would do. It could be checked if this property exists on the currently selected object. Or maybe even reuse the current Original LaTeX code property to continue storing the LaTeX code in there. If that property exists, you know that the Mesh was generated by your plugin and can then show this LaTeX code in the panel.
  • What happens when clicking on Recompile as Mesh. Maybe the mesh data could be completely destroyed and replaced by the newly generated mesh data. Of course, shape keys would be lost with this, but there's probably no way around this as shape keys are specific to the mesh data. Modifiers and everything else (that is not directly related to the mesh data itself, e.g. materials, animations of the object) shouldn't be affected by this.
  • When replacing the mesh data: where should the new origin of the mesh be situated? In my opinion, the new mesh data should be placed such that its calculated "surface center" (center of mass) is located exactly at the old origin of the object. Otherwise, already existing animations that rely on that origin might look weird.
  • A "nice to have" feature related to this would be a history of LaTeX commands for a specific object, such that you could easily go back to an older version of your LaTeX code.

Splines avatar Jun 27 '24 21:06 Splines