Model Viewing Bug

Results 1 to 6 of 6
  1. #1
    Member dotaboiz123 is offline
    MemberRank
    Oct 2015 Join Date
    49Posts

    Model Viewing Bug

    Model Viewing Bug
    Can anyone help me how to fix this?



  2. #2
    ‎‎‎‎ Ketchup is offline
    ModeratorRank
    Jan 2009 Join Date
    1,540Posts

    Re: Model Viewing Bug

    __LOOKCHANGE is missing.

  3. #3
    Member dotaboiz123 is offline
    MemberRank
    Oct 2015 Join Date
    49Posts

    Re: Model Viewing Bug

    Quote Originally Posted by Ketchup View Post
    __LOOKCHANGE is missing.
    Im using ur v18 vs2019 released files that files has already have __LOOKCHANGE right sir @Ketchup?

    Edit: Thats the only bug i got after i add __WIKI and __MODEL_VIEW & __MODEL_VIEWER in v18 source After i click the item that i wanted to see it in WIKIPEDIA the item will not pop-up.
    Last edited by dotaboiz123; 13-09-20 at 08:18 PM.

  4. #4
    ‎‎‎‎ Ketchup is offline
    ModeratorRank
    Jan 2009 Join Date
    1,540Posts

    Re: Model Viewing Bug

    Quote Originally Posted by dotaboiz123 View Post
    Im using ur v18 vs2019 released files that files has already have __LOOKCHANGE right sir @Ketchup?

    Edit: Thats the only bug i got after i add __WIKI and __MODEL_VIEW & __MODEL_VIEWER in v18 source After i click the item that i wanted to see it in WIKIPEDIA the item will not pop-up.
    __LOOKCHANGE has to be added to model view that's why the body is missing.

    Not my code but you can use this as a guide:
    Code:
    #include "stdafx.h"
    #include "WndModelView.h"
    #include "ResData.h"
    #include "defineObj.h"
    #include "DPClient.h"
    extern CDPClient g_DPlay;
    
    #ifdef __MODEL_VIEW
    CWndModelView::CWndModelView( void ) 
    {
    	m_pTexture = NULL;
    	m_pModel = NULL;
    	m_bLButtonDownRot = FALSE;
    	m_bRButtonDownTrans = FALSE;
    	m_fRotX = 0.0f;
    	m_fRotY = 0.0f;
    	m_fTransX = 0.0f;
    	m_fTransY = -0.6f;
    	m_fScale = 1.2f;
    }
    
    CWndModelView::~CWndModelView( void )
    {
    	m_pTexture = NULL;
    	SAFE_DELETE(m_pModel);
    }
    
    BOOL CWndModelView::Process()
    {
    	if( m_pModel )
    		m_pModel->FrameMove();
    
    	return TRUE;
    }
    
    BOOL CWndModelView::Initialize( CWndBase* pWndParent, DWORD dwType )
    {
        return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_MODEL_VIEW, WBS_THICKFRAME, CPoint( 0, 0 ), pWndParent );
    }
    
    void CWndModelView::SetWndRect(CRect rectWnd, BOOL bOnSize)
    {
    	AdjustMinRect(&rectWnd, 288, 208);
    	AdjustMaxRect(&rectWnd, 640, 640);
    	CWndNeuz::SetWndRect(rectWnd, bOnSize);
    }
    
    void CWndModelView::OnSize(UINT nType, int cx, int cy)
    {
    
    
    	CWndNeuz::OnSize(nType, cx, cy);
    }
    
    void CWndModelView::OnDraw( C2DRender* p2DRender )
    {
    	if( m_pModel == NULL )
    		return;
    
    	bool isMover = g_pPlayer->GetIndex() == m_dwIndex;
    
    	LPDIRECT3DDEVICE9 pd3dDevice = p2DRender->m_pd3dDevice;
    
    	// ¨¬a¨¡¡À¨¡¢ç ¨ù¨ù¨¡A 
    	D3DVIEWPORT9 viewport;
    
    	viewport.X      = p2DRender->m_ptOrigin.x + 5;//100;// + 5;
    	viewport.Y      = p2DRender->m_ptOrigin.y + 5;// + 5;
    	viewport.Width  = p2DRender->m_clipRect.Width() - 100;//105;
    	viewport.Height = 182;//p2DRender->m_clipRect.Height() - 200;
    	viewport.MinZ   = 0.0f;
    	viewport.MaxZ   = 1.0f;
    
    	DWORD dwColor1 = D3DCOLOR_ARGB( 100, 0, 0,  0 );//D3DCOLOR_TEMP( 255,   0,   0,  50 );//
    	DWORD dwColor2 = D3DCOLOR_ARGB( 255, 240, 240,  240 );//D3DCOLOR_TEMP( 255,  80,  80, 120 );//
    	DWORD dwColor3 = D3DCOLOR_ARGB( 100, 200, 200,  200 );//D3DCOLOR_TEMP( 255,  80,  80, 120 );//
    
    	pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
    	pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
    	pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
    	pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
    	pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
    	pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
    
    	pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
    	pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
    	pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );		
    	pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
    
    	pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
    
    	pd3dDevice->SetRenderState( D3DRS_AMBIENT,  D3DCOLOR_ARGB( 255, 255,255,255) );
    	
    	CRect rect = GetClientRect();
    
    	// ¨¬a¨¡¡À¨¡¢ç ¨ù¨ù¨¡A 
    	D3DXMATRIXA16 matWorld;
    	D3DXMATRIXA16 matScale;
    	D3DXMATRIXA16 matRotX;
    	D3DXMATRIXA16 matRotY;
    	D3DXMATRIXA16 matTrans;
    
    	// A¡ì¢¬¨­¢Òo 
    	D3DXMATRIX  matView;
    	D3DXVECTOR3 vecLookAt( 0.0f, 0.0f, 3.0f );
    	D3DXVECTOR3 vecPos(  0.0f, 0.7f, -3.5f );
    	
    	D3DXMatrixLookAtLH( &matView, &vecPos, &vecLookAt, &D3DXVECTOR3(0.0f,1.0f,0.0f) );
    	
    	pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
    	
    	#ifdef __YENV
    	D3DXVECTOR3 vDir( 0.0f, 0.0f, 1.0f );
    	SetLightVec( vDir );
    	#endif //__YENV
    	
    	// ¢¯¨­AE ¢¯©ª¨¬¡í ¢¬©£¥ì¡§ ¡¤¡Ì¢¥o¢¬¥ì
    	{
    		/*LPWNDCTRL lpFace = GetWndCtrl( WIDC_CUSTOM1 );
    
    		viewport.X      = p2DRender->m_ptOrigin.x + lpFace->rect.left;
    		viewport.Y      = p2DRender->m_ptOrigin.y + lpFace->rect.top;
    		viewport.Width  = lpFace->rect.Width();
    		viewport.Height = lpFace->rect.Height();*/
    
    		viewport.X = p2DRender->m_ptOrigin.x + 16;
    		viewport.Y = p2DRender->m_ptOrigin.y + 16;
    		viewport.Width = rect.Width() - 32;
    		viewport.Height = rect.Height() - 32;
    
    		viewport.MinZ   = 0.0f;
    		viewport.MaxZ   = 1.0f;
    		pd3dDevice->SetViewport(&viewport);
    		pd3dDevice->Clear(0, NULL, D3DCLEAR_ZBUFFER, 0xffa08080, 1.0f, 0 ) ;
    
    		D3DXMATRIX matProj;
    		D3DXMatrixIdentity( &matProj );
    		FLOAT fAspect = ((FLOAT)viewport.Width) / (FLOAT)viewport.Height;
    /*
    		D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4.0f, fAspect, CWorld::m_fNearPlane - 0.01f, CWorld::m_fFarPlane );
    		pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
    */		
    		FLOAT fov = D3DX_PI/4.0f;//796.0f;
    		FLOAT h = cos(fov/2) / sin(fov/2);
    		FLOAT w = h * fAspect;
    		D3DXMatrixOrthoLH( &matProj, w, h, CWorld::m_fNearPlane - 0.01f, CWorld::m_fFarPlane );
    		pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
    		
    	    D3DXMatrixIdentity(&matScale);
    		D3DXMatrixIdentity(&matRotX);
    		D3DXMatrixIdentity(&matRotY);
    		D3DXMatrixIdentity(&matTrans);
    		D3DXMatrixIdentity(&matWorld);
    		
    		D3DXMatrixRotationY(&matRotX, D3DXToRadian(m_fRotX));
    		D3DXMatrixRotationX(&matRotY, D3DXToRadian(m_fRotY));
    		
    		D3DXMatrixScaling(&matScale, m_fScale, m_fScale, m_fScale);
    		D3DXMatrixTranslation(&matTrans,m_fTransX,m_fTransY,0.0f);
    		
    		D3DXMatrixMultiply(&matWorld, &matWorld, &matScale);
    		D3DXMatrixMultiply(&matWorld, &matWorld, &matRotX);
    		D3DXMatrixMultiply(&matWorld, &matWorld, &matRotY);
    		D3DXMatrixMultiply(&matWorld, &matWorld, &matTrans );
    		pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
    
    		// ¡¤¡Ì¢¥o¢¬¥ì 
    		pd3dDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
    		pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );//m_bViewLight );
    		
    		::SetLight( FALSE );
    		::SetFog( FALSE );
    		SetDiffuse( 1.0f, 1.0f, 1.0f );
    		SetAmbient( 1.0f, 1.0f, 1.0f );
    
    		if (isMover)
    		{
    			m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[0] = g_pPlayer->m_fHairColorR;
    			m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[1] = g_pPlayer->m_fHairColorG;
    			m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[2] = g_pPlayer->m_fHairColorB;
    		}
    
    		D3DXVECTOR4 vConst( 1.0f, 1.0f, 1.0f, 1.0f );
    	#ifdef __YENV
    		g_Neuz.m_pEffect->SetVector( g_Neuz.m_hvFog, &vConst );
    	#else //__YENV						
    		pd3dDevice->SetVertexShaderConstantF( 95, (float*)&vConst, 1 );
    	#endif //__YENV
    		::SetTransformView( matView );
    		::SetTransformProj( matProj );
    			
    		if (isMover)
    		{
    			m_Mover.OverCoatItemRenderCheck(m_pModel);
    
    			// Ci¢¬aAI ¢¬O¢¬¢çA¡ì¢Òo ©ø?¡¤A¨ú©¬CI¢¥A¡ÆIAI©øA?  // AI¨¬¡ÍAI ¨ú©ª¢¥A¡Æ©¡¢¯i
    			DWORD dwId = m_Mover.m_aEquipInfo[PARTS_CAP].dwId;;
    			
    #ifdef __LOOKCHANGE
    			if (m_Mover.m_aEquipInfo[PARTS_CAP].dwLook != NULL_ID)
    				dwId = m_Mover.m_aEquipInfo[PARTS_CAP].dwLook;			
    #endif
    			O3D_ELEMENT*	pElement = NULL;
    			ItemProp*		pItemProp = NULL;
    			
    			if( dwId != NULL_ID )
    			{
    				pItemProp	= prj.GetItemProp( dwId );
    				
    				if( pItemProp && pItemProp->dwBasePartsIgnore != -1 )
    				{
    					pElement = m_pModel->SetEffect(pItemProp->dwBasePartsIgnore, XE_HIDE );
    				}
    				
    				// ¢¯UAoAC¡íoA¡í AO¨úuA¡í¡Æ©¡¢¯i ¢¬O¢¬¢ç©ø?¢¬¡¾¡ÆIAI¡Æ¢®AC ¡¾aA¨ªA¡í ¢¯UAo ¢¬©£AU¢¬| ¡¾aA¨ªA¢¬¡¤I ©öU©÷U¢¥U
    				dwId	= m_Mover.m_aEquipInfo[PARTS_HAT].dwId;
    #ifdef __LOOKCHANGE
    				if (m_Mover.m_aEquipInfo[PARTS_HAT].dwLook != NULL_ID)
    					dwId = m_Mover.m_aEquipInfo[PARTS_HAT].dwLook;
    #endif
    				if( dwId != NULL_ID )
    				{
    					if( !(m_Mover.m_aEquipInfo[PARTS_HAT].byFlag & CItemElem::expired) )
    					{
    						pItemProp	= prj.GetItemProp( dwId );
    						if( pItemProp && pItemProp->dwBasePartsIgnore != -1 )
    						{
    							if( pItemProp->dwBasePartsIgnore == PARTS_HEAD )
    								((CModelObject*)m_pModel)->SetEffect(PARTS_HAIR, XE_HIDE );
    							
    							((CModelObject*)m_pModel)->SetEffect(pItemProp->dwBasePartsIgnore, XE_HIDE );
    						}
    						else
    						{
    							if( pElement )
    								pElement->m_nEffect &= ~XE_HIDE;
    						}
    					}
    				}
    									
    			}
    			else
    			{
    				// ¢¯UAoAC¡íoA¡í AO¨úuA¡í¡Æ©¡¢¯i ¢¬O¢¬¢ç©ø?¢¬¡¾¡ÆIAI¡Æ¢®AC ¡¾aA¨ªA¡í ¢¯UAo ¢¬©£AU¢¬| ¡¾aA¨ªA¢¬¡¤I ©öU©÷U¢¥U
    
    				dwId = m_Mover.m_aEquipInfo[PARTS_HAT].dwId;
    #ifdef __LOOKCHANGE
    				if (m_Mover.m_aEquipInfo[PARTS_HAT].dwLook != NULL_ID)
    					dwId = m_Mover.m_aEquipInfo[PARTS_HAT].dwLook;
    #endif
    				if( dwId != NULL_ID )
    				{
    					if( !(m_Mover.m_aEquipInfo[PARTS_HAT].byFlag & CItemElem::expired) )
    					{						
    						pItemProp	= prj.GetItemProp( dwId );
    						if( pItemProp && pItemProp->dwBasePartsIgnore != -1 )
    						{
    							if( pItemProp->dwBasePartsIgnore == PARTS_HEAD )
    								((CModelObject*)m_pModel)->SetEffect(PARTS_HAIR, XE_HIDE );
    
    							((CModelObject*)m_pModel)->SetEffect(pItemProp->dwBasePartsIgnore, XE_HIDE );
    						}
    					}
    				}							
    			}
    			m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[0] = g_pPlayer->m_fHairColorR;
    			m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[1] = g_pPlayer->m_fHairColorG;
    			m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[2] = g_pPlayer->m_fHairColorB;
    		}
    		else
    		{
    			m_pModel->SetTextureEx(m_pModel->m_pModelElem->m_nTextureEx);
    		}
    			
    		m_pModel->SetGroup( 0 );	
    		m_pModel->Render( p2DRender->m_pd3dDevice, &matWorld );
    	}
    
    	return;
    
    }
    void CWndModelView::OnInitialUpdate( void )
    {
        CWndNeuz::OnInitialUpdate(); 
        RestoreDeviceObjects();
        MoveParentCenter();
    
    	InitMoverModel();
    }
    
    void CWndModelView::InitMoverModel()
    {
    	for (int i = 0; i < MAX_HUMAN_PARTS; ++i)
    	{
    		if (g_pPlayer->GetEquipItem(i))
    		{
    			m_Mover.m_aEquipInfo[i].dwId = g_pPlayer->GetEquipItem(i)->m_dwItemId;
    #ifdef __LOOKCHANGE
    			m_Mover.m_aEquipInfo[i].dwLook = NULL_ID;
    #endif
    		}
    	}
    
    	InitModel(g_pPlayer->GetIndex());
    
    	CMover::UpdateParts(g_pPlayer->GetSex(), g_pPlayer->m_dwSkinSet, g_pPlayer->m_dwFace, g_pPlayer->m_dwHairMesh, g_pPlayer->m_dwHeadMesh, m_Mover.m_aEquipInfo, m_pModel, NULL);
    }
    
    void CWndModelView::InitModel(DWORD dwIndex)
    {
    	m_dwIndex = dwIndex;
    	SAFE_DELETE(m_pModel);
    	//if (dwIndex == g_pPlayer->GetIndex())
    	{
    		m_pModel = (CModelObject*)prj.m_modelMng.LoadModel(g_Neuz.m_pd3dDevice, OT_MOVER, dwIndex, dwIndex == g_pPlayer->GetIndex());
    		prj.m_modelMng.LoadMotion(m_pModel, OT_MOVER, dwIndex, MTI_STAND);
    		m_pModel->InitDeviceObjects(g_Neuz.GetDevice());
    	}
    }
    
    void CWndModelView::OnLButtonDown(UINT nFlags, CPoint point)
    {
    	SetCapture();
    	//if( GetWndCtrl(WIDC_CUSTOM1)->rect.PtInRect(point) )
    	{
    		m_ptOld = point;
    		m_bLButtonDownRot = TRUE;
    	}
    }
    
    void CWndModelView::OnLButtonUp(UINT nFlags, CPoint point)
    {
    	ReleaseCapture();
    	m_bLButtonDownRot = FALSE;
    }
    
    void CWndModelView::OnRButtonDown(UINT nFlags, CPoint point)
    {
    	SetCapture();
    	//if (GetWndCtrl(WIDC_CUSTOM1)->rect.PtInRect(point))
    	{
    		m_ptOld = point;
    		m_bRButtonDownTrans = TRUE;
    	}
    }
    
    void CWndModelView::OnRButtonUp(UINT nFlags, CPoint point)
    {
    	ReleaseCapture();
    	m_bRButtonDownTrans = FALSE;
    }
    
    void CWndModelView::OnMouseMove(UINT nFlags, CPoint point)
    {
    	if( m_bLButtonDownRot )
    	{
    		m_fRotX += (m_ptOld.x - point.x) * 0.75f;
    		m_fRotY += (m_ptOld.y - point.y) * 0.75f;
    		m_ptOld = point;
    	}
    	else if (m_bRButtonDownTrans)
    	{
    		m_fTransX += (m_ptOld.x - point.x) * 0.01f;
    		m_fTransY -= (m_ptOld.y - point.y) * 0.01f;
    		m_ptOld = point;
    	}
    }
    
    BOOL CWndModelView::OnMouseWheel(UINT flags, short zDelta, CPoint pt)
    {
    	if (zDelta < 0)
    	{
    		m_fScale -= 0.1f;
    	}
    	else
    	{
    		m_fScale += 0.1f;
    	}
    	return CWndNeuz::OnMouseWheel(flags, zDelta, pt);
    }
    
    bool CWndModelView::SetPart(ItemProp *pProp)
    {
    	bool result = false;
    	if( pProp )
    	{
    		if (pProp->dwParts >= 2 && pProp->dwParts < MAX_HUMAN_PARTS)
    		{
    			if (m_dwIndex != g_pPlayer->GetIndex())
    			{
    				InitMoverModel();
    			}
    			if (pProp->dwItemSex == NULL_ID || g_pPlayer->GetSex() == pProp->dwItemSex)
    			{
    				int nArryEquip1[5] = { PARTS_CAP, PARTS_UPPER_BODY, PARTS_HAND, PARTS_FOOT, PARTS_CLOAK };
    				int nArryEquip2[5] = { PARTS_HAT, PARTS_CLOTH, PARTS_GLOVE, PARTS_BOOTS, PARTS_CLOAK2 };
    				for (int i = 0; i < 5; ++i)
    				{
    					if (pProp->dwParts == nArryEquip1[i])
    					{
    						m_Mover.m_aEquipInfo[nArryEquip2[i]].dwId = NULL_ID;
    #ifdef __LOOKCHANGE
    						m_Mover.m_aEquipInfo[nArryEquip2[i]].dwLook = NULL_ID;
    #endif
    						break;
    					}
    					if (pProp->dwParts == nArryEquip2[i])
    					{
    						m_Mover.m_aEquipInfo[nArryEquip1[i]].dwId = NULL_ID;
    #ifdef __LOOKCHANGE
    						m_Mover.m_aEquipInfo[nArryEquip1[i]].dwLook = NULL_ID;
    #endif
    						break;
    					}
    				}
    				m_Mover.m_aEquipInfo[pProp->dwParts].dwId = pProp->dwID;
    #ifdef __LOOKCHANGE
    				m_Mover.m_aEquipInfo[pProp->dwParts].dwLook = NULL_ID;
    #endif
    				{
    					CMover::UpdateParts(g_pPlayer->GetSex(), g_pPlayer->m_dwSkinSet, g_pPlayer->m_dwFace, g_pPlayer->m_dwHairMesh, g_pPlayer->m_dwHeadMesh, m_Mover.m_aEquipInfo, m_pModel, NULL);
    				}
    				result = true;
    			}
    		}
    		else if (pProp->dwItemKind3 == IK3_PET)
    		{
    			InitModel(pProp->dwLinkKind);
    			result = true;
    		}
    	}
    	return result;
    }
    #endif
    Last edited by Ketchup; 13-09-20 at 09:37 PM.

  5. #5
    Member dotaboiz123 is offline
    MemberRank
    Oct 2015 Join Date
    49Posts

    Re: Model Viewing Bug

    Quote Originally Posted by Ketchup View Post
    __LOOKCHANGE has to be added to model view that's why the body is missing.

    Not my code but you can use this as a guide:
    Code:
    #include "stdafx.h"
    #include "WndModelView.h"
    #include "ResData.h"
    #include "defineObj.h"
    #include "DPClient.h"
    extern CDPClient g_DPlay;
    
    #ifdef __MODEL_VIEW
    CWndModelView::CWndModelView( void ) 
    {
        m_pTexture = NULL;
        m_pModel = NULL;
        m_bLButtonDownRot = FALSE;
        m_bRButtonDownTrans = FALSE;
        m_fRotX = 0.0f;
        m_fRotY = 0.0f;
        m_fTransX = 0.0f;
        m_fTransY = -0.6f;
        m_fScale = 1.2f;
    }
    
    CWndModelView::~CWndModelView( void )
    {
        m_pTexture = NULL;
        SAFE_DELETE(m_pModel);
    }
    
    BOOL CWndModelView::Process()
    {
        if( m_pModel )
            m_pModel->FrameMove();
    
        return TRUE;
    }
    
    BOOL CWndModelView::Initialize( CWndBase* pWndParent, DWORD dwType )
    {
        return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_MODEL_VIEW, WBS_THICKFRAME, CPoint( 0, 0 ), pWndParent );
    }
    
    void CWndModelView::SetWndRect(CRect rectWnd, BOOL bOnSize)
    {
        AdjustMinRect(&rectWnd, 288, 208);
        AdjustMaxRect(&rectWnd, 640, 640);
        CWndNeuz::SetWndRect(rectWnd, bOnSize);
    }
    
    void CWndModelView::OnSize(UINT nType, int cx, int cy)
    {
    
    
        CWndNeuz::OnSize(nType, cx, cy);
    }
    
    void CWndModelView::OnDraw( C2DRender* p2DRender )
    {
        if( m_pModel == NULL )
            return;
    
        bool isMover = g_pPlayer->GetIndex() == m_dwIndex;
    
        LPDIRECT3DDEVICE9 pd3dDevice = p2DRender->m_pd3dDevice;
    
        // ¨¬a¨¡¡À¨¡¢ç ¨ù¨ù¨¡A 
        D3DVIEWPORT9 viewport;
    
        viewport.X      = p2DRender->m_ptOrigin.x + 5;//100;// + 5;
        viewport.Y      = p2DRender->m_ptOrigin.y + 5;// + 5;
        viewport.Width  = p2DRender->m_clipRect.Width() - 100;//105;
        viewport.Height = 182;//p2DRender->m_clipRect.Height() - 200;
        viewport.MinZ   = 0.0f;
        viewport.MaxZ   = 1.0f;
    
        DWORD dwColor1 = D3DCOLOR_ARGB( 100, 0, 0,  0 );//D3DCOLOR_TEMP( 255,   0,   0,  50 );//
        DWORD dwColor2 = D3DCOLOR_ARGB( 255, 240, 240,  240 );//D3DCOLOR_TEMP( 255,  80,  80, 120 );//
        DWORD dwColor3 = D3DCOLOR_ARGB( 100, 200, 200,  200 );//D3DCOLOR_TEMP( 255,  80,  80, 120 );//
    
        pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
        pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
        pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
        pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
        pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
        pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
    
        pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
        pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
        pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );        
        pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
    
        pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
    
        pd3dDevice->SetRenderState( D3DRS_AMBIENT,  D3DCOLOR_ARGB( 255, 255,255,255) );
        
        CRect rect = GetClientRect();
    
        // ¨¬a¨¡¡À¨¡¢ç ¨ù¨ù¨¡A 
        D3DXMATRIXA16 matWorld;
        D3DXMATRIXA16 matScale;
        D3DXMATRIXA16 matRotX;
        D3DXMATRIXA16 matRotY;
        D3DXMATRIXA16 matTrans;
    
        // A¡ì¢¬¨­¢Òo 
        D3DXMATRIX  matView;
        D3DXVECTOR3 vecLookAt( 0.0f, 0.0f, 3.0f );
        D3DXVECTOR3 vecPos(  0.0f, 0.7f, -3.5f );
        
        D3DXMatrixLookAtLH( &matView, &vecPos, &vecLookAt, &D3DXVECTOR3(0.0f,1.0f,0.0f) );
        
        pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
        
        #ifdef __YENV
        D3DXVECTOR3 vDir( 0.0f, 0.0f, 1.0f );
        SetLightVec( vDir );
        #endif //__YENV
        
        // ¢¯¨­AE ¢¯©ª¨¬¡í ¢¬©£¥ì¡§ ¡¤¡Ì¢¥o¢¬¥ì
        {
            /*LPWNDCTRL lpFace = GetWndCtrl( WIDC_CUSTOM1 );
    
            viewport.X      = p2DRender->m_ptOrigin.x + lpFace->rect.left;
            viewport.Y      = p2DRender->m_ptOrigin.y + lpFace->rect.top;
            viewport.Width  = lpFace->rect.Width();
            viewport.Height = lpFace->rect.Height();*/
    
            viewport.X = p2DRender->m_ptOrigin.x + 16;
            viewport.Y = p2DRender->m_ptOrigin.y + 16;
            viewport.Width = rect.Width() - 32;
            viewport.Height = rect.Height() - 32;
    
            viewport.MinZ   = 0.0f;
            viewport.MaxZ   = 1.0f;
            pd3dDevice->SetViewport(&viewport);
            pd3dDevice->Clear(0, NULL, D3DCLEAR_ZBUFFER, 0xffa08080, 1.0f, 0 ) ;
    
            D3DXMATRIX matProj;
            D3DXMatrixIdentity( &matProj );
            FLOAT fAspect = ((FLOAT)viewport.Width) / (FLOAT)viewport.Height;
    /*
            D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4.0f, fAspect, CWorld::m_fNearPlane - 0.01f, CWorld::m_fFarPlane );
            pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
    */        
            FLOAT fov = D3DX_PI/4.0f;//796.0f;
            FLOAT h = cos(fov/2) / sin(fov/2);
            FLOAT w = h * fAspect;
            D3DXMatrixOrthoLH( &matProj, w, h, CWorld::m_fNearPlane - 0.01f, CWorld::m_fFarPlane );
            pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
            
            D3DXMatrixIdentity(&matScale);
            D3DXMatrixIdentity(&matRotX);
            D3DXMatrixIdentity(&matRotY);
            D3DXMatrixIdentity(&matTrans);
            D3DXMatrixIdentity(&matWorld);
            
            D3DXMatrixRotationY(&matRotX, D3DXToRadian(m_fRotX));
            D3DXMatrixRotationX(&matRotY, D3DXToRadian(m_fRotY));
            
            D3DXMatrixScaling(&matScale, m_fScale, m_fScale, m_fScale);
            D3DXMatrixTranslation(&matTrans,m_fTransX,m_fTransY,0.0f);
            
            D3DXMatrixMultiply(&matWorld, &matWorld, &matScale);
            D3DXMatrixMultiply(&matWorld, &matWorld, &matRotX);
            D3DXMatrixMultiply(&matWorld, &matWorld, &matRotY);
            D3DXMatrixMultiply(&matWorld, &matWorld, &matTrans );
            pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
    
            // ¡¤¡Ì¢¥o¢¬¥ì 
            pd3dDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
            pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );//m_bViewLight );
            
            ::SetLight( FALSE );
            ::SetFog( FALSE );
            SetDiffuse( 1.0f, 1.0f, 1.0f );
            SetAmbient( 1.0f, 1.0f, 1.0f );
    
            if (isMover)
            {
                m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[0] = g_pPlayer->m_fHairColorR;
                m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[1] = g_pPlayer->m_fHairColorG;
                m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[2] = g_pPlayer->m_fHairColorB;
            }
    
            D3DXVECTOR4 vConst( 1.0f, 1.0f, 1.0f, 1.0f );
        #ifdef __YENV
            g_Neuz.m_pEffect->SetVector( g_Neuz.m_hvFog, &vConst );
        #else //__YENV                        
            pd3dDevice->SetVertexShaderConstantF( 95, (float*)&vConst, 1 );
        #endif //__YENV
            ::SetTransformView( matView );
            ::SetTransformProj( matProj );
                
            if (isMover)
            {
                m_Mover.OverCoatItemRenderCheck(m_pModel);
    
                // Ci¢¬aAI ¢¬O¢¬¢çA¡ì¢Òo ©ø?¡¤A¨ú©¬CI¢¥A¡ÆIAI©øA?  // AI¨¬¡ÍAI ¨ú©ª¢¥A¡Æ©¡¢¯i
                DWORD dwId = m_Mover.m_aEquipInfo[PARTS_CAP].dwId;;
                
    #ifdef __LOOKCHANGE
                if (m_Mover.m_aEquipInfo[PARTS_CAP].dwLook != NULL_ID)
                    dwId = m_Mover.m_aEquipInfo[PARTS_CAP].dwLook;            
    #endif
                O3D_ELEMENT*    pElement = NULL;
                ItemProp*        pItemProp = NULL;
                
                if( dwId != NULL_ID )
                {
                    pItemProp    = prj.GetItemProp( dwId );
                    
                    if( pItemProp && pItemProp->dwBasePartsIgnore != -1 )
                    {
                        pElement = m_pModel->SetEffect(pItemProp->dwBasePartsIgnore, XE_HIDE );
                    }
                    
                    // ¢¯UAoAC¡íoA¡í AO¨úuA¡í¡Æ©¡¢¯i ¢¬O¢¬¢ç©ø?¢¬¡¾¡ÆIAI¡Æ¢®AC ¡¾aA¨ªA¡í ¢¯UAo ¢¬©£AU¢¬| ¡¾aA¨ªA¢¬¡¤I ©öU©÷U¢¥U
                    dwId    = m_Mover.m_aEquipInfo[PARTS_HAT].dwId;
    #ifdef __LOOKCHANGE
                    if (m_Mover.m_aEquipInfo[PARTS_HAT].dwLook != NULL_ID)
                        dwId = m_Mover.m_aEquipInfo[PARTS_HAT].dwLook;
    #endif
                    if( dwId != NULL_ID )
                    {
                        if( !(m_Mover.m_aEquipInfo[PARTS_HAT].byFlag & CItemElem::expired) )
                        {
                            pItemProp    = prj.GetItemProp( dwId );
                            if( pItemProp && pItemProp->dwBasePartsIgnore != -1 )
                            {
                                if( pItemProp->dwBasePartsIgnore == PARTS_HEAD )
                                    ((CModelObject*)m_pModel)->SetEffect(PARTS_HAIR, XE_HIDE );
                                
                                ((CModelObject*)m_pModel)->SetEffect(pItemProp->dwBasePartsIgnore, XE_HIDE );
                            }
                            else
                            {
                                if( pElement )
                                    pElement->m_nEffect &= ~XE_HIDE;
                            }
                        }
                    }
                                        
                }
                else
                {
                    // ¢¯UAoAC¡íoA¡í AO¨úuA¡í¡Æ©¡¢¯i ¢¬O¢¬¢ç©ø?¢¬¡¾¡ÆIAI¡Æ¢®AC ¡¾aA¨ªA¡í ¢¯UAo ¢¬©£AU¢¬| ¡¾aA¨ªA¢¬¡¤I ©öU©÷U¢¥U
    
                    dwId = m_Mover.m_aEquipInfo[PARTS_HAT].dwId;
    #ifdef __LOOKCHANGE
                    if (m_Mover.m_aEquipInfo[PARTS_HAT].dwLook != NULL_ID)
                        dwId = m_Mover.m_aEquipInfo[PARTS_HAT].dwLook;
    #endif
                    if( dwId != NULL_ID )
                    {
                        if( !(m_Mover.m_aEquipInfo[PARTS_HAT].byFlag & CItemElem::expired) )
                        {                        
                            pItemProp    = prj.GetItemProp( dwId );
                            if( pItemProp && pItemProp->dwBasePartsIgnore != -1 )
                            {
                                if( pItemProp->dwBasePartsIgnore == PARTS_HEAD )
                                    ((CModelObject*)m_pModel)->SetEffect(PARTS_HAIR, XE_HIDE );
    
                                ((CModelObject*)m_pModel)->SetEffect(pItemProp->dwBasePartsIgnore, XE_HIDE );
                            }
                        }
                    }                            
                }
                m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[0] = g_pPlayer->m_fHairColorR;
                m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[1] = g_pPlayer->m_fHairColorG;
                m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[2] = g_pPlayer->m_fHairColorB;
            }
            else
            {
                m_pModel->SetTextureEx(m_pModel->m_pModelElem->m_nTextureEx);
            }
                
            m_pModel->SetGroup( 0 );    
            m_pModel->Render( p2DRender->m_pd3dDevice, &matWorld );
        }
    
        return;
    
    }
    void CWndModelView::OnInitialUpdate( void )
    {
        CWndNeuz::OnInitialUpdate(); 
        RestoreDeviceObjects();
        MoveParentCenter();
    
        InitMoverModel();
    }
    
    void CWndModelView::InitMoverModel()
    {
        for (int i = 0; i < MAX_HUMAN_PARTS; ++i)
        {
            if (g_pPlayer->GetEquipItem(i))
            {
                m_Mover.m_aEquipInfo[i].dwId = g_pPlayer->GetEquipItem(i)->m_dwItemId;
    #ifdef __LOOKCHANGE
                m_Mover.m_aEquipInfo[i].dwLook = NULL_ID;
    #endif
            }
        }
    
        InitModel(g_pPlayer->GetIndex());
    
        CMover::UpdateParts(g_pPlayer->GetSex(), g_pPlayer->m_dwSkinSet, g_pPlayer->m_dwFace, g_pPlayer->m_dwHairMesh, g_pPlayer->m_dwHeadMesh, m_Mover.m_aEquipInfo, m_pModel, NULL);
    }
    
    void CWndModelView::InitModel(DWORD dwIndex)
    {
        m_dwIndex = dwIndex;
        SAFE_DELETE(m_pModel);
        //if (dwIndex == g_pPlayer->GetIndex())
        {
            m_pModel = (CModelObject*)prj.m_modelMng.LoadModel(g_Neuz.m_pd3dDevice, OT_MOVER, dwIndex, dwIndex == g_pPlayer->GetIndex());
            prj.m_modelMng.LoadMotion(m_pModel, OT_MOVER, dwIndex, MTI_STAND);
            m_pModel->InitDeviceObjects(g_Neuz.GetDevice());
        }
    }
    
    void CWndModelView::OnLButtonDown(UINT nFlags, CPoint point)
    {
        SetCapture();
        //if( GetWndCtrl(WIDC_CUSTOM1)->rect.PtInRect(point) )
        {
            m_ptOld = point;
            m_bLButtonDownRot = TRUE;
        }
    }
    
    void CWndModelView::OnLButtonUp(UINT nFlags, CPoint point)
    {
        ReleaseCapture();
        m_bLButtonDownRot = FALSE;
    }
    
    void CWndModelView::OnRButtonDown(UINT nFlags, CPoint point)
    {
        SetCapture();
        //if (GetWndCtrl(WIDC_CUSTOM1)->rect.PtInRect(point))
        {
            m_ptOld = point;
            m_bRButtonDownTrans = TRUE;
        }
    }
    
    void CWndModelView::OnRButtonUp(UINT nFlags, CPoint point)
    {
        ReleaseCapture();
        m_bRButtonDownTrans = FALSE;
    }
    
    void CWndModelView::OnMouseMove(UINT nFlags, CPoint point)
    {
        if( m_bLButtonDownRot )
        {
            m_fRotX += (m_ptOld.x - point.x) * 0.75f;
            m_fRotY += (m_ptOld.y - point.y) * 0.75f;
            m_ptOld = point;
        }
        else if (m_bRButtonDownTrans)
        {
            m_fTransX += (m_ptOld.x - point.x) * 0.01f;
            m_fTransY -= (m_ptOld.y - point.y) * 0.01f;
            m_ptOld = point;
        }
    }
    
    BOOL CWndModelView::OnMouseWheel(UINT flags, short zDelta, CPoint pt)
    {
        if (zDelta < 0)
        {
            m_fScale -= 0.1f;
        }
        else
        {
            m_fScale += 0.1f;
        }
        return CWndNeuz::OnMouseWheel(flags, zDelta, pt);
    }
    
    bool CWndModelView::SetPart(ItemProp *pProp)
    {
        bool result = false;
        if( pProp )
        {
            if (pProp->dwParts >= 2 && pProp->dwParts < MAX_HUMAN_PARTS)
            {
                if (m_dwIndex != g_pPlayer->GetIndex())
                {
                    InitMoverModel();
                }
                if (pProp->dwItemSex == NULL_ID || g_pPlayer->GetSex() == pProp->dwItemSex)
                {
                    int nArryEquip1[5] = { PARTS_CAP, PARTS_UPPER_BODY, PARTS_HAND, PARTS_FOOT, PARTS_CLOAK };
                    int nArryEquip2[5] = { PARTS_HAT, PARTS_CLOTH, PARTS_GLOVE, PARTS_BOOTS, PARTS_CLOAK2 };
                    for (int i = 0; i < 5; ++i)
                    {
                        if (pProp->dwParts == nArryEquip1[i])
                        {
                            m_Mover.m_aEquipInfo[nArryEquip2[i]].dwId = NULL_ID;
    #ifdef __LOOKCHANGE
                            m_Mover.m_aEquipInfo[nArryEquip2[i]].dwLook = NULL_ID;
    #endif
                            break;
                        }
                        if (pProp->dwParts == nArryEquip2[i])
                        {
                            m_Mover.m_aEquipInfo[nArryEquip1[i]].dwId = NULL_ID;
    #ifdef __LOOKCHANGE
                            m_Mover.m_aEquipInfo[nArryEquip1[i]].dwLook = NULL_ID;
    #endif
                            break;
                        }
                    }
                    m_Mover.m_aEquipInfo[pProp->dwParts].dwId = pProp->dwID;
    #ifdef __LOOKCHANGE
                    m_Mover.m_aEquipInfo[pProp->dwParts].dwLook = NULL_ID;
    #endif
                    {
                        CMover::UpdateParts(g_pPlayer->GetSex(), g_pPlayer->m_dwSkinSet, g_pPlayer->m_dwFace, g_pPlayer->m_dwHairMesh, g_pPlayer->m_dwHeadMesh, m_Mover.m_aEquipInfo, m_pModel, NULL);
                    }
                    result = true;
                }
            }
            else if (pProp->dwItemKind3 == IK3_PET)
            {
                InitModel(pProp->dwLinkKind);
                result = true;
            }
        }
        return result;
    }
    #endif
    Nice!!. Thank you very much sir @Ketchup it works so well. (wink!)

  6. #6
    Member Percuflex is offline
    MemberRank
    Jan 2020 Join Date
    IsraelLocation
    76Posts

    Re: Model Viewing Bug

    Quote Originally Posted by dotaboiz123 View Post
    Nice!!. Thank you very much sir @Ketchup it works so well. (wink!)
    Yep he is one of a kind. Unlike other selfish people from another community which does not mention her name :)



Advertisement