Jump to content

Recommended Posts

  • Bot

Currently im trying to draw a circle with my player as center point and if he moves, the circle should also move with him. But my problem is, that I dont know how to do it. So far this is the code:

void CPythonCharacterManager::DrawCircle()
{
	CInstanceBase* pMainInstance = CPythonPlayer::Instance().NEW_GetMainActorPtr();
	if (!pMainInstance)
		return;

	TPixelPosition pixelPos;
	pMainInstance->NEW_GetPixelPosition(&pixelPos);

	static CScreen screen;
	STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, D3DCOLOR_XRGB(50, 50, 255));

	const int iSteps = 60;
  	const float fRadius = 200;
	screen.RenderCircle2d(pixelPos.x, pixelPos.y, pixelPos.z, fRadius, iSteps);
}

When I call the code, nothing happens. Tried also with other D3DRender state type, but either strange visual bugs appear or nothing happens

english_banner.gif

Link to comment
https://metin2.dev/topic/33726-draw-circle-on-ground/
Share on other sites

  • Honorable Member

You must use screen position, not the position of the instance. Since the main instance is located always at the center of the screen you can use:

RenderCircle2d(0, 0, 0, 200);

 

Edited by Owsap
  • Metin2 Dev 1
  • Good 1
Link to comment
https://metin2.dev/topic/33726-draw-circle-on-ground/#findComment-170701
Share on other sites

  • Bot
8 hours ago, Owsap said:

You must use screen position, not the position of the instance. Since the main instance is located always at the center of the screen you can use:

RenderCircle2d(0, 0, 0, 200);

 

I changed the code like that 

void CPythonCharacterManager::DrawCircle()
{
	CInstanceBase* pMainInstance = CPythonPlayer::Instance().NEW_GetMainActorPtr();
	if (!pMainInstance)
		return;

	static CScreen screen;
  	STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, D3DCOLOR_XRGB(50, 50, 255));
  
	screen.RenderCircle2d(0.0f, 0.0f, 0.0f, 100.0f);
}

But still same problem, when I call the function nothing happens. I debuged it already and set a breakpoint at the function and he call it fully.

Edited by blackList

english_banner.gif

Link to comment
https://metin2.dev/topic/33726-draw-circle-on-ground/#findComment-170707
Share on other sites

  • Honorable Member
//STATEMANAGER.SaveRenderState(D3DRS_ZENABLE, FALSE); // This would make the circle render on top of everything.
STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, FALSE);
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);

static CScreen s_kScreen;
s_kScreen.SetDiffuseColor(0.0f, 1.0f, 1.0f);
s_kScreen.RenderCircle2d(0, 0, 0, 300, 50);

//STATEMANAGER.RestoreRenderState(D3DRS_ZENABLE);
STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, TRUE);
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, TRUE);

 

Edited by Owsap
  • Metin2 Dev 1
Link to comment
https://metin2.dev/topic/33726-draw-circle-on-ground/#findComment-170734
Share on other sites

  • Bot
19 hours ago, Owsap said:
//STATEMANAGER.SaveRenderState(D3DRS_ZENABLE, FALSE); // This would make the circle render on top of everything.
STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, FALSE);
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);

static CScreen s_kScreen;
s_kScreen.SetDiffuseColor(0.0f, 1.0f, 1.0f);
s_kScreen.RenderCircle2d(0, 0, 0, 300, 50);

//STATEMANAGER.RestoreRenderState(D3DRS_ZENABLE);
STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, TRUE);
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, TRUE);

 

Still same problem

 

 

Edited by blackList
Core X - External 2 Internal

english_banner.gif

Link to comment
https://metin2.dev/topic/33726-draw-circle-on-ground/#findComment-170743
Share on other sites

  • Honorable Member
1 hour ago, blackList said:

.gif

Example

Spoiler
void CInstanceBase::Render()
{
	// 2004.07.17.levites.isShow를 ViewFrustumCheck로 변경
	if (!__CanRender())
		return;

	++ms_dwRenderCounter;

	m_kHorse.Render();
	m_GraphicThingInstance.Render();

	if (CActorInstance::IsDirLine())
	{
		if (NEW_GetDstPixelPositionRef().x != 0.0f)
		{
			static CScreen s_kScreen;

			STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
			STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
			STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
			STATEMANAGER.SaveRenderState(D3DRS_ZENABLE, FALSE);
			STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, FALSE);
			STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);

			TPixelPosition px;
			m_GraphicThingInstance.GetPixelPosition(&px);
			D3DXVECTOR3 kD3DVt3Cur(px.x, px.y, px.z);
			//D3DXVECTOR3 kD3DVt3Cur(NEW_GetSrcPixelPositionRef().x, -NEW_GetSrcPixelPositionRef().y, NEW_GetSrcPixelPositionRef().z);
			D3DXVECTOR3 kD3DVt3Dest(NEW_GetDstPixelPositionRef().x, -NEW_GetDstPixelPositionRef().y, NEW_GetDstPixelPositionRef().z);

			//printf("%s %f\n", GetNameString(), kD3DVt3Cur.y - kD3DVt3Dest.y);
			//float fdx = NEW_GetDstPixelPositionRef().x - NEW_GetSrcPixelPositionRef().x;
			//float fdy = NEW_GetDstPixelPositionRef().y - NEW_GetSrcPixelPositionRef().y;

			s_kScreen.SetDiffuseColor(0.0f, 0.0f, 1.0f);
			s_kScreen.RenderLine3d(kD3DVt3Cur.x, kD3DVt3Cur.y, px.z, kD3DVt3Dest.x, kD3DVt3Dest.y, px.z);
			STATEMANAGER.RestoreRenderState(D3DRS_ZENABLE);
			STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, TRUE);
			STATEMANAGER.SetRenderState(D3DRS_LIGHTING, TRUE);
		}
	}

	CPythonBackground& rkBG = CPythonBackground::Instance();
	if (rkBG.IsMapOutdoor())
	{
		//STATEMANAGER.SaveRenderState(D3DRS_ZENABLE, FALSE); // This would make the circle render on top of everything.
		STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, FALSE);
		STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);

		static CScreen s_kScreen;
		s_kScreen.SetDiffuseColor(0.0f, 1.0f, 1.0f);
		s_kScreen.RenderCircle2d(0, 0, 5, 300, 50);

		//STATEMANAGER.RestoreRenderState(D3DRS_ZENABLE);
		STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, TRUE);
		STATEMANAGER.SetRenderState(D3DRS_LIGHTING, TRUE);
	}
}

 

 

Edited by Owsap
  • Love 1
Link to comment
https://metin2.dev/topic/33726-draw-circle-on-ground/#findComment-170744
Share on other sites

  • Bot
On 5/13/2025 at 5:06 PM, Owsap said:

.gif

Example

  Reveal hidden contents
void CInstanceBase::Render()
{
	// 2004.07.17.levites.isShow를 ViewFrustumCheck로 변경
	if (!__CanRender())
		return;

	++ms_dwRenderCounter;

	m_kHorse.Render();
	m_GraphicThingInstance.Render();

	if (CActorInstance::IsDirLine())
	{
		if (NEW_GetDstPixelPositionRef().x != 0.0f)
		{
			static CScreen s_kScreen;

			STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
			STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
			STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
			STATEMANAGER.SaveRenderState(D3DRS_ZENABLE, FALSE);
			STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, FALSE);
			STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);

			TPixelPosition px;
			m_GraphicThingInstance.GetPixelPosition(&px);
			D3DXVECTOR3 kD3DVt3Cur(px.x, px.y, px.z);
			//D3DXVECTOR3 kD3DVt3Cur(NEW_GetSrcPixelPositionRef().x, -NEW_GetSrcPixelPositionRef().y, NEW_GetSrcPixelPositionRef().z);
			D3DXVECTOR3 kD3DVt3Dest(NEW_GetDstPixelPositionRef().x, -NEW_GetDstPixelPositionRef().y, NEW_GetDstPixelPositionRef().z);

			//printf("%s %f\n", GetNameString(), kD3DVt3Cur.y - kD3DVt3Dest.y);
			//float fdx = NEW_GetDstPixelPositionRef().x - NEW_GetSrcPixelPositionRef().x;
			//float fdy = NEW_GetDstPixelPositionRef().y - NEW_GetSrcPixelPositionRef().y;

			s_kScreen.SetDiffuseColor(0.0f, 0.0f, 1.0f);
			s_kScreen.RenderLine3d(kD3DVt3Cur.x, kD3DVt3Cur.y, px.z, kD3DVt3Dest.x, kD3DVt3Dest.y, px.z);
			STATEMANAGER.RestoreRenderState(D3DRS_ZENABLE);
			STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, TRUE);
			STATEMANAGER.SetRenderState(D3DRS_LIGHTING, TRUE);
		}
	}

	CPythonBackground& rkBG = CPythonBackground::Instance();
	if (rkBG.IsMapOutdoor())
	{
		//STATEMANAGER.SaveRenderState(D3DRS_ZENABLE, FALSE); // This would make the circle render on top of everything.
		STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, FALSE);
		STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);

		static CScreen s_kScreen;
		s_kScreen.SetDiffuseColor(0.0f, 1.0f, 1.0f);
		s_kScreen.RenderCircle2d(0, 0, 5, 300, 50);

		//STATEMANAGER.RestoreRenderState(D3DRS_ZENABLE);
		STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, TRUE);
		STATEMANAGER.SetRenderState(D3DRS_LIGHTING, TRUE);
	}
}

 

 

Thank you very much, now it works well.

One question more. Is it easy to edit the code, so the circle follow the terrain height or depth?

  • Metin2 Dev 1

english_banner.gif

Link to comment
https://metin2.dev/topic/33726-draw-circle-on-ground/#findComment-170786
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.