My Broken Pencil_Making from vndeepak3d on Vimeo.







Live Action Series - Term 1 - Building Explosion from Lennard Schmidt on Vimeo.







Dragon 2 : Ice Blast from Lucas Janin on Vimeo.



RABBIT Trail from Flooz on Vimeo.


Rabbit_trail.03.hip


Intro to python in Houdini from Ruben Mayor on Vimeo.



Tutorial 53 - Creating Particle Goals and Curves in Houdini from Sam Welker on Vimeo.


/ -> exhelp padzero 

string padzero (float size, float value)

        Returns a string padding a number to a given length with zeros.

        

        Returns a string containing <value> preceded by enough zeros to make up

        <size> digits.

        

        EXAMPLES

              padzero(5, 126) = 00126

        

              padzero(5, 23) = 00023

        

              padzero(1, 23) = 23



padzero(4, $FF)

 

Hscript에 보시면, padzero()라는 함수가 있는데요, $F를 0001~1000과 같은 형식으로 바꿔주는 역할을 합니다. 

 

 

python에서 구현할경우

 

 

Strings일 경우에는:


>>> n = '4'

>>> print n.zfill(3)

>>> '004'


그리고, 숫자일 경우에는:


>>> n = 4

>>> print '%03d' % n

>>> 004

>>> print "{0:03d}".format(4) # python >= 2.6

>>> 004

>>> print("{0:03d}".format(4)) # python 3

>>> 004


이런식으로 해 주시면 됩니다. 레퍼런스 링크를 참조하세요.

References:

http://stackoverflow.com/questions/339007/python-nicest-way-to-pad-zeroes-to-string

 

 

'Houdini > └ VEX' 카테고리의 다른 글

[VEX] 오브젝트리스트 파라메터 값 가져올때"op:"  (0) 2016.10.12
/ -> exhelp opinput
string opinput (string name, float index)
        REPLACED BY
            hou.Node.inputConnectors()
        
        Returns the name of the node connected to a given input.
        
        <index> is the 0-based number of the input. For example, to get the name
        of the node connected to the first input, use opinput(".", 0), and for
        the second input, use opinput(".", 1).
        
        EXAMPLES
              point("../" + opinput(".", 0), $PT, "P", 0)

opinput은 지정경로의 input으로 들어오는 노드의 이름을 가져온다. 예제 익스프레션을 풀이 하자면

"point 함수로 각 포인트의 포지션 X축을 가져오는데 경로는 현재경로의 첫번째 인풋으로 들어오는 경로를 이용한다."라는 건데

그냥 절대 경로를 입력시 계속 경로를 바꿔주는 번거로움이 있으므로 point의 경로를 

[ "../"(현재 레벨) + opinput("."(현재 노드), 0) ]로 설정하여 자동화 시킨것이다.

---------------------------------------------------------------------------------------------------------

/ -> exhelp opinputpath

string opinputpath (string name, float index)

        REPLACED BY

            hou.Node.path()

        

        Returns the full path of the node connected to a given input.

        

        <index> is the 0-based number of the input. For example, to get the path

        of the node connected to the first input, use opinputpath(".", 0), and

        for the second input, use opinputpath(".", 1).

        

        EXAMPLES

              point(opinputpath(".", 0), $PT, "P", 0)

        

opinputpath는 지정경로의 input으로 들어오는 노드의 경로를 가져온다.

        

        RELATED

          * opinput

          * opninputs

          * opoutput

          * opoutputpath

          * opnoutputs

 

 

'Houdini > └ EXP' 카테고리의 다른 글

[EXP] argc("This has four arguments")  (0) 2016.10.17
[EXP] parameter 타입별 expressions 사용법  (0) 2016.10.17

Returns the number of arguments in an HScript-style list of arguments.

Usage

argc(line)

Standard parsing is done, no variable expansion is done on the line.

Examples

 

argc("This has four arguments")
Returns 4, as that is the number of space delimited words.

 

 

argc("Quoting 'makes this one arg'")

Returns two as the quotes cause the last four words to count as a single word.

 

argc는 리스트의 총 인수 갯수를 출력해준다

 

ex) argc(primgrouplist("/obj/box/voronoifracture1"))

 

 

parameter 타입별로 익스프레션을 사용하는 방법이 필요하다. 일반적인 변수 입력창에는 익스프레션을 그대로 작성하면 되지만 노드를 선택해서 가져오는경우나 파일을 여는 파라메터에서는 추가해 주어야 할 것이 있다.

 

 

 

위와 같이 외부 파일만을 받는 파라메터에서 후디니 노드를 입력해야 할 경우 앞부분에 "op:"를 입력 후 " ` "back tick을 이용하여 익스프레션의 리턴값을 받아오게끔 해줘야 익스프레션이 작동된다.

object_distance_text.hip

 

오브젝트의 distance 값을 비주얼하게 텍스트로 보여주게 할 수 있다.

 

네트워크는 위와 같으며 chopnet에서 두 오브젝트와의 거리를 구한 후 font노드에서 distance값을 받아와 카메라에 룩엣을 해주었다. 

 

텍스트의 위치는 블렌드를 이용하여 중간위치를 구해 배치해 주었다.

 

 

<< Chopnet >>

 

<< Chopnet에서 구한 distance값을 불러드렸다 >>

 

<< 결과물 >>

 

Common Houdini Surface operators (SOPs)

Box, Sphere, Grid, Tube, Circle, Line, Torus, Curve Some basic operators that give you geometry primitives
File Loads a mesh (objbgeo, etc)
Trace Uses a threshold to generate geometry from an image
Add Creates individual points and/or polygons
Merge Combines multiple pieces of geometry
Point Manipulates point properties and attributes. The second input allows operations between two sets of points from different sources providing they have the same number.
Primitive Manipulates primitive (usually polygons) properties and attributes
Transform Moves, rotates, and scales geometry
Facet Most commonly used to calculate normals, but does a few other things too.
Group Allows you to assign a group to a set of vertices, points, or primitives. (A bit like XSI’s Clusters)
Copy Copies input geometry. The second input allows you to copy the geometry from the first input, onto each point of the second input. This operator allows loop-style processing by using the Copy/Stamp feature.
Delete Deletes geometry. Can be used with a Copy operator to perform loop-style processing.
AttribCreate Allows you to store custom information at each vertex, point, primitive, or object
AttribTransfer Copies attributes from one piece of geometry to another. The geometry does not have to match (just like XSI’s GATOR).
AttribPromote Allows you to do various statistics on an attribute (e.g. average, minimum, maximum, mode, sum of squares, etc.) and transfer it to the corresponding vertex, point, or primitive.
Measure Allows you to calculate polygon area, perimeter or mesh curvature.
Cache Stores geometry in memory to allow for faster previews.
Trail Can calculate per a point velocity, or generate trails of points from animated geometry.
Skin Performs a “loft” style operation
Resample Redistributes points along a curve
Ray Does ray tracing based on point nomal. Can be used to shrink wrap one mesh onto another.
Cookie, Boolean Different types of Boolean style operations
Sort Can sort point order based on various things.
Peak Transforms points based on their normals
Connectivity Creates an attribute with a value based on connectivity information. Works well with Partition operator
Partition Assigns geometry to a group based on an attribute value. Often used with the Connectivity operator

 

Common Houdini Expressions

You can find the full list of expressions here:
http://www.sidefx.com/docs/houdini11.0/expressions/

ch(<parameter path>) Gets the current value of the parameter
chf(<parameter path>,<frame> ) Gets the value of the parameter at a particular frame
stamp(<Copy SOP path>, <stamp variable>, <default value>) Retrieves the current value of the specified stamp variable (See Houdini docs for more info on the copy-stamping process)
point(<SOP path>, <point number>, <attribute name>, <index>) Retrieves a point attribute value. If attribute is a vector (e.g. position), then index specifies vector component (e.g., 0=”x”, 1=”y”, 2=”z”)
prim(<SOP path>, <point number>, <attribute name>, <index>) Same as point, but for primitives
clamp(<value>,<min>,<max>) Keeps the value within the minimum and maximum values
fit(<value>,<min>,<max>,<newmin>,<newmax>) Remaps the value from the old range to the new range and clamps it.
fit01(<value>,<newmin>,<newmax>) Just like fit() but assumes value is already in the range 0 to 1.
smooth(<value>,<min>,<max>) Outputs a smoothed value between 0 and 1 as value goes from minimum to maximum.
noise(<x>, <y>, <z>) Returns a noise value for a given position in space.
rand(<seed>) Gives a random number based on the seed value. The returned value will always be the same for a particular seed.
length(<x>, <y>, <z>) Returns the length of the vector
distance(<x1>, <y1>, <z1>,<x2>, <y2>, <z2>) Returns the distance between two points
if(<expr>, <value if true>, <value if false>) Gives a choice of two values depending on the expression evaluating to true or false
opinput(<operator path>, <input index>) Returns the path of the operator connected to the input specified by the input index.
bbox(<SOP path>, <dimension type>) Returns the required measurement of the bounding box of some geometry. “dimension type” can be one of these:

 

D_XMIN, D_YMIN, D_ZMIN, D_XMAX, D_YMAX, D_ZMAX, D_XSIZE, D_YSIZE, D_ZSIZE

centroid(<SOP path>, <dimension type>) Returns the X, Y, or Z position of the center of the bounding box. “dimension type” can be one of these:

 

D_X, D_Y, D_Z

pic(<COP path>, <u>, <v>, <color type>) Returns the interpolated pixel color from a compositing operator at the specified UV. “color type” can be one of these:

 

D_CR, D_CG, D_CB, D_CA, D_CHUE, D_CSAT, D_CVAL, D_CLUM

 

Houdini expressions also contain the common mathematical functions that are found in most scripting and expression languages. Here are just a few:

sin, cos, tan, asin, acos, atan, atan2, abs, pow, sqrt, ceil, floor, atof, dot, cross, deg, rad, exp, frac, hsv, rgb, min, max, log, log10, round, substr, strreplace

Note: Trigonometric functions accept angles in degrees.

The modulus operation is achieved using the % character, and boolean logic is achieved using the standard C operators, i.e. <. >, <=, >=, ==, !=, !

Common Houdini Expression Local Variables

Important: The following variables are NOT available in every operator. Each operator has its own local variables, and you can find which ones in Houdini’s help documentation. The ones listed here are the ones you’ll most commonly encounter.

$PT Point number. Used in most SOPs that manipulate points
$PR Primitive number. Used in most SOPs that manipulate primitives
$CY Used by the Copy SOP to identify the current copy being made. Unlessthe second Copy input is being used, in which case $PT will be used instead.
$TX, $TY, $TZ Position of a point
$NX, $NY, $NZ Normal of a point/primitive
$CR, $CG, $CB, $CA Color of a point/primitive
$VX, $VY, $VZ Velocity of a point
$BBX, $BBY, $BBZ The normalised (0 to 1) position of the point in the bounding box
$CEX, $CEY, $CEZ Centroid of the geometry
$AGE Number of seconds a particle has been alive
$LIFE Normalised age (0 to 1) of a particle
$XMIN, $XMAX, etc. Extents of the bounding box
$SIZEX, $SIZEY, $SIZEZ Size of the bounding box
$TX2, $TY2, $TZ2 Used to identify the position of a point coming from the second input of a Point SOP. Similarly for other attributes, e.g. Normals, $NX2, etc.

 

 

 

Creating a monitor profile for Nuke for accurate colour rendering from Dave Girard on Vimeo.

 

생성한 blut파일은 후디니 및 타 프로그램에서 사용
 

fracture_Pack_Change_Naming_TEST.hip

flip_spline_motion_test.hip

 

Curve_Attach_to_AnimationObject.hip

 

SopSolver_age_trailDeform.hip

 

SopSolver_age_trailDeform.hip

calc_functions.py

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
96
97
98
99
100
101
# 파이썬 계산기의 함수 모듈: 다음 단계
 
# 팩토리얼 함수:
def factorial(n):
    try:
        n = int(n)
    except:
        return "--> 오류!"
 
    # '0'과 같은지 체크(특별한 경우):
    if n == 0:
        return 1
 
    # 매우 큰 수인지 확인해서 돌려보냄:
    if n > 40:
        return "--> 답이 화면을 가득 채울 수 있습니다!"
    
    # 음수에 발생한 경우에 대한 점검:
    if n < 0:
        return "--> 오류!"
    
    # 팩토리얼 알고리즘 적용:
    ans = n
    while n > 1:
        ans = ans*(n-1)
        n = n-1
        return ans
 
 
 
# 로마 숫자로 변환하는 함수01:
def to_roman(n):
    try:
        n = int(n)
    except:
        return "--> 오류!"
 
    # 인수가 4999보다 큰 숫자인지 범위를 벗어난 것으로 판단합니다.:
    if n > 4999:
        return "--> 범위를 넘어섭니다."
 
    # 튜플 안에 튜플  생성:
    romans = ((1000,"M"), (900,"CM"), (500,"D"), (400,"CD"), (100,"C"), (90,"XC"), (50,"L"),
               (40,"XL"), (10,"X"), (9,"IX"), (5,"V"), (4,"IV"), (1,"I"))
 
    # 알고리즘 시작:
    result =""
    for (value,letters) in romans:
        while n >= value:
            result = result + letters
            n = n - value        
    return result
 
 
 
 
# 로마 숫자로 변환하는 함수02:
def to_roman02(n):
    try:
        n = int(n)
    except:
        return "--> 오류!"
 
    # 인수가 4999보다 큰 숫자인지 범위를 벗어난 것으로 판단합니다.:
    if n > 4999:
        return "--> 범위를 넘어섭니다."
    
    # 튜플과 사전 생성:
    numberBreaks = (1000,900,500,400,100,90,50,40,10,9,5,4,1)
    letters = {1000:"M"900:"CM"500:"D"400:"CD"100:"C"90:"XC"50:"L",
               40:"XL"10:"X"9:"IX"5:"V"4:"IV"1:"I"}
 
    # 알고리즘 시작:    
    result =""
    for value in numberBreaks:
        while n >= value:
            result = result + letters[value]
            n = n - value        
    return result
 
 
 
 
# 10진수를 2진수로 변환하는 함수:
def to_binary(n):
    try:
        n = int(n)
        return bin(n)[2:]
    except:
        return "-->오류!"
 
 
 
 
# 2진수를 10진수로 변환하는 함수:
def from_binary(n):
    try:
        return int(n,2)
    except:
        return "-->오류!"
 
cs


Main.py

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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Main.py
 
from tkinter import *
from decimal import *
import calc_functions
 
# 키 입력 함수:
def click(key):
    # = 버튼이 눌렸을 때 계산 수행:
    if key == "=":
       try:
            result = str(eval(display.get()))[0:10]
            display.insert(END, "=" + result)
       except:
            display.insert(END, "--> 오류!")
 
    # C 버튼이 눌렸을 때 display 엔트리 위젯 내용 비움:
    elif key == "C":
        display.delete(0, END)
 
    # 상수 버튼에 대한 연결 코드:
    elif key == constants_list[0]:
        display.insert(END, "3.141592654")
    elif key == constants_list[1]:
        display.insert(END, "300000000")
    elif key == constants_list[2]:
        display.insert(END, "330")
    elif key == constants_list[3]:
        display.insert(END, "149597887.5")
 
    # 함수 버튼 행동 정의:
    elif key == functions_list[0]:
        n = display.get() # display 엔트리 위젯 내용 수집
        display.delete(0,END) # display 엔트리 위젯 내용 비움
        display.insert(END, calc_functions.factorial(n))
    elif key == functions_list[1]:
        n = display.get() # display 엔트리 위젯 내용 수집
        display.delete(0,END) # display 엔트리 위젯 내용 비움
        display.insert(END, calc_functions.to_roman(n))
    elif key == functions_list[2]:
        n = display.get() # display 엔트리 위젯 내용 수집
        display.delete(0,END) # display 엔트리 위젯 내용 비움
        display.insert(END, calc_functions.to_binary(n))
    elif key == functions_list[3]:
        n = display.get() # display 엔트리 위젯 내용 수집
        display.delete(0,END) # display 엔트리 위젯 내용 비움
        display.insert(END, calc_functions.from_binary(n))
        
        
    # 그 외 다른 키를 눌렀을 때 실행될 기본 동작:
    else:
        display.insert(END, key)
 
 
 
##### 메인:
window = Tk()
window.title("Mycalcultor")
 
# top_row 프레임 생성
top_row = Frame(window)
top_row.grid(row=0, column=0, columnspan=2,sticky=N)
 
# 내용 수정이 가능한 엔트리 위젯을 사용해 결과 디스플레이 사용
display = Entry(top_row, width=45, bg="light gray")
display.grid()
 
# 숫자 버튼 생성
num_pad = Frame(window)
num_pad.grid(row=1, column=0, sticky=W)
 
# 숫자 버튼에 제공될 숫자
num_pad_list = [
'7','8','9',
'4','5','6',
'1','2','3',
'0','.','=']
 
# 반복문으로 숫자 버튼 생성
= 0 # 행 카운터
= 0 # 열 카운터
 
for btn_text in num_pad_list:
    def cmd(x=btn_text):
        click(x)
 
    Button(num_pad, text=btn_text, width=7, command=cmd).grid(row=r, column=c)
    c = c+1
    if c > 2:
        c = 0
        r = r + 1
 
# 연산자 프레임 생성
operator = Frame(window)
operator.grid(row=1, column=1, sticky=E)
 
operator_list = [
'*''/',
'+','-',
'(',')',
'C']
 
# 반복문 안에서 연산자 버튼 생성
for btn_text in operator_list:
    def cmd(x=btn_text):
        click(x)
 
    Button(operator, text=btn_text, width=5, command=cmd).grid(row=r, column=c)
    c = c+1
    if c > 1:
        c = 0
        r = r + 1
 
# 상수 프레임 생성
constants = Frame(window)
constants.grid(row=3, column=0, sticky=W)
 
constants_list = [
    'pi',
    '빛의 이동 속도(m/s)',
    '소리의 이동 속도(m/s)',
    '태양과의 평균 거리(km)']
 
# 반복문과 함께 상수 버튼 생성
= 0
= 0
 
for btn_text in constants_list:
    def cmd(x=btn_text):
        click(x)
    Button(constants, text=btn_text, width=24, command=cmd).grid(row=r, column=c)
    r = r+1
 
 
# 함수 프레임 생성
functions = Frame(window)
functions.grid(row=3, column=1, sticky=E)
 
functions_list = [
    'factorial (!)',
    '-> roman',
    '-> binary',
    'binary -> 10']
 
# 반복문과 함께 함수 버튼 생성
= 0
= 0
 
for btn_text in functions_list:
    def cmd(x=btn_text):
        click(x)
    Button(functions, text=btn_text, width=24, command=cmd).grid(row=r, column=c)
    r = r+1
 
 
 
 
 
 
 
###### 메인 반복문 실행
window.mainloop()
 
 
 
cs


1
2
3
4
5
string pc = "op:"+chs("pcopen");
 
int handle = pcopen(pc, "P", @P, 110);
 
@Cd = pcfilter(handle,"Cd");

cs





'Houdini > └ VEX' 카테고리의 다른 글

[VEX] padzero(size, value)  (0) 2016.10.17

+ Recent posts