Interesting... I wonder if this is why I've been having problems with KP's
PC2 reader with huge files just over 2GB? I ended up splitting my meshes to
work around it, but now I wonder...




On Sat, Nov 16, 2013 at 2:18 PM, Alok Gandhi <[email protected]>wrote:

> Hi All,
>
> I have update the ReadPC2ICE node to version 1.1
>
> You can find the addon here <http://bit.ly/1axgUea> and code 
> here<http://bit.ly/17ZKRpU>
> .
>
> Change Log:
>
> Bug fixes:
>
>
>
> ·         Point data for files over 2 GB was not read correctly due to
> limitations of <int> data type. It is changed to <__int64> which can handle
> the data > 2 GB. Now the node can easily read files over 2 GB.
>
>
>
> *Notes*
>
> ·         The same changes needs to be applied for *KP_PointCacheReader*for 
> this bugfix. I am not aware if Kai has fixed this already in other
> updates to his code. But the 
> one<http://sculptwork.com/rr/bak/kaipirinha/KP_PointCacheV25.zip> I
> had from rray.de does not have this change. Kai, if you are listening can
> you confirm that?
>
>
>
> ·         The code for this bugfix is not supported on Linux. However, in
> case you want to compile for Linux, please note that the <__int64> data
> type for windows translates to <long long> on a gcc compiler for Linux. I
> will add support for Linux once I have a machine with Linux up and running.
> Till then you have to change the code yourself.
>
>
>
>
>
> ·         Suppressed unnecessary warning messages in cases of pc2 file
> not specified and unable to open file. They were kind of annoying. Just
> uncomment my code lines to bring them back if you want.
>
>
>
>
>
> New features:
>
>
>
> ·         When working with pc2 files I always missed the ability to know
> beforehand the start and end frame of the file. Now the node supports this.
> There are two new output ports that furnish the start and end frames as
> scalars. You can use this to do time warps, offsets, view them in viewports
> as custom attributes or whatever else you might find it useful for.
>
> Please feel free to mail me if you have any question or problems/bugs with
> this addon.
>
> Thanks.
>
>
>
> On Mon, Nov 4, 2013 at 9:00 PM, Alok Gandhi <[email protected]>wrote:
>
>> And here is the github for the code:
>>
>> https://github.com/alok1974/KP_PointCache-Reader-ICE-Node
>>
>>
>> On Mon, Nov 4, 2013 at 8:42 PM, Alok Gandhi <[email protected]>wrote:
>>
>>> Here is the code for the pc2 reader:
>>>
>>> ----------------------------------------------------------
>>> """
>>> .PC2 File Format:
>>> You can create or modify PointCache2 files by hand using the following
>>> file format.
>>> The start of the file is a header containing:
>>>
>>> char    cacheSignature[12];   // Will be 'POINTCACHE2' followed by a
>>> trailing null character.
>>> int     fileVersion;          // Currently 1
>>> int     numPoints;            // Number of points per sample
>>> float   startFrame;           // Corresponds to the UI value of the same
>>> name.
>>> float   sampleRate;           // Corresponds to the UI value of the same
>>> name.
>>> int     numSamples;           // Defines how many samples are stored in
>>> the file.
>>>
>>> Be sure to check the version number. If it isn't 1, then don't mess with
>>> the file,
>>> as the format will change in the future.
>>>
>>> Following the header, there is a straight dump of all the cache
>>> samples (which are snapshots of all the point positions for an object).
>>> Each sample is stored one after the other as a flat array of x/y/z floats
>>> for each point (so each sample is (numPoints * sizeof(float) * 3) bytes).
>>> """
>>>
>>>
>>> # Note for Alan : You might want to extend this class by adding a method
>>> to fetch the frame data
>>> #                 for a prticular frame. It is trivial to do so, just
>>> look at my code below for
>>> #                 getting bounding box data.
>>>
>>> import os
>>> import sys
>>> import time
>>> from struct import unpack
>>>
>>> class CacheObject(object):
>>>     def __init__(self, pth):
>>>         self._dFile = None
>>>         self.fPath = pth
>>>         self._headerString = ''
>>>         self._cacheFileVersionNumber = 0
>>>         self._pCount = 0
>>>         self._startFrame = 0
>>>         self._sampleRate = 0
>>>         self._numSamples = 0
>>>         self._mshBBox = {}
>>>         self._headerRead = False
>>>         self._dataRead = False
>>>
>>>     def _setFile(self):
>>>         if not self._dFile:
>>>             self._dFile = open(self.fPath, 'rb')
>>>             self._msh = os.path.splitext(os.path.basename(self.fPath))[0]
>>>
>>>         if not self._headerRead:
>>>             self._processHeader()
>>>
>>>
>>>
>>>     def _processHeader(self):
>>>         self._headerRead = True
>>>
>>>         self._setFile()
>>>
>>>         dfile = self._dFile
>>>
>>>         self._headerString = unpack('12s', dfile.read(12))[0]
>>>         self._cacheFileVersionNumber = unpack('I', dfile.read(4))[0]
>>>         self._pCount = unpack('L', dfile.read(4))[0]
>>>         self._startFrame = unpack('f', dfile.read(4))[0]
>>>         self._sampleRate = unpack('f', dfile.read(4))[0]
>>>         self._numSamples = unpack('L', dfile.read(4))[0]
>>>
>>>         if not self._dataRead:
>>>             dfile.flush()
>>>             dfile.close()
>>>             self._dFile = None
>>>
>>>
>>>
>>>     def _processBBoxData(self):
>>>         self._dataRead = True
>>>         self._setFile()
>>>
>>>         dfile = self._dFile
>>>         data = {}
>>>
>>>
>>>         s = int(self._startFrame)
>>>         e = int(s + self._numSamples)
>>>
>>>         for f in range(s, e):
>>>             xArr = []
>>>             yArr = []
>>>             zArr = []
>>>
>>>             for i in range(self._pCount):
>>>                 x = unpack('f', dfile.read(4))[0]
>>>                 y = unpack('f', dfile.read(4))[0]
>>>                 z = unpack('f', dfile.read(4))[0]
>>>
>>>                 xArr.append((x, i))
>>>                 yArr.append((y, i))
>>>                 zArr.append((z, i))
>>>
>>>             # min\max data
>>>             d = (max(xArr)[0], max(yArr)[0], max(zArr)[0], min(xArr)[0],
>>> min(yArr)[0], min(zArr)[0])
>>>
>>>             data[f] = { 0:(d[3], d[4], d[5]),
>>>                         1:(d[3], d[1], d[5]),
>>>                         2:(d[0], d[1], d[5]),
>>>                         3:(d[0], d[4], d[5]),
>>>                         4:(d[3], d[4], d[2]),
>>>                         5:(d[3], d[1], d[2]),
>>>                         6:(d[0], d[1], d[2]),
>>>                         7:(d[0], d[4], d[2]),
>>>                       }
>>>
>>>         self._mshBBox = data
>>>
>>>         dfile.flush()
>>>         dfile.close()
>>>         self._dFile = None
>>>
>>>     def getHeaderInfo(self):
>>>         self._processHeader()
>>>         return {'HEADER': self._headerString,
>>>                 'VERSION': self._cacheFileVersionNumber,
>>>                 'NB_POINTS': self._pCount,
>>>                 'START_FRAME': self._startFrame,
>>>                 'SAMPLE_RATE': self._sampleRate,
>>>                 'NB_SAMPLES': self._numSamples,}
>>>
>>>     def getBBoxData(self):
>>>         self._processBBoxData()
>>>         return self._mshBBox
>>>
>>> if __name__ == '__main__':
>>>     f = r'<pc2 file path>'
>>>     o = CacheObject(f)
>>>     print o.getHeaderInfo()
>>>
>>> ---------------------------------------------------------
>>>
>>>
>>>  On Mon, Nov 4, 2013 at 8:37 PM, Alok Gandhi 
>>> <[email protected]>wrote:
>>>
>>>> Hmm, there are a few options to load the data in reader operator.
>>>> Stream, Frame or Memory. Try selecting the frame or memory options. By
>>>> default, it is the stream which might have problems similar to one you
>>>> have. Anyways, in addition to the ICE Node, few years back, I also wrote a
>>>> python reader class to read the pc2 file data directly through python. Not
>>>> optimised using numpy or scipy but it can still let you investigate the
>>>> contents of a ,pc2 file in a human-readable format. I will also post the
>>>> code to it.
>>>>
>>>>
>>>> On Mon, Nov 4, 2013 at 8:33 PM, Alan Fregtman 
>>>> <[email protected]>wrote:
>>>>
>>>>> Intermittent empty frames. Sometimes they work, sometimes not. Mind
>>>>> you... it's very dense topo, and the pc2 file is about 2GB. It might be
>>>>> reaching some sort of limit somewhere.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Mon, Nov 4, 2013 at 8:29 PM, Alok Gandhi <[email protected]
>>>>> > wrote:
>>>>>
>>>>>> You do realise that my node is an exact copy of the KP_PointCache
>>>>>> Reader Operator. Only difference is that instead of applying the
>>>>>> pointposition on the host mesh posarray, it furnishes the same data in 
>>>>>> the
>>>>>> vector array format in ICE.
>>>>>>
>>>>>> I am not sure if reading the pointpositions in ICE through my node
>>>>>> will give you any extra functionality that Kai's original operator can't.
>>>>>> But anyways, feel free to try it.
>>>>>>
>>>>>> Btw, may I know what is the issue that you are having ?
>>>>>>
>>>>>>
>>>>>> On Mon, Nov 4, 2013 at 8:25 PM, Alan Fregtman <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> Great! Thank you. Just today we've been experiencing an issue with
>>>>>>> KP's reader for this one specific mesh. We're temporarily using Alembic
>>>>>>> manually, but I'm curious if your reader will be any better.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Nov 4, 2013 at 7:45 PM, Alok Gandhi <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> Surething, will post the source probably on github. My old laptop
>>>>>>>> with ubuntu died a few months ago :( so I cant compile it myself.
>>>>>>>>
>>>>>>>> I will post the link here soon.
>>>>>>>>
>>>>>>>> Sent from my iPhone
>>>>>>>>
>>>>>>>> On Nov 4, 2013, at 7:20 PM, Alan Fregtman <[email protected]>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Hey Alok,
>>>>>>>>
>>>>>>>> Any chance for a Linux compile? Or sources to attempt a compile
>>>>>>>> ourselves?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mon, Nov 4, 2013 at 11:21 AM, Alok Gandhi <
>>>>>>>> [email protected]> wrote:
>>>>>>>>
>>>>>>>>> Glad it helped you. And yea, now thinking in retrospect, you won't
>>>>>>>>> need the switch context as the getpointid already does that.
>>>>>>>>>
>>>>>>>>> Sent from my iPhone
>>>>>>>>>
>>>>>>>>> On Nov 4, 2013, at 9:23 AM, Cristobal Infante <[email protected]>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> VERY HANDY Alok, I can confirm you don't need the switch context
>>>>>>>>> node, all the rest worked fine..
>>>>>>>>>
>>>>>>>>> By the way, the BIG difference in relation to the default  "Cache
>>>>>>>>> on File" read node, is that you are able to move your cached geometry
>>>>>>>>> around the scene. So if you have a last minute layout change you
>>>>>>>>> can deal with it in rendering. This is way we've stuck with KP op
>>>>>>>>> reader so far..
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 4 November 2013 13:58, Alok Gandhi 
>>>>>>>>> <[email protected]>wrote:
>>>>>>>>>
>>>>>>>>>> Hi Cristobal,
>>>>>>>>>>
>>>>>>>>>> The node output a single array of pointpositions. So you have to
>>>>>>>>>> convert the array to per point attribute. A getpointid plugged into 
>>>>>>>>>> the
>>>>>>>>>> select in array and them set pointposition will do the trick. Of 
>>>>>>>>>> course you
>>>>>>>>>> know that the target mesh or pointcloud should have same number 
>>>>>>>>>> points as
>>>>>>>>>> in the pc2 file. Also you might need a  switch context node before 
>>>>>>>>>> set
>>>>>>>>>> pointposition.
>>>>>>>>>>
>>>>>>>>>> In case of an empty pointcloud, it is easier. Just plug the
>>>>>>>>>> output of the node directly into an add points node.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Sent from my iPhone
>>>>>>>>>>
>>>>>>>>>> On Nov 4, 2013, at 8:13 AM, Cristobal Infante <[email protected]>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Hi Alok,
>>>>>>>>>>
>>>>>>>>>> Thanks again for sharing this tool, we still rely KP pc2 reader
>>>>>>>>>> so having an alternative is really handy.
>>>>>>>>>>
>>>>>>>>>> I was guessing "Read PC2 File" > "Set Point Position"?
>>>>>>>>>>
>>>>>>>>>> But I am getting a structure mismatch, probably doing the wrong
>>>>>>>>>> thing!
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>> Cris
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On 4 November 2013 05:40, Alok Gandhi 
>>>>>>>>>> <[email protected]>wrote:
>>>>>>>>>>
>>>>>>>>>>> Ah I see, I was confused when you said " i haven't tried
>>>>>>>>>>> multiple files per frame (does softimage even export pc2 files this 
>>>>>>>>>>> way?)
>>>>>>>>>>> ".
>>>>>>>>>>>
>>>>>>>>>>> Well in that, sure you can export single file per frame per
>>>>>>>>>>> object through KP_PointCache manager, you simply have to select the 
>>>>>>>>>>> start
>>>>>>>>>>> and end frame as the same. PC2 file format have the notion of  
>>>>>>>>>>> "samples"
>>>>>>>>>>> rather than frame, so if you have one sample per frame set then 
>>>>>>>>>>> basically
>>>>>>>>>>> you are exporting one data set (pointpositions) per frame.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Mon, Nov 4, 2013 at 12:26 AM, Steven Caron 
>>>>>>>>>>> <[email protected]>wrote:
>>>>>>>>>>>
>>>>>>>>>>>> no one said that you could have multiple objects in the same
>>>>>>>>>>>> .pc2 file.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Sun, Nov 3, 2013 at 8:37 PM, Alok Gandhi <
>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> I am a little confused...
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> For sure, you cannot have multiple objects in the same .pc2
>>>>>>>>>>>>> file, the format simply doesn't support that.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>>
>>>
>>>
>>>
>>> --
>>>
>>
>>
>>
>> --
>>
>
>
>
> --
>

Reply via email to