void WidgetBase::RenderOutline(const Vec2& worldPos, const Vec2& widgetSize, float lineWidth) { glPushAttrib(GL_LINE_BIT); glLineWidth(lineWidth); float opacity = GetOpacity(); RGBA edgeColor; Vertex baseOutlineVertex; Vertex outlineVertices[4]; GetPropertyForCurrentState("border color", edgeColor); edgeColor.a() = static_cast<unsigned char>(edgeColor.a() * opacity); baseOutlineVertex.m_color = edgeColor; Vertex bottomLeftOutlineVertex = baseOutlineVertex; Vertex topLeftOutlineVertex = baseOutlineVertex; Vertex topRightOutlineVertex = baseOutlineVertex; Vertex bottomRightOutlineVertex = baseOutlineVertex; bottomLeftOutlineVertex.m_position = worldPos; topLeftOutlineVertex.m_position = worldPos + Vec2(0.f, widgetSize.y()); topRightOutlineVertex.m_position = worldPos + widgetSize; bottomRightOutlineVertex.m_position = worldPos + Vec2(widgetSize.x(), 0.f); outlineVertices[0] = bottomLeftOutlineVertex; outlineVertices[1] = topLeftOutlineVertex; outlineVertices[2] = topRightOutlineVertex; outlineVertices[3] = bottomRightOutlineVertex; Renderer& renderer = Renderer::GetInstance(); renderer.RenderPrimitives(GL_LINE_LOOP, outlineVertices, 4); glPopAttrib(); }
void Accel_ImagePanel::RenderImage() { image img_final; img_final.rgb_data = Render.GetData(); img_final.alpha_data = Render.GetAlpha(); img_final.pos_data.width = Render.GetSize().GetWidth(); img_final.pos_data.height = Render.GetSize().GetHeight(); rect fill_r; fill_r.width = Render.GetSize().GetWidth(); fill_r.height = Render.GetSize().GetHeight(); fill_r.x = fill_r.y = 0; device.Fill(img_final, fill_r, color()); image next_img; next_img.pos_data = img_final.pos_data; for(int layer = LayerCount() - 1; layer >= 0; layer--) { if(GetVisability(layer)) { next_img.rgb_data = GetRGBChannel(layer); next_img.alpha_data = GetAlphaChannel(layer); next_img.opacity = GetOpacity(layer); device.Blend(img_final, next_img, &Layers[layer].Channels); } } }
/*! Subdivides the mesh uniformly one step */ void LoopSubdivisionMesh::Subdivide() { // Create new mesh and copy all the attributes HalfEdgeMesh subDivMesh; subDivMesh.SetTransform(GetTransform()); subDivMesh.SetName(GetName()); subDivMesh.SetColorMap(GetColorMap()); subDivMesh.SetWireframe(GetWireframe()); subDivMesh.SetShowNormals(GetShowNormals()); subDivMesh.SetOpacity(GetOpacity()); if (IsHovering()) subDivMesh.Hover(); if (IsSelected()) subDivMesh.Select(); subDivMesh.mMinCMap = mMinCMap; subDivMesh.mMaxCMap = mMaxCMap; subDivMesh.mAutoMinMax = mAutoMinMax; // loop over each face and create 4 new ones for (unsigned int i=0; i<mFaces.size(); i++){ // subdivide face std::vector< std::vector<Vector3<float> > > faces = Subdivide(i); // add new faces to subDivMesh for(unsigned int j=0; j<faces.size(); j++){ subDivMesh.AddFace(faces.at(j)); } } // Assigns the new mesh *this = LoopSubdivisionMesh(subDivMesh, ++mNumSubDivs); Update(); }
void mitk::Material::PrintSelf ( std::ostream &os, itk::Indent /* unused */ ) const { os << "Name: " << GetName() << std::endl; os << "Color: " << GetColor() << std::endl; os << "ColorCoefficient" << GetColorCoefficient() << std::endl; os << "SpecularColor: " << GetSpecularColor() << std::endl; os << "SpecularCoefficient: " << GetSpecularCoefficient() << std::endl; os << "SpecularPower: " << GetSpecularPower() << std::endl; os << "Opacity: " << GetOpacity() << std::endl; os << "Line width: " << GetLineWidth() << std::endl; switch ( GetInterpolation() ) { case ( Flat ) : os << "Interpolation: Flat" << std::endl; break; case ( Gouraud ) : os << "Interpolation: Gouraud" << std::endl; break; case ( Phong ) : os << "Interpolation: Phong" << std::endl; break; } switch ( GetRepresentation() ) { case ( Points ) : os << "Representation: Points" << std::endl; break; case ( Wireframe ) : os << "Representation: Wireframe" << std::endl; break; case ( Surface ) : os << "Representation: Surface" << std::endl; break; } }
/* ============= OpenGLModel::PreRender Uses the appropriate program for the model ============= */ void OpenGLModel::PreRender( void ) { if ( !m_visible ) { return; } OpenGLProgramManager::GetInstance()->UseProgramWithFeatures( m_requiredFeatures ); OpenGLProgram* prog = OpenGLProgramManager::GetInstance()->GetActiveProgram(); if ( !prog ) { return; } if ( m_animator ) { m_animator->PreRender(); } for ( unsigned int i = 0; i < m_meshCount; ++i ) { if ( m_meshes[i] ) { m_meshes[i]->PreRender(); } } if ( m_attachedPass & PassType::TRANSPARENCY ) { prog->SetUniform( "u_Opacity", GetOpacity() ); } if ( m_requiredFeatures & ProgramFeatures::NORMALS ) { prog->SetUniform( "u_NormalMatrix", glm::inverse( glm::transpose( glm::mat3( m_renderer->GetCameraData().GetViewMatrix() * GetCompositeMatrix() ) ) ) ); } prog->SetUniform( "u_ModelMatrix", GetCompositeMatrix() ); ( ( const OpenGLRenderModule* )m_renderer )->SendGlobalUniforms(); }
mixed inventory_visible(){ if( GetOpacity() > 33 ){ return 0; } else { return 1; } }
void ProgressBarWidget::Render() { Vec2 worldPos = GetWorldPosition(); float progress; Vec2 size; GetPropertyForCurrentState("size", size); float borderSize; GetPropertyForCurrentState("border size", borderSize); float opacity = GetOpacity(); RGBA backgroundColor; RGBA innerColor; GetPropertyForCurrentState("color", backgroundColor); GetPropertyForCurrentState("inner color", innerColor); backgroundColor.a() *= static_cast<unsigned char>(backgroundColor.a() * opacity); innerColor.a() = static_cast<unsigned char>(innerColor.a() * opacity); RenderBackground(worldPos, size, backgroundColor); GetPropertyForCurrentState("progress", progress); CardinalDir dir; GetPropertyForCurrentState("direction", dir); switch (dir) { case C_DIRECTION_EAST: RenderBackground(worldPos, Vec2(size.x() * progress, size.y()), innerColor); break; case C_DIRECTION_WEST: { Vec2 fillSize = Vec2(size.x() * progress, size.y()); Vec2 leftEnd = Vec2(worldPos.x() + size.x() - fillSize.x(), worldPos.y()); RenderBackground(leftEnd, fillSize, innerColor); break; } case C_DIRECTION_SOUTH: { Vec2 fillSize = Vec2(size.x(), size.y() * progress); Vec2 top = Vec2(worldPos.x(), worldPos.y() + size.y() - fillSize.y()); RenderBackground(top, fillSize, innerColor); break; } case C_DIRECTION_NORTH: RenderBackground(worldPos, Vec2(size.x(), size.y() * progress), innerColor); break; } RenderOutline(worldPos, size, borderSize); WidgetBase::ProcessRenderEvent(); /* RenderBackground(worldPos + (size * 0.25f), size * 0.5f, innerColor); RenderOutline(worldPos, size, borderSize); */ }
float Layer::GetEffectiveOpacity() { float opacity = GetOpacity(); for (ContainerLayer* c = GetParent(); c && !c->UseIntermediateSurface(); c = c->GetParent()) { opacity *= c->GetOpacity(); } return opacity; }
mitk::Material::Material( ) { InitializeStandardValues(); SetColor( GetColor() ); SetColorCoefficient( GetColorCoefficient() ); SetSpecularColor( GetSpecularColor() ); SetSpecularCoefficient( GetSpecularCoefficient() ); SetSpecularPower( GetSpecularPower() ); SetOpacity( GetOpacity() ); SetInterpolation( GetInterpolation() ); SetRepresentation( GetRepresentation() ); SetLineWidth( GetLineWidth() ); }
void RuntimeSpriteObject::GetPropertyForDebugger(std::size_t propertyNb, gd::String & name, gd::String & value) const { if ( propertyNb == 0 ) {name = _("Animation"); value = gd::String::From(GetCurrentAnimation());} else if ( propertyNb == 1 ) {name = _("Direction"); value = gd::String::From(GetCurrentDirection());} else if ( propertyNb == 2 ) {name = _("Image"); value = gd::String::From(GetSpriteNb());} else if ( propertyNb == 3 ) {name = _("Opacity"); value = gd::String::From(GetOpacity());} else if ( propertyNb == 4 ) {name = _("Blend mode"); if ( blendMode == 0) value = "0 (Alpha)"; else if ( blendMode == 1) value = "1 (Add)"; else if ( blendMode == 2) value = "2 (Multiply)"; else if ( blendMode == 3) value = "3 (None)";} else if ( propertyNb == 5 ) {name = _("X Scale"); value = gd::String::From(GetScaleX());} else if ( propertyNb == 6 ) {name = _("Y Scale"); value = gd::String::From(GetScaleY());} }
bool pcl::visualization::context_items::Text::Paint (vtkContext2D *painter) { vtkTextProperty *text_property = painter->GetTextProp (); text_property->SetColor (255.0 * colors[0], 255.0 * colors[1], 255.0 * colors[2]); text_property->SetOpacity (GetOpacity ()); text_property->SetFontFamilyToArial (); text_property->SetFontSize (10); text_property->SetJustificationToLeft (); text_property->BoldOff (); text_property->ShadowOff (); painter->DrawString (params[0], params[1], text.c_str ()); return (true); }
//----------------------------------------------------------------------------------------------------------------------------------- void GameMouse::Draw(SpriteBatch* spriteBatch, SpriteFont* spriteFont) { if (IsVisible()) { spriteBatch->Draw( GetTexture()->GetTexture(), GetWorldPosition(), nullptr, GetColour() * GetOpacity(), GetWorldRotation(), Vector2::Zero, XMVectorDivide(GetSize(), GetTexture()->GetDimensions())); } }
void mitk::ImageVtkMapper2D::ApplyOpacity( mitk::BaseRenderer* renderer ) { LocalStorage* localStorage = this->GetLocalStorage( renderer ); float opacity = 1.0f; // check for opacity prop and use it for rendering if it exists GetOpacity( opacity, renderer ); //set the opacity according to the properties localStorage->m_Actor->GetProperty()->SetOpacity(opacity); if ( localStorage->m_Actors->GetParts()->GetNumberOfItems() > 1 ) { dynamic_cast<vtkActor*>( localStorage->m_Actors->GetParts()->GetItemAsObject(0) )->GetProperty()->SetOpacity(opacity); } }
void mitk::LabelAnnotation3D::UpdateVtkAnnotation(mitk::BaseRenderer *renderer) { if (m_LabelCoordinates.IsNull()) { MITK_WARN << "No pointset defined to print labels!"; return; } LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); if (ls->IsGenerateDataRequired(renderer, this)) { vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New(); size_t pointsetsize = (size_t)m_LabelCoordinates->GetSize(); ls->m_Labels->SetNumberOfValues(pointsetsize); ls->m_Sizes->SetNumberOfValues(pointsetsize); for (size_t i = 0; i < pointsetsize; i++) { mitk::Point3D coordinate = m_LabelCoordinates->GetPoint(i); points->InsertNextPoint(coordinate[0] + GetOffsetVector()[0], coordinate[1] + GetOffsetVector()[1], coordinate[2] + GetOffsetVector()[2]); if (m_LabelVector.size() > i) ls->m_Labels->SetValue(i, m_LabelVector[i]); else ls->m_Labels->SetValue(i, ""); if (m_PriorityVector.size() > i) ls->m_Sizes->SetValue(i, m_PriorityVector[i]); else ls->m_Sizes->SetValue(i, 1); } ls->m_Points->SetPoints(points); ls->m_PointSetToLabelHierarchyFilter->Update(); ls->m_LabelMapper->Update(); float color[3] = {1, 1, 1}; float opacity = 1.0; GetColor(color); GetOpacity(opacity); ls->m_LabelsActor->GetProperty()->SetColor(color[0], color[1], color[2]); ls->m_LabelsActor->GetProperty()->SetOpacity(opacity); ls->UpdateGenerateDataTime(); } }
void SrAnimPattern::_Draw() const { // For this pattern, we just use the opacity at the 0th gate. float opacity = GetOpacity()[0]; if (opacity <= 0.0) { return; } const ofImage & img = _imageSequence.GetImage(_currentFrame); ofSetColor(ofFloatColor(opacity, opacity, opacity)); // CRASH img.draw(_gateIndex, 0, img.getWidth(), GetModel()->GetLightsPerGate()); img.draw(_gateIndex - GetModel()->GetNumGates(), 0); }
/* ======== OpenGLParticleEmitter::PreRender Setup before render ======== */ void OpenGLParticleEmitter::PreRender( void ) { if ( m_livingParticles == 0 ) { return; } glBindBuffer( GL_ARRAY_BUFFER, m_particleVBO ); UpdateParticleBuffer(); OpenGLProgramManager::GetInstance()->UseProgramWithFeatures( ProgramFeatures::PARTICLE_BILLBOARDING ); ( ( OpenGLRenderModule* ) m_renderer )->SendGlobalUniforms(); OpenGLProgram* prog = OpenGLProgramManager::GetInstance()->GetActiveProgram(); glm::mat3 test = glm::mat3( m_renderer->GetCameraData().GetViewMatrix() ) * glm::transpose( glm::mat3( m_renderer->GetCameraData().GetViewMatrix() ) ); prog->SetUniform( "u_BillboardMatrix", glm::transpose( glm::mat3( m_renderer->GetCameraData().GetViewMatrix() ) ) ); prog->SetUniform( "u_DiffuseColor", m_emitterSettings.particleColor ); prog->SetUniform( "u_Opacity", GetOpacity() ); prog->SetUniform( "u_ParticleSize", m_emitterSettings.particleSize ); }
void WidgetBase::Render() { Vec2 worldPos = GetWorldPosition(); float opacity = GetOpacity(); RGBA backgroundColor; GetPropertyForCurrentState("color", backgroundColor); backgroundColor.a() = static_cast<unsigned char>(backgroundColor.a() * opacity); Vec2 size; GetPropertyForCurrentState("size", size); float borderSize; GetPropertyForCurrentState("border size", borderSize); RenderBackground(worldPos, size, backgroundColor); RenderOutline(worldPos, size, borderSize); }
void mitk::TextOverlay3D::UpdateVtkOverlay(mitk::BaseRenderer *renderer) { LocalStorage* ls = this->m_LSH.GetLocalStorage(renderer); if(ls->IsGenerateDataRequired(renderer,this)) { ls->m_follower->SetPosition( GetPosition3D(renderer)[0]+GetOffsetVector(renderer)[0], GetPosition3D(renderer)[1]+GetOffsetVector(renderer)[1], GetPosition3D(renderer)[2]+GetOffsetVector(renderer)[2]); ls->m_textSource->SetText(GetText().c_str()); float color[3] = {1,1,1}; float opacity = 1.0; GetColor(color,renderer); GetOpacity(opacity,renderer); ls->m_follower->GetProperty()->SetColor(color[0], color[1], color[2]); ls->m_follower->GetProperty()->SetOpacity(opacity); ls->m_follower->SetScale(this->GetFontSize()); vtkRenderer* vtkRender = renderer->GetVtkRenderer(); if(vtkRender) ls->m_follower->SetCamera(vtkRender->GetActiveCamera()); ls->UpdateGenerateDataTime(); } }
void mitk::TextOverlay2D::UpdateVtkOverlay2D(mitk::BaseRenderer *renderer) { LocalStorage* ls = this->m_LSH.GetLocalStorage(renderer); if (ls->IsGenerateDataRequired(renderer, this)) { float color[3] = { 0.0, 1.0, 0.0 }; float opacity = 1.0; GetColor(color, renderer); GetOpacity(opacity, renderer); ls->m_TextProp->SetColor(color[0], color[1], color[2]); ls->m_STextProp->SetColor(0, 0, 0); ls->m_TextProp->SetFontSize(GetFontSize()); ls->m_TextProp->SetOpacity(opacity); ls->m_STextProp->SetFontSize(GetFontSize()); ls->m_STextProp->SetOpacity(opacity); bool drawShadow; GetBoolProperty("drawShadow", drawShadow); ls->m_TextProp->SetShadow(false); ls->m_STextProp->SetShadow(false); ls->m_STextActor->SetVisibility(drawShadow); ls->m_TextActor->SetInput(GetText().c_str()); ls->m_STextActor->SetInput(GetText().c_str()); mitk::Point2D posT, posS; posT[0] = GetPosition2D(renderer)[0] + GetOffsetVector(renderer)[0]; posT[1] = GetPosition2D(renderer)[1] + GetOffsetVector(renderer)[1]; posS[0] = posT[0] + 1; posS[1] = posT[1] - 1; ls->m_TextActor->SetDisplayPosition(posT[0], posT[1]); ls->m_STextActor->SetDisplayPosition(posS[0], posS[1]); ls->UpdateGenerateDataTime(); } }
void OnPaint(const PaintProps &paint_props) { if (webView_.Null()) return; TBRect rect = GetRect(); rect.x = rect.y = 0; ConvertToRoot(rect.x, rect.y); float* data = &vertexData_[0]; UI* ui = webView_->GetSubsystem<UI>(); float color; float fopacity = GetOpacity() * ui->GetRenderer()->GetOpacity(); unsigned char opacity = (unsigned char) (fopacity* 255.0f); ((unsigned&)color) = (0x00FFFFFF + (((uint32)opacity) << 24)); float x = (float) rect.x; float y = (float) rect.y; float w = (float) rect.w; float h = (float) rect.h; #ifdef ATOMIC_PLATFORM_WINDOWS #ifndef ATOMIC_D3D11 //Direct3D9 Adjustment x += 0.5f; y += 0.5f; #endif #endif data[3] = color; data[9] = color; data[15] = color; data[21] = color; data[27] = color; data[33] = color; data[0] = x; data[1] = y; data[6] = x + w; data[7] = y; data[12] = x + w; data[13] = y + h; data[18] = x; data[19] = y; data[24] = x + w; data[25] = y + h; data[30] = x; data[31] = y + h; ui->SubmitBatchVertexData(webView_->GetWebTexture2D()->GetTexture2D(), vertexData_); }
void plPassMtl::SetupGfxMultiMaps(TimeValue t, Material *mtl, MtlMakerCallback &cb) { #if 0 if (texHandleValid.InInterval(t)) { mtl->texture.SetCount(numTexHandlesUsed); for (int i=0; i<numTexHandlesUsed; i++) { if (texHandle[i]) { mtl->texture[i].textHandle = texHandle[i]->GetHandle(); Texmap *tx = (*maps)[useSubForTex[i]].map; cb.GetGfxTexInfoFromTexmap(t, mtl->texture[i], tx ); SetTexOps(mtl,i,texOpsType[i]); } } return; } #endif #if 0 // WTF?!?!?!? Texmap *tx[2]; int diffChan = stdIDToChannel[ ID_DI ]; int opacChan = stdIDToChannel[ ID_OP ]; tx[0] = (*maps)[diffChan].IsActive()?(*maps)[diffChan].map:NULL; tx[1] = (*maps)[opacChan].IsActive()?(*maps)[opacChan].map:NULL; #endif int nsupport = cb.NumberTexturesSupported(); #if 0 BITMAPINFO *bmi[NTEXHANDLES]; int nmaps=0; for (int i=0; i<NTEXHANDLES; i++) { if (tx[i]) nmaps ++; bmi[i] = NULL; } mtl->texture.SetCount(nmaps); if (nmaps==0) return; for (i=0; i<nmaps; i++) mtl->texture[i].textHandle = NULL; texHandleValid.SetInfinite(); Interval valid; BOOL needDecal = FALSE; int ntx = 0; int op; int forceW = 0; int forceH = 0; if (tx[0]) { cb.GetGfxTexInfoFromTexmap(t, mtl->texture[0], tx[0]); TextureInfo &ti = mtl->texture[0]; if (ti.tiling[0]==GW_TEX_NO_TILING||ti.tiling[1]==GW_TEX_NO_TILING) needDecal = TRUE; op = needDecal?TXOP_ALPHABLEND:TXOP_MODULATE; bmi[0] = tx[0]->GetVPDisplayDIB(t,cb,valid,FALSE); if (bmi[0]) { texHandleValid &= valid; useSubForTex[0] = diffChan; ntx = 1; forceW = bmi[0]->bmiHeader.biWidth; forceH = bmi[0]->bmiHeader.biHeight; } } if (tx[1]) { cb.GetGfxTexInfoFromTexmap(t, mtl->texture[ntx], tx[1]); if (nsupport>ntx) { bmi[1] = tx[1]->GetVPDisplayDIB(t,cb,valid,TRUE); if (bmi[1]) { texHandleValid &= valid; StuffAlpha(bmi[1], (*maps)[opacChan].amount, GetOpacity(t),ntx?whiteCol:pShader->GetDiffuseClr(t)); texHandle[ntx] = cb.MakeHandle(bmi[1]); bmi[1] = NULL; mtl->texture[ntx].textHandle = texHandle[ntx]->GetHandle(); SetTexOps(mtl,ntx,TXOP_OPACITY); useSubForTex[ntx] = opacChan; ntx++; } } else { if (!needDecal) { TextureInfo ti; // if (SameUV(mtl->texture[0],mtl->texture[1])) { // Not really correct to combine channels for different UV's but what the heck. bmi[1] = tx[1]->GetVPDisplayDIB(t,cb,valid,TRUE, forceW, forceH); if (bmi[1]) { texHandleValid &= valid; StuffAlphaInto(bmi[1], bmi[0], (*maps)[opacChan].amount, GetOpacity(t)); op = TXOP_OPACITY; free(bmi[1]); bmi[1] = NULL; } // } } } } if (bmi[0]) { texHandle[0] = cb.MakeHandle(bmi[0]); bmi[0] = NULL; mtl->texture[0].textHandle = texHandle[0]->GetHandle(); SetTexOps(mtl,0,op); } mtl->texture.SetCount(ntx); numTexHandlesUsed = ntx; #endif }
bool pcl::visualization::context_items::Markers::Paint (vtkContext2D *painter) { int nb_points (params.size () / 2); if (size <= 0) size = 2.3 * painter->GetPen ()->GetWidth (); painter->GetPen ()->SetWidth (size); painter->GetPen ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ()))); painter->DrawPointSprites (0, ¶ms[0], nb_points); painter->GetPen ()->SetWidth (1); painter->GetPen ()->SetColor (point_colors[0], point_colors[1], point_colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ()))); painter->DrawPointSprites (0, ¶ms[0], nb_points); return (true); }
bool pcl::visualization::context_items::Points::Paint (vtkContext2D *painter) { painter->GetPen ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ()))); painter->DrawPoints (¶ms[0], static_cast<int> (params.size () / 2)); return (true); }
bool pcl::visualization::context_items::Line::Paint (vtkContext2D *painter) { painter->GetPen ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ()))); painter->DrawLine (params[0], params[1], params[2], params[3]); return (true); }
bool pcl::visualization::context_items::Rectangle::Paint (vtkContext2D *painter) { painter->GetPen ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ()))); float p[] = { params[0], params[1], params[2], params[1], params[2], params[3], params[0], params[3], params[0], params[1] }; painter->DrawPoly (p, 5); return (true); }
void Game_Character::MoveTypeCustom() { // Detect if custom movement or event overwrite const RPG::MoveRoute* active_route; int active_route_index; bool overwrite_changed = IsMoveRouteOverwritten(); if (IsMoveRouteOverwritten()) { active_route = &GetMoveRoute(); active_route_index = GetMoveRouteIndex(); } else { active_route = &original_move_route; active_route_index = GetOriginalMoveRouteIndex(); } if (IsStopping()) { move_failed = false; for (; (size_t)active_route_index < active_route->move_commands.size(); ++active_route_index) { if (!IsStopping() || wait_count > 0 || stop_count < max_stop_count) break; const RPG::MoveCommand& move_command = active_route->move_commands[active_route_index]; switch (move_command.command_id) { case RPG::MoveCommand::Code::move_up: case RPG::MoveCommand::Code::move_right: case RPG::MoveCommand::Code::move_down: case RPG::MoveCommand::Code::move_left: case RPG::MoveCommand::Code::move_upright: case RPG::MoveCommand::Code::move_downright: case RPG::MoveCommand::Code::move_downleft: case RPG::MoveCommand::Code::move_upleft: Move(move_command.command_id); break; case RPG::MoveCommand::Code::move_random: MoveRandom(); break; case RPG::MoveCommand::Code::move_towards_hero: MoveTowardsPlayer(); break; case RPG::MoveCommand::Code::move_away_from_hero: MoveAwayFromPlayer(); break; case RPG::MoveCommand::Code::move_forward: MoveForward(); break; case RPG::MoveCommand::Code::face_up: Turn(Up); break; case RPG::MoveCommand::Code::face_right: Turn(Right); break; case RPG::MoveCommand::Code::face_down: Turn(Down); break; case RPG::MoveCommand::Code::face_left: Turn(Left); break; case RPG::MoveCommand::Code::turn_90_degree_right: Turn90DegreeRight(); break; case RPG::MoveCommand::Code::turn_90_degree_left: Turn90DegreeLeft(); break; case RPG::MoveCommand::Code::turn_180_degree: Turn180Degree(); break; case RPG::MoveCommand::Code::turn_90_degree_random: Turn90DegreeLeftOrRight(); break; case RPG::MoveCommand::Code::face_random_direction: FaceRandomDirection(); break; case RPG::MoveCommand::Code::face_hero: TurnTowardHero(); break; case RPG::MoveCommand::Code::face_away_from_hero: TurnAwayFromHero(); break; case RPG::MoveCommand::Code::wait: Wait(); break; case RPG::MoveCommand::Code::begin_jump: BeginJump(active_route, &active_route_index); break; case RPG::MoveCommand::Code::end_jump: // EndJump(); break; case RPG::MoveCommand::Code::lock_facing: SetFacingLocked(true); break; case RPG::MoveCommand::Code::unlock_facing: SetFacingLocked(false); break; case RPG::MoveCommand::Code::increase_movement_speed: SetMoveSpeed(min(GetMoveSpeed() + 1, 6)); break; case RPG::MoveCommand::Code::decrease_movement_speed: SetMoveSpeed(max(GetMoveSpeed() - 1, 1)); break; case RPG::MoveCommand::Code::increase_movement_frequence: SetMoveFrequency(min(GetMoveFrequency() + 1, 8)); break; case RPG::MoveCommand::Code::decrease_movement_frequence: SetMoveFrequency(max(GetMoveFrequency() - 1, 1)); break; case RPG::MoveCommand::Code::switch_on: // Parameter A: Switch to turn on Game_Switches[move_command.parameter_a] = true; Game_Map::SetNeedRefresh(Game_Map::Refresh_All); break; case RPG::MoveCommand::Code::switch_off: // Parameter A: Switch to turn off Game_Switches[move_command.parameter_a] = false; Game_Map::SetNeedRefresh(Game_Map::Refresh_All); break; case RPG::MoveCommand::Code::change_graphic: // String: File, Parameter A: index SetGraphic(move_command.parameter_string, move_command.parameter_a); break; case RPG::MoveCommand::Code::play_sound_effect: // String: File, Parameters: Volume, Tempo, Balance if (move_command.parameter_string != "(OFF)" && move_command.parameter_string != "(Brak)") { RPG::Sound sound; sound.name = move_command.parameter_string; sound.volume = move_command.parameter_a; sound.tempo = move_command.parameter_b; sound.balance = move_command.parameter_c; Game_System::SePlay(sound); } break; case RPG::MoveCommand::Code::walk_everywhere_on: through = true; break; case RPG::MoveCommand::Code::walk_everywhere_off: through = false; break; case RPG::MoveCommand::Code::stop_animation: walk_animation = false; break; case RPG::MoveCommand::Code::start_animation: walk_animation = true; break; case RPG::MoveCommand::Code::increase_transp: SetOpacity(max(40, GetOpacity() - 45)); break; case RPG::MoveCommand::Code::decrease_transp: SetOpacity(GetOpacity() + 45); break; } last_move_failed = move_failed; if (move_failed) { if (active_route->skippable) { last_move_failed = false; continue; } break; } } if ((size_t)active_route_index >= active_route->move_commands.size() && IsStopping()) { // End of Move list if (active_route->repeat) { active_route_index = 0; SetMoveRouteRepeated(true); } else if (IsMoveRouteOverwritten()) { CancelMoveRoute(); Game_Map::RemovePendingMove(this); stop_count = 0; } } } // When the overwrite status changed the active_index belongs to the // current non-active move route if (overwrite_changed != IsMoveRouteOverwritten()) { if (IsMoveRouteOverwritten()) { SetOriginalMoveRouteIndex(active_route_index); } else { SetMoveRouteIndex(active_route_index); } } else { if (IsMoveRouteOverwritten()) { SetMoveRouteIndex(active_route_index); } else { SetOriginalMoveRouteIndex(active_route_index); } } }
void SceneViewWidget::OnPaint(const PaintProps &paint_props) { if (sceneView_.Null()) return; TBRect rect = GetRect(); rect.x = rect.y = 0; ConvertToRoot(rect.x, rect.y); IntVector2 size = sceneView_->GetSize(); if (size.x_ != rect.w || size.y_ != rect.h) { size.x_ = rect.w; size.y_ = rect.h; sceneView_->SetResizeRequired(); // early out here, responsible for flicker // https://github.com/AtomicGameEngine/AtomicGameEngine/issues/115 return; } float* data = &vertexData_[0]; float color; float fopacity = GetOpacity() * sceneView_->renderer_->GetOpacity(); unsigned char opacity = (unsigned char) (fopacity* 255.0f); ((unsigned&)color) = (0x00FFFFFF + (((uint32)opacity) << 24)); float x = (float) rect.x; float y = (float) rect.y; float w = (float) rect.w; float h = (float) rect.h; #ifdef ATOMIC_PLATFORM_WINDOWS #ifndef ATOMIC_D3D11 //Direct3D9 Adjustment x += 0.5f; y += 0.5f; #endif #endif data[3] = color; data[9] = color; data[15] = color; data[21] = color; data[27] = color; data[33] = color; data[0] = x; data[1] = y; data[6] = x + w; data[7] = y; data[12] = x + w; data[13] = y + h; data[18] = x; data[19] = y; data[24] = x + w; data[25] = y + h; data[30] = x; data[31] = y + h; sceneView_->GetSubsystem<UI>()->SubmitBatchVertexData(sceneView_->GetRenderTexture(), vertexData_); }
void ThebesLayerD3D9::RenderLayer() { if (mVisibleRegion.IsEmpty()) { return; } nsIntRect visibleRect = mVisibleRegion.GetBounds(); // We differentiate between these formats since D3D9 will only allow us to // call GetDC on an opaque surface. D3DFORMAT fmt = (UseOpaqueSurface(this) && !mD2DSurface) ? D3DFMT_X8R8G8B8 : D3DFMT_A8R8G8B8; if (mTexture) { D3DSURFACE_DESC desc; mTexture->GetLevelDesc(0, &desc); if (fmt != desc.Format) { // The new format isn't compatible with the old texture, toss out the old // texture. mTexture = nsnull; mValidRegion.SetEmpty(); } } if (!mTexture) { CreateNewTexture(gfxIntSize(visibleRect.width, visibleRect.height)); mValidRegion.SetEmpty(); } if (!mValidRegion.IsEqual(mVisibleRegion)) { nsIntRegion region; region.Sub(mVisibleRegion, mValidRegion); DrawRegion(region); mValidRegion = mVisibleRegion; } float quadTransform[4][4]; /* * Matrix to transform the <0.0,0.0>, <1.0,1.0> quad to the correct position * and size. To get pixel perfect mapping we offset the quad half a pixel * to the top-left. * * See: http://msdn.microsoft.com/en-us/library/bb219690%28VS.85%29.aspx */ memset(&quadTransform, 0, sizeof(quadTransform)); quadTransform[0][0] = (float)visibleRect.width; quadTransform[1][1] = (float)visibleRect.height; quadTransform[2][2] = 1.0f; quadTransform[3][0] = (float)visibleRect.x - 0.5f; quadTransform[3][1] = (float)visibleRect.y - 0.5f; quadTransform[3][3] = 1.0f; device()->SetVertexShaderConstantF(0, &quadTransform[0][0], 4); device()->SetVertexShaderConstantF(4, &mTransform._11, 4); float opacity[4]; /* * We always upload a 4 component float, but the shader will use only the * first component since it's declared as a 'float'. */ opacity[0] = GetOpacity(); device()->SetPixelShaderConstantF(0, opacity, 1); mD3DManager->SetShaderMode(DeviceManagerD3D9::RGBLAYER); device()->SetTexture(0, mTexture); device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); }
/*! Subdivides the mesh one step, depending on subdividability */ void AdaptiveLoopSubdivisionMesh::Subdivide() { // Create new mesh and copy all the attributes HalfEdgeMesh subDivMesh; subDivMesh.SetTransform(GetTransform()); subDivMesh.SetName(GetName()); subDivMesh.SetColorMap(GetColorMap()); subDivMesh.SetWireframe(GetWireframe()); subDivMesh.SetShowNormals(GetShowNormals()); subDivMesh.SetOpacity(GetOpacity()); if (IsHovering()) subDivMesh.Hover(); if (IsSelected()) subDivMesh.Select(); subDivMesh.mMinCMap = mMinCMap; subDivMesh.mMaxCMap = mMaxCMap; subDivMesh.mAutoMinMax = mAutoMinMax; // loop over each face and create new ones for(unsigned int i=0; i<GetNumFaces(); i++){ // find neighbor faces unsigned int f1, f2, f3; EdgeIterator eit = GetEdgeIterator( f(i).edge ); f1 = eit.Pair().GetEdgeFaceIndex(); eit.Pair(); f2 = eit.Next().Pair().GetEdgeFaceIndex(); eit.Pair(); f3 = eit.Next().Pair().GetEdgeFaceIndex(); unsigned int numNotSubdividable = !Subdividable(f1) + !Subdividable(f2) + !Subdividable(f3); // Do not subdivide if "self" is not subdividable if(!Subdividable(i)){ numNotSubdividable = 3; } std::vector< std::vector <Vector3<float> > > faces; switch(numNotSubdividable){ case 0: // normal subdivision (from LoopSubdivisionMesh) faces = LoopSubdivisionMesh::Subdivide(i); break; case 1: // special case 1 faces = Subdivide1(i); break; case 2: // special case 2 faces = Subdivide2(i); break; case 3: // trivial case, no subdivision, same as if subdividable(fi) == false faces = Subdivide3(i); break; } // add the faces (if any) to subDivMesh for(unsigned int j=0; j<faces.size(); j++){ subDivMesh.AddFace(faces.at(j)); } } // Assign the new mesh *this = AdaptiveLoopSubdivisionMesh(subDivMesh, ++mNumSubDivs); Update(); }
void Game_Character::MoveTypeCustom() { // Detect if custom movement or event overwrite const RPG::MoveRoute* active_route; int active_route_index; bool overwrite_changed = IsMoveRouteOverwritten(); if (IsMoveRouteOverwritten()) { active_route = &GetMoveRoute(); active_route_index = GetMoveRouteIndex(); } else { active_route = &original_move_route; active_route_index = GetOriginalMoveRouteIndex(); } if (IsStopping()) { move_failed = false; if ((size_t)active_route_index >= active_route->move_commands.size()) { // End of Move list if (active_route->repeat) { active_route_index = 0; SetMoveRouteRepeated(true); } else if (IsMoveRouteOverwritten()) { SetMoveRouteOverwritten(false); EndMoveRoute(); stop_count = 0; } } else { do { const RPG::MoveCommand& move_command = active_route->move_commands[active_route_index]; int command_id = move_command.command_id; if (!jumping && command_id == RPG::MoveCommand::Code::begin_jump) { active_route_index = BeginJump(active_route, active_route_index); } switch (move_command.command_id) { case RPG::MoveCommand::Code::move_up: MoveUp(); break; case RPG::MoveCommand::Code::move_right: MoveRight(); break; case RPG::MoveCommand::Code::move_down: MoveDown(); break; case RPG::MoveCommand::Code::move_left: MoveLeft(); break; case RPG::MoveCommand::Code::move_upright: MoveUpRight(); break; case RPG::MoveCommand::Code::move_downright: MoveDownRight(); break; case RPG::MoveCommand::Code::move_downleft: MoveDownLeft(); break; case RPG::MoveCommand::Code::move_upleft: MoveUpLeft(); break; case RPG::MoveCommand::Code::move_random: MoveRandom(); break; case RPG::MoveCommand::Code::move_towards_hero: MoveTowardsPlayer(); break; case RPG::MoveCommand::Code::move_away_from_hero: MoveAwayFromPlayer(); break; case RPG::MoveCommand::Code::move_forward: MoveForward(); break; case RPG::MoveCommand::Code::face_up: TurnUp(); break; case RPG::MoveCommand::Code::face_right: TurnRight(); break; case RPG::MoveCommand::Code::face_down: TurnDown(); break; case RPG::MoveCommand::Code::face_left: TurnLeft(); break; case RPG::MoveCommand::Code::turn_90_degree_right: Turn90DegreeRight(); break; case RPG::MoveCommand::Code::turn_90_degree_left: Turn90DegreeLeft(); break; case RPG::MoveCommand::Code::turn_180_degree: Turn180Degree(); break; case RPG::MoveCommand::Code::turn_90_degree_random: Turn90DegreeLeftOrRight(); break; case RPG::MoveCommand::Code::face_random_direction: FaceRandomDirection(); break; case RPG::MoveCommand::Code::face_hero: TurnTowardHero(); break; case RPG::MoveCommand::Code::face_away_from_hero: TurnAwayFromHero(); break; case RPG::MoveCommand::Code::wait: Wait(); break; case RPG::MoveCommand::Code::begin_jump: // Multiple BeginJumps are ignored break; case RPG::MoveCommand::Code::end_jump: active_route_index = EndJump(active_route, active_route_index); break; case RPG::MoveCommand::Code::lock_facing: SetFacingLocked(true); break; case RPG::MoveCommand::Code::unlock_facing: SetFacingLocked(false); break; case RPG::MoveCommand::Code::increase_movement_speed: SetMoveSpeed(min(GetMoveSpeed() + 1, 6)); break; case RPG::MoveCommand::Code::decrease_movement_speed: SetMoveSpeed(max(GetMoveSpeed() - 1, 1)); break; case RPG::MoveCommand::Code::increase_movement_frequence: SetMoveFrequency(min(GetMoveFrequency() + 1, 8)); break; case RPG::MoveCommand::Code::decrease_movement_frequence: SetMoveFrequency(max(GetMoveFrequency() - 1, 1)); break; case RPG::MoveCommand::Code::switch_on: // Parameter A: Switch to turn on Game_Switches[move_command.parameter_a] = true; Game_Map::SetNeedRefresh(true); break; case RPG::MoveCommand::Code::switch_off: // Parameter A: Switch to turn off Game_Switches[move_command.parameter_a] = false; Game_Map::SetNeedRefresh(true); break; case RPG::MoveCommand::Code::change_graphic: // String: File, Parameter A: index SetGraphic(move_command.parameter_string, move_command.parameter_a); break; case RPG::MoveCommand::Code::play_sound_effect: // String: File, Parameters: Volume, Tempo, Balance if (move_command.parameter_string != "(OFF)") { Audio().SE_Play(move_command.parameter_string, move_command.parameter_a, move_command.parameter_b); } break; case RPG::MoveCommand::Code::walk_everywhere_on: through = true; break; case RPG::MoveCommand::Code::walk_everywhere_off: through = false; break; case RPG::MoveCommand::Code::stop_animation: walk_animation = false; break; case RPG::MoveCommand::Code::start_animation: walk_animation = true; break; case RPG::MoveCommand::Code::increase_transp: SetOpacity(max(40, GetOpacity() - 45)); break; case RPG::MoveCommand::Code::decrease_transp: SetOpacity(GetOpacity() + 45); break; } if (active_route->skippable || !move_failed) { ++active_route_index; } } while (jumping); if ((size_t)active_route_index >= active_route->move_commands.size()) { stop_count = (active_route->repeat ? 0 : 256); } } } // When the overwrite status changed the active_index belongs to the // current non-active move route if (overwrite_changed != IsMoveRouteOverwritten()) { if (IsMoveRouteOverwritten()) { SetOriginalMoveRouteIndex(active_route_index); } else { SetMoveRouteIndex(active_route_index); } } else { if (IsMoveRouteOverwritten()) { SetMoveRouteIndex(active_route_index); } else { SetOriginalMoveRouteIndex(active_route_index); } } }