Jump to content

glassman3d

Members
  • Posts

    35
  • Joined

  • Last visited

Personal Information

  • Name
    Sam
  • Location
    London

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

glassman3d's Achievements

Newbie

Newbie (1/14)

2

Reputation

  1. intersting developments: https://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=41265
  2. this is amazing serg, thanks! really informative
  3. a quick update I have have just come across this thread and had a similar problem I managed to solve it with a vex function: pointprims Returns the list of primitives containing a point. Overview int [] pointprims(string geometry, int ptnum) int [] pointprims(int opinput, int ptnum) Returns an empty array if failed to find the point or there are no primitives owning it. This function returns an array of primitives that contain the given point. The order should not be relied on, but will be consistent. geometry The name of the geometry file to reference. Inside Houdini, this may be op:full_path_to_sop to reference a SOP. ptnum The point number to get a primitive from.
  4. amazing thanks! been trying to get refracted IDs working for ages in pbr
  5. Hi All These shaders are fantastic, I have been using the disney plausible shader on all my work for a few months now with substance designer - truly a revelation I am currently wrapping it up into an ubershader and have the same errors in my shell as Ajz is there any chance someone could point me in the right direction with how to resolve this? many thanks
  6. I should add the syntax is a bit crazy, here's a working python example to export animation on a camera called cam1 hou.hscript( """ chwrite -f 101 300 {0}t? {0}r? {0}focal /tmp/cliptest.bchan """.format( "/obj/cam1/") ) I've used python to utilise handy string formatting the hscript equivalent is: chwrite -f 101 300 /obj/cam1/t? /obj/cam1/r? /obj/cam1/focal /tmp/cliptest.bchan
  7. nevermind found it! chwrite, also opsave
  8. Hi All I'm creating an animation publishing system and I am looking for a way to export out .bclip information for two cases: 1) all channels in a given chop node 2) all channels in a parm or parm tuple There is a right click menu for both but I've been searching the hou module for both hou.ChopNode and hou.Parm for similar functions with no success. The File chop is only able to read clips Any ideas anyone? Is there some hscript function somewhere? many thanks
  9. thanks owl, I will give that a go as well!
  10. also on the reading side I managed to hack the pc2read otl to get faster performance using numpy import numpy # This code is called when instances of this SOP cook. geo = hou.pwd().geometry() # Read from Point Cache if hou.parm("read").eval(): pc2File = open(hou.evalParm("file"), "rb") # Header headerFormat='<12siiffi' pc2Header = pc2File.read(struct.calcsize(headerFormat)) fields = struct.unpack(headerFormat, pc2Header) signature, fileVer, numPoints, startFrame, sampleRate, numSamples = fields hou.parm("signature").set(signature) hou.parm("fileversion").set(str(fileVer)) hou.parm("points").set(str(numPoints)) hou.parm("samples").set(str(numSamples)) hou.parm("startframe").set(str(startFrame)) hou.parm("samplerate").set(str(sampleRate)) hou.parm("headerbytes").set(str(struct.calcsize(headerFormat))) points = geo.points() frame_int = ((int(hou.evalParm("frame")) - startFrame) + 1) xyz_size = struct.calcsize('<fff') hou.parm("posbytes").set(str(xyz_size)) seek_offset = max([0, frame_int-1]) * len(points) * xyz_size hou.parm("seekoffset").set(str(seek_offset)) if ((numPoints==len(points)) and (frame_int<=numSamples)): # Seek relative to the current file pos (os.SEEK_CUR==1) pc2File.seek(seek_offset, 1) buffer = pc2File.read(xyz_size * len(points)) positions = numpy.frombuffer(buffer, dtype="f4,f4,f4").copy() positions.dtype.names = ("x", "y", "z") geo.setPointFloatAttribValuesFromString("P", positions) pc2File.close()
  11. for completeness thought I would post the feedback I have received from SESI I will probably keep going with the hdk implementation as a learning exercise: You need to include <GA/GA_Types.h> to get GA_Offset. And you need to include <GA/GA_GBMacros.h> to get GA_FOR_ALL_PTOFF. You can implement hou.setFrame() in the HDK like so: #include <CH/CH_Manager.h> #include <OP/OP_Director.h> OPgetDirector()->setTime( OPgetDirector()->getChannelManager()->getTime(the_frame_to_be_set)); You can use the convenience function, UTwrite() to write out binary data to the file. For example: #include <FS/FS_Writer.h> #include <UT/UT_NTStreamUtil.h> int some_number = 3; FS_Writer writer("/path/to/file"); UTwrite(*writer.getStream(), some_number);
  12. oh I wasn't aware of pointFloatAttribValuesAsString() - that could work very well I will give that a go now thanks! UPDATE: It worked like a charm - I can cache out 150 frames of point positions for 90,000 points in about 30 secs perfectly fine for my current needs - here is my code for perusal thanks symek! import sys import struct def doCache(): sf = hou.evalParm("startframe") ef = hou.evalParm("endframe") sr = 1 ns = (ef - sf) + 1 geo = hou.pwd().geometry() points = geo.points() np = len(points) pc2File = open(hou.evalParm("file"), "wb") with hou.InterruptableOperation("PC2 Cache",open_interrupt_dialog=True) as operation: with hou.InterruptableOperation("Exporting %s" % hou.pwd().name(),open_interrupt_dialog=True) as export: # Write header headerFormat='<12siiffi' #headerStr = struct.pack(headerFormat, 'P','O','I','N','T','C','A','C','H','E','2','\0', 1, np, sf, sr, ns) headerStr = struct.pack(headerFormat, "POINTCACHE2\0", 1, np, sf, sr, ns) pc2File.write(headerStr) for f in range(sf, sf+ns, sr): hou.setFrame(f) pos = geo.pointFloatAttribValuesAsString("P") pc2File.write(pos) export.updateProgress( f/ns ) operation.updateLongProgress(0.5 * (f/ns) ) with hou.InterruptableOperation("Finishing",open_interrupt_dialog=True) as finish: pc2File.flush() pc2File.close() finish.updateProgress(1) operation.updateLongProgress(1)
  13. Hi Symek Every package besides Softimage seems to have implemented Alembic in a robust and sensible fashion to my immense frustration, even renderers like Arnold support it natively! thanks again for the code, one more piece to the puzzle! I should have specified, this is only a sop in the sense that it lives in sops - more of a 'soprop' like the filecache node for example. My code lives in a callback on an export button, My intention was to to iterate through the timeline, cook each frame, and append the point positions to the binary file in python for example: # iterate points def writePP(p,f): hou.setFrame(f) curp = p.position() curps = pc2File.write( struct.pack('<fff', float(curp[0]), float(-curp[2]), float(curp[1]) ) ) a = [ writePP(p,f) for f in xrange(sf, sf+ns, sr) for p in geo.points() ] could I ask is it necessary to unlock/lock the Input as below if I am in a callback context? if(lockInput(0, other_frame_contex) >= UT_ERROR_ABORD) { unlockInput(0); return error(); } duplicatePointSource(other_frame_context); Could I avoid this by iterating the timeline in python and calling my hdk function only to iterate the points? thanks for all your help, I have really jumped in the deep end here!
  14. Hi Symek thanks for that code! it'll come in very handy when I get to the reader, and I will go through it to see if there is anything I can use on the way out of Houdini as well! we were using alembic but the exocortex implementation in softimage is quite buggy as a point cache best Sam
  15. Hi there I am building a pc2 writer sop to export point cache data from Houdini I have a working python solution but it can be a bit slow (code has been hacked from the various examples on odforce ect) see below: import sys, struct def doCache(): sf = hou.evalParm("startframe") ef = hou.evalParm("endframe") sr = 1 ns = (ef - sf) + 1 geo = hou.pwd().geometry() points = geo.points() np = len(points) pc2File = open(hou.evalParm("file"), "wb") geo = hou.pwd().geometry() # Write header headerFormat='<12siiffi' headerStr = struct.pack(headerFormat, "POINTCACHE2\0", 1, np, sf, sr, ns) pc2File.write(headerStr) # iterate points def writePP(p,f): hou.setFrame(f) curp = p.position() curps = pc2File.write( struct.pack('<fff', float(curp[0]), float(-curp[2]), float(curp[1]) ) ) a = [ writePP(p,f) for f in xrange(sf, sf+ns, sr) for p in geo.points() ] # close file pc2File.flush() pc2File.close() Due to slow speeds I am attempting to implement this using inlinecpp to speed up the execution time. My attempt can be found below, (non-functional at the mo). I am a HDK newb so there are probably lots of very simple mistakes in there. Would anyone with HDK experience be able to give me a few pointers in where I am going wrong? import sys import struct import inlinecpp writePts = inlinecpp.createLibrary( name="cpp_string_library", includes="#include <GU/GU_Detail.h>, #include <FS/FS_Writer.h>, #include <UT/UT_Vector3.h>, #include <HOM/HOM_Module.h>", function_sources=[ """void writePC2(GU_Detail *gdp, const char *filename, const char *pc2, int *numPoints, float *start, float *samplerate, int *numSamples ) { // open the file for writing FS_Writer fs(filename); ostream *file = fs.getStream(); // write header file << pc2; file << int(1); file << numPoints; file << start; file << samplerate; file << numSamples; // iterate through frames through points for ( float i=start; i<end; ++i) { HOM_Module::setFrame( double(i) ) //iterate through the points GA_Offset ptoff; GA_FOR_ALL_PTOFF(gdp, ptoff) { UT_Vector3 pos = gdp->getPos3(ptoff); file << pos.x << pos.y << pos.z; } } // close the file file.close() } """]) def doCache(): sf = hou.evalParm("startframe") ef = hou.evalParm("endframe") sr = 1 ns = (ef - sf) + 1 geo = hou.pwd().geometry() filename = hou.evalParm("file") pc2 = "POINTCACHE2\0" writePts.writePC2(geo, filename, pc2, len(geo.points), sf, sr, ns) Much obliged!!! Sam Swift-Glasman
×
×
  • Create New...