コード例 #1
0
ファイル: OcTree.cpp プロジェクト: colinchen1984/fury3d
	void OcTree::GetRenderQuery(const Collidable &collider, const std::shared_ptr<RenderQuery> &renderQuery) const
	{
		renderQuery->Clear();

		WalkScene(collider, [&](const SceneNode::Ptr &sceneNode)
		{
			if (sceneNode->GetComponent<Light>() != nullptr)
				renderQuery->AddLight(sceneNode);
			
			if (auto render = sceneNode->GetComponent<MeshRender>())
			{
				if (render->GetRenderable())
					renderQuery->AddRenderable(sceneNode);
			}
		});
	}
コード例 #2
0
ファイル: PlotWindowOpened.cpp プロジェクト: PaulJing/Sora
void PlotWindowOpened::RemoveChannelOpened(std::shared_ptr<ChannelOpened> channel)
{
	auto SThis = dynamic_pointer_cast<PlotWindowOpened, AsyncObject>(shared_from_this());

	channel->Clear();

	TaskQueue()->QueueTask([SThis, channel](){	

		int chId = channel->Id();

		auto iterCh = SThis->_chMap.find(channel);
		if (iterCh != SThis->_chMap.end())
		{
			SThis->_chMap.erase(iterCh);
			SThis->OnChannelClosed(channel);
			channel->SetOpenState(false);
		}

		auto iterNewCh = SThis->_newChSet.find(chId);
		if (iterNewCh != SThis->_newChSet.end())
		{
			SThis->_newChSet.erase(chId);
		}

		if (SThis->_chMap.size() == 0)
		{
			HWND hWnd = SThis->_plotWnd->m_hWnd;
			if (hWnd)
				::PostMessage(hWnd, WM_CLOSE, 0, 0);
			SThis->_bWndValid = false;
		}
		else
		{
			SThis->UpdateWndCaption();
		}

	});
}
コード例 #3
0
void DrawImageData(uint32_t cam_id)
{
    if (cam_id == 0) {
        gui_vars.handler->track_centers.clear();
    }

    line_strip->Clear();
    for (uint32_t ii = 0; ii < poses.size() ; ++ii) {
        axes[ii]->SetPose(poses[ii]->t_wp.matrix());
        Eigen::Vector3f vertex = poses[ii]->t_wp.translation().cast<float>();
        line_strip->AddVertex(vertex);
    }

    // Draw the tracks
    for (std::shared_ptr<sdtrack::DenseTrack>& track : *current_tracks) {
        Eigen::Vector2d center;
        if (track->keypoints.back()[cam_id].tracked || is_manual_mode) {
            DrawTrackData(track, image_width, image_height, center,
                          gui_vars.handler->selected_track == track, cam_id);
        }
        if (cam_id == 0) {
            gui_vars.handler->track_centers.push_back(
                std::pair<Eigen::Vector2d, std::shared_ptr<sdtrack::DenseTrack>>(
                    center, track));
        }
    }

    // Populate the first column with the reference from the selected track.
    if (gui_vars.handler->selected_track != nullptr) {
        DrawTrackPatches(gui_vars.handler->selected_track, gui_vars.patches);
    }

    for (uint32_t cam_id = 0; cam_id < rig.cameras_.size(); ++cam_id) {
        gui_vars.camera_view[cam_id]->RenderChildren();
    }
}
コード例 #4
0
ファイル: Main.cpp プロジェクト: saadmahboob/DeepLoco
void CleanUp()
{
	gScenario.reset();
	gArgParser->Clear();
}
コード例 #5
0
ファイル: HUD.cpp プロジェクト: ousttrue/dscvd3d
    void Update()
    {
        if(m_text==m_ss.str()){
            return;
        }

        m_text=m_ss.str();

        m_image->Clear();
        BYTE *data=m_image->GetSample();
        int pitch=m_image->GetWidth()*4;

        // フォントの生成
        LOGFONT lf = {m_fontsize, 0, 0, 0, 0, 0, 0, 0, 
            SHIFTJIS_CHARSET, OUT_TT_ONLY_PRECIS,
            CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FIXED_PITCH | FF_MODERN, _T("MS 明朝")};
        HFONT hFont=CreateFontIndirect(&lf);
        if(!(hFont)){
            return;
        }

        // デバイスコンテキスト取得
        // デバイスにフォントを持たせないとGetGlyphOutline関数はエラーとなる
        HDC hdc = GetDC(NULL);
        HFONT oldFont = (HFONT)SelectObject(hdc, hFont);

        std::vector<BYTE> gryph;
        int x_pos=0;
        int y_pos=0;
        int col_size=m_fontsize/2;
        for(auto c=m_text.begin(); c!=m_text.end(); ++c){

            if(y_pos>=m_row*m_fontsize){
                break;
            }

            if(*c==L'\n'){
                y_pos+=m_fontsize+5;
                x_pos=0;
                continue;
            }

            if(x_pos+col_size>=m_col*col_size){
                y_pos+=m_fontsize+5;
                x_pos=0;
            }

            // フォントビットマップ取得
            TEXTMETRIC TM;
            GetTextMetrics( hdc, &TM );
            GLYPHMETRICS GM;
            CONST MAT2 Mat = {{0,1},{0,0},{0,0},{0,1}};
            DWORD size = GetGlyphOutline(hdc, *c, GGO_GRAY4_BITMAP, &GM, 0, NULL, &Mat);

            if(size>0){
                gryph.resize(size);
                GetGlyphOutline(hdc, *c, GGO_GRAY4_BITMAP, &GM, gryph.size(), &gryph[0], &Mat);

                // フォント情報の書き込み
                // iOfs_x, iOfs_y : 書き出し位置(左上)
                // iBmp_w, iBmp_h : フォントビットマップの幅高
                // Level : α値の段階 (GGO_GRAY4_BITMAPなので17段階)
                int iOfs_x = x_pos+GM.gmptGlyphOrigin.x;
                int iOfs_y = y_pos+TM.tmAscent - GM.gmptGlyphOrigin.y;
                int iBmp_w = GM.gmBlackBoxX + (4-(GM.gmBlackBoxX%4))%4;
                int iBmp_h = GM.gmBlackBoxY;
                int Level = 17;
                DWORD Alpha, Color;
                for(int y=iOfs_y; y<iOfs_y+iBmp_h; y++){
                    for(size_t x=iOfs_x; x<iOfs_x+GM.gmBlackBoxX; x++){
                        Alpha = (255 * gryph[x-iOfs_x + iBmp_w*(y-iOfs_y)]) / (Level-1);
                        Color = 0x00ffffff | (Alpha<<24);
                        memcpy((BYTE*)data + pitch*y + 4*x, &Color, sizeof(DWORD));
                    }
                }
                x_pos+=iBmp_w;
            }
            else{
                x_pos+=col_size;
            }
        }

        // デバイスコンテキストとフォントハンドルの開放
        SelectObject(hdc, oldFont);
        DeleteObject(hFont);
        ReleaseDC(NULL, hdc);
    }
コード例 #6
0
ファイル: Pacman.cpp プロジェクト: AlexanderMladenov/Pacman
	void Pacman::Update(const SDLInput& input, Tilemap& tilemap, float deltaTime, const std::shared_ptr<SDLRenderTarget>& tileSurface, const std::vector<SDLSurface>& gridSurf)
	{
		if (m_State == PacState::PowerUp) // if powered up
		{
			float currentTime = Timer::GetTime();
			if ((currentTime - m_powerDuration) > 5.f) // if powered up for more tha 5 seconds
			{
				m_State = PacState::Normal;// return to normal
			}
		}

		//set our speed
		float speed = 5.5f * deltaTime;

		// clamp position
		size_t cX = (size_t)(clamp(m_Position.x, 0.f, 18.f) + 0.5f);
		size_t cY = (size_t)(clamp(m_Position.y, 0.f, 22.f) + 0.5f);

		switch (m_CurrentDirection) // move in direction
		{
		case Direction::Left:
			m_Position.x -= speed;
			break;
		case Direction::Right:
			m_Position.x += speed;
			break;
		case Direction::Up:
			m_Position.y -= speed;
			break;
		case Direction::Down:
			m_Position.y += speed;
			break;
		}

		//make the side wall let us trough
		if (m_Position.x < 0.f)
		{
			m_Position.x = 19.f;
		}

		if (m_Position.x > 19.0f)
		{
			m_Position.x = 0.f;
		}

		if (m_CurrentDirection == Direction::None && m_NextDirection != Direction::None && tilemap.GetDirectionFlag(cX, cY, (size_t)m_NextDirection))
		{// if the current direction is None and the next input direction is not none and we can go in that direction
			m_CurrentDirection = m_NextDirection; // switch directions
			m_NextDirection = Direction::None; // set next to none
		}

		if (m_CurrentDirection != Direction::None) // if our  current direction is not None ( we are not at base)
		{
			m_DistanceLeft -= speed; // reduce the distance of travel

			if (m_DistanceLeft <= 0.f) //if we have traveled 1 tile
			{
				if (!tilemap.GetDirectionFlag(cX, cY, (size_t)m_CurrentDirection)) // if the tile we are on dosent have the current direction direction flag set
				{
					m_CurrentDirection = Direction::None;// make curent dir none
				}

				if (m_NextDirection != Direction::None) // if we have a pending direction command
				{
					if (tilemap.GetDirectionFlag(cX, cY, (size_t)m_NextDirection)) // and if the tile we are one has the next direction tag set
					{
						m_CurrentDirection = m_NextDirection;// go in that direction
					}
				}
				m_DistanceLeft += 1.0f;// add distace to travel
			}
		}

		Rect rect(m_Position.x + 0.05f, m_Position.y + 0.05f, 0.9f, 0.9f);//construct a collision rect;

		//get all intersections
		auto intersections = tilemap.Intersect(rect);

		for (auto &i : intersections) // go trough them
		{
			if (i.type == Coin) // if its a coin
			{
				m_Points += 1; // increase points
				tilemap.Set(i.x, i.y, Empty); //remove coin 
				tileSurface->Clear(); // clear tilemap render
				tileSurface->RenderTileset(gridSurf, tilemap.GetGrid(), 19, 32.0f);// re - render the grid without the coin.
			}
		}

		//set directions accortind to input keys
		if (input.GetKey(Left))
		{
			m_NextDirection = Direction::Left;
		}

		if (input.GetKey(Right))
		{
			m_NextDirection = Direction::Right;
		}

		if (input.GetKey(Up))
		{
			m_NextDirection = Direction::Up;
		}

		if (input.GetKey(Down))
		{
			m_NextDirection = Direction::Down;
		}
	}