当前位置: 首页>>代码示例>>C++>>正文


C++ cube::setVoxel方法代码示例

本文整理汇总了C++中cube::setVoxel方法的典型用法代码示例。如果您正苦于以下问题:C++ cube::setVoxel方法的具体用法?C++ cube::setVoxel怎么用?C++ cube::setVoxel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cube的用法示例。


在下文中一共展示了cube::setVoxel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: helix

//HELIX ANIMATION 
uint8_t animation::helix(cube &c){
    float X = 0;
    float Y = 0;
    float Z = 0;
    
    slow++;
    if(slow < 100){
        return 0;
    }
    slow = 0;
    
    c.clearVoxels();
    
    //use my fancy pants sine function
    for(uint8_t i = 0; i < 3; i++){
        for(uint8_t z = 0; z < 4; z++){
            Z = z*52;
            X = get_sinA(Z + phase + 18*i);
            Y = get_sinA(Z + phase + 90 + 18*i);
            X = (X+1)*4;
            Y = (Y+1)*4;
            c.setVoxel((uint8_t)X, (uint8_t)Y, z);
            c.setVoxel((uint8_t)(8-X), (uint8_t)(8-Y), z+4);
        }
    }
    
    //increment the phase 
    phase+=18;
    
    if(phase > 360){
        phase -= 360;
    }
    
    return 1;
}
开发者ID:AndreasBur,项目名称:MaxMatrix,代码行数:36,代码来源:animation.cpp

示例2: cubePulse

//CUBE PULSE
uint8_t animation::cubePulse(cube &c){
    uint8_t cubeSize = pos+1;
    uint8_t test = 0;
    uint8_t xCen = 0;
    uint8_t yCen = 0;
    uint8_t zCen = 0;
    
    slow++;
    if(slow < 150){
        return 0;
    }
    slow = 0;
    
    //build the cube with consitional statements, 
    //I feel like I could do this more elegantly but it works
    for(uint8_t x = 0; x < Xd; x++){
        for(uint8_t y = 0; y <Yd; y++){
            for(uint8_t z = 0; z < Zd; z++){
                test = 0;
                xCen = absA(2*(x-centre));
                yCen = absA(2*(y-centre));
                zCen = absA(2*(z-centre));
                
                if(xCen == cubeSize && yCen == cubeSize && zCen == cubeSize){
                    c.setVoxel(x, y, z);
                    test = 1;
                }
                if(xCen == cubeSize && yCen == cubeSize && zCen < cubeSize){
                    c.setVoxel(x, y, z);
                    test = 1;
                }
                if(xCen == cubeSize && zCen == cubeSize && yCen < cubeSize){
                    c.setVoxel(x, y, z);
                    test = 1;
                }
                if(zCen == cubeSize && yCen == cubeSize && xCen < cubeSize){
                    c.setVoxel(x, y, z);
                    test = 1;
                }
                
                if(!test && c.getVoxel(x, y, z)){
                    c.clearVoxel(x, y, z);
                }
            }
        }
    }
    
    pos += dir*2;
    
    if(pos > 6 || pos < 0){
        dir *= -1;
        pos += dir*2;
    }
    
    return 1;
}
开发者ID:AndreasBur,项目名称:MaxMatrix,代码行数:57,代码来源:animation.cpp

示例3: bouncePlane

//SINGLE PLANE BOUNCING
uint8_t animation::bouncePlane(cube &c, uint8_t axis){
    slow++;
    if(slow < 200){
        return 0;
    }
    slow = 0;
    
    //the X animation looks the same but actually clears everything in its path
    //rather than clear everything at the start, it makes a simple but cool 
    //transition between some animations
    if(axis != 'X'){
        c.clearVoxels();
    }
    
    switch(axis){
        case 'X':
            for(uint8_t z = 0; z < Zd; z++){
                for(uint8_t y = 0; y < Yd; y++){
                    for(uint8_t x = 0; x < Xd; x++){
                        if(x == pos - dir){
                            c.clearVoxel(x, y, z);
                        }
                        c.setVoxel(pos, y, z);
                    }
                }
            }
            break;
        case 'Y':
            for(uint8_t x = 0; x < Xd; x++){
                for(uint8_t z = 0; z < Zd; z++){
                    c.setVoxel(x, pos, z);
                }
            }
            break;
        case 'Z':
            for(uint8_t x = 0; x < Xd; x++){
                for(uint8_t y = 0; y < Yd; y++){
                    c.setVoxel(x, y, pos);
                }
            }
            break;
    }
    
    //bounce the pos variable between 0 and 7
    bouncePos();
    
    return 1;
}   
开发者ID:AndreasBur,项目名称:MaxMatrix,代码行数:49,代码来源:animation.cpp

示例4: rain

//RAIN FUNCTION
uint8_t animation::rain(cube &c){
    uint16_t count = 0;
    uint8_t rX = 0;
    uint8_t rY = 0;
    uint8_t rZ = 0;
    
    slow++;
    if(slow < 200){
        return 0;
    }
    slow = 0;
    
    randomSeed(analogRead(0));
    
    //shift the rain down
    for(int x = 0; x < Xd; x++){
        for(int y = 0; y < Yd; y++){
            for(int z = 0; z < Zd-1; z++){
                if(z == 0 && c.getVoxel(x, y, z)){
                    c.clearVoxel(x, y, z);
                }
                
                if(c.getVoxel(x, y, z+1)){
                    c.clearVoxel(x, y, z+1);
                    c.setVoxel(x, y, z);
                }
            }
        }
    }
    
    //create some raindrops
    rX = random(0,8);
    rY = random(0,8);
    while(c.getVoxel(rX, rY, 7) != 0 && count < 100){
        rX = random(0,8);
        rY = random(0,8);
        count++;
    }
    c.setVoxel(rX, rY, 7);

    return 1;
}
开发者ID:AndreasBur,项目名称:MaxMatrix,代码行数:43,代码来源:animation.cpp

示例5: randomExpand

//RANDOM LIGHTS
uint8_t animation::randomExpand(cube &c){
    uint16_t count = 0;
	uint8_t rX, rY, rZ;
    
    slow++;
    if(slow < 20){
        return 0;
    }
    slow = 0;
    
    randomSeed(analogRead(0));
    rX = rand()%8+0;
    rY = rand()%8+0;
    rZ = rand()%8+0;
	
    //find an empty voxel
    while(c.getVoxel(rX, rY, rZ) == 1 && dir == 1){
        rX = random(0, 8);
        rY = random(0, 8);
        rZ = random(0, 8);
        count++;
        
        if(count > 200){
            dir *= -1;
        }
    }
    count = 0;

    //find a full voxel
    while(c.getVoxel(rX, rY, rZ) == 0 && dir == -1){
        rX = random(0, 8);
        rY = random(0, 8);
        rZ = random(0, 8);
        count++;

        if(count > 200){
            dir *= -1;
        }
    }

    //fill or clear the voxel found
    if(dir == 1){
        c.setVoxel(rX, rY, rZ);
    }else{
        c.clearVoxel(rX, rY, rZ);
    }
    
    return 1;
}
开发者ID:AndreasBur,项目名称:MaxMatrix,代码行数:50,代码来源:animation.cpp


注:本文中的cube::setVoxel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。