Jump to content

Water Output Render


Recommended Posts

  • Bot

What it does?

 

Framerate and Size of the Waterframes, the stuff is completly self explained

 

void CMapOutdoor::LoadWaterTexture()
{
    UnloadWaterTexture();
    char buf[256]; // bigger the texture bigger the buffer
    for (int i = 0; i < 30; ++i) // count of the frames
    {
        sprintf(buf, "d:/ymir Work/special/water/%02d.dds", i+1); // Special/etc/ path can be set to a custom path
        m_WaterInstances[i].SetImagePointer((CGraphicImage *) CResourceManager::Instance().GetResourcePointer(buf));
    }
}
void CMapOutdoor::UnloadWaterTexture()
{
    for (int i = 0; i < 30; ++i) // count of the frames
        m_WaterInstances[i].Destroy();
}

example for bigger textures

 

void CMapOutdoor::LoadWaterTexture()
{
    UnloadWaterTexture();
    char buf[512];
    for (int i = 0; i < 99; ++i)
    {
        sprintf(buf, "d:/ymir Work/special/water/%02d.dds", i+1);
        m_WaterInstances[i].SetImagePointer((CGraphicImage *)CResourceManager::Instance().GetResourcePointer(buf));
    } 
}
void CMapOutdoor::UnloadWaterTexture()
{
    for (int i = 0; i < 99; ++i)
        m_WaterInstances[i].Destroy();
}

i Prefer Png cause they are easy to create but its about your Choice if you got Questions

example how it can look: https://metin2.download/picture/3XfhhS83IV4OQ71U9XQbR8Y6ZTJcQB1H/.gif

discord: ToXiC#9214

 

cheers

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 4
  • Good 1
  • Love 1

english_banner.gif

Link to comment
Share on other sites

  • Premium
CGraphicImageInstance m_WaterInstances[30];

Edit this part in the MapOutdoor.h as well ;).

STATEMANAGER.SetTexture(0, m_WaterInstances[((ELTimer_GetMSec() / 70) % 30)].GetTexturePointer()->GetD3DTexture());

And this in the MapOutdoorWater.cpp.

And I believe that buffer is used for the path of the texture and not the actual size of the texture.

Edited by Sonitex
  • Love 2
Link to comment
Share on other sites

  • Forum Moderator
On 2/22/2020 at 2:28 PM, ToXiC4000 said:


   char buf[512]; // bigger the texture bigger the buffer

 

Why you modify the buffer size to 512? Your file name has more than 225 characters? I'm sure not, it's enough 256.

Also you should do a check if your water texture file exists in your path for sure, otherwise everything will be fucked up with the array when trying to get texture pointer and function D3D texture. (possible crash because of nullptr)

So, you should change:

		m_WaterInstances[i].SetImagePointer((CGraphicImage *)CResourceManager::Instance().GetResourcePointer(buf));

With:

		if (CResourceManager::Instance().IsFileExist(buf))
			m_WaterInstances[i].SetImagePointer(dynamic_cast<CGraphicImage *>(CResourceManager::Instance().GetResourcePointer(buf)));

 

Also, instead of change everywhere 30 with 99 or what value you want, you should do a constant variable and use it everywhere.

This is the hidden content, please

Also this is the good method for accessing the array with a safe method.

	STATEMANAGER.SetTexture(0, m_WaterInstances[((ELTimer_GetMSec() / 70) % 30)].GetTexturePointer()->GetD3DTexture());
[...]
	auto pImageInstance = m_WaterInstances[(ELTimer_GetMSec() / 70) % _countof(m_WaterInstances)];
	if (pImageInstance.GetTexturePointer())
		STATEMANAGER.SetTexture(0, pImageInstance.GetTexturePointer()->GetD3DTexture());

 

Edited by VegaS™
  • Metin2 Dev 8
  • Smile Tear 1
  • Think 1
  • Good 3
  • Love 2
  • Love 18
Link to comment
Share on other sites

Announcements



×
×
  • 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.