Obi Official Forum
Switching between 3D and 2D mode in runtime? - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Fluid (https://obi.virtualmethodstudio.com/forum/forum-3.html)
+--- Thread: Switching between 3D and 2D mode in runtime? (/thread-1146.html)



Switching between 3D and 2D mode in runtime? - Yelmer - 02-05-2019

Is there any way to swap between 2D and 3D mode on a obi solver (fluids) in runtime? I am trying to access the variable/parameter trough scripting, but I can not find a "Mode" on the Obisolver. Either I am looking in the wrong place - or the answer is "no you can not"? Sonrisa

And since someone always asks "Why would you want to do that" let me clarify that I understand I can not do both 2d and 3d at the *same* time.  Guiño 
It just would like using the same one solver and swap between 3d and 2d mode and keep all other settings - instead of setting up another one and point emitters back and forth and make sure all things match up. It is a visual effect thing that happens in between some other things in a visual art thing.


RE: Switching between 3D and 2D mode in runtime? - josemendez - 03-05-2019

(02-05-2019, 02:46 PM)Yelmer Wrote: Is there any way to swap between 2D and 3D mode on a obi solver (fluids) in runtime? I am trying to access the variable/parameter trough scripting, but I can not find a "Mode" on the Obisolver. Either I am looking in the wrong place - or the answer is "no you can not"? Sonrisa

And since someone always asks "Why would you want to do that" let me clarify that I understand I can not do both 2d and 3d at the *same* time.  Guiño 
It just would like using the same one solver and swap between 3d and 2d mode and keep all other settings - instead of setting up another one and point emitters back and forth and make sure all things match up. It is a visual effect thing that happens in between some other things in a visual art thing.

Hi there,

Just do:

Code:
solver.parameters.mode = <2D or 3D>
solver.UpdateParameters();

See:
http://obi.virtualmethodstudio.com/api.html

Note however, than when switching from 3D to 2D existing particles won't be projected back to a common 2D plane. Each one will continue simulating in their own plane, centered at their current Z coordinate. You might want to loop trough all of them setting their Z to 0 (or whatever value you need it to be, so that they all share the same 2D plane).

Switching from 2D to 3D, no special care needs to be taken Sonrisa