quarta-feira, 8 de abril de 2015

Sierpinski_triangle

Crie um Cubo e Rode o Script com o Cubo selecionado :


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
global proc int sierp(int $counter , int $max)
{
    int $currentCounter = $counter ;
    if($currentCounter == $max)
    {
        return 0 ;
    }
    
    
    string  $objs[];
    clear($objs);
    $objs = `ls -sl -tr`;
    
    
    string $newObjsList[];
    clear($newObjsList);
    
    for( $item in $objs)
    {
        string $tempArray[];
        // pega Bouding Box 
        float $bbox[]= `polyEvaluate -b $item`;
        // separa em elemtos
        float $xmin = $bbox[0];
        float $xmax = $bbox[1];
        float $ymin = $bbox[2];
        float $ymax = $bbox[3];
        float $zmin = $bbox[4];
        float $zmax = $bbox[5];
        
        //print $xmin ;
        //print "\n" ;
        //print $xmax ;
        //print "\n" ;
        
        // acha divisoes
        float $quarter = ($xmax -  $xmin)/4;
        float $half = ($xmax - $xmin) /2;
        
        float $leftQuarter = ($xmin + $quarter);
        float $rightQuarter = ($xmax - $quarter);
        
        float $mid = $xmin + $half ;
        
        
        float $bottomQuarter = ($ymin + $quarter);
        float $topQuarter = ($ymax - $quarter);
        float $topMid = ($ymax - $half);
        
        float $frontQuarter = ($zmax - $quarter); 
        float $backQuarter = ($zmin + $quarter);
        float $frontMid = ($zmax - $half);
        
        
        //********** CRIA CUBOS ************
        //LEFT BOTTOM FRONT
        $tempArray = `polyCube -w $half  -h $half -d $half -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;
        move -absolute $leftQuarter $bottomQuarter $frontQuarter ; 
        $newObjsList[size($newObjsList)] = $tempArray[0];
        clear($tempArray);
        
        //RIGHT BOTTOM FRONT
        $tempArray = `polyCube -w $half  -h $half -d $half -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;
        move -absolute $rightQuarter $bottomQuarter $frontQuarter ; 
        $newObjsList[size($newObjsList)] = $tempArray[0];
        clear($tempArray);     
        
        //LEFT BOTTOM BACK
        $tempArray = `polyCube -w $half  -h $half -d $half -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;
        move -absolute $leftQuarter $bottomQuarter $backQuarter ; 
        $newObjsList[size($newObjsList)] = $tempArray[0];
        clear($tempArray);    
        
        //RIGHT BOTTOM BACK
        $tempArray = `polyCube -w $half  -h $half -d $half -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;
        move -absolute $rightQuarter $bottomQuarter $backQuarter ; 
        $newObjsList[size($newObjsList)] = $tempArray[0];
        clear($tempArray);    
        
        // MID TOP FRONTMID
        $tempArray = `polyCube -w $half  -h $half -d $half -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;
        move -absolute $mid $topQuarter $frontMid ; 
        $newObjsList[size($newObjsList)] = $tempArray[0];
        clear($tempArray);
        // DELETA OBJ ORIGINAL
        delete $item;
        }
    $currentCounter += 1;
    select $newObjsList;
    sierp($currentCounter ,  $max);
    return 0;
    
}

sierp(0,  5);

quarta-feira, 8 de outubro de 2014

size of vector data


// vector of pointer to T class 
std::vector<T*> animais;

// add new T instance object , into the animais vector pointer 
animais.pushBack( new T() );
animais.pushBack( new T() );


//  show size in bytes , kbytes , megaBytes 
std::cout << (animais.size() * sizeof(std::vector<T>))<<"bytes" << std::endl;
std::cout << (animais.size() * sizeof(std::vector<pessoa>))/ 1024 <<"kb" << std::endl;
std::cout << (animais.size() * sizeof(std::vector<pessoa>))/ 1048576 <<"mb" << std::endl;

Convert Bytes to KiloBytes, MegaBytes, Gigabytes

1 KB = 1024 B 
1 MB = 1048576 B = 1024 KB 
1 GB = 1073741824 B = 1048576 KB = 1024 MB


So... the formula is 

X KB = NumberOfBytes/1024
X MB = NumberOfBytes/1048576 'or X MB = NumberOfBytes/1024/1024

etc, etc.

terça-feira, 30 de setembro de 2014

multidimensional array and pseudo-multidimensional array



#2D array access 
#define WIDTH 5
#define HEIGHT 3

int jimmy [HEIGHT][WIDTH];
int n,m;

int main ()
{
  for (n=0; n<HEIGHT; n++)
    for (m=0; m<WIDTH; m++)
    {
      jimmy[n][m]=(n+1)*(m+1);
    }
}



#1D array access

#define WIDTH 5
#define HEIGHT 3

int jimmy [HEIGHT * WIDTH];
int n,m;

int main ()
{
  for (n=0; n<HEIGHT; n++)
    for (m=0; m<WIDTH; m++)
    {
      jimmy[n*WIDTH+m]=(n+1)*(m+1);
    }
}

sábado, 27 de setembro de 2014

REMAP function and LERP function


remap range:
double fit(double index, double old_min, double old_max, double new_min,double new_max)
{
    return new_min + (new_max - new_min) * (index - old_min) / (old_max- old_min);
}
usage :
fit(0.5, 0, 1, 10, 20);
>> 15.0
>>

LERP: 
Precise method which guarantees v = v1 when t = 1.

float lerp(float v0, float v1, float t)
{
  return (1-t)*v0 + t*v1;
}

sábado, 9 de agosto de 2014

PadZero in string Parameters Houdini

create string parameters keyframe
then edit expression

Python:
hou.node("..").name() + '_%03d' % hou.intFrame()

hou.node("..").name() : parent name 

*/ works for Integers  Floats and Strings*/ 
 '_%03d' % hou.intFrame() : pad3 decimals places  using Frame as base number    

****another method only for strings*****:

n = '4'
print n.zfill(3)
>>> '004'



HScript:

opname("..")+"_" + padzero(3,"$F") 


opname(".."): parent name 

padzero(3,"$F")  :pad3 decimals places  using Frame as base number




quinta-feira, 6 de fevereiro de 2014

RealFLow 2 vray VectorBlur


Use wildcards!  and convert to vrmesh
using ply2vrmesh app

./ply2vrmesh.exe "/Users/chrysl666/Desktop/TNT/VRAY_proxyMesh/meshExp11_01_*.bin" 


Then load one vrmesh file from the sequence  and change its path:
/Users/chrysl666/Desktop/TNT/VRAY_proxyMesh/meshExp11_01_0001.vrmesh

to something like this:
/Users/chrysl666/Desktop/TNT/VRAY_proxyMesh/meshExp11_01_%04d.vrmesh
ready to render using velocity path !