Beispiel #1
0
void StFftCubeDistort::createMesh(){
    mesh = ofBoxPrimitive(ofGetWidth() * 2.0, ofGetWidth() * 2.0, ofGetWidth() * 2.0).getMesh();
    for (int i = 0; i < mesh.getVertices().size(); i++) {
        ofVec2f texCoord = mesh.getTexCoord(i);
        texCoord.x *= tex.getWidth();
        texCoord.y  = (1.0 - texCoord.y) * tex.getHeight();
        mesh.setTexCoord(i, texCoord);
        
        currentVertex.push_back(ofVec3f(mesh.getVertices()[i].x, mesh.getVertices()[i].y, mesh.getVertices()[i].z));
    }
}
Beispiel #2
0
//--------------------------------------------------------------
void ofApp::setup(){
	ofSetFrameRate(60);
	ofSetVerticalSync(true);
	ofBackground(0);
	
	lase.setup();
	
	// preview utils -> ofxOpenLase/bin/simulator
	conn.setup();
	conn.connect("libol:out_x", "simulator:in_x");
	conn.connect("libol:out_y", "simulator:in_y");
	conn.connect("libol:out_g", "simulator:in_g");
	
	mesh = ofBoxPrimitive(100, 100, 100, 1, 1, 1).getMesh();
}
 BoxPerticle(ofTexture & tex , int max_num_box = 400):mTex(tex), maxNumBox(max_num_box)
 {
     base::mParamGroup.add(mBoxNum.set("num_box", 10, 1, maxNumBox));
     base::mParamGroup.add(mRotationSpeed.set("rotation_speed", 0.1, 0, 0.4));
     base::mParamGroup.add(mBoxSize.set("box_size", 10, 0, 600));
     base::mParamGroup.add(mSpacing.set("spaceing", 10, 1, 100));
     base::mParamGroup.add(mCloudSize.set("cloud_size", 600, 100, 2000));
     base::mParamGroup.add(mCol.set("color", ofColor(255,255,255,255), ofColor(0,0,0), ofColor(255,255,255,255)));
     base::mParamGroup.add(mRandomCol.set("random_color", false));
     
     
     for (int i = 0; i < maxNumBox; i++) {
         mBox.push_back(ofBoxPrimitive());
     }
 }
Beispiel #4
0
void testApp::setupBoxes() {

    for (int i = 0; i < demos.size(); i++) {
        demos[i].color = ofFloatColor(ofRandom(1.0),
            ofRandom(1.0),
            ofRandom(1.0));

        demos[i].pos = ofVec3f(ofRandom(-8, 8), 0, ofRandom(-8, 8));

        demos[i].box = ofBoxPrimitive();
        demos[i].box.set(ofRandom(0.2, 0.8));
        demos[i].box.enableTextures();

        demos[i].floatPos.x = demos[i].pos.x;
        demos[i].floatPos.z = demos[i].pos.z;

        demos[i].bMouseOver = false;
        demos[i].bGazeOver = false;
    }
}
Beispiel #5
0
//--------------------------------------------------------------
void testApp::setup(){
	ofBackground(0);
	mode = 1;
	xA=0;
	yA=0;
	zA=0;
	xM=0;
	yM=0;
	zM=0;
	receiver.setup(2234);
	box = ofBoxPrimitive(2,4,0.2f);
	cam.setPosition(ofVec3f(0,0,5));
	light.enable();
	light.setDirectional();
	light.setPosition(0,0,5);
	ofFloatColor color(1.0f,0.7f,0.3f,1.0f);
	light.setAmbientColor(color);
	light.setSpecularColor(color);
	light.setDiffuseColor(color);
}
Beispiel #6
0
//--------------------------------------------------------------
void ofApp::draw3d(){
    //ofEnableDepthTest();

    points.clear();
    sizes.clear();
    points2.clear();
    sizes2.clear();

    
    //カメラ設定
    int cx,cy;
    cameraCount++;
    cameraMoving = ofVec3f(0,objRoad.count*objRoad.speed,0);
    camera2.setPosition(camera.getPosition()+cameraMoving);
    camera2.lookAt(cameraMoving,ofVec3f(0,0,1));
    
    switch (cameraId) {
        case 1:
            camera.setPosition(0, -1000, 400);
            camera.lookAt(ofVec3f(0,0,0),ofVec3f(0,0,1));
            break;
        case 2:
            camera.setPosition(800, -800, 300);
            //camera.setPosition(1500, -3000, 800);
            camera.lookAt(ofVec3f(0,0,0),ofVec3f(0,0,1));
            break;
        case 3:
            camera.setPosition(0, 1500, 500);
            camera.lookAt(ofVec3f(0,0,0),ofVec3f(0,0,1));
            break;
        case 4:
            cx = 1200*cos( cameraCount/200.0 );
            cy = 1200*sin( cameraCount/200.0 );
            camera.setPosition(cx, cy, 400);
            camera.lookAt(ofVec3f(0,0,0),ofVec3f(0,0,1));
            break;
        case 5:
            cx = -1200*cos( cameraCount/100.0 )*(cos(cameraCount/100.0)+2)/3;
            cy = 1200*sin( cameraCount/100.0 )*(cos(cameraCount/100.0)+2)/3;
            camera.setPosition(cx, cy, 400*(cos(cameraCount/100.0)+2)/3);
            camera.lookAt(ofVec3f(0,0,0),ofVec3f(0,0,1));
            break;
        default:
            break;
    }
    
    glDepthMask(GL_FALSE);//デプスバッファに書き込むのを禁止する
    
    ofEnableBlendMode(OF_BLENDMODE_ADD);//加算描画 this makes everything look glowy
    ofEnablePointSprites();
    
    
    //道路表示
    //shader2.begin();
    camera2.begin();
    ofVec4f bufpos,bufpos_1f;
    for(int i=objRoad.getIdxStart();i<objRoad.getIdxEnd();i++){
        bufpos = objRoad.getLeftPos(i);
        int roadwidth = objRoad.getRoadWidth(i);
        if(i==objRoad.getIdxStart()){
            continue;
        }
        //ofSetColor(rainbow[(i/10)%7][0],rainbow[(i/10)%7][1],rainbow[(i/10)%7][2],bufpos.w);
        ofSetColor(0,200,0,bufpos.w);
        ofBoxPrimitive buf_box;
        buf_box = ofBoxPrimitive(roadwidth, objRoad.width, 1);
        buf_box.setPosition(bufpos_1f.x, bufpos_1f.y+objRoad.width/2, bufpos.z);
        buf_box.draw();
        if(i%20==0){
            ofSetColor(255,0,0,255);
            ofSpherePrimitive a;
            a = ofSpherePrimitive(10, 20);
            a.setPosition(bufpos_1f.x, bufpos_1f.y, 0);
            a.draw();
            ofBoxPrimitive b;
            b = ofBoxPrimitive(roadwidth, 3, 20);
            b.setPosition(bufpos_1f.x, bufpos_1f.y, bufpos.z);
            b.draw();
        }
        bufpos_1f = bufpos;
    }
    camera2.end();
    //shader2.end();
    
    ofDisablePointSprites();
    ofDisableBlendMode();
    
    glDepthMask(GL_TRUE);
    
    //観客描画
    //ofEnableBlendMode(OF_BLENDMODE_ADD);//加算描画 this makes everything look glowy
    if(bDraw3d){
        int buf_x,buf_y,buf_z,buf_speed;
        for (int i = 0; i < ObjHumans.size(); i++) {
            buf_x = ObjHumans[i].position.x;
            buf_x = ((buf_x - 512 - objFrameOffsetx)*scalex)>>5; //32等倍
            buf_y = ObjHumans[i].position.y;
            buf_y = ((buf_y - 512 - objFrameOffsety)*scaley)>>5; //32等倍
            buf_z = (ObjHumans[i].positionz * scalez) >>5;//32等倍
            buf_speed = (int)(ObjHumans[i].speed*humanscale/50+humansizeoffset);
            if(ObjHumans[i].humanStd <= ObjHumans[i].objMissThr){

                if(ObjHumans[i].humanStd>=0){
                    addPoint(buf_x, buf_y, buf_z,buf_speed*2);
                }
                addPoint(buf_x, buf_y, buf_z,buf_speed*2);
                boxScale.push_back(buf_speed);
            }else{
                addPoint2(buf_x, buf_y, buf_z,buf_speed*2);
                boxScale2.push_back(buf_speed);
            }
        }
    }
    glDepthMask(GL_FALSE);

    
    
    
    
    // this makes everything look glowy :)
    ofEnablePointSprites();
    //ofEnableBlendMode(OF_BLENDMODE_ADD);
    ofEnableAlphaBlending();
    
    shader.begin();
    camera.begin();
    
    glPointSize(20);
    
    //観客ノード
    texture.bind();
    //texture2.bind();
    //ofSetColor(255);
    ofSetColor(0, 100, 255);
    int total = (int)points.size();
    vbo.setVertexData(&points[0], total, GL_STATIC_DRAW);
    vbo.setNormalData(&sizes[0], total, GL_STATIC_DRAW);
    vbo.draw(GL_POINTS, 0, (int)points.size());
    
    ofSetColor(255, 100, 90);
    total = (int)points2.size();
    vbo.setVertexData(&points2[0], total, GL_STATIC_DRAW);
    vbo.setNormalData(&sizes2[0], total, GL_STATIC_DRAW);
    vbo.draw(GL_POINTS, 0,(int)points2.size());
    texture.unbind();
    //texture2.unbind();

    //ライブハウスグリッド描画
    objFrame.draw();

    
    
    camera.end();
    shader.end();
    
    ofDisablePointSprites();
    //ofDisableBlendMode();
    ofDisableAlphaBlending();
    
    //基準座標
    camera2.begin();
    ofSetLineWidth(1);
    
    /*ofSetColor(255,0,0);
    ofLine(ofVec3f(0,0,0), ofVec3f(300,0,0));
    ofSetColor(0,255,0);
    ofLine(ofVec3f(0,0,0), ofVec3f(0,300,0));
    ofSetColor(0,0,255);
    ofLine(ofVec3f(0,0,0), ofVec3f(0,0,300));*/
    
    //ここから松
    ofEnableAlphaBlending();
    // bind the shader so that wee can change the
    // size of the points via the vert shader
    billboardShader.begin();
    ofEnablePointSprites(); // not needed for GL3/4
    texture_.getTextureReference().bind();
    billboards.draw();
    texture_.getTextureReference().unbind();
    ofDisablePointSprites(); // not needed for GL3/4
    billboardShader.end();
    ofDisableAlphaBlending();
    //ここまで松
    
    camera2.end();
    
    /*float boxSize = 100;
    ofFill();
    ofSetColor(255);
    ofDrawBox(boxSize);
    ofNoFill();*/
    //ba.drawNormals(1000);
    //texture3.getTextureReference().unbind();
    ofEnableAlphaBlending();
    
    camera2.begin();
    objTorii.draw(texTorii);
    for(int i =0 ;i< objClouds.size();i++){
        if(objClouds[i].visible(cameraMoving.y)){
            objClouds[i].draw(texCloud);
        }
    }


    
    for(int i =0 ;i< objLibs.size();i++){
        if(objLibs[i].visible(cameraMoving.y)){
            objLibs[i].draw(texLibs[objLibs[i].texidi*TEXLIBNUM+objLibs[i].texidj]);
        }else{
            if(objLibs[i].killmyself(cameraMoving.y)){
                objLibs.erase(objLibs.begin()+i);
            }
        }
    }
    
    camera2.end();

    //ここから応援コメント
    camera.begin();
    ofSetColor(255,255,255);
    
    for (int i = 0; i < 3 ;i++){
        for(int j = 0;j < 2; j++){
            for(int k =0; k < 2; k++){
                if(commentdraw[i][j][k]){
                    objTexts[i*4+j*2+k].draw(texTexts[i*4+j*2+k]);
                }
            }
        }
    }
    camera.end();
    ofDisableAlphaBlending();

    
    glDepthMask(GL_TRUE);
}