Exemplo n.º 1
0
void ClSoundDS::Set3DListener(float x,float y,float z,float deg)
{
	if(!Enable)return;
	if(lpSoundDS->lpListener){
		lpSoundDS->lpListener->SetPosition(x,y,z,DS3D_IMMEDIATE);
		lpSoundDS->lpListener->SetOrientation(sinf(DEGtoRAD(deg)),0,cosf(DEGtoRAD(deg)),
			0,1.0f,0,DS3D_IMMEDIATE);
	}
} // ClSoundDS::Set3DListener
Exemplo n.º 2
0
void SelectWnd::selectBlt()
{
    int		i;
    float fadeAlpha = (cosf(DEGtoRAD(6*sysInf.animeCnt)) +1.0f) /8.0f +0.75f;

    if(off==bSelect)return;
    for(i=0; i<slctCnt; i++) {
        rect.left = 0;
        rect.right = 640;
        if(i==selectNum) {
            rect.top = 120;
            rect.bottom = 180;
            selectBase.alpha = fadeAlpha;
            g_DibInf.colorBuf.BltFast(selectRect[i].left,selectRect[i].top,&selectBase,&rect,TRUE);
        } else {
            rect.top = 0;
            rect.bottom = 60;
            g_DibInf.colorBuf.BltFast(selectRect[i].left,selectRect[i].top,&selectBase,&rect,FALSE);
        }
        rect.left = 0;
        rect.right = width;
        rect.top = i*60;
        rect.bottom = rect.top +60;
        g_DibInf.colorBuf.BltFast(selectRect[i].left,selectRect[i].top,&selectMsg,&rect,FALSE);
    }
} // SelectWnd::selectBlt
Exemplo n.º 3
0
void DrawMap(void)
{

  char buff[512];
	
  /*------------------------------------------------------------------------------
  //Begin Input Ctrl & View Matrix Setup
  ------------------------------------------------------------------------------*/
  static float angle = 0.0f;
  static float view = -240.0f;
  //view = -view;
  D3DXMATRIX matWorld;
  D3DXMATRIX matWorld2;
  D3DXMatrixTranslation(&matWorld2,0.0f,0.0f,angle/1500.0f);
  //D3DXMatrixRotationX(&matWorld, DEGtoRAD(angle/1.0069));
  //DXMatrixRotationY(&matWorld, DEGtoRAD(angle));
  D3DXMatrixRotationYawPitchRoll(&matWorld,DEGtoRAD(angle/20.0f),DEGtoRAD(angle/15.0f),DEGtoRAD(angle/10.0f));
  matWorld*=matWorld2;
  angle += 1.0f;
  //g_pD3DDevice->SetTransform(D3DTS_WORLD, &matWorld);

  D3DXMATRIX matView;
  static float mawari = 0.0f;
  float delta;
  delta = 0.02f;
  if( GetKeyState(VK_CONTROL)&0x8000 ){ delta = 0.1f; };
  if( GetKeyState(VK_RIGHT) & 0x8000 ) mawari-=delta;
  if( GetKeyState(VK_LEFT)  & 0x8000 ) mawari+=delta;
  static D3DXVECTOR3 pos(0.0f, 0.0f, 0.0f);
  delta = 2.0f;
  if( GetKeyState(VK_CONTROL)&0x8000 ){ delta = 5.0f; };
  if( GetKeyState(VK_UP)    & 0x8000 ){ pos.x+=cos(mawari)*delta; pos.z+=sin(mawari)*delta; }
  if( GetKeyState(VK_DOWN)  & 0x8000 ){ pos.x+=cos(mawari+3.1415926f)*delta; pos.z+=sin(mawari+3.1415926f)*delta; }
  if( GetKeyState(VK_PRIOR) & 0x8000 ){ pos.y+=delta; }
  if( GetKeyState(VK_NEXT)  & 0x8000 ){ pos.y-=delta; }
  if( GetKeyState(VK_HOME)  & 0x8000 ){ mawari=pos.x=pos.y=pos.z=0.0f; }
  D3DXVECTOR3 pnt(pos.x+cos(mawari), pos.y+0.0f, pos.z+sin(mawari));
  D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
  D3DXMatrixLookAtRH(&matView, &pos, &pnt, &up);
  g_pD3DDevice->SetTransform(D3DTS_VIEW, &matView); 

  D3DXMATRIX matProj;
  D3DXMatrixPerspectiveFovRH(&matProj, DEGtoRAD(45.0f), 4.0f / 3.0f, 1.0f, 500.0f);
  g_pD3DDevice->SetTransform(D3DTS_PROJECTION, &matProj);


   if( GetAsyncKeyState(VK_RETURN)  & 0x1 ){ AutoMakeMMB=TRUE;}


  /*------------------------------------------------------------------------------
  //End Input Ctrl & View Matrix Setup
  ------------------------------------------------------------------------------*/

  /*------------------------------------------------------------------------------
  //Begin RenderState
  ------------------------------------------------------------------------------*/
  //g_pD3DDevice->SetRenderState( D3DRS_CULLMODE,   D3DCULL_CW/*/D3DCULL_NONE*/  );
  g_pD3DDevice->SetRenderState( D3DRS_CULLMODE,   D3DCULL_CCW/*/D3DCULL_NONE*/  );
  g_pD3DDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
  //g_pD3DDevice->SetLight(0,&light);
  //g_pD3DDevice->LightEnable(0,TRUE);
  g_pD3DDevice->SetRenderState(D3DRS_LIGHTING,FALSE);
  //g_pD3DDevice->SetRenderState(D3DRS_AMBIENT, 0xF0F0F0F0);
  g_pD3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD );

  g_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
  g_pD3DDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE );
  g_pD3DDevice->SetRenderState( D3DRS_ALPHATESTENABLE , TRUE );
  g_pD3DDevice->SetRenderState( D3DRS_ALPHAREF , 0x80 );
  g_pD3DDevice->SetRenderState( D3DRS_ALPHAFUNC  , D3DCMP_GREATER );
  //g_pD3DDevice->SetRenderState(D3DRS_EDGEANTIALIAS,TRUE);
  /*------------------------------------------------------------------------------
  //End RenderState
  ------------------------------------------------------------------------------*/

  //地图是在TheDesertWorld.cpp里画的
  //g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,128), 1.0f, 0L );



  if( flgFirst ) logprintf("MZB:%d",noj);
  pory = 0;
  for( int i=0; i< noj; i++ )
  {
    //if(i>=50) break;
    D3DXMATRIX matWorld;
    D3DXMATRIX matWorld2;
    D3DXMATRIX matWorld3;
    D3DXMATRIX matWorld4;
    D3DXMATRIX matWorldR4;
    D3DXMATRIX matWorldR5;
    D3DXMATRIX matWorldR6;
    ZeroMemory(&matWorld,sizeof(D3DXMATRIX));
    D3DXMatrixScaling(&matWorld3,oj[i].fScaleX,oj[i].fScaleY,oj[i].fScaleZ); 
    D3DXMatrixTranslation(&matWorld,oj[i].fTransX,oj[i].fTransY,oj[i].fTransZ);
    D3DXMatrixRotationX(&matWorldR4,oj[i].fRotX);
    D3DXMatrixRotationY(&matWorldR5,oj[i].fRotY);
    D3DXMatrixRotationZ(&matWorldR6,oj[i].fRotZ);
    matWorld2 = matWorldR4 * matWorldR5 * matWorldR6;
    matWorld=((matWorld3*matWorld2)/**matWorld4*/)*matWorld;
    g_pD3DDevice->SetTransform(D3DTS_WORLD, &matWorld);
    if( oj[i].fScaleX*oj[i].fScaleY*oj[i].fScaleZ < 0.0f )
	{ 
      g_pD3DDevice->SetRenderState( D3DRS_CULLMODE,   D3DCULL_CW );
    }
	else
	{
      g_pD3DDevice->SetRenderState( D3DRS_CULLMODE,   D3DCULL_CCW );
    }
    if(0)
	{
       float pp[]={-20,0,0,20,0,0, 0,-20,0,0,20,0, 0,0,-20,0,0,20};
       //float pp[]={-10,0,0,10,0,0, 0,-10,0,0,10,0, 0,0,-10,0,0,10};
       g_pD3DDevice->SetFVF(D3DFVF_XYZ);
       g_pD3DDevice->DrawPrimitiveUP(D3DPT_LINELIST,3,pp,12);
    }



	//Draw MzbLists Hint
	{
    RECT rc={5,91,600,128};

	  //自动输出
	  i = haha; //这个会打乱文件名和文件内容的正确配对吗?
	  if (AutoMakeMMB == TRUE) {haha+=1;};
      if (haha == (noj -1)) {haha = 0;AutoMakeMMB == false;};

    sprintf(buff,"-----MZBList:%d/%d",i,noj);
    pDxFont->DrawTextA(NULL,buff,lstrlen(buff),&rc, DT_LEFT,  D3DCOLOR_XRGB(0,0,255)); 
	}


    for( int j=0; j< NumMMB; j++ )
	{
      if( memcmp(MMBlist[j]+16,oj[i].id,16) ) continue;

	//Draw Mmb Hint
	{
    RECT rc={5,134,600,160};
    sprintf(buff,"------- Draw MMB:%s",sstr(oj[i].id,16));
    pDxFont->DrawTextA(NULL,buff,lstrlen(buff),&rc, DT_LEFT,  D3DCOLOR_XRGB(0,0,255)); 
	}

    /*------------------------------------------------------------------------------
    //Begin MapObj Files Output
    ------------------------------------------------------------------------------*/
    char opname[16];  //要输出的文件名
    CopyMemory(opname,MMBlist[j]+16,16);
    ChangeSpaceToNull(opname);
	lstrcat(opname,".MapObj");


    if (DoesFileExist(opname)) { logprintf("发现有文件重复将自动复盖,这些文件是%s",opname);}
    HANDLE hFile = CreateFile(opname,GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL );
    //ReadFile(hFile,pdat,dwSize,&dmy,NULL);	  

    if( hFile!=INVALID_HANDLE_VALUE && hFile!=NULL )
	{
    DWORD dmy;
    //SetFilePointer(hFile,0,NULL,FILE_END);

	LPSTR ReadLocate = MMBlist[j+1]-16;

	int size = (int)(((*(DWORD*)&ReadLocate[4])>>3)&0x007ffff0);

    WriteFile(hFile,&ReadLocate[0],size,&dmy,NULL);
    CloseHandle(hFile);
	}
   /*------------------------------------------------------------------------------
   //End MapObj Files Output
   ------------------------------------------------------------------------------*/

    DrawMMB(MMBlist[j]);

    //信息输出1
	{
    RECT rc={5,5,600,64};
    sprintf(buff,"正在绘制Index数=%d\nLookAt:X=%02.2f Y=%02.2f Z=%02.2f",pory,pos.x,pos.y,pos.z);
    pDxFont->DrawTextA(NULL,buff,lstrlen(buff),&rc, DT_LEFT,  D3DCOLOR_XRGB(196,196,0)); 
	}
    //信息输出2
	{
    RECT rc={5,48,600,96};
    sprintf(buff,"%sMZB=%d MMB=%d\n当前第%d个MMB",oj?"总共":"第",noj,NumMMB,j);
    pDxFont->DrawTextA(NULL,buff,lstrlen(buff),&rc, DT_LEFT,  D3DCOLOR_XRGB(196,196,0)); 
	}

	break;
	}//End For MumMMB

  break;
  }//End For Noj
Exemplo n.º 4
0
	point rotate(double theta){
		double rad = DEGtoRAD(theta);
		return point(x * cos(rad) - y * sin(rad), x * sin(rad) + y * cos(rad));
	}
Exemplo n.º 5
0
void StaffmodeWnd::DrawMaze(ColorBuf *destCBuf)
{
	D3DXVECTOR3	inVec[4];
	float		rad,leng,ratio;
	int		i,j,bSetDiff;

	dest.buf = (RGB24 *)destCBuf->pBuf;
	dest.sx = destCBuf->width; dest.sy = destCBuf->height;

	for(j=0;j<4;j++){
		int ddeg = (deg +90*j) % 360;
		if(ddeg>110 && ddeg<250)continue; 
		bSetDiff = 0;
		for(i=0;i<4;i++){
			rad = (float)ddeg-45+90*(i&1);

			leng = 7.07107f;
			inVec[i].x = leng *sinf(DEGtoRAD(rad));
			inVec[i].y = 5.0f -(i/2)*10.0f;
			inVec[i].z = leng *cosf(DEGtoRAD(rad));
		}
		for(i=0;i<4;i++){
			if(inVec[i].z >= 0)continue;
			if(i==1 || i==3){
				inVec[i].x = (inVec[i].x -inVec[i-1].x)/(inVec[i].z -inVec[i-1].z) *(-inVec[i-1].z) + inVec[i-1].x;
				inVec[i].z = 0;
				leng = lineLength(inVec[i-1].x,inVec[i-1].z,inVec[i].x,inVec[i].z);
				bSetDiff = 1;
			}else{
				inVec[i].x = (inVec[i].x -inVec[i+1].x)/(inVec[i].z -inVec[i+1].z) *(-inVec[i+1].z) + inVec[i+1].x;
				inVec[i].z = 0;
				leng = lineLength(inVec[i+1].x,inVec[i+1].z,inVec[i].x,inVec[i].z);
				bSetDiff = 2;
			}
			ratio = (7.07107f*1.142f) /leng ;
		}
		for(i=0;i<4;i++){
			GetMazeVec(&inVec[i],0);
		}
		if(bSetDiff==1)for(i=1;i<4;i+=2){
			leng = lineLength(inVec[i-1].x,inVec[i-1].y,inVec[i].x,inVec[i].y);
			leng = leng *ratio;
			rad = atan2f(inVec[i].x-inVec[i-1].x,-(inVec[i].y-inVec[i-1].y));
			float rtd = RADtoDEG(rad);
			inVec[i].x = inVec[i-1].x +leng *sinf(rad);
			inVec[i].y = inVec[i-1].y -leng *cosf(rad);
		}
		if(bSetDiff==2)for(i=0;i<4;i+=2){
			leng = lineLength(inVec[i+1].x,inVec[i+1].y,inVec[i].x,inVec[i].y);
			leng = leng *ratio;
			rad = atan2f(inVec[i].x-inVec[i+1].x,-(inVec[i].y-inVec[i+1].y));
			float rtd = RADtoDEG(rad);
			inVec[i].x = inVec[i+1].x +leng *sinf(rad);
			inVec[i].y = inVec[i+1].y -leng *cosf(rad);
		}
		int light;
		if(ddeg < 180){
			light = 128 -100*ddeg/180;
		}else{
			light = 128 -100*(360-ddeg)/180;
		}
		if(3!=bTurn){
			DRW_DrawPOLY4_FB_Simple(&dest, &src[j],
				(int)inVec[0].x, (int)inVec[0].y,
				(int)inVec[1].x, (int)inVec[1].y,
				(int)inVec[2].x, (int)inVec[2].y,
				(int)inVec[3].x, (int)inVec[3].y, light,light,light);
		}else{
			D3DXVECTOR2	pt[4];
			if(ddeg == 0){
				pt[0].x = inVec[0].x -177*moveStep/18;
				pt[1].x = inVec[1].x +177*moveStep/18;
				pt[2].x = inVec[2].x -177*moveStep/18;
				pt[3].x = inVec[3].x +177*moveStep/18;
			}else if(ddeg == 90){
				for(i=0;i<4;i++){
					pt[i].x = inVec[i].x +177*moveStep/18;
				}
			}else if(ddeg == 270){
				for(i=0;i<4;i++){
					pt[i].x = inVec[i].x -177*moveStep/18;
				}
			}
			for(i=0;i<4;i++){
				if(i/2==0){
					pt[i].y = inVec[i].y -133*moveStep/18;
				}else{
					pt[i].y = inVec[i].y +133*moveStep/18;
				}
			}
			DRW_DrawPOLY4_FB_Simple(&dest, &src[j],
				(int)pt[0].x, (int)pt[0].y,
				(int)pt[1].x, (int)pt[1].y,
				(int)pt[2].x, (int)pt[2].y,
				(int)pt[3].x, (int)pt[3].y, light,light,light);
		}
	}
} //StaffmodeWnd::DrawMaze
Exemplo n.º 6
0
BOOL ClMsgWnd::BltMessage()
{
	BOOL	bAlphaUse;
	if(off==sysInf.bShowMsgwin){
		msgFrame.alpha -= 0.2f;
		if(msgFrame.alpha < 0) msgFrame.alpha = 0;
	}else{
		msgFrame.alpha += 0.2f;
		if(msgFrame.alpha > 1.0f) msgFrame.alpha = 1.0f;
	}
	msgPlate.alpha = msgFrame.alpha;
	if(0==msgPlate.alpha)return FALSE;
	bAlphaUse = FALSE;
	if(msgPlate.alpha < 1.0f)bAlphaUse = TRUE;
	POINT shakePt = {0,0};
	g_DibInf.colorBuf.BltFast(offset.x, offset.y+shakePt.y, &msgFrame,NULL,bAlphaUse);
	if(_BAK_TXT_SHAKE==bgInf.in_type){
		int s_size = bgInf.shakeSize;
		int step;
		if(0<bgInf.look_max){
			step = bgInf.look_max-bgInf.look_cnt;
			s_size = (s_size*(bgInf.look_max-step) /bgInf.look_max );
		}else{
			step = bgInf.shake_cnt;
		}
		shakePt.y = int (s_size *sin(DEGtoRAD(20*step)));
	}
	g_DibInf.colorBuf.BltFast(offset.x, offset.y+shakePt.y, &msgPlate,NULL,bAlphaUse);
	if(bName){
		namePlate.alpha += 0.25f;
		if(namePlate.alpha > 1.0f) namePlate.alpha = 1.0f;
	}else{
		namePlate.alpha -= 0.25f;
		if(namePlate.alpha < 0) namePlate.alpha = 0;
	}
	if(namePlate.alpha > msgFrame.alpha) namePlate.alpha = msgFrame.alpha;
	nameFrame.alpha = namePlate.alpha;
	if(namePlate.alpha){
		bAlphaUse = FALSE;
		if(namePlate.alpha < 1.0f)bAlphaUse = TRUE;
		g_DibInf.colorBuf.BltFast(offset.x+30, offset.y-38, &nameFrame,NULL,bAlphaUse);
		g_DibInf.colorBuf.BltFast(offset.x+30, offset.y-26, &namePlate,NULL,bAlphaUse);
	}
	if(off==sysInf.bMsgStop){
		msgWait.alpha -= 0.2f;
		if(msgWait.alpha < 0){
			msgWait.alpha = 0;
			return TRUE;
		}
	}else{
		msgWait.alpha += 0.1f;
		if(msgWait.alpha > 1.0f) msgWait.alpha = 1.0f;
	}
	if(msgWait.alpha > msgFrame.alpha) msgWait.alpha = msgFrame.alpha;
	waitStep ++;
	if(waitStep >= 30)waitStep = 0;
	rect.left = waitStep *34;
	rect.right = rect.left +34;
	rect.top = 0;	rect.bottom = 34;
	g_DibInf.colorBuf.BltFast(offset.x+738, offset.y+130, &msgWait, &rect, TRUE);
	return TRUE;
} // ClMsgWnd::BltMessage