void setup() { size(1024, 768); background(0); setFrameRate(60); // Setup lighting ambientLight(30); light.init(200, 200, 200, 0, 3, 0); // Uncomment this line to see the position of the light light.drawDebug(true); // Init 3d object's properties box.init(50, 25, 75); box.setPosition(width/2.0f, height/2.0f); sphere1.init(30); sphere2.init(60); sphere3.init(100); // Now, we make the spheres children of the box's (scene node) box.addChild( sphere1 ); box.addChild( sphere2 ); box.addChild( sphere3 ); // Translate the sphere (relative to its parent, the box) // This way, when we rotate the box (parent object), the spheres will orbitate around it sphere1.setPosition( 2, 0, 0 ); sphere2.setPosition( 5, 0, 0 ); sphere3.setPosition( 7, 0, 0 ); // Add the second light as child of one of the spheres sphere1.addChild( light ); }
void setup() { size(1024, 768); background(0); enableShadows( STENCIL_MODULATIVE ); applyCoordinateSystemTransform(OPENGL3D); // Setup lighting ambientLight(10); light.init(255, 255, 255, width/2 + 100, height/2 + 100, 100); // Uncomment this line to see the position of the light light.drawDebug(); // Init 3d object's properties box.init(10, 4, 14); box.setPosition(width/2.0f, 100); sphere1.init(6); sphere2.init(12); sphere3.init(20); // Now, we make the spheres children of the box's (scene node) box.addChild( sphere1 ); box.addChild( sphere2 ); box.addChild( sphere3 ); // Translate the sphere (relative to its parent, the box) // This way, when we rotate the box (parent object), the spheres will orbitate around it sphere1.setPosition( 2, -2, 0 ); sphere2.setPosition( 5, -7, 0 ); sphere3.setPosition( 7, -12, 0 ); // Ground ground.init(5000, 25, 5000 ); ground.setPosition( width/2, -200 ); // Camera control enableDefault3DCameraControl(); }
void setup() { // start AudioInputphone mic.startCapturing(); // setup plane and sphere plane.init( 100000 ); plane.setPosition( width/2, height/2 + 500, 0 ); sphere.init( 100 ); sphere.setPosition( width/2, height/2, 0 ); // setup light ambientLight( 20, 20, 20 ); light.init( 0, 0, 0, width/2, height/2, 200 ); }
JNIEXPORT void JNICALL Java_org_nzdis_example03_GLESView_mySurfaceChanged (JNIEnv *env, jclass c, jint width, jint height) { glViewport(0, 0, width, height); aspect = (float)width / (float)height; // Generate a perspective matrix with a 60 degree FOV esMatrixLoadIdentity(&perspective); //LOGI("%f %d %d", aspect, width, height); esPerspective(&perspective, 60.0f, aspect, 1.0f, 30.0f); esTranslate(&perspective, 0.0f, 0.0f, -5.0f); //esRotate(&perspective, 45.0f, 1.0f, 0.0f, 0.0f); //esRotate(&perspective, -5.0f, 0.0f, 1.0f, 0.0f); origin.init(width, height); sphere.init(width, height); terrain.init(width, height); }
void setup() { size( 1024, 768 ); // load sound sound.load( "loop.ogg" ); sound.play( true ); // setup plane and sphere plane.init( 100000 ); plane.setPosition( width/2, height/2 + 200, 0 ); sphere.init( 100 ); sphere.setPosition( width/2, height/2, 0 ); // setup light ambientLight( 20, 20, 20 ); light.init( 0, 0, 0, width/2, height/2, 200 ); }
void CubeMapApp::initApp() { D3DApp::initApp(); fx::InitAll(md3dDevice); InputLayout::InitAll(md3dDevice); GetTextureMgr().init(md3dDevice); mTech = fx::CubeMapFX->GetTechniqueByName("CubeMapTech"); mfxLightVar = fx::CubeMapFX->GetVariableByName("gLight"); mfxEyePosVar = fx::CubeMapFX->GetVariableByName("gEyePosW"); mfxWVPVar = fx::CubeMapFX->GetVariableByName("gWVP")->AsMatrix(); mfxWorldVar = fx::CubeMapFX->GetVariableByName("gWorld")->AsMatrix(); mfxTexMtxVar = fx::CubeMapFX->GetVariableByName("gTexMtx")->AsMatrix(); mfxReflectMtrlVar = fx::CubeMapFX->GetVariableByName("gReflectMtrl")->AsVector(); mfxCubeMapEnabledVar = fx::CubeMapFX->GetVariableByName("gCubeMapEnabled")->AsScalar(); mfxDiffuseMapVar = fx::CubeMapFX->GetVariableByName("gDiffuseMap")->AsShaderResource(); mfxSpecMapVar = fx::CubeMapFX->GetVariableByName("gSpecMap")->AsShaderResource(); mfxCubeMapVar = fx::CubeMapFX->GetVariableByName("gCubeMap")->AsShaderResource(); //mClearColor = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); GetCamera().position() = D3DXVECTOR3(0.0f, 1.8f, -10.0f); mBallMapRV = GetTextureMgr().createTex(L"blackdiffuse.dds"); //mSpecMapRV = GetTextureMgr().createTex(L"spec.dds"); mDefaultSpecMapRV = GetTextureMgr().createTex(L"defaultspec.dds"); mEnvMapRV = GetTextureMgr().createCubeTex(L"grassenvmap1024.dds"); mFloor.init(md3dDevice, 41, 21, 1.0f); mBase.init(md3dDevice, 2.0f); mBall.init(md3dDevice, 0.5f, 30, 30); mColumn.init(md3dDevice, 0.25f, 1.0f, 3.0f, 30, 30); mSky.init(md3dDevice, mEnvMapRV, 5000.0f); mParallelLight.dir = D3DXVECTOR3(0.57735f, -0.57735f, 0.57735f); mParallelLight.ambient = D3DXCOLOR(0.3f, 0.3f, 0.3f, 1.0f); mParallelLight.diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mParallelLight.specular = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f); }
RigidBody* Sphere::Create(int columns, int rows) { Sphere* p = new Sphere(); // top vertex p->vertices.push_back(Vector3(0.0, 1.0, 0.0)); real step_row_angle = R_PI / rows; real step_col_angle = 2 * R_PI / columns; // vertices real cur_row_angle = step_row_angle; for (int i = 0; i < rows - 1; i++) { real cur_row_sin = sin(cur_row_angle); real cur_row_cos = cos(cur_row_angle); real cur_col_angle = 0.0; for (int j = 0; j <= columns; j++) { real cur_col_sin = sin(cur_col_angle); real cur_col_cos = cos(cur_col_angle); p->vertices.push_back(Vector3( cur_col_sin * cur_row_sin, cur_row_cos, cur_col_cos * cur_row_sin )); cur_col_angle += step_col_angle; } cur_row_angle += step_row_angle; } // bottom vertex p->vertices.push_back(Vector3(0.0, -1.0, 0.0)); // sets up tringtles for (int i = 0; i < columns; i++) { p->indices.push_back(0); p->indices.push_back(i + 1); p->indices.push_back(i + 2); } int row_cur = 1; int row_next = row_cur + (columns + 1); for (int i = 0; i < rows - 2; i++) { for (int j = 0; j < columns; j++) { p->indices.push_back(row_cur + j); p->indices.push_back(row_next + j); p->indices.push_back(row_next + j + 1); } for (int j = 0; j < columns; j++) { p->indices.push_back(row_cur + j); p->indices.push_back(row_cur + j + 1); p->indices.push_back(row_next + j + 1); } row_cur = row_next; row_next += (columns + 1); } for (int i = 0; i < columns; i++) { p->indices.push_back(row_cur + i); p->indices.push_back(row_cur + i + 1); p->indices.push_back(row_next); } p->init(); return p; }
void GLApplication::initialize() { if (!windowManager || !windowManager->initialize(800, 700, "Window GLFW", false)) { this->destroy(); exit(-1); } glViewport(0, 0, WindowManager::screenWidth, WindowManager::screenHeight); glClearColor(0.2f, 0.2f, 0.2f, 0.0f); glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); shader.initialize("Shaders/lightingSpecularMap.vs", "Shaders/lightingSpecularMap.fs"); sphere.init(); sphere.load(); textureDifuse.load(); textureSpecular.load(); alutInit(0, NULL); alListenerfv(AL_POSITION, listenerPos); alListenerfv(AL_VELOCITY, listenerVel); alListenerfv(AL_ORIENTATION, listenerOri); alGetError(); // clear any error messages if (alGetError() != AL_NO_ERROR) { printf("- Error creating buffers !!\n"); exit(1); } else { printf("init() - No errors yet."); } // Generate buffers, or else no sound will happen! alGenBuffers(NUM_BUFFERS, buffer); buffer[0] = alutCreateBufferFromFile("sounds/lawyer1.wav"); //buffer[0] = alutCreateBufferHelloWorld(); alGetError(); /* clear error */ alGenSources(NUM_SOURCES, source); if (alGetError() != AL_NO_ERROR) { printf("- Error creating sources !!\n"); exit(2); } else { printf("init - no errors after alGenSources\n"); } alSourcef(source[0], AL_PITCH, 1.0f); alSourcef(source[0], AL_GAIN, 1.0f); alSourcefv(source[0], AL_POSITION, source0Pos); alSourcefv(source[0], AL_VELOCITY, source0Vel); alSourcei(source[0], AL_BUFFER, buffer[0]); alSourcei(source[0], AL_LOOPING, AL_TRUE); alSourcef(source[0], AL_MAX_DISTANCE, 1200); objModel.loadModel("objects/nanosuit/nanosuit.obj"); /*alSourcef(source[1], AL_PITCH, 1.0f); alSourcef(source[1], AL_GAIN, 1.0f); alSourcefv(source[1], AL_POSITION, source1Pos); alSourcefv(source[1], AL_VELOCITY, source1Vel); alSourcei(source[1], AL_BUFFER, buffer[1]); alSourcei(source[1], AL_LOOPING, AL_TRUE); alSourcef(source[2], AL_PITCH, 1.0f); alSourcef(source[2], AL_GAIN, 1.0f); alSourcefv(source[2], AL_POSITION, source2Pos); alSourcefv(source[2], AL_VELOCITY, source2Vel); alSourcei(source[2], AL_BUFFER, buffer[2]); alSourcei(source[2], AL_LOOPING, AL_TRUE);*/ }