RefResult plRTProjDirLight::EvalLightState( TimeValue t, Interval& valid, LightState *ls ) { ls->type = DIRECT_LGT; if( fLightPB->GetInt( kLightOn, t ) ) ls->color = GetRGBColor( t, valid ); else ls->color = Color( 0, 0, 0 ); ls->on = fLightPB->GetInt( kLightOn, t ); ls->intens = GetIntensity( t, valid ); float fall = fProjPB->GetFloat( kWidth, t ); if( fall < fProjPB->GetFloat( kHeight, t ) ) fall = fProjPB->GetFloat( kHeight, t ); ls->hotsize = ls->fallsize = fall / 2.f; ls->useNearAtten = false; ls->useAtten = false; ls->shape = RECT_LIGHT; ls->aspect = fProjPB->GetFloat( kHeight, t ) / fProjPB->GetFloat( kWidth, t ); ls->overshoot = false; ls->shadow = false; ls->ambientOnly = false; ls->affectDiffuse = fLightPB->GetInt( kAffectDiffuse, t ); ls->affectSpecular = fLightPB->GetInt( kSpec, t ); return REF_SUCCEED; }
float calculate_convolution(const cv::Mat& oImage, const cv::Mat_<float>& oKernel, int color, int row_index, int col_index) { float sum = 0; int row_shift = -(oKernel.rows / 2); int col_shift = - (oKernel.cols / 2); for (int kernel_row_index = 0; kernel_row_index < oKernel.rows; ++kernel_row_index) { int image_row_index = row_index + row_shift + kernel_row_index; for (int kernel_col_index = 0; kernel_col_index < oKernel.cols; ++kernel_col_index) { int image_col_index = col_index + col_shift + kernel_col_index; cv::Vec3b intensity = GetIntensity(oImage, image_row_index, image_col_index); float filterValue = oKernel.at<float>(kernel_row_index, kernel_col_index); sum += intensity.val[color] * filterValue; } } return sum; }
wxString IACSystem::ToString(bool includePosition) const { wxString t; t.Append(GetType(m_type) + wxT(" ")); if (!GetValue().IsEmpty()) { t.Append(wxT("(") + GetValue() + wxT(") ")); } if (!GetIntensity().IsEmpty()) { t.Append(wxT(" ") + GetIntensity() + wxT(" ")); } if (m_char >= 0) { t.Append(GetCharacteristic(m_char) + wxT("\n")); } if (includePosition) { t.Append(PositionsToString() + wxT("\n")); } t.Append(GetMovement()); return t; }
void cEntityEffectHunger::OnTick(cPawn & a_Target) { super::OnTick(a_Target); if (a_Target.IsPlayer()) { cPlayer & Target = reinterpret_cast<cPlayer &>(a_Target); Target.AddFoodExhaustion(0.025 * (static_cast<double>(GetIntensity()) + 1.0)); // 0.5 per second = 0.025 per tick } }
void DialogRepositionSurface::OnApply() { LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindow()->GetActiveLayer("Surface"); LayerMRI* mri = (LayerMRI*)MainWindow::GetMainWindow()->GetActiveLayer("MRI"); QString msg; if ( !surf ) msg = "No active surface found."; else if ( !mri && ui->tabWidget->currentIndex() == 0) msg = "No active volume found."; if (!msg.isEmpty()) { QMessageBox::warning(this, "Error", msg); return; } if (ValidateAll()) { ui->pushButtonApply->setDisabled(true); if (ui->tabWidget->currentIndex() == 0) { if (ui->comboBoxTarget->currentIndex() == 0) { surf->RepositionSurface(mri, GetVertex(), GetIntensity(), GetNeighborSize(), GetSigma(), GetFlags()); } else { double pos[3]; GetCoordinate(pos); surf->RepositionSurface( mri, GetVertex(), pos, GetNeighborSize(), GetSigma(), GetFlags()); } } else if (ui->tabWidget->currentIndex() == 1) { double pos[3]; GetCoordinate(pos); surf->RepositionVertex(GetVertex(), pos); } else { surf->RepositionSmoothSurface(GetVertex(), GetNeighborSize(), GetSmoothingSteps()); } UpdateUI(); ui->pushButtonApply->setDisabled(false); QTimer::singleShot(0, MainWindow::GetMainWindow(), SIGNAL(SlicePositionChanged())); } }
void SkyLight::RenderLight(RenderManagerPtr pRenderer) { if(GetEnabled() == false) { return; } const math::Matrix44& view = pRenderer->GetViewMatrix(); const math::Matrix44& proj = pRenderer->GetProjMatrix(); pRenderer->SetMatrixBlock(m_pMaterial, math::MatrixIdentity()); const math::Matrix44& tm = GetWorldTM(); math::Vector3 d = tm.GetRow3(2); struct DirLightParam { math::Vector3 d; float i; math::Vector3 c; }; DirLightParam l; l.d = d; l.i = GetIntensity(); const math::Color4& diffClr = GetDiffuseColor(); l.c = math::Vector3(diffClr.r, diffClr.g, diffClr.b); MaterialParameterPtr pParam = m_pMaterial->GetParameterByName("light"); pParam->SetParameterBlock(&l, sizeof(DirLightParam)); pRenderer->SetGBuffer(m_pMaterial); if(m_bCastShadow) { pParam = m_pMaterial->GetParameterByName("shadow_map"); pParam->SetParameterTexture(m_pShadowMap->GetTexture(0)); pParam = m_pMaterial->GetParameterByName("light_tm"); pParam->SetParameterMatrix(m_lightTM); } pRenderer->DrawFullScreenQuad(m_pMaterial); }
int Controller::OnIntensity(MM::PropertyBase* pProp, MM::ActionType eAct, long index) { long intensity; if (eAct == MM::BeforeGet) { GetIntensity(intensity,index); pProp->Set(intensity); } else if (eAct == MM::AfterSet) { pProp->Get(intensity); SetIntensity(intensity, index); } return HandleErrors(); }
void ETHParallaxManager::SetShaderParameters(const VideoConstPtr& video, const ShaderPtr& shader, const Vector3& entityPos, const float& individualParallaxIntensity, const bool drawToTarget) const { if (!drawToTarget) { const float parallaxIntensity = GetIntensity() * individualParallaxIntensity; #ifdef GLES2 shader->SetConstant(GS_L("entityPos3D_parallaxIntensity"), Vector4(entityPos, parallaxIntensity)); #else shader->SetConstant(GS_L("entityPos3D"), entityPos); shader->SetConstant(GS_L("parallaxIntensity"), parallaxIntensity); #endif shader->SetConstant(GS_L("parallaxOrigin_verticalIntensity"), Vector3(GetInScreenOrigin(video), GetVerticalIntensity())); } else { shader->SetConstant(GS_L("parallaxIntensity"), 0.0f); } }
void SkyLight::RenderLight(RenderSystemPtr pRenderer) { if(GetEnabled() == false) { return; } const math::Matrix44& view = pRenderer->GetViewMatrix(); const math::Matrix44& proj = pRenderer->GetProjMatrix(); m_pMaterial->SetWorldMatrix(math::MatrixIdentity()); m_pMaterial->SetViewMatrix(view); m_pMaterial->SetProjMatrix(proj); const math::Matrix44& tm = GetWorldTM(); math::Vector3 d = tm.GetRow3(2); struct DirLightParam { math::Vector3 d; float i; math::Vector3 c; float specularPow; }; DirLightParam l; l.d = d; l.i = GetIntensity(); const math::Color4& diffClr = GetDiffuseColor(); l.c = math::Vector3(diffClr.r, diffClr.g, diffClr.b); l.specularPow = GetSpecularPow(); m_pMaterial->SetCBByName("light", &l, sizeof(DirLightParam)); m_pMaterial->SetGBuffer(pRenderer->GetGBuffer()); pRenderer->DrawFullScreenQuad(m_pMaterial); }
void DialogRepositionSurface::OnApply( wxCommandEvent& event ) { LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindowPointer()->GetActiveLayer( "Surface" ); LayerMRI* mri = (LayerMRI*)MainWindow::GetMainWindowPointer()->GetActiveLayer( "MRI" ); wxString msg; if ( !surf ) msg = _("No active surface found."); else if ( !mri ) msg = _("No active volume found." ); if ( !msg.IsEmpty() ) { wxMessageDialog dlg( this, msg, _("Error"), wxOK ); dlg.ShowModal(); return; } if ( ValidateAll() ) { if ( m_choiceTarget->GetCurrentSelection() == 0 ) { surf->RepositionSurface( mri, GetVertex(), GetIntensity(), GetNeighborSize(), GetSigma() ); } else { double pos[3]; GetCoordinate( pos ); surf->RepositionSurface( mri, GetVertex(), pos, GetNeighborSize(), GetSigma() ); } UpdateUI(); } }
/// <summary> /// Handle new depth data /// </summary> void CDepthBasics::ProcessDepth() { HRESULT hr; NUI_IMAGE_FRAME imageFrame; // Attempt to get the depth frame hr = m_pNuiSensor->NuiImageStreamGetNextFrame(m_pDepthStreamHandle, 0, &imageFrame); if (FAILED(hr)) { return; } BOOL nearMode; INuiFrameTexture* pTexture; // Get the depth image pixel texture hr = m_pNuiSensor->NuiImageFrameGetDepthImagePixelFrameTexture( m_pDepthStreamHandle, &imageFrame, &nearMode, &pTexture); if (FAILED(hr)) { goto ReleaseFrame; } NUI_LOCKED_RECT LockedRect; // Lock the frame data so the Kinect knows not to modify it while we're reading it pTexture->LockRect(0, &LockedRect, NULL, 0); // Make sure we've received valid data if (LockedRect.Pitch != 0) { // Get the min and max reliable depth for the current frame int minDepth = (nearMode ? NUI_IMAGE_DEPTH_MINIMUM_NEAR_MODE : NUI_IMAGE_DEPTH_MINIMUM) >> NUI_IMAGE_PLAYER_INDEX_SHIFT; int maxDepth = (nearMode ? NUI_IMAGE_DEPTH_MAXIMUM_NEAR_MODE : NUI_IMAGE_DEPTH_MAXIMUM) >> NUI_IMAGE_PLAYER_INDEX_SHIFT; BYTE * rgbrun = m_depthRGBX; const NUI_DEPTH_IMAGE_PIXEL * pBufferRun = reinterpret_cast<const NUI_DEPTH_IMAGE_PIXEL *>(LockedRect.pBits); // end pixel is start + width*height - 1 const NUI_DEPTH_IMAGE_PIXEL * pBufferEnd = pBufferRun + (cDepthWidth * cDepthHeight); USHORT minReliableDepth = (m_nearMode ? NUI_IMAGE_DEPTH_MINIMUM_NEAR_MODE : NUI_IMAGE_DEPTH_MINIMUM) >> NUI_IMAGE_PLAYER_INDEX_SHIFT; USHORT maxReliableDepth = (m_nearMode ? NUI_IMAGE_DEPTH_MAXIMUM_NEAR_MODE : NUI_IMAGE_DEPTH_MAXIMUM) >> NUI_IMAGE_PLAYER_INDEX_SHIFT; while ( pBufferRun < pBufferEnd ) { // discard the portion of the depth that contains only the player index USHORT depth = pBufferRun->depth; USHORT index = pBufferRun->playerIndex; //USHORT depth = NuiDepthPixelToDepth(pBufferRun->depth); //USHORT index = NuiDepthPixelToPlayerIndex(pBufferRun->depth); // To convert to a byte, we're discarding the most-significant // rather than least-significant bits. // We're preserving detail, although the intensity will "wrap." // Values outside the reliable depth range are mapped to 0 (black). // Note: Using conditionals in this loop could degrade performance. // Consider using a lookup table instead when writing production code. //BYTE intensity = static_cast<BYTE>(depth >= minDepth && depth <= maxDepth ? depth % 256 : 0); BYTE r; BYTE g; BYTE b; if (index == 0 && depth == 0) { //Unknown Depth r = 63; g = 63; b = 7; } else if (index == 0 && depth < minReliableDepth) { //Too Near r = 31; g = 127; b = 255; } else if (index == 0 && depth > maxReliableDepth && depth <= USHRT_MAX) { //Too Far r = 127; g = 15; b = 63; } else { BYTE intensity = GetIntensity(depth); r = intensity >> m_intensityShiftR[index]; g = intensity >> m_intensityShiftG[index]; b = intensity >> m_intensityShiftB[index]; } //BYTE * // Write out blue byte //*(rgbrun++) = intensity; *(rgbrun++) = b; // Write out green byte //*(rgbrun++) = intensity; *(rgbrun++) = g; // Write out red byte //*(rgbrun++) = intensity; *(rgbrun++) = r; //*rgbrun = m_depthColorTable[index][depth]; //rgbrun++; //rgbrun++; //rgbrun++; // We're outputting BGR, the last byte in the 32 bits is unused so skip it // If we were outputting BGRA, we would write alpha here. //*(rgbrun++) = 1; ++rgbrun; // Increment our index into the Kinect's depth buffer ++pBufferRun; } // Draw the data with Direct2D m_pDrawDepth->Draw(m_depthRGBX, cDepthWidth * cDepthHeight * cBytesPerPixel); }