/// <summary> /// カメラ、ライト、フォグ、画質の設定を初期設定に戻します。 /// </summary> /// <returns> /// なし /// </returns> inline void ResetScene() { SetAmbientLight(ColorF(0.1)); SetAmbientLightForward(ColorF(0.1)); SetLight(0, Light::Default()); for (uint32 i = 1; i <= MaxLightIndex; ++i) { SetLight(i, Light::None()); } SetLightForward(0, Light::Default()); for (uint32 i = 1; i <= MaxLightIndexForward; ++i) { SetLightForward(i, Light::None()); } SetFog(Fog::None()); SetFogForward(Fog::None()); SetCamera(Camera()); SetAntiAliasing(AntiAliasing::Default); SetLightBufferQuality(100); }
void Render(HWND hWnd) { g_pDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); g_pDevice->BeginScene(); SetMatrix(); if (::GetAsyncKeyState(0x31) & 0x8000f) g_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); if (::GetAsyncKeyState(0x32) & 0x8000f) g_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); if (::GetAsyncKeyState(0x51) & 0x8000f) SetLight(g_pDevice, 1); if (::GetAsyncKeyState(0x57) & 0x8000f) SetLight(g_pDevice, 2); if (::GetAsyncKeyState(0x45) & 0x8000f) SetLight(g_pDevice, 3); D3DXMatrixTranslation(&g_WorldMatrix[0], -3.0f, -3.0f, 0.0f); g_WorldMatrix[0] = g_WorldMatrix[0] * R; g_pDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[0]); g_pTeapot->DrawSubset(0); D3DXMatrixTranslation(&g_WorldMatrix[1], 3.0f, -3.0f, 0.0f); g_WorldMatrix[1] = g_WorldMatrix[1] * R; g_pDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[1]); g_pCube->DrawSubset(0); D3DXMatrixTranslation(&g_WorldMatrix[2], 3.0f, 3.0f, 0.0f); g_WorldMatrix[2] = g_WorldMatrix[2] * R; g_pDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[2]); g_pTorus->DrawSubset(0); D3DXMatrixTranslation(&g_WorldMatrix[3], -3.0f, 3.0f, 0.0f); g_WorldMatrix[3] = g_WorldMatrix[3] * R; g_pDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[3]); g_pSphere->DrawSubset(0); RECT rect; GetClientRect(hWnd, &rect); int count = _stprintf_s(g_strFPS, 20, TEXT("FPS : %0.3f"), GetFPS()); g_pFont->DrawText(NULL, g_strFPS, count, &rect, DT_TOP | DT_RIGHT, D3DCOLOR_XRGB(255, 239, 136)); g_pDevice->EndScene(); g_pDevice->Present(NULL, NULL, NULL, NULL); }
void DrawObject() { char *str1="Score "; char *str2="GameOver"; char buf[16]; sprintf(buf,"%d",score); double gl_para[16]; argDrawMode3D(); argDraw3dCamera(0, 0); argConvGlpara(patt_trans,gl_para); glMatrixMode(GL_MODELVIEW); glLoadMatrixd(gl_para); SetLight(); glClear(GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glTranslatef(-20.0f,0.0f,20.0f); // glRotatef(0.0,1.0,0.0,0.0); if(GameOver==false){ FontRender(str1,0,0); FontRender(buf,60,0); WallRender(); p.Render(Box); f.Render(Box); } else{ FontRender(str2,0,0); } glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); }
HRESULT InitObject(void) { srand(unsigned(time(NULL))); if (FAILED(D3DXCreateFont(g_pDevice, 30, 0, 0, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, 0, TEXT("宋体"), &g_pFont))) { return E_FAIL; } if (FAILED(D3DXCreateTeapot(g_pDevice, &g_pTeapot, NULL))) return E_FAIL; if (FAILED(D3DXCreateBox(g_pDevice, 2.0f, 2.0f, 2.0f, &g_pCube, NULL))) return E_FAIL; if (FAILED(D3DXCreateSphere(g_pDevice, 1.5f, 25, 25, &g_pSphere, NULL))) return E_FAIL; if (FAILED(D3DXCreateTorus(g_pDevice, 0.5f, 1.2f, 25, 25, &g_pTorus, NULL))) return E_FAIL; //设置材质 D3DMATERIAL9 material; ZeroMemory(&material, sizeof(D3DMATERIAL9)); material.Ambient = D3DXCOLOR(0.5f, 0.5f, 0.7f, 1.0f); //环境光 material.Diffuse = D3DXCOLOR(0.6f, 0.6f, 0.6f, 1.0f); //漫反射 material.Specular = D3DXCOLOR(0.3f, 0.3f, 0.3f, 0.3f); //镜面反射 material.Emissive = D3DXCOLOR(0.3f, 0.0f, 0.1f, 1.0f); g_pDevice->SetMaterial(&material); //设置光照 SetLight(g_pDevice, 1); g_pDevice->SetRenderState(D3DRS_LIGHTING, TRUE); g_pDevice->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE); g_pDevice->SetRenderState(D3DRS_SPECULARENABLE, TRUE); //开启背面消隐 g_pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); return S_OK; }
SceneA::SceneA() { SetWireframe(true); SetLight(false); SetTexture(false); s = MakeObject(SPHERE); }
bool CSector::r_LoadVal( CScript &s ) { ADDTOCALLSTACK("CSector::r_LoadVal"); EXC_TRY("LoadVal"); switch ( FindTableSorted( s.GetKey(), sm_szLoadKeys, CountOf( sm_szLoadKeys )-1 )) { case SC_COLDCHANCE: SetWeatherChance( false, s.HasArgs() ? s.GetArgVal() : -1 ); return true; case SC_FLAGS: m_dwFlags = s.GetArgVal(); return true; case SC_LIGHT: if ( g_Cfg.m_bAllowLightOverride ) SetLight( (s.HasArgs()) ? s.GetArgVal() : -1 ); else g_Log.EventWarn("AllowLightOverride flag is disabled in sphere.ini, so sector's LIGHT property wasn't set\n"); return true; case SC_RAINCHANCE: SetWeatherChance( true, s.HasArgs() ? s.GetArgVal() : -1 ); return true; case SC_SEASON: SetSeason(s.HasArgs() ? static_cast<SEASON_TYPE>(s.GetArgVal()) : SEASON_Summer); return (true); case SC_WEATHER: SetWeather(s.HasArgs() ? static_cast<WEATHER_TYPE>(s.GetArgVal()) : WEATHER_DRY); return true; } EXC_CATCH; EXC_DEBUG_START; EXC_ADD_SCRIPT; EXC_DEBUG_END; return false; }
gint redrawGL2PS() { GLdouble m[4][4]; GtkWidget *widget = GLArea; if(!GTK_IS_WIDGET(widget)) return TRUE; if(!GTK_WIDGET_REALIZED(widget)) return TRUE; glMatrixMode(GL_PROJECTION); glLoadIdentity(); addFog(); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); set_background_color(); mYPerspective(45,(GLdouble)widget->allocation.width/(GLdouble)widget->allocation.height,1,100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if(optcol==-1) drawChecker(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if(perspective) mYPerspective(Zoom,(GLdouble)widget->allocation.width/(GLdouble)widget->allocation.height,zNear,zFar); else { gdouble fw = (GLdouble)widget->allocation.width/(GLdouble)widget->allocation.height; gdouble fh = 1.0; glOrtho(-fw,fw,-fh,fh,-1,1); } glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if(perspective) glTranslatef(Trans[0],Trans[1],Trans[2]); else { glTranslatef(Trans[0]/10,Trans[1]/10,0); glScalef(1/Zoom*2,1/Zoom*2,1/Zoom*2); } SetLight(); build_rotmatrix(m,Quat); glMultMatrixd(&m[0][0]); redrawGeometry(); redrawSurfaces(); redrawCell(); redrawContours(); redrawPlanesMapped(); if(get_show_symbols() || get_show_numbers() || get_show_charges()) showLabelSymbolsNumbersCharges(); if(get_show_dipole()) showLabelDipole(); if(get_show_distances()) showLabelDistances(); if(get_show_axes()) showLabelAxes(); if(get_show_axes()) showLabelPrincipalAxes(); showLabelTitle(GLArea->allocation.width,GLArea->allocation.height); /* Swap backbuffer to front */ glFlush(); return TRUE; }
void cMainGame::Setup() { // cObjLoader l; // m_pGroupHead = l.Load("./obj/Map.obj"); cAseLoader loader; m_pRoot = loader.Load("woman/woman_01_all.ASE"); //폰트 생성 D3DXFONT_DESC fd; ZeroMemory(&fd,sizeof(D3DXFONT_DESC)); fd.Height = 45; fd.Width = 28; fd.Weight = FW_MEDIUM; fd.Italic = false; fd.CharSet = DEFAULT_CHARSET; fd.OutputPrecision = OUT_DEFAULT_PRECIS; fd.PitchAndFamily = FF_DONTCARE; //strcpy_s(fd.FaceName, "궁서체"); //글꼴 스타일 AddFontResource("umberto.ttf"); strcpy(fd.FaceName, "umberto"); D3DXCreateFontIndirect(g_pD3DDevice, &fd, &m_pFont); m_pCamera = new cCamera; m_pCamera->Setup(NULL); m_pGrid = new cGrid; m_pGrid->Setup(15, 1.0f); SetLight(); }
void DrawScene(Mtx view) { Mtx model,modelview; // Various matrices guVector axis; // Axis to rotate on // BUG: Light ignores underlying polygon colors. SetLight(view); // Setup the light for (yloop = 1; yloop < 6; yloop++) { // Loop through the y plane for (xloop = 0; xloop < yloop; xloop++) { // Loop through the x plane // Position the cubes on the screen guMtxIdentity(model); axis.x = 1.0f; axis.y = 0; axis.z = 0; guMtxRotAxisDeg(model,&axis,(45.0f-(2.0f*(float)yloop)+xrot)); // Tilt the cubes up and down axis.x = 0; axis.y = 1.0f; guMtxRotAxisDeg(model,&axis,(45.0f+yrot)); // Spin cubes left and right guMtxTransApply(model,model,(1.4f+((float)xloop*2.8f)-((float)yloop*1.4f)),(((6.0f-(float)yloop)*2.2f)-7.0f),-20.0f); guMtxConcat(model,view,modelview); GX_LoadPosMtxImm(modelview, GX_PNMTX0); GX_CallDispList(boxList[yloop-1],boxSize[yloop-1]); // Draw the box } } }
void cMainGame::Setup() { //폰트 생성 D3DXFONT_DESC fd; ZeroMemory(&fd,sizeof(D3DXFONT_DESC)); fd.Height = 45; fd.Width = 28; fd.Weight = FW_MEDIUM; fd.Italic = false; fd.CharSet = DEFAULT_CHARSET; fd.OutputPrecision = OUT_DEFAULT_PRECIS; fd.PitchAndFamily = FF_DONTCARE; //strcpy_s(fd.FaceName, "궁서체"); //글꼴 스타일 AddFontResource("umberto.ttf"); strcpy(fd.FaceName, "umberto"); D3DXCreateFontIndirect(g_pD3DDevice, &fd, &m_pFont); m_pCamera = new cCamera; m_pCamera->Setup(NULL); m_pGrid = new cGrid; m_pGrid->Setup(15, 1.0f); LPDIRECT3DTEXTURE9 pTexture = NULL; D3DXCreateTextureFromFile(g_pD3DDevice, "Batman.png", &pTexture); cBody* pBody = new cBody; pBody->Setup(); pBody->SetTexture(pTexture); m_pRoot = pBody; cHead* pHead = new cHead; pHead->Setup(); pHead->SetTexture(pTexture); m_pRoot->AddChild(pHead); cLeftArm* pLeftArm = new cLeftArm; pLeftArm->Setup(); pLeftArm->SetTexture(pTexture); m_pRoot->AddChild(pLeftArm); cRightArm* pRightArm = new cRightArm; pRightArm->Setup(); pRightArm->SetTexture(pTexture); m_pRoot->AddChild(pRightArm); cLeftLeg* pLeftLeg = new cLeftLeg; pLeftLeg->Setup(); pLeftLeg->SetTexture(pTexture); m_pRoot->AddChild(pLeftLeg); cRightLeg* pRightLeg = new cRightLeg; pRightLeg->Setup(); pRightLeg->SetTexture(pTexture); m_pRoot->AddChild(pRightLeg); SAFE_RELEASE(pTexture); SetLight(); }
std::unique_ptr<n0::NodeComp> CompLight::Clone(const n0::SceneNode& node) const { auto comp = std::make_unique<CompLight>(); if (!m_light) { return comp; } auto type = m_light->get_type(); auto ctor = type.get_constructor(); auto var = ctor.invoke(); auto dst = var.get_value<std::shared_ptr<pt3::Light>>(); comp->SetLight(dst); for (auto& prop : type.get_properties()) { if (prop.get_metadata(js::RTTR::NoSerializeTag())) { continue; } rttr::variant prop_value = prop.get_value(m_light); if (!prop_value) { continue; } prop.set_value(dst, prop_value); } return comp; }
/*************************************************************//** * * @brief 非公開の描画処理を行う * @param なし * @return なし * ****************************************************************/ void C_SmallBeamOption::DoDraw() { pGlslObject_->BeginWithUnifomBuffer(pUniformBuffer_->GetHandle(), uniformBlockIndex_); pGlslObject_->BindActiveSubroutine(cameraSubroutineIndex_, Shader::GLSL::Type::s_VERTEX); upRigidBody_->GetTransform().getOpenGLMatrix(modelMatrix_.a_); modelMatrix_ = modelMatrix_ * Matrix4x4::s_CreateScaling(Vector3(radius_)); pGlslObject_->SetUniformMatrix4x4("u_modelMatrix", modelMatrix_); // ライトとマテリアルを設定 SetLight(pMainLight_); SetMaterial(pNowMaterial_); auto pOpenGlManager = OpenGL::C_OpenGlManager::s_GetInstance(); auto pTextureManager = Texture::C_TextureManager::s_GetInstance(); // アクティブなテクスチャユニットを設定し、テクスチャをバインド pTextureManager->SetActiveUnit(0); pModelTextureData_ = Texture::C_TextureManager::s_GetInstance()->GetTextureData(Path::Texture::s_pSMALL_BEAM_OPTION).get(); pTextureManager->Bind(Texture::Type::s_2D, pModelTextureData_->handle_); pOpenGlManager->DrawPrimitiveWithIndices(OpenGL::Primitive::s_TRIANGLE, pModelData_->GetVertexArrayObjectHandle(), pModelData_->GetIndexBufferObjectHandle(), OpenGL::DataType::s_UNSIGNED_SHORT, static_cast<int32_t>(pModelData_->GetIndexCount())); pTextureManager->Unbind(Texture::Type::s_2D); pGlslObject_->End(); }
void PointLight::DrawGlobalLights(X3DDrawContext* pDC) { if (getGlobal() && getOn()) { SetLight(pDC); } }
void PointLight::PreDraw(X3DDrawContext* pDC) { if (!getGlobal() && getOn()) { SetLight(pDC); } }
void cMainGame::Setup() { // m_pMap = new cHeightMap; // m_pMap->Setup("HeightMapData", "HeightMap.raw", "terrain.jpg"); m_vecVertex.resize(1000); for (int i = 0; i < m_vecVertex.size(); ++i) { m_vecVertex[i].p = D3DXVECTOR3( (rand() % 1000 - 500) / 10.0f, (rand() % 1000 - 500) / 10.0f, (rand() % 1000 - 500) / 10.0f); m_vecVertex[i].c = D3DCOLOR_ARGB(255, 180, 70, 20); } // 포인트를 확대 축소 할 수 있게 해줌 g_pD3DDevice->SetRenderState(D3DRS_POINTSCALEENABLE, true); // 포인트 사이즈 설정 g_pD3DDevice->SetRenderState(D3DRS_POINTSIZE, FtoDw(10.0f)); // 포인트 스케일링 Factor값 설정 g_pD3DDevice->SetRenderState(D3DRS_POINTSCALE_A, FtoDw(0.0f)); g_pD3DDevice->SetRenderState(D3DRS_POINTSCALE_B, FtoDw(0.0f)); g_pD3DDevice->SetRenderState(D3DRS_POINTSCALE_C, FtoDw(1.0f)); // 포인트 최소 크기 g_pD3DDevice->SetRenderState(D3DRS_POINTSIZE_MIN, FtoDw(0.0f)); // 포인트 최대 크기 g_pD3DDevice->SetRenderState(D3DRS_POINTSIZE_MAX, FtoDw(100.0f)); // 포인트에 텍스쳐를 입힐 수 있게 해줌 g_pD3DDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, true); // 알파블랜딩 방식 결정. g_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); g_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); // 텍스쳐 알파 옵션 설정 g_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); g_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); g_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); cSkinnedMesh* pSkinnedMesh = new cSkinnedMesh("Zealot/", "zealot.X"); pSkinnedMesh->SetAnimationIndex(3); m_pCharacter = pSkinnedMesh; m_pGrid = new cGrid; m_pGrid->Setup(); m_pCamera = new cCamera; m_pCamera->Setup(); m_pCamera->SetTarget(&m_pCharacter->GetPosition()); SetLight(); }
void loop(){ RS485(); SetLight(); actualChannel++; if (actualChannel>4) actualChannel=0; }
void cMainGame::Setup() { m_pSkinnedMesh = new cSkinnedMesh; m_pSkinnedMesh->Setup("Zealot", "zealot.X"); m_pFrustum = new cFrustum; m_pFrustum->Setup(); // 디버깅용 바운딩 스피어 생성. D3DXCreateSphere(g_pD3DDevice, 1.f, 100, 100, &m_pSphere, NULL); for (int i = 0; i < 1000; ++i) { float x = rand() % 4000 / 100.0f - 20; float y = rand() % 4000 / 100.0f - 20; float z = rand() % 4000 / 100.0f - 20; m_vecSpherePosition.push_back(D3DXVECTOR3(x, y, z)); } // cAseLoader loader; // m_pRoot = loader.Load("woman/woman_01_all.ASE"); ZeroMemory(&m_stWhiteMtl, sizeof(D3DMATERIAL9)); m_stWhiteMtl.Ambient = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f); m_stWhiteMtl.Diffuse = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f); m_stWhiteMtl.Specular = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f); ZeroMemory(&m_stRedMtl, sizeof(D3DMATERIAL9)); m_stRedMtl.Ambient = D3DXCOLOR(0.8f, 0.0f, 0.0f, 1.0f); m_stRedMtl.Diffuse = D3DXCOLOR(0.8f, 0.0f, 0.0f, 1.0f); m_stRedMtl.Specular = D3DXCOLOR(0.8f, 0.0f, 0.0f, 1.0f); //폰트 생성 D3DXFONT_DESC fd; ZeroMemory(&fd,sizeof(D3DXFONT_DESC)); fd.Height = 45; fd.Width = 28; fd.Weight = FW_MEDIUM; fd.Italic = false; fd.CharSet = DEFAULT_CHARSET; fd.OutputPrecision = OUT_DEFAULT_PRECIS; fd.PitchAndFamily = FF_DONTCARE; //strcpy_s(fd.FaceName, "궁서체"); //글꼴 스타일 AddFontResource("umberto.ttf"); strcpy(fd.FaceName, "umberto"); D3DXCreateFontIndirect(g_pD3DDevice, &fd, &m_pFont); m_pCamera = new cCamera; m_pCamera->Setup(NULL); m_pGrid = new cGrid; m_pGrid->Setup(15, 1.0f); SetLight(); }
CBaseSky::CBaseSky() : skyLight(NULL) , dynamicSky(false) , cloudDensity(0.0f) , wireframe(false) , fogStart(0.0f) { SetLight(configHandler->Get("DynamicSun", 1) != 0); }
bool CSector::r_Verb( CScript & s, CTextConsole * pSrc ) { ADDTOCALLSTACK("CSector::r_Verb"); EXC_TRY("Verb"); ASSERT(pSrc); int index = FindTableSorted( s.GetKey(), sm_szVerbKeys, COUNTOF(sm_szVerbKeys)-1 ); switch (index) { case SEV_ALLCHARS: // "ALLCHARS" v_AllChars( s, pSrc ); break; case SEV_ALLCHARSIDLE: // "ALLCHARSIDLE" v_AllCharsIdle( s, pSrc ); break; case SEV_ALLCLIENTS: // "ALLCLIENTS" v_AllClients( s, pSrc ); break; case SEV_ALLITEMS: // "ALLITEMS" v_AllItems( s, pSrc ); break; case SEV_DRY: // "DRY" SetWeather( WEATHER_DRY ); break; case SEV_LIGHT: if ( g_Cfg.m_bAllowLightOverride ) SetLight( (s.HasArgs()) ? s.GetArgVal() : -1 ); break; case SEV_RAIN: SetWeather(s.HasArgs() ? static_cast<WEATHER_TYPE>(s.GetArgVal()) : WEATHER_RAIN); break; case SEV_RESPAWN: ( toupper( s.GetArgRaw()[0] ) == 'A' ) ? g_World.RespawnDeadNPCs() : RespawnDeadNPCs(); break; case SEV_RESTOCK: // x // set restock time of all vendors in World, set the respawn time of all spawns in World. ( toupper( s.GetArgRaw()[0] ) == 'A' ) ? g_World.Restock() : Restock(); break; case SEV_SEASON: SetSeason(static_cast<SEASON_TYPE>(s.GetArgVal())); break; case SEV_SNOW: SetWeather( WEATHER_SNOW ); break; default: return( CScriptObj::r_Verb( s, pSrc )); } return true; EXC_CATCH; EXC_DEBUG_START; EXC_ADD_SCRIPTSRC; EXC_DEBUG_END; return false; }
void CGraphics::SetLight( int id, D3DLIGHTTYPE type, float x, float y, float z, float range ) { SetLight( id, type, D3DXVECTOR3(x, y, z), D3DXVECTOR3(x, y, z), D3DXCOLOR(1, 1, 1, 1), range ); }
void FixedFunctions::ResetLights() { // Get default light settings Light sLight; GetDefaultLightSettings(sLight); // Reset lights for (uint32 i=0; i<m_sCapabilities.nMaxActiveLights; i++) { SetLightEnabled(i, false); SetLight(i, sLight); } }
std::map<unsigned int, SceneNode *> SceneManager::CreateNodes(const std::map<unsigned int, std::shared_ptr<EntityComponent> > components, SceneNode * pParent) { std::map<unsigned int, SceneNode *> nodes; for (auto component : components) { // creat this node std::shared_ptr<SceneComponent> scene_component = std::dynamic_pointer_cast<SceneComponent>(component.second); auto node = new SceneNode(pParent, scene_component); // add any necessary assets to the scene node // XXX this should also happen during update incase the model asset is changed anytime during // the scene components life cycle if (auto mesh_component = std::dynamic_pointer_cast<MeshComponent>(scene_component)) { auto path = mesh_component->GetMeshPath(); if (m_pAssets != nullptr) { auto asset = m_pAssets->GetAsset(path.c_str()); node->SetMesh(asset); } } // get the material path, load as an asset, and set it on the node. auto material_path = scene_component->GetMaterialPath(); std::shared_ptr<Material> pMaterial; if (m_pAssets != nullptr) { auto pAsset = m_pAssets->GetAsset(material_path.c_str()); // XXX TODO - pass asset through a material manager, so that only one // material every exists for a given material script. pMaterial = std::make_shared<Material>(pAsset); node->SetMaterial(pMaterial); } if (auto light_component = std::dynamic_pointer_cast<LightComponent>(scene_component)) { // create a light based on the light component and set it on the scene node Light * pLight = new Light(light_component); node->SetLight(pLight); } // do a depth first creation, so the list of child nodes can be passed into the scene node creation. std::map<unsigned int, SceneNode *> child_nodes = this->CreateNodes(component.second->GetComponents(), node); node->SetChildren(child_nodes); nodes[component.first] = node; } return nodes; }
ISky::ISky() : wireframe(false) , dynamicSky(false) , skyColor(mapInfo->atmosphere.skyColor) , sunColor(mapInfo->atmosphere.sunColor) , cloudColor(mapInfo->atmosphere.cloudColor) , fogColor(mapInfo->atmosphere.fogColor) , fogStart(mapInfo->atmosphere.fogStart) , fogEnd(mapInfo->atmosphere.fogEnd) , cloudDensity(mapInfo->atmosphere.cloudDensity) , skyLight(NULL) // , cloudDensity(0.0f) { SetLight(configHandler->GetBool("DynamicSun")); }
void RenderingWidget::initializeGL() { glClearColor(0.3, 0.3, 0.3, 0.0); glShadeModel(GL_SMOOTH); glEnable(GL_DOUBLEBUFFER); glEnable(GL_POINT_SMOOTH); glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); glEnable(GL_DEPTH_TEST); glClearDepth(1); SetLight(); }
void InitGL() { /* static GLdouble fog_color[4] = { 0.0, 0.0, 0.0, 0.0 };*/ /* remove back faces */ glEnable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE); /*glEnable(GL_COLOR_MATERIAL);*/ glEnable(GL_NORMALIZE); glShadeModel(GL_SMOOTH); SetLight(); init_labels_font(); glInitFonts(); /* glFogi(GL_FOG_MODE, GL_EXP); glFogf(GL_FOG_DENSITY, 0.15); glFogdv(GL_FOG_COLOR, fog_color); */ }
void GLManager::Init() { glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(m_ClientWidth, m_ClientHeight); glutInitWindowPosition(0, 0); glutCreateWindow(m_Title.c_str()); glutDisplayFunc(RenderScene); glutReshapeFunc(ChangeSize); glutIdleFunc(IdleFunc); glutMouseFunc(DoMouseClick); glutMotionFunc(DoMouseDrag); glutPassiveMotionFunc(DoMouseMove); m_Timer = new GameTimer(); m_Camera = new Camera(); SetupRC(); SetLight(); SetObject(); }
void RenderingWidget::paintGL() { glShadeModel(GL_SMOOTH); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //add guoxian glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // if (has_lighting_) { SetLight(); } else { glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); } glMatrixMode(GL_MODELVIEW); glLoadIdentity(); register vec eyepos = eye_distance_*eye_direction_; gluLookAt(eyepos[0], eyepos[1], eyepos[2], eye_goal_[0], eye_goal_[1], eye_goal_[2], 0.0, 1.0, 0.0); glPushMatrix(); glMultMatrixf(ptr_arcball_->GetBallMatrix()); Render(); glPopMatrix(); }
/*********************************************************** clear all nodes of the display tree typically called when changing map ***********************************************************/ void OsgHandler::ResetDisplayTree() { if(!_translNode) return; if(_lightNode) _translNode->removeChild(_lightNode); _lightNode = new osg::LightSource(); _translNode->addChild(_lightNode); // check if we use shadow or not if(_displayShadow) { osg::ref_ptr<osgShadow::ShadowedScene> shadowscene = new osgShadow::ShadowedScene(); shadowscene->setReceivesShadowTraversalMask(ReceivesShadowTraversalMask); shadowscene->setCastsShadowTraversalMask(CastsShadowTraversalMask); osg::ref_ptr<osgShadow::StandardShadowMap> shmap = new osgShadow::StandardShadowMap(); shadowscene->setShadowTechnique(shmap.get()); _sceneRootNode = shadowscene; } else { _sceneRootNode = new osg::Group(); } _lightNode->addChild(_sceneRootNode); //set default light LbaMainLightInfo Linf; Linf.UseLight = false; SetLight(Linf); }
//----------------------------------------------------------------------------- // Desc: 渲染图形 //----------------------------------------------------------------------------- VOID Render() { //清空后台缓冲区 g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(45, 50, 170), 1.0f, 0 ); //开始在后台缓冲区绘制图形 if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { //设置灯光和材质 SetLight(); //在后台缓冲区绘制图形 g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2*50-2 ); //结束在后台缓冲区渲染图形 g_pd3dDevice->EndScene(); } //将在后台缓冲区绘制的图形提交到前台缓冲区显示 g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }
void VisualSceneOCCGeometry :: DrawScene () { if ( occgeometry->changed ) { BuildScene(); occgeometry -> changed = 0; } glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SetLight(); glPushMatrix(); glMultMatrixf (transformationmat); glShadeModel (GL_SMOOTH); glDisable (GL_COLOR_MATERIAL); glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // glEnable (GL_LIGHTING); double shine = vispar.shininess; // double transp = vispar.transp; glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shine); glLogicOp (GL_COPY); glEnable (GL_NORMALIZE); float mat_col[] = { 0.2f, 0.2f, 0.8f, 1.0f}; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); glPolygonOffset (1, 1); glEnable (GL_POLYGON_OFFSET_FILL); // Philippose - 30/01/2009 // Added clipping planes to Geometry view SetClippingPlane(); GLfloat matcoledge[] = { 0, 0, 1, 1}; GLfloat matcolhiedge[] = { 1, 0, 0, 1}; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcoledge); glLineWidth (1.0f); if (vispar.occshowedges) glCallList (linelists.Get(1)); if (vispar.occshowsurfaces) glCallList (trilists.Get(1)); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcolhiedge); glLineWidth (5.0f); if (vispar.occshowedges) glCallList (linelists.Get(2)); for (int i = 1; i <= occgeometry->vmap.Extent(); i++) if (occgeometry->vvispar[i-1].IsHighlighted()) { glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcolhiedge); glLineWidth (5.0f); glBegin (GL_LINES); gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(occgeometry->vmap(i))); double d = rad/100; glVertex3f (p.X()-d, p.Y(), p.Z()); glVertex3f (p.X()+d, p.Y(), p.Z()); glVertex3f (p.X(), p.Y()-d, p.Z()); glVertex3f (p.X(), p.Y()+d, p.Z()); glVertex3f (p.X(), p.Y(), p.Z()-d); glVertex3f (p.X(), p.Y(), p.Z()+d); glEnd(); } glDisable (GL_POLYGON_OFFSET_FILL); glPopMatrix(); // DrawCoordinateCross (); // DrawNetgenLogo (); glFinish(); glDisable (GL_POLYGON_OFFSET_FILL); }