변압기 로고 애니메이션
                                            
                                                
                                                
                                                
                                                
                                                
                                                 7382 단어  HOUDINI
                    
소개
새해 복 많이 받으세요. 후지 야마 타카시입니다. 새해! 라고 하는 것으로 트랜스포머풍의 뉴이어 로고를 만들었으므로, 그것에 대해 가볍게 설명시키고 받으려고 생각합니다. 잘 부탁드립니다.
 
 조각 세팅
 
우선은 divide나 무엇인가로 분할합니다.
PrimWrangle에서 i@baseid = @primnum;로 baseid를 만듭니다.
 
복사합니다.
복사 후 PrimWrangle을 사용하여 아래 코드의 polyneighbours로 인접한 다각형의 프리미티브 번호 목록을 가져옵니다.
i@primid = @primnum;
s@name = concat("piece",itoa(@primid));
i[]@neighbours = polyneighbours(0, @primnum); 
 
polyExtrude로 두께를 붙입니다.
Pack 후 prim 속성의 baseid와 neighbours를 포인트에 승격하고, 아래의 코드로 복사 대상의 축에 있는 인접 객체의 번호를 취득해 neighbours에 추가합니다.
string group = concat( "base_",itoa(i@baseid));
int moreNeighbours[] = pcfind(0, group, "P", @P, ch("radius"), 3);
moreNeighbours = moreNeighbours[1::];
append( i[]@neighbours, moreNeighbours );
지금까지의 조작은 인접 PackObject의 넘버 리스트마저 취득할 수 있으면 무엇이든지 좋다.
 계층 설정
계층화는 이전에 쓴 확산되는 박스 의 방법과 비슷합니다.
Solver 내에서 인접 객체를 활성화해 가면서, 처리하고 있는 순서대로 그 ptnum 의 리스트를 추가해 갑니다. 이 처리에 의해 자신의 부모 계층의 리스트를 취득하게 됩니다.
 
Solver 전에 준비할 속성입니다. hierarchy에 계층 구조 목록을 저장합니다.
i@rootid = @ptnum;
if((rand(@ptnum + 123123)<0.6)){
    i@top = 1;
    i@connected = 1;
    i@level = 0;
    i[]@hierarchy = array(@ptnum);
    }
Solver 내의 코드, 미리 준비하고 있던 인접 오브젝트의 넘버를 추적해 갑니다.
i@top = 0;
i[]@neighbours;
int unconnecteds[] = {};
foreach(int i; i[]@neighbours){
    if(point(0,"connected",i) == 0){
        append(unconnecteds,i);
    }
}
int active = 0;
if( len(unconnecteds) != 0 ){
    if(i@top == 1){
        active = 1;
    }else{
        if(rand(@ptnum+999 + @Frame) <  0.1 )active = 1;
    }
}
///select Next
if( active ){
    int selNex = floor( rand(@ptnum * 12 + @Frame) * len(unconnecteds) );
    int nextP = unconnecteds[selNex];
    setpointattrib(0, "top", nextP, 1);
    setpointattrib(0, "connected", nextP, 1);
    setpointattrib(0, "rootid", nextP, i@rootid);
    setpointattrib(0, "level", nextP, i@level + 1);
    int hierarchyPlus[] = i[]@hierarchy;
    append(hierarchyPlus, nextP);
    setpointattrib(0, "hierarchy", nextP, hierarchyPlus );
}
 매트릭스 계층의 애니메이션
계층 변환은 아이의 계층으로부터 부모를 향해 걸어 갈 필요가 있습니다. 변환의 행렬에는 maketransform을 사용합니다. 쉽게 Pivot을 설정할 수 있기 때문입니다.
matrix xform = ident();
for(int i=0; i<len(@hierarchy); i++ ){
    int index = @hierarchy[::-1][i];
    vector move;
    move[floor( rand(index + 11)*3 )] = fit01(rand(index + 110),-1,1) * 0.05; 
    vector rotation; 
    rotation[floor( rand(index + 22)*3 )] = rint( fit01(rand(index + 220),-1,1) * 3 ) * 90;
    vector pivot = point(0,"P",index);
    xform *= maketransform(0, 0, move, rotation, set(1,1,1), pivot);
}
@P *= xform;
setattrib(0, "primintrinsic", "transform", @primnum, -1, matrix3(xform), "set");
이것이 기본 코드입니다. int index = @hierarchy[::-1][i]; 에서 계층 구조의 번호를 반대로 추적합니다.
index를 사용하여 랜덤 시드를 사용합니다. 계층 중심점은 point(0,"P",index)로 얻을 수 있습니다.
rottimingList와 movetimingList를 정화하여 각 계층의 애니메이션 타이밍을 설정하고 나란히 한 상자를 이동해 봅니다.
i[]@hierarchy;
float rottimingList[] = {};
float movetimingList[] = {};
float startFrame = 1;
for(int i=0; i<len(@hierarchy); i++ ){
    append(rottimingList, startFrame);
    startFrame += 2 + rand(@hierarchy[i] + 666) * 1;
    append(movetimingList, startFrame);
    startFrame += 4 + rand(@hierarchy[i] + 999) * 1;
}
matrix xform = ident();
for(int i=0; i<len(@hierarchy); i++ ){
    int index = @hierarchy[::-1][i];
    float rottiming = rottimingList[::-1][i];
    float movetiming = movetimingList[::-1][i];
    vector move;
    move [floor( rand(index + 11)*3 )] = rand(index + 111) * 1 * fit(@Frame,movetiming,movetiming + 5,1,0);
    vector rotation; 
    rotation[floor( rand(index + 22)*3 )] = floor( rand(index + 222) * 3 ) * 90 * fit(@Frame,rottiming,rottiming + 5,1,0);
    vector pivot = point(0,"P",index);
    xform *= maketransform(0, 0, move, rotation, set(1,1,1), pivot);
}
@P *= xform;
setattrib(0, "primintrinsic", "transform", @primnum, -1, matrix3(xform), "set");
 
이런 느낌입니다. 이 코드는 거의 그대로 분획한 입체 로고에 적응할 수 있습니다. 다소 조정한 코드가 아래와 같습니다.
i[]@hierarchy;
float rottimingList[] = {};
float movetimingList[] = {};
float startFrame = rand(@rootid + 333) * 20 + 1;
for(int i=0; i<len(@hierarchy); i++ ){
    append(rottimingList, startFrame);
    startFrame += 5 + rand(@hierarchy[i] + 666) * 5;
    append(movetimingList, startFrame);
    startFrame += 5 + rand(@hierarchy[i] + 999) * 15;
}
matrix xform = ident();
for(int i=0; i<len(@hierarchy); i++ ){
    int index = @hierarchy[::-1][i];
    float rottiming = rottimingList[::-1][i];
    float movetiming = movetimingList[::-1][i];
    vector move;
    move[floor( rand(index + 11)*3 )] = fit01(rand(index + 110),-1,1) * 0.05 * fit(@Frame,movetiming,movetiming + 5,1,0); 
    vector rotation; 
    rotation[floor( rand(index + 22)*3 )] = rint( fit01(rand(index + 220),-1,1) * 3 ) * 90 * fit(@Frame,rottiming,rottiming + 15,1,0);
    vector pivot = point(0,"P",index);
    xform *= maketransform(0, 0, move, rotation, set(1,1,1), pivot);
}
@P *= xform;
setattrib(0, "primintrinsic", "transform", @primnum, -1, matrix3(xform), "set");
 
작성한 파일은 이쪽이 됩니다.
 h tps://d ゔぇ. 오, ぇ. 이 m/후ぃぇ/d/1이 f2사 B즈x1오gkYM키에h6PjcHMrD응BGーh/ごぃえw? 우 sp = 샤린 g
폰트는 이쪽으로부터 다운로드 했습니다만, 샘플 파일의 텍스트는 프리즈 시키고 있습니다.
 htps //w w. 흠 ts 파세. 코 m / 카테고 ry / t rans fur rs
그럼 이번은 이상이 됩니다. 여기까지 읽어 주셔서 감사합니다!
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(변압기 로고 애니메이션), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/takashiFujiyama/items/74216e830b86b825ed0c
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            

우선은 divide나 무엇인가로 분할합니다.
PrimWrangle에서
i@baseid = @primnum;로 baseid를 만듭니다.
복사합니다.
복사 후 PrimWrangle을 사용하여 아래 코드의 polyneighbours로 인접한 다각형의 프리미티브 번호 목록을 가져옵니다.
i@primid = @primnum;
s@name = concat("piece",itoa(@primid));
i[]@neighbours = polyneighbours(0, @primnum); 

polyExtrude로 두께를 붙입니다.
Pack 후 prim 속성의 baseid와 neighbours를 포인트에 승격하고, 아래의 코드로 복사 대상의 축에 있는 인접 객체의 번호를 취득해 neighbours에 추가합니다.
string group = concat( "base_",itoa(i@baseid));
int moreNeighbours[] = pcfind(0, group, "P", @P, ch("radius"), 3);
moreNeighbours = moreNeighbours[1::];
append( i[]@neighbours, moreNeighbours );
지금까지의 조작은 인접 PackObject의 넘버 리스트마저 취득할 수 있으면 무엇이든지 좋다.
계층 설정
계층화는 이전에 쓴 확산되는 박스 의 방법과 비슷합니다.
Solver 내에서 인접 객체를 활성화해 가면서, 처리하고 있는 순서대로 그 ptnum 의 리스트를 추가해 갑니다. 이 처리에 의해 자신의 부모 계층의 리스트를 취득하게 됩니다.
 
Solver 전에 준비할 속성입니다. hierarchy에 계층 구조 목록을 저장합니다.
i@rootid = @ptnum;
if((rand(@ptnum + 123123)<0.6)){
    i@top = 1;
    i@connected = 1;
    i@level = 0;
    i[]@hierarchy = array(@ptnum);
    }
Solver 내의 코드, 미리 준비하고 있던 인접 오브젝트의 넘버를 추적해 갑니다.
i@top = 0;
i[]@neighbours;
int unconnecteds[] = {};
foreach(int i; i[]@neighbours){
    if(point(0,"connected",i) == 0){
        append(unconnecteds,i);
    }
}
int active = 0;
if( len(unconnecteds) != 0 ){
    if(i@top == 1){
        active = 1;
    }else{
        if(rand(@ptnum+999 + @Frame) <  0.1 )active = 1;
    }
}
///select Next
if( active ){
    int selNex = floor( rand(@ptnum * 12 + @Frame) * len(unconnecteds) );
    int nextP = unconnecteds[selNex];
    setpointattrib(0, "top", nextP, 1);
    setpointattrib(0, "connected", nextP, 1);
    setpointattrib(0, "rootid", nextP, i@rootid);
    setpointattrib(0, "level", nextP, i@level + 1);
    int hierarchyPlus[] = i[]@hierarchy;
    append(hierarchyPlus, nextP);
    setpointattrib(0, "hierarchy", nextP, hierarchyPlus );
}
 매트릭스 계층의 애니메이션
계층 변환은 아이의 계층으로부터 부모를 향해 걸어 갈 필요가 있습니다. 변환의 행렬에는 maketransform을 사용합니다. 쉽게 Pivot을 설정할 수 있기 때문입니다.
matrix xform = ident();
for(int i=0; i<len(@hierarchy); i++ ){
    int index = @hierarchy[::-1][i];
    vector move;
    move[floor( rand(index + 11)*3 )] = fit01(rand(index + 110),-1,1) * 0.05; 
    vector rotation; 
    rotation[floor( rand(index + 22)*3 )] = rint( fit01(rand(index + 220),-1,1) * 3 ) * 90;
    vector pivot = point(0,"P",index);
    xform *= maketransform(0, 0, move, rotation, set(1,1,1), pivot);
}
@P *= xform;
setattrib(0, "primintrinsic", "transform", @primnum, -1, matrix3(xform), "set");
이것이 기본 코드입니다. int index = @hierarchy[::-1][i]; 에서 계층 구조의 번호를 반대로 추적합니다.
index를 사용하여 랜덤 시드를 사용합니다. 계층 중심점은 point(0,"P",index)로 얻을 수 있습니다.
rottimingList와 movetimingList를 정화하여 각 계층의 애니메이션 타이밍을 설정하고 나란히 한 상자를 이동해 봅니다.
i[]@hierarchy;
float rottimingList[] = {};
float movetimingList[] = {};
float startFrame = 1;
for(int i=0; i<len(@hierarchy); i++ ){
    append(rottimingList, startFrame);
    startFrame += 2 + rand(@hierarchy[i] + 666) * 1;
    append(movetimingList, startFrame);
    startFrame += 4 + rand(@hierarchy[i] + 999) * 1;
}
matrix xform = ident();
for(int i=0; i<len(@hierarchy); i++ ){
    int index = @hierarchy[::-1][i];
    float rottiming = rottimingList[::-1][i];
    float movetiming = movetimingList[::-1][i];
    vector move;
    move [floor( rand(index + 11)*3 )] = rand(index + 111) * 1 * fit(@Frame,movetiming,movetiming + 5,1,0);
    vector rotation; 
    rotation[floor( rand(index + 22)*3 )] = floor( rand(index + 222) * 3 ) * 90 * fit(@Frame,rottiming,rottiming + 5,1,0);
    vector pivot = point(0,"P",index);
    xform *= maketransform(0, 0, move, rotation, set(1,1,1), pivot);
}
@P *= xform;
setattrib(0, "primintrinsic", "transform", @primnum, -1, matrix3(xform), "set");
 
이런 느낌입니다. 이 코드는 거의 그대로 분획한 입체 로고에 적응할 수 있습니다. 다소 조정한 코드가 아래와 같습니다.
i[]@hierarchy;
float rottimingList[] = {};
float movetimingList[] = {};
float startFrame = rand(@rootid + 333) * 20 + 1;
for(int i=0; i<len(@hierarchy); i++ ){
    append(rottimingList, startFrame);
    startFrame += 5 + rand(@hierarchy[i] + 666) * 5;
    append(movetimingList, startFrame);
    startFrame += 5 + rand(@hierarchy[i] + 999) * 15;
}
matrix xform = ident();
for(int i=0; i<len(@hierarchy); i++ ){
    int index = @hierarchy[::-1][i];
    float rottiming = rottimingList[::-1][i];
    float movetiming = movetimingList[::-1][i];
    vector move;
    move[floor( rand(index + 11)*3 )] = fit01(rand(index + 110),-1,1) * 0.05 * fit(@Frame,movetiming,movetiming + 5,1,0); 
    vector rotation; 
    rotation[floor( rand(index + 22)*3 )] = rint( fit01(rand(index + 220),-1,1) * 3 ) * 90 * fit(@Frame,rottiming,rottiming + 15,1,0);
    vector pivot = point(0,"P",index);
    xform *= maketransform(0, 0, move, rotation, set(1,1,1), pivot);
}
@P *= xform;
setattrib(0, "primintrinsic", "transform", @primnum, -1, matrix3(xform), "set");
 
작성한 파일은 이쪽이 됩니다.
 h tps://d ゔぇ. 오, ぇ. 이 m/후ぃぇ/d/1이 f2사 B즈x1오gkYM키에h6PjcHMrD응BGーh/ごぃえw? 우 sp = 샤린 g
폰트는 이쪽으로부터 다운로드 했습니다만, 샘플 파일의 텍스트는 프리즈 시키고 있습니다.
 htps //w w. 흠 ts 파세. 코 m / 카테고 ry / t rans fur rs
그럼 이번은 이상이 됩니다. 여기까지 읽어 주셔서 감사합니다!
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(변압기 로고 애니메이션), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/takashiFujiyama/items/74216e830b86b825ed0c
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
i@rootid = @ptnum;
if((rand(@ptnum + 123123)<0.6)){
    i@top = 1;
    i@connected = 1;
    i@level = 0;
    i[]@hierarchy = array(@ptnum);
    }
i@top = 0;
i[]@neighbours;
int unconnecteds[] = {};
foreach(int i; i[]@neighbours){
    if(point(0,"connected",i) == 0){
        append(unconnecteds,i);
    }
}
int active = 0;
if( len(unconnecteds) != 0 ){
    if(i@top == 1){
        active = 1;
    }else{
        if(rand(@ptnum+999 + @Frame) <  0.1 )active = 1;
    }
}
///select Next
if( active ){
    int selNex = floor( rand(@ptnum * 12 + @Frame) * len(unconnecteds) );
    int nextP = unconnecteds[selNex];
    setpointattrib(0, "top", nextP, 1);
    setpointattrib(0, "connected", nextP, 1);
    setpointattrib(0, "rootid", nextP, i@rootid);
    setpointattrib(0, "level", nextP, i@level + 1);
    int hierarchyPlus[] = i[]@hierarchy;
    append(hierarchyPlus, nextP);
    setpointattrib(0, "hierarchy", nextP, hierarchyPlus );
}
계층 변환은 아이의 계층으로부터 부모를 향해 걸어 갈 필요가 있습니다. 변환의 행렬에는 maketransform을 사용합니다. 쉽게 Pivot을 설정할 수 있기 때문입니다.
matrix xform = ident();
for(int i=0; i<len(@hierarchy); i++ ){
    int index = @hierarchy[::-1][i];
    vector move;
    move[floor( rand(index + 11)*3 )] = fit01(rand(index + 110),-1,1) * 0.05; 
    vector rotation; 
    rotation[floor( rand(index + 22)*3 )] = rint( fit01(rand(index + 220),-1,1) * 3 ) * 90;
    vector pivot = point(0,"P",index);
    xform *= maketransform(0, 0, move, rotation, set(1,1,1), pivot);
}
@P *= xform;
setattrib(0, "primintrinsic", "transform", @primnum, -1, matrix3(xform), "set");
이것이 기본 코드입니다.
int index = @hierarchy[::-1][i]; 에서 계층 구조의 번호를 반대로 추적합니다.index를 사용하여 랜덤 시드를 사용합니다. 계층 중심점은 point(0,"P",index)로 얻을 수 있습니다.
rottimingList와 movetimingList를 정화하여 각 계층의 애니메이션 타이밍을 설정하고 나란히 한 상자를 이동해 봅니다.
i[]@hierarchy;
float rottimingList[] = {};
float movetimingList[] = {};
float startFrame = 1;
for(int i=0; i<len(@hierarchy); i++ ){
    append(rottimingList, startFrame);
    startFrame += 2 + rand(@hierarchy[i] + 666) * 1;
    append(movetimingList, startFrame);
    startFrame += 4 + rand(@hierarchy[i] + 999) * 1;
}
matrix xform = ident();
for(int i=0; i<len(@hierarchy); i++ ){
    int index = @hierarchy[::-1][i];
    float rottiming = rottimingList[::-1][i];
    float movetiming = movetimingList[::-1][i];
    vector move;
    move [floor( rand(index + 11)*3 )] = rand(index + 111) * 1 * fit(@Frame,movetiming,movetiming + 5,1,0);
    vector rotation; 
    rotation[floor( rand(index + 22)*3 )] = floor( rand(index + 222) * 3 ) * 90 * fit(@Frame,rottiming,rottiming + 5,1,0);
    vector pivot = point(0,"P",index);
    xform *= maketransform(0, 0, move, rotation, set(1,1,1), pivot);
}
@P *= xform;
setattrib(0, "primintrinsic", "transform", @primnum, -1, matrix3(xform), "set");

이런 느낌입니다. 이 코드는 거의 그대로 분획한 입체 로고에 적응할 수 있습니다. 다소 조정한 코드가 아래와 같습니다.
i[]@hierarchy;
float rottimingList[] = {};
float movetimingList[] = {};
float startFrame = rand(@rootid + 333) * 20 + 1;
for(int i=0; i<len(@hierarchy); i++ ){
    append(rottimingList, startFrame);
    startFrame += 5 + rand(@hierarchy[i] + 666) * 5;
    append(movetimingList, startFrame);
    startFrame += 5 + rand(@hierarchy[i] + 999) * 15;
}
matrix xform = ident();
for(int i=0; i<len(@hierarchy); i++ ){
    int index = @hierarchy[::-1][i];
    float rottiming = rottimingList[::-1][i];
    float movetiming = movetimingList[::-1][i];
    vector move;
    move[floor( rand(index + 11)*3 )] = fit01(rand(index + 110),-1,1) * 0.05 * fit(@Frame,movetiming,movetiming + 5,1,0); 
    vector rotation; 
    rotation[floor( rand(index + 22)*3 )] = rint( fit01(rand(index + 220),-1,1) * 3 ) * 90 * fit(@Frame,rottiming,rottiming + 15,1,0);
    vector pivot = point(0,"P",index);
    xform *= maketransform(0, 0, move, rotation, set(1,1,1), pivot);
}
@P *= xform;
setattrib(0, "primintrinsic", "transform", @primnum, -1, matrix3(xform), "set");

작성한 파일은 이쪽이 됩니다.
h tps://d ゔぇ. 오, ぇ. 이 m/후ぃぇ/d/1이 f2사 B즈x1오gkYM키에h6PjcHMrD응BGーh/ごぃえw? 우 sp = 샤린 g
폰트는 이쪽으로부터 다운로드 했습니다만, 샘플 파일의 텍스트는 프리즈 시키고 있습니다.
htps //w w. 흠 ts 파세. 코 m / 카테고 ry / t rans fur rs
그럼 이번은 이상이 됩니다. 여기까지 읽어 주셔서 감사합니다!
Reference
이 문제에 관하여(변압기 로고 애니메이션), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/takashiFujiyama/items/74216e830b86b825ed0c텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)