Mirosław Piekutowski

POLPPMnietek

About Me

専門知識
Freelancer
業界:
Advertising / Motion Graphics

Connect

LOCATION
Warsaw, Poland
ウェブサイト

Houdini Engine

Availability

Not Specified

Recent Forum Posts

any way to export points to .prt file 2023年1月23日21:14

I found this python code:
https://forums.thinkboxsoftware.com/t/houdini-exporter/12527/8 [forums.thinkboxsoftware.com]

after some changes i get rid of errors and script produce some files.
This is a code:


import sys, struct, zlib

node = hou.pwd()
geo = node.geometry()

frameNum = str(hou.intFrame()).zfill(4)
OutFilename = 'H:/Particles_%s.prt' %frameNum

particleCount = len(geo.points())

out = open(OutFilename, 'wb')

out.write(struct.pack("B", 0xc0)) # Magic numbers
out.write(struct.pack("B", 0x50))
out.write(struct.pack("B", 0x52))
out.write(struct.pack("B", 0x54))
out.write(struct.pack("B", 0x0d))
out.write(struct.pack("B", 0x0a))
out.write(struct.pack("B", 0x1a))
out.write(struct.pack("B", 0x0a))

out.write(struct.pack("<I", 56)) # Header Length
out.write(struct.pack("@32s", b"Extensible Particle Format" )) #Format Name
out.write(struct.pack("<I", 1)) # Version Number
out.write(struct.pack("<Q", particleCount)) # Particle Count
out.write(struct.pack("<I", 4)) # Reserved 4 bytes
out.write(struct.pack("<I", 6)) # Number of Channels
out.write(struct.pack("<I", 44)) # Channel definition entry length

# Write Channel Definitions

out.write(struct.pack("@32s", b"Position" )) #Name of Channel
out.write(struct.pack("<I", 4)) # Data type
out.write(struct.pack("<I", 3)) # number of values per particle for this channel
out.write(struct.pack("<I", 0)) # Data offset of this channel

out.write(struct.pack("@32s", b"Orientation" )) #Name of Channel
out.write(struct.pack("<I", 4)) # Data type
out.write(struct.pack("<I", 4)) # number of values per particle for this channel
out.write(struct.pack("<I", 12)) # Data offset of this channel

out.write(struct.pack("@32s", b"Scale" )) #Name of Channel
out.write(struct.pack("<I", 4)) # Data type
out.write(struct.pack("<I", 3)) # number of values per particle for this channel
out.write(struct.pack("<I", 28)) # Data offset of this channel

out.write(struct.pack("@32s", b"ShapeIndex" )) #Name of Channel
out.write(struct.pack("<I", 1)) # Data type
out.write(struct.pack("<I", 1)) # number of values per particle for this channel
out.write(struct.pack("<I", 40)) # Data offset of this channel

out.write(struct.pack("@32s", b"MtlIndex" )) #Name of Channel
out.write(struct.pack("<I", 1)) # Data type
out.write(struct.pack("<I", 1)) # number of values per particle for this channel
out.write(struct.pack("<I", 44)) # Data offset of this channel

out.write(struct.pack("@32s", b"Color" )) #Name of Channel
out.write(struct.pack("<I", 4)) # Data type
out.write(struct.pack("<I", 3)) # number of values per particle for this channel
out.write(struct.pack("<I", 48)) # Data offset of this channel

data = []

m = hou.Matrix4((   1, 0, 0, 0,     0, 0, 1, 0,      0, -1, 0, 0,     0, 0, 0, 1   ))  # Transform matrix to transform into 3DSMax space

for point in geo.points():

    #Transform Position
    pos = point.position()
    pos = pos*m
    data.append(pos)
    
    #Transform Orientation
    ov = point.attribValue('orient')
    x = ov[0]
    y = ov[1]
    z = ov[2]
    w = ov[3]
    orient = hou.Quaternion(x, y, z, w)
    
    orientM = hou.Matrix4(orient.extractRotationMatrix3())
    newMatrix = orientM*m
    
    orient = hou.Quaternion(newMatrix)    
    
    data.append(orient)
    
    data.append(point.attribValue('pscale'))
    data.append(point.attribValue('meshID'))
    data.append(point.attribValue('MtlIndex'))

z = zlib.compressobj()

for p in data:
    if type(p) is int:
        x = (struct.pack("<i", p))
        compressedData = z.compress(x)
        out.write(compressedData)
    else:
        for v in p:
            x = (struct.pack("<f", v))
            compressedData = z.compress(x)
            out.write(compressedData)

compressedData = z.flush()
out.write(compressedData)
out.close()

I can read this .prt files in max but data is incomplete. KrakatoaPRTLoader gives error "zlib_reader::read() Unexpected EOF"...
Any thoughts?

any way to export points to .prt file 2023年1月23日18:08

I need a way to get particles from Houdini to pFlow in 3ds Max.
And found that tyFlow can read .prt files. So I need to get out .prt from Houdini.
I searched the whole internet and only found this old repo:
https://github.com/flipswitchingmonkey/houdini_PRTROP [github.com]

I even tried to build this for Houdini 19 but no luck...

Any other way?

How to limit Geomtry Wrangle in DOP to specific object 2023年1月23日18:00

Thank you, sir