Jump to content

few_a_fx

Members
  • Content count

    101
  • Donations

    0.00 CAD 
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by few_a_fx

  1. I'm trying to run a rbd simulation where a window unit breaks; however the sim keeps crashing around frame 100, so I'm not able to fully bake or even see how the final animation looks. I had a similar problem with a particle fluid animation, I just lowered the particle count. It worked, but the water doesn't look as well as it should. I plan on compositing the final animation into a live action plate, so I need it to look as real as possible. Any suggestions on how to run/bake the simulation without it crashing due to not enough memory? I have a PC with 6g RAM, running windows 32 bit.
  2. I just got a new hard, 1TB. So I'm ok on that.
  3. Using the explicit cache seems to be working. I can finally see whats going on. Going to try and run it through the command line, so it sims while I'm at work. Will keep you updated. Thanks again sam.h and SYmek
  4. Right now I can't afford a 64 bit system, will switch when able too. Anyways thanks for the tips. I'll try out the cache, command line and ODE stuff. Thanks.
  5. RBD Object Tips

    This is a simple problem, which I somehow forgot how to fix. Working with rbd & the make breakable tool. trying have something break through a solid box object, but when ever I start the sim the left corner breaks and then the upper corner starts to break before the sphere reaches the box. Now I have the box on the groundplane, but I have no idea why its breaking before anything hits it. Any tips on how to fix this.
  6. New 2011 Reel.

    Any feed back on my new reel would awesome. Working on a scene to replace the test render/WIP. http://vimeo.com/22629751
  7. New 2011 Reel.

    Re-edited reel: http://vimeo.com/22629751
  8. New 2011 Reel.

    Thanks for your opinion. Re-editing the fx tool demo now. As for the amount of fx shots, I took out 2 pieces that I thought were the weakest. I was told better to have quality over quantity. I added as much particles as I could for the water, that about as much as my computer could use with out crashing every time I rendered. Will repost new reel as soon as I edit, might throw in one other shot. Thanks
  9. Quick Python Question

    Create a render button for my fx tool. When you click it mplay pops up and it starts rendering, but nothing shows up. However if I go into the output tab and select the mantra node and click render on it, the scene renders out. Can anyone tell me what I'm doing wrong, or have any suggestions to fix this. Here is the code I have. def OnRender(self, event): renderIt = hou.node('/out/RENDER_IT') renderIt.render()
  10. Quick Python Question

    Still a little new to python, so I'm sorry for not following you. In your previous post you said you got rid of the threading and MyApp stuff. What threads do I have to delete and do I just deleted the MyApp class? Also do I have to rebuild the UI once I do this, or can my current UI work with this set up? It would be nice to get this render button working, so the user can use the fx tool and not have to dive into houdini all the time; however if its to complicated for a python newbie, I'll tackle this problem later. Thanks for your tips graham, you've been very helpful.
  11. Quick Python Question

    Thanks graham. One thing though, I didn't know if you need the entire script or just the render section. I also have several other controls (wxSliders, checkboxes and combo boxes). Is there a way to bring this into my current file with threading, but not have the threading effect what you have posted? (hope that makes since). I guess I should have posted the entire code. ############################################################################### ########################### RAIN SYSTEM TOOL | RST ############################ ########################### Created by: Jason Fugh ############################ ############################################################################### # This tool was created to be used in Side Effects Houdini. # It was written in python & wxPython. # This fx tool allows the user to create and control a basic rain/particle system import sys, threading, wx if __name__ != "__main__": import hou import toolutils def exc_log(): print "Exception: '%s' on line %d" % (sys.exc_value, sys.exc_traceback.tb_lineno) class MyApp(wx.App): def OnInit(self): frame = MyFxTool(None, -1, 'Rain System Tool') frame.Show(True) self.SetTopWindow(frame) return True # Creates the Window class MyFxTool(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size (405, 505), style = wx.CAPTION | wx.SYSTEM_MENU | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.STAY_ON_TOP) self.sizer= wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.sizer) self.panel= MyFxToolPanel(self) self.sizer.Add(self.panel, 1, flag= wx.EXPAND) self.Layout() # Creates the Layout class MyFxToolPanel(wx.Panel): def __init__(self, parent): super(MyFxToolPanel, self).__init__(parent) self.sizer= wx.BoxSizer(wx.VERTICAL) self._add_flex_grid() self.SetSizer(self.sizer) def _add_flex_grid(self): self.flex_grid_sizer= wx.FlexGridSizer(cols= 2, vgap= 10, hgap= 70) self.sizer.Add(self.flex_grid_sizer, 1, border= 20, flag= wx.ALL|wx.EXPAND) self._add_static_text("Rain System") self.start_button= self._add_button("Make It Rain") self._add_static_text("Amount of Rain") self.amount_slider= self._addAmount_slider() self._add_static_text("Rain Speed") self.r_speed_slider= self._addSpeed_slider() self._add_static_text("Wind Speed") self.w_speed_slider= self._addScale_slider() self._add_static_text("Life") self.life_slider= self._addLife_slider() self._add_static_text("Collisions") self._add_colisions() self._add_static_text("Bounce") self.bounce_slider= self._addBounce_slider() self._add_static_text("Render Effect") self._render_button= self._render_button("Render") ########################################################################### ####################### PARAMETER CONTROLS ################################ ########################################################################### def _add_static_text(self, label_text): static_text= wx.StaticText(self, label= label_text, style= wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL) self.flex_grid_sizer.Add(static_text, flag= wx.ALIGN_CENTER_VERTICAL) def _add_button(self, label_text): button= wx.Button(self, label= label_text) button.Bind(wx.EVT_BUTTON, self.OnClickAdd) self.flex_grid_sizer.Add(button, flag= wx.ALIGN_CENTER_VERTICAL) return button def _addAmount_slider(self): slider_sizer= wx.BoxSizer(wx.HORIZONTAL) self.flex_grid_sizer.Add(slider_sizer, flag= wx.ALIGN_CENTER_VERTICAL) self.slider = wx.Slider(self, value= 100, minValue= 1, maxValue= 500, style= wx.SL_LABELS) self.slider.Bind(wx.EVT_SLIDER, self.sliderUpdate1) slider_sizer.Add(self.slider, flag= wx.ALIGN_CENTER_VERTICAL) return self.slider def _addSpeed_slider(self): slider_sizer= wx.BoxSizer(wx.HORIZONTAL) self.flex_grid_sizer.Add(slider_sizer, flag= wx.ALIGN_CENTER_VERTICAL) self.slider1= wx.Slider(self, value= 2, minValue= 0, maxValue= 5, style= wx.SL_LABELS) self.slider1.Bind(wx.EVT_SLIDER, self.sliderUpdate1) slider_sizer.Add(self.slider1, flag= wx.ALIGN_CENTER_VERTICAL) return self.slider1 def _addScale_slider(self): slider_sizer= wx.BoxSizer(wx.HORIZONTAL) self.flex_grid_sizer.Add(slider_sizer, flag= wx.ALIGN_CENTER_VERTICAL) self.slider2= wx.Slider(self, value= 1, minValue=0, maxValue= 10, style= wx.SL_LABELS) self.slider2.Bind(wx.EVT_SLIDER, self.sliderUpdate1) slider_sizer.Add(self.slider2, flag= wx.ALIGN_CENTER_VERTICAL) return self.slider2 def _addLife_slider(self): slider_sizer= wx.BoxSizer(wx.HORIZONTAL) self.flex_grid_sizer.Add(slider_sizer, flag= wx.ALIGN_CENTER_VERTICAL) self.slider3= wx.Slider(self, value= 100, minValue= 0, maxValue= 100, style= wx.SL_LABELS) self.slider3.Bind(wx.EVT_SLIDER, self.sliderUpdate1) slider_sizer.Add(self.slider3, flag= wx.ALIGN_CENTER_VERTICAL) return self.slider3 def _add_colisions(self): colisions_sizer= wx.BoxSizer(wx.HORIZONTAL) self.flex_grid_sizer.Add(colisions_sizer, flag= wx.ALIGN_CENTER_VERTICAL) self.collide_on= wx.CheckBox(self, label= "On/Off") colisions_sizer.Add(self.collide_on, 0, flag= wx.ALIGN_CENTER_VERTICAL) self.collide_on.Bind(wx.EVT_CHECKBOX, self.CheckOn) self.collide_button= wx.Button(self, label= "Collide With") colisions_sizer.Add(self.collide_button, 0, border= 10, flag= wx.LEFT|wx.ALIGN_CENTER_VERTICAL) self.collide_button.Bind(wx.EVT_BUTTON, self.AddCollision) options = ['Die', 'Bounce', 'Stop', 'Stick', 'Slide','Continue'] self.collide_op = wx.ComboBox(self, value= "", choices = options, id=5) self.collide_op.Bind(wx.EVT_COMBOBOX, self.SelectBehavior) colisions_sizer.Add(self.collide_op, 0, border= 10, flag= wx.LEFT|wx.ALIGN_CENTER_VERTICAL) def _addBounce_slider(self): slider_sizer= wx.BoxSizer(wx.HORIZONTAL) self.flex_grid_sizer.Add(slider_sizer, flag= wx.ALIGN_CENTER_VERTICAL,) self.slider4= wx.Slider(self, value= 10, minValue= 0, maxValue= 10, style= wx.SL_LABELS) self.slider4.Bind(wx.EVT_SLIDER, self.sliderUpdate1) slider_sizer.Add(self.slider4, flag= wx.ALIGN_CENTER_VERTICAL) return self.slider4 def _render_button(self, label_text): button= wx.Button(self, label= label_text) button.Bind(wx.EVT_BUTTON, self.OnRender) self.flex_grid_sizer.Add(button, flag= wx.ALIGN_CENTER_VERTICAL) return button ########################################################################### ####################### PARAMETER EVENTS ################################## ########################################################################### #Allow you to create the acual rain system. #create both SOP and PO nodes. def OnClickAdd(self, event): geo = hou.node("/obj").createNode("geo", "Rain_System", run_init_scripts = False) grid = geo.createNode("grid", "EMIT_FROM") grid.setParms({"ty":10}) popnet = grid.createOutputNode("popnet", "RAIN_EMITTER") popnet.setDisplayFlag(1) popnet.setRenderFlag(1) source = popnet.createNode("source", "RAIN_ORIGIN") defaultGeo = source.parm("usecontextgeo") defaultGeo.set("first") birthPlace = source.parm("emittype") birthPlace.set("surfacerandom") gravity = source.createOutputNode("force", "RAIN_DirCtrl") defaultRainDir = gravity.parm("forcey") defaultRainDir.set(-1) rSpeed = gravity.createOutputNode("drag", "RAIN_Spd_Ctrl") defaultRainSpd = rSpeed.parm("scale") defaultRainSpd.set(2) render = rSpeed.createOutputNode("render", "RENDER_ME") renderAs = render.parm("prtype") renderAs.set("line") renderSize = render.parm("prsize") renderSize.set(.0025) render.setRenderFlag(1) collide = render.createOutputNode("collision", "COLLIDE_WITH") out = hou.node("/out") renderIt = out.createNode("ifd", "RENDER_IT") # Next 3 functions are to create a collision. # Once checked render flag(display) switches from drag to collision node. def CheckOn(self, event): collide = hou.node('/obj/Rain_System/RAIN_EMITTER/COLLIDE_WITH') render = hou.node('/obj/Rain_System/RAIN_EMITTER/RENDER_ME') if self.collide_on.GetValue(): collide.setRenderFlag(1) else: render.setRenderFlag(1) def OnRender(self, event): try: hou.node('/out/RENDER_IT').render() except: exc_log Or is it possible to have it when you click the render button it runs a separate script without without threading?
  12. Quick Python Question

    Here is the python script. ############################################################################### ########################### RAIN SYSTEM TOOL | RST ############################ ########################### Created by: Jason Fugh ############################ ############################################################################### # This tool was created to be used in Side Effects Houdini. # It was written in python & wxPython. # This fx tool allows the user to create and control a basic rain/particle system import sys, threading, wx if __name__ != "__main__": import hou import toolutils def exc_log(): print "Exception: '%s' on line %d" % (sys.exc_value, sys.exc_traceback.tb_lineno) class MyApp(wx.App): def OnInit(self): frame = MyFxTool(None, -1, 'Rain System Tool') frame.Show(True) self.SetTopWindow(frame) return True # Creates the Window class MyFxTool(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size (405, 505), style = wx.CAPTION | wx.SYSTEM_MENU | wx.CLOSE_BOX | wx.STAY_ON_TOP) self.sizer= wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.sizer) self.panel= MyFxToolPanel(self) self.sizer.Add(self.panel, 1, flag= wx.EXPAND) self.Layout() # Creates the Layout class MyFxToolPanel(wx.Panel): def __init__(self, parent): super(MyFxToolPanel, self).__init__(parent) self.sizer= wx.BoxSizer(wx.VERTICAL) self._add_flex_grid() self.SetSizer(self.sizer) def _add_flex_grid(self): self.flex_grid_sizer= wx.FlexGridSizer(cols= 2, vgap= 10, hgap= 70) self.sizer.Add(self.flex_grid_sizer, 1, border= 20, flag= wx.ALL|wx.EXPAND) self._add_static_text("Rain System") self.start_button= self._add_button("Make It Rain") self._add_static_text("Render Effect") self._render_button= self._render_button("Render") ########################################################################### ####################### PARAMETER CONTROLS ################################ ########################################################################### def _add_static_text(self, label_text): static_text= wx.StaticText(self, label= label_text, style= wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL) self.flex_grid_sizer.Add(static_text, flag= wx.ALIGN_CENTER_VERTICAL) def _add_button(self, label_text): button= wx.Button(self, label= label_text) button.Bind(wx.EVT_BUTTON, self.OnClickAdd) self.flex_grid_sizer.Add(button, flag= wx.ALIGN_CENTER_VERTICAL) return button def _render_button(self, label_text): button= wx.Button(self, label= label_text) button.Bind(wx.EVT_BUTTON, self.OnRender) self.flex_grid_sizer.Add(button, flag= wx.ALIGN_CENTER_VERTICAL) return button ########################################################################### ####################### PARAMETER EVENTS ################################## ########################################################################### #Allow you to create the acual rain system. #create both SOP and PO nodes. def OnClickAdd(self, event): geo = hou.node("/obj").createNode("geo", "Rain_System", run_init_scripts = False) grid = geo.createNode("grid", "EMIT_FROM") grid.setParms({"ty":10}) popnet = grid.createOutputNode("popnet", "RAIN_EMITTER") popnet.setDisplayFlag(1) popnet.setRenderFlag(1) source = popnet.createNode("source", "RAIN_ORIGIN") defaultGeo = source.parm("usecontextgeo") defaultGeo.set("first") birthPlace = source.parm("emittype") birthPlace.set("surfacerandom") gravity = source.createOutputNode("force", "RAIN_DirCtrl") defaultRainDir = gravity.parm("forcey") defaultRainDir.set(-1) rSpeed = gravity.createOutputNode("drag", "RAIN_Spd_Ctrl") defaultRainSpd = rSpeed.parm("scale") defaultRainSpd.set(2) render = rSpeed.createOutputNode("render", "RENDER_ME") renderAs = render.parm("prtype") renderAs.set("line") renderSize = render.parm("prsize") renderSize.set(.0025) render.setRenderFlag(1) collide = render.createOutputNode("collision", "COLLIDE_WITH") out = hou.node("/out") renderIt = out.createNode("ifd", "RENDER_IT") def OnRender(self, event): try: hou.node('/out/RENDER_IT').render() except: exc_log class AppThread(threading.Thread): def run(self): app = MyApp(0) app.MainLoop() if __name__ == "__main__": AppThread().start() Save it as a .py file and place it in the houdini python folder. Then create a new tool and add this script to it. import sys try: del sys.modules["fx_rst"] except: pass import fx_rst fx_rst.AppThread().start() Once thats done you can click on the tool and a window will pop up, and you can start using the tool.
  13. Quick Python Question

    Would this fall under 3rd party rendering? Even though I'm using a mantra, I'm using python to tell mantra to render the scene. If so then that explains it. Using the apprentice version, no 3rd party aloud.
  14. Quick Python Question

    Your set up works, but for some reason it doesn't work for me. I create a tool in wxPython/Python, and I've added a render button to the UI, now I'm trying to get it to work. If I run the script in the python sheel it works just fine, works just like your example. Here's the set up for the tool: def _add_flex_grid(self): self._add_static_text("Render Effect") self._render_button= self._render_button("Render") def _render_button(self, label_text): button= wx.Button(self, label= label_text) button.Bind(wx.EVT_BUTTON, self.OnRender) self.flex_grid_sizer.Add(button, flag= wx.ALIGN_CENTER_VERTICAL) return button def OnRender(self, event): renderIt = hou.node('/out/RENDER_IT') renderIt.render() Hope this helps with understanding my proble,. I'll continue to work on it and let you know if I figure it out. Still if anyone has anymore suggestions or tips that would be awesome.
  15. First Python/Houdini Effects Tool

    Hey guys, So I finally finished my first effects tool. Thanks to everyone in the scripting forum that helped me out. Here's a link to my blog that goes over the controls of the tool. There is also a link on the blog that takes you to a quick demo of the tool. Not the greatest quality, but you can still see whats happening, looking for a better screen recorder. Anyways any feedback (good or bad) it welcome. Just keep in mind I'm teaching myself python and this is my first attempt a building a tool. Thanks again. Jason blog: http://jasonfugh.blogspot.com/2011/04/pythonhoudini-fx-tool-finished-start.html or vimeo: http://vimeo.com/21857802
  16. First Python/Houdini Effects Tool

    New vimeo Link. http://vimeo.com/fughfx/python-fx-rst
  17. Another Python Question

    Adding some new features to my fx tool. I'm using a trail and cache node now, and I want to be able to clear the cache SOP without going to the cache node and clicking clear. I've create a button for the "clear cache" parameter on my wxPython GUI, now I'm stuck on this. If anyone knows how to clear the cache sop through python that would be very helpful.
  18. Another Python Question

    Posting new thread in Artist section. It will be a link to my blog and vimeo page to demo the effects tool.
  19. Another Python Question

    Problem solved. Thanks guys for you help.
  20. Another Python Question

    I must be putting it in wrong then, because its only clear the cache when I press the button on the cache SOP and not on my python GUI. Here's the code I have. def clearCache(self, event): try: node = hou.node('/obj/Rain_System/TRAILING') #point at your cache node node.parm("clear").pressButton() #and call its onPressedButton function except: exc_log Here's the wxPython scripts for the GUI: def _add_trails(self): trails_sizer= wx.BoxSizer(wx.HORIZONTAL) self.flex_grid_sizer.Add(trails_sizer, flag= wx.ALIGN_CENTER_VERTICAL) self.trail_on= wx.CheckBox(self, label= "On/Off") trails_sizer.Add(self.trail_on, 0, flag= wx.ALIGN_CENTER_VERTICAL) self.trail_on.Bind(wx.EVT_CHECKBOX, self.TrailOn) self.clear_button= wx.Button(self, label= "Clear Cache") trails_sizer.Add(self.clear_button, 0, border= 10, flag= wx.LEFT|wx.ALIGN_CENTER_VERTICAL) self.clear_button.Bind(wx.EVT_BUTTON, self.clearCache)
  21. Another Python Question

    Then do I have to put anything in the .pressButton() parentheses? I just put those to strings in my code and nothing is happening when I click the button.
  22. Another Python Question

    For the onPressButton function, do I have to write a callback script for this to work?
  23. Python Question

    Hey everyone, First ignore the last post. Figured out the problem. So my question for today is how can I create a geo node with a grid node inside it and connected to a popnet node? I know how to create each one separately but not connected. Any suggestions?
  24. Python Question

    Got it working again. Still have those minor problems. So I saved a copy just in case I screw up the code again. Hoping to have 1 of the 2 problems fixed today.
  25. Python Question

    So while trying to fix this problem and an issue with the GUI, I some how managed to mess up my fx tool. It no longer works properly. The make popnet button works and the collision options work. All the sliders no longer "work", however the GUI for the sliders works now. The numbers/labels for it change as you scroll, but they don't change the houdini parameters they're suppose to. And I'm still having the problem with the previous problem with the text box. I want them to recognize both numeric numbers and hscript expressions. Here's the code. I've been trying to fix this for over a week, and somehow keep making it worst, so any help, tips or suggestions would be much appreciated. Thanks. import sys, threading, wx if __name__ != "__main__": import hou import toolutils def exc_log(): print "Exception: '%s' on line %d" % (sys.exc_value, sys.exc_traceback.tb_lineno) class MyApp(wx.App): def OnInit(self): frame = MyFxTool(None, -1, 'Rain System Tool') frame.Show(True) self.SetTopWindow(frame) return True # Creates the Window class MyFxTool(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size (450, 320), style = wx.CAPTION | wx.SYSTEM_MENU | wx.CLOSE_BOX | wx.STAY_ON_TOP) self.sizer= wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.sizer) self.panel= MyFxToolPanel(self) self.sizer.Add(self.panel, 1, flag= wx.EXPAND) self.Layout() # Creates the Layout class MyFxToolPanel(wx.Panel): def __init__(self, parent): super(MyFxToolPanel, self).__init__(parent) self.sizer= wx.BoxSizer(wx.VERTICAL) self._add_flex_grid() self.SetSizer(self.sizer) def _add_flex_grid(self): self.flex_grid_sizer= wx.FlexGridSizer(cols= 2, vgap= 10, hgap= 70) self.sizer.Add(self.flex_grid_sizer, 1, border= 20, flag= wx.ALL|wx.EXPAND) self._add_static_text("Rain System Tool") self.start_button= self._add_button("Make It Rain") self._add_static_text("Amount of Rain") self.amount_slider= self._addAmount_slider() self._add_static_text("Rain Speed") self.r_speed_slider= self._addSpeed_slider() self._add_static_text("Direction") self._add_wdirection() self._add_static_text("Turbulance") self.turb_slider= self._addTurb_slider() self._add_static_text("Life") self.life_slider= self._addLife_slider() self._add_static_text("Collisions") self._add_colisions() self._add_static_text("Bounce") self.bounce_slider= self._addBounce_slider() ########################################################################### ####################### PARAMETER CONTROLS ################################ ########################################################################### def _add_static_text(self, label_text): static_text= wx.StaticText(self, label= label_text, style= wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL) self.flex_grid_sizer.Add(static_text, flag= wx.ALIGN_CENTER_VERTICAL) def _add_button(self, label_text): button= wx.Button(self, label= label_text) button.Bind(wx.EVT_BUTTON, self.OnClickAdd) self.flex_grid_sizer.Add(button, flag= wx.ALIGN_CENTER_VERTICAL) return button def _addAmount_slider(self): slider= SliderAndStaticText(self) self.flex_grid_sizer.Add(slider, flag= wx.ALIGN_CENTER_VERTICAL) return slider.slider def _on_amount_slider(self, event): print event.GetPosition() event.Skip() def _addSpeed_slider(self): slider= SliderAndStaticText(self) self.flex_grid_sizer.Add(slider, flag= wx.ALIGN_CENTER_VERTICAL) return slider.slider def _addTurb_slider(self): slider= SliderAndStaticText(self) self.flex_grid_sizer.Add(slider, flag= wx.ALIGN_CENTER_VERTICAL) return slider.slider def _addLife_slider(self): slider= SliderAndStaticText(self) self.flex_grid_sizer.Add(slider, flag= wx.ALIGN_CENTER_VERTICAL) return slider.slider def _add_wdirection(self): wdirection_sizer= wx.BoxSizer(wx.HORIZONTAL) self.flex_grid_sizer.Add(wdirection_sizer, flag= wx.ALIGN_CENTER_VERTICAL) self.x_value= self._add_letter_value("X:", wdirection_sizer) wdirection_sizer.AddSpacer(20,0) self.y_value= self._add_letter_value("Y:", wdirection_sizer) wdirection_sizer.AddSpacer(20,0) self.z_value= self._add_letter_value("Z:", wdirection_sizer) self.x_value.Bind(wx.EVT_TEXT, self.enterText) self.y_value.Bind(wx.EVT_TEXT, self.enterText) self.z_value.Bind(wx.EVT_TEXT, self.enterText) def _add_letter_value(self, letter_text, sizer): x= wx.StaticText(self, label= letter_text) sizer.Add(x, flag= wx.ALIGN_CENTER_VERTICAL) text_ctrl= wx.TextCtrl(self, size= (40, -1)) sizer.Add(text_ctrl, border= 2, flag= wx.LEFT|wx.ALIGN_CENTER_VERTICAL) return text_ctrl def _add_colisions(self): colisions_sizer= wx.BoxSizer(wx.HORIZONTAL) self.flex_grid_sizer.Add(colisions_sizer, flag= wx.ALIGN_CENTER_VERTICAL) self.collide_on= wx.CheckBox(self, label= "On/Off") colisions_sizer.Add(self.collide_on, 0, flag= wx.ALIGN_CENTER_VERTICAL) self.collide_on.Bind(wx.EVT_CHECKBOX, self.CheckOn) self.collide_button= wx.Button(self, label= "Collide With") colisions_sizer.Add(self.collide_button, 0, border= 10, flag= wx.LEFT|wx.ALIGN_CENTER_VERTICAL) self.collide_button.Bind(wx.EVT_BUTTON, self.AddCollision) options = ['Die', 'Bounce', 'Stop', 'Stick', 'Slide','Continue'] self.collide_op = wx.ComboBox(self, value= "", choices = options, id=5) self.collide_op.Bind(wx.EVT_COMBOBOX, self.SelectBehavior) colisions_sizer.Add(self.collide_op, 0, border= 10, flag= wx.LEFT|wx.ALIGN_CENTER_VERTICAL) def _addBounce_slider(self): slider= SliderAndStaticText(self) self.flex_grid_sizer.Add(slider, flag= wx.ALIGN_CENTER_VERTICAL) return slider.slider ########################################################################### ####################### PARAMETER EVENTS ################################## ########################################################################### #Allow you to create the acual rain system. #create both SOP and PO nodes. def OnClickAdd(self, event): geo = hou.node("/obj").createNode("geo", "Rain_System", run_init_scripts = False) grid = geo.createNode("grid", "EMIT_FROM") grid.setParms({"ty":10}) popnet = grid.createOutputNode("popnet", "RAIN_EMITTER") popnet.setDisplayFlag(1) source = popnet.createNode("source", "RAIN_ORIGIN") defaultGeo = source.parm("usecontextgeo") defaultGeo.set("first") birthPlace = source.parm("emittype") birthPlace.set("surfacerandom") gravity = source.createOutputNode("force", "RAIN_DirCtrl") defaultRainDir = gravity.parm("forcey") defaultRainDir.set(-4) rSpeed = gravity.createOutputNode("drag", "RAIN_Spd_Ctrl") defaultRainSpd = rSpeed.parm("scale") defaultRainSpd.set(2) rSpeed.setRenderFlag(1) collide = rSpeed.createOutputNode("collision", "COLLIDE_WITH") # Next 3 functions are to create a collision. # Once checked render flag(display) switches from drag to collision node. def CheckOn(self, event): collide = hou.node('/obj/Rain_System/RAIN_EMITTER/COLLIDE_WITH') rSpeed = hou.node('/obj/Rain_System/RAIN_EMITTER/RAIN_Spd_Ctrl') if self.collide_on.GetValue(): collide.setRenderFlag(1) else: rSpeed.setRenderFlag(1) # Allows the user to select a target for the "soppath" on the collision node once the button is clicked def AddCollision(self, event): try: target = hou.node('/obj/Rain_System/RAIN_EMITTER/COLLIDE_WITH') viewer = toolutils.sceneViewer() hitMe = viewer.selectObjects(quick_select = True)[-1].path() target.parm("soppath").set(hitMe) except: exc_log() # Allows user to switch behaviors for the collision. def SelectBehavior(self, event): try: op = self.collide_op colPop = hou.node('/obj/Rain_System/RAIN_EMITTER/COLLIDE_WITH') value = op.GetCurrentSelection() colPop.parm("behavior").set(value) except: exc_log() # Allows user to change the direction of the particle. Default is already set at -4. # Also effects the speed, if drag is low. def enterText(self, event): try: text = self.x_value text1 = self.y_value text2 = self.z_value entered = hou.node('/obj/Rain_System/RAIN_EMITTER/RAIN_DirCtrl') val = text.GetValue() val1 = text1.GetValue() val2 = text2.GetValue() entered.parm("forcex").set(val) entered.parm("forcey").set(val1) entered.parm("forcez").set(val2) except: exc_log() # Allow the user to adjust ALL sliders class SliderAndStaticText(wx.BoxSizer): def __init__(self, parent): super(SliderAndStaticText, self).__init__(wx.HORIZONTAL) self.slider= wx.Slider(parent, value= 10, minValue= 1, maxValue= 200) self.slider.Bind(wx.EVT_SCROLL, self._on_evt_scroll) self.Add(self.slider, flag= wx.ALIGN_CENTER_VERTICAL) self.slider_display= wx.StaticText(parent, label= "10") self.Add(self.slider_display, flag= wx.ALIGN_CENTER_VERTICAL) def _on_evt_scroll(self, event): self.slider_display.SetLabel("%s" % (event.GetPosition())) def sliderUpdate1(self, event): try: slider1 = self.slider slider2 = self.slider1 slider3 = self.slider2 slider4 = self.slider3 slider5 = self.slider4 emitHere = hou.node('/obj/Rain_System/RAIN_EMITTER/RAIN_ORIGIN') emitHere2 = hou.node('/obj/Rain_System/RAIN_EMITTER/RAIN_Spd_Ctrl') emitHere3 = hou.node('/obj/Rain_System/RAIN_EMITTER/RAIN_DirCtrl') emitHere4 = hou.node('/obj/Rain_System/RAIN_EMITTER/RAIN_ORIGIN') emitHere5 = hou.node('/obj/Rain_System/RAIN_EMITTER/COLLIDE_WITH') val = slider1.GetValue() val1 = slider2.GetValue() val2 = slider3.GetValue() val3 = slider4.GetValue() val4 = slider5.GetValue() emitHere.parm("constantrate").set(val) emitHere2.parm("scale").set(val1) emitHere3.parm("turb").set(val2) emitHere4.parm("life").set(val3) emitHere5.parm("bounce").set(val4) except: exc_log() class AppThread(threading.Thread): def run(self): app = MyApp(0) app.MainLoop() if __name__ == "__main__": AppThread().start()
×