Exemple #1
0
/* Unit clock inter frame events handle function.
 * ARGUMENTS:
 *   - self-pointer to unit object:
 *       vg4UNIT_CLOCK *Uni;
 *   - animation context:
 *       vg4ANIM *Ani;
 * RETURNS: None.
 */
static VOID VG4_UnitResponse( vg4UNIT_CLOCK *Uni, vg4ANIM *Ani )
{
  DBL r;

  if (Ani->Keys[VK_SPACE])
    VG4_AnimAddUnit(VG4_UnitCreateBall());
  if (Ani->Keys['C'])
    VG4_AnimAddUnit(VG4_UnitCreateCube());
  if (Ani->KeysClick[VK_RETURN] && Ani->Keys[VK_MENU])
    VG4_AnimFlipFullScreen();
  if (Ani->KeysClick[VK_ESCAPE])
    VG4_AnimDoExit();
  if (Ani->KeysClick['P'])
    Ani->IsPause = !Ani->IsPause;


  /* Uni->Pos.Y += Ani->JY * Ani->GlobalDeltaTime; */

  Uni->Pos = VecMulMatr43(Uni->Pos, MatrRotateX(59 * Ani->JY * Ani->GlobalDeltaTime));
  Uni->Pos = VecMulMatr43(Uni->Pos, MatrRotateY(59 * Ani->JX * Ani->GlobalDeltaTime));

  if (Ani->Keys[VK_LBUTTON])
  {
    Uni->Pos = VecMulMatr43(Uni->Pos, MatrRotateY(59 * Ani->Mdx * Ani->GlobalDeltaTime));
    Uni->Pos = VecMulMatr43(Uni->Pos, MatrRotateX(59 * Ani->Mdy * Ani->GlobalDeltaTime));
  }

  Uni->Pos = VecMulMatr43(Uni->Pos, MatrRotateY(59 * Ani->Keys[VK_RIGHT] * Ani->GlobalDeltaTime));
  Uni->Pos = VecMulMatr43(Uni->Pos, MatrRotateY(-59 * Ani->Keys[VK_LEFT] * Ani->GlobalDeltaTime));

  r = VecLen(Uni->Pos);
  Uni->Pos = VecMulNum(Uni->Pos, (r + Ani->Mdz * Ani->DeltaTime * 0.1) / r);

  VG4_RndMatrView = MatrView(Uni->Pos, VecSet(0, 0, 0), VecSet(0, 1, 0));
} /* End of 'VG4_UnitResponse' function */
Exemple #2
0
/* Функция построения объекта анимации.
 * АРГУМЕНТЫ:
 *   - указатель на "себя" - сам объект анимации:
 *       as3UNIT_MODEL *Uni;
 *   - указатель на контекст анимации:
 *       as3ANIM *Ani;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
static VOID AS3_AnimUnitRender( as3UNIT_MODEL *Uni, as3ANIM *Ani )
{  
  INT i, j;

  AS3_RndMatrView = MatrView(VecSet(8, 8, 8),
                             VecSet(0, 0, 0),
		             VecSet(0, 1, 0));

  if (Ani->KeysClick['W'])
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
  if (Ani->KeysClick['Q'])
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  glEnable(GL_DEPTH_TEST);

  for (i = -2; i < 2; i++)
    for (j = -2; j < 2; j++)
    {
      AS3_RndMatrWorld =
                         MatrMulMatr(MatrMulMatr(MatrMulMatr(
			             MatrTranslate(Ani->JX * 228, Ani->JY * 228, 0),
				     MatrScale(0.1, 0.1, 0.1)),
				     MatrRotateY(30 * Ani->Time + Ani->JR * 180)),
				     MatrTranslate(j * 2.5, 0, i * 2.5 + 228 * Ani->JZ));
      glColor3d(i & 1, j & 1, 1 - ((i & 1) + (j & 1)) / 2);
      AS3_RndGObjDraw(&Uni->Model);
    }
  
} /* End of 'AS3_AnimUnitRender' function */
Exemple #3
0
/* Функция построения объекта анимации.
 * АРГУМЕНТЫ:
 *   - указатель на "себя" - сам объект анимации:
 *       vg4UNIT_CTRL *Uni;
 *   - указатель на контекст анимации:
 *       vg4ANIM *Ani;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
static VOID VG4_AnimUnitRender( vg4UNIT_CTRL *Uni, vg4ANIM *Ani )
{
  HFONT hFntOld = SelectObject(Ani->hDC, Uni->hFnt);
  static DBL count = 30;
  static CHAR Buf[1000];

  count += Ani->GlobalDeltaTime;
  if (count > 1)
  {
    count = 0;
    sprintf(Buf, "FPS: %.3f", Ani->FPS);
    SetWindowText(Ani->hWnd, Buf);
  }

  /* вертолет */
  VG4_RndMatrWorld =
    MatrMulMatr(MatrMulMatr(MatrMulMatr(
      MatrRotateX(-Ani->JY * 30), MatrRotateZ(Ani->JX * 59)),
      MatrRotateY(Uni->Head)), MatrTranslate(Uni->Pos.X, Uni->Pos.Y, Uni->Pos.Z));
  VG4_GeomDraw(&Uni->Helic);

  /* оси */
  VG4_RndMatrWorld = MatrIdentity();
  VG4_GeomDraw(&Uni->Axes);

  //VG4_RndMatrWorld = MatrTranslate(Uni->At.X, Uni->At.Y, Uni->At.Z);
  //VG4_PrimDraw(&Uni->Sph);

} /* End of 'VG4_AnimUnitRender' function */
Exemple #4
0
/* Begin of 'WinMain' function */
INT WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, CHAR *CmdLine, INT ShowCmd )
{
  MATR m =
  {{
    {2, 0, 0, 0},
    {1, 2, 0, 0},
    {1, 1, 2, 0},
    {1, 1, 1, 2}
  }};
  DBL g;

  m = MatrIdentity();
  m = MatrTranslate(VecSet(1, 2, 3));
  m = MatrScale(VecSet(1, 2, 3));
  m = MatrRotateX(30);
  m = MatrRotateY(30);
  m = MatrRotateZ(30);
  m = MatrRotate(30, VecSet(1, 2, 3));
  m = MatrMulMatr(MatrRotateX(90), MatrScale(VecSet(2, 2, 2)));
  m = MatrInverse(m);
  g = MatrDeterm(m);
  m = MatrTranspose(m);

  return 0;
}/* Begin of 'WinMain' function */
Exemple #5
0
/* Функция построения объекта анимации.
 * АРГУМЕНТЫ:
 *   - указатель на "себя" - сам объект анимации:
 *       AO5UNIT_MODEL *Uni;
 *   - указатель на контекст анимации:
 *       AO5ANIM *Ani;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
static VOID AO5_AnimUnitRender( ao5UNIT_MODEL *Uni, ao5ANIM *Ani )
{
  INT i, j;
  static BOOL ok = TRUE;
  AO5_RndMatrView = MatrView(VecSet(0, 5, 10),
                             VecSet(0, 0, 0),
                             VecSet(0, 1, 0));

  if (Ani->KeysClick['W'])
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
  if (Ani->KeysClick['Q'])
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  glEnable(GL_DEPTH_TEST);
  if (ok)
    AO5_RndMatrWorld = MatrMulMatr(MatrRotateY(30 * Ani->Time + 180), MatrTranslate(0, -1.5, 0));
  else
    AO5_RndMatrWorld = MatrMulMatr(MatrRotateX(90), MatrRotateZ(90));
  if(Ani->KeysClick['Z'])
	  ok = !ok;
  for (i = 0; i < 1; i++)
    for (j = 0; j < 1; j++)
    {
		
      glColor3d(i & 1, j & 1, 1 - ((i & 1) + (j & 1)) / 2);
      AO5_GeomDraw(&Uni->Model);
    }
  //MatrMulMatr(MatrRotateZ(30 * sin(Ani->Time * 3.0)), MatrRotateY(30 * Ani->Time));
  //AO5_GeomDraw(&Uni->Geom);

  glActiveTexture(GL_TEXTURE0);
  glBindTexture(GL_TEXTURE_2D, Uni->TextId);
  //AO5_PrimDraw(&Uni->Pr);
} /* End of 'AO5_AnimUnitRender' function */
Exemple #6
0
/* Unit render function.
 * ARGUMENTS:
 *   - self-pointer to unit object:
 *       ra3UNIT_LUIGI *Uni;
 *   - animation context:
 *       ra3ANIM *Ani;
 * RETURNS: None.
 */
static VOID RA3_UnitRender( ra3UNIT_LUIGI *Uni, ra3ANIM *Ani )
{
  RA3_RndMatrWorld = MatrMulMatr(MatrScale(VecSet(1, 1, 1)),
                     MatrMulMatr(MatrRotateY((Uni->TimerSpeed * Ani->Time) * 30 + Uni->TimerShift),
                                 MatrTranslate(VecAddVec(Uni->Pos,
                                 VecMulNum(VecSet(Ani->JX *2, Ani->JY * 2, Ani->JZ * 2), 3)))));
  RA3_RndObjDraw(&Uni->Luigi);
} /* End of 'RA3_UnitRender' function */
Exemple #7
0
/* Unit render function.
 * ARGUMENTS:
 *   - self-pointer to unit object:
 *       ra3UNIT_CUBE *Uni;
 *   - animation context:
 *       ra3ANIM *Ani;
 * RETURNS: None.
 */
static VOID RA3_UnitRender( ra3UNIT_CUBE *Uni, ra3ANIM *Ani )
{
  RA3_RndMatrWorld = MatrMulMatr(MatrScale(VecSet(0.1, 0.1, 0.1)),
                     MatrMulMatr(MatrRotateY((Uni->TimerSpeed * Ani->Time) * 30 + Uni->TimerShift),
                                 MatrTranslate(VecAddVec(Uni->Pos,
                                                         VecMulNum(VecSet(Ani->JX, Ani->JY, Ani->JZ), 3)))));
  RA3_RndPrimDraw(&Cube);
} /* End of 'RA3_UnitRender' function */
Exemple #8
0
/* Unit render function.
 * ARGUMENTS:
 *   - self-pointer to unit object:
 *       VK3UNIT_CUBE *Uni;
 *   - animation context:
 *       VK3ANIM *Ani;
 * RETURNS: None.
 */
static VOID VK3_UnitRender( vk3UNIT_CUBE *Uni, vk3Anim *Ani )
{
  VK3_RndMatrWorld = MatrMulMatr(MatrScale(VecSet(0.1F, 0.1F, 0.1F)),
                     MatrMulMatr(MatrRotateY((Uni->TimerSpeed * Ani->Time) * 30 + Uni->TimerShift),
                                 MatrTranslate(VecAddVec(Uni->Pos,
                                                         VecMulNum(VecSet(Ani->JX, Ani->JY, Ani->JZ), 3)))));
  VK3_RndPrimDraw(&Uni->Pr);
} /* End of ‘VK3_UnitRender' function */
Exemple #9
0
static VOID MP2_UnitResponse( mp2CONTROL *Uni, mp2ANIM *Ani )
{
  DBL r;
  VEC Dir = VecNormalize(VecSubVec(View, Uni->Pos)),
      Right = VecNormalize(VecCrossVec(Dir, VecSet(0, 1, 0)));
  if (Ani->Keys['T'])
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  if (Ani->Keys['Y'])
    glPolygonMode(GL_FRONT, GL_LINE);
  if (Ani->Keys['U'])
    glPolygonMode(GL_BACK, GL_LINE);
  /*if (Ani->Keys[VK_SPACE])
    MP2_AnimAddUnit(MP2_UnitCreateBall()); */
  if (Ani->KeysClick['C'])
    MP2_AnimAddUnit(MP2_UnitCreateCube(/*Rnd1() * 4, Rnd1() * 4, Rnd1() * 4*/0, 0, 0));
  if (Ani->KeysClick['V'])
    MP2_AnimAddUnit(MP2_UnitCreateSTATICMODEL(/*Rnd1() * 4, Rnd1() * 4, Rnd1() * 4*/0, 0, 0));
  if (Ani->KeysClick[VK_RETURN] && Ani->Keys[VK_MENU])
    MP2_FlipFullScreen(MP2_Anim.hWnd);
  /*if (Ani->KeysClick[VK_ESCAPE])
    MP2_AnimDoExit();*/
  if (Ani->KeysClick['P'])
    Ani->IsPause = !Ani->IsPause;

  /* Uni->Pos.Y += Ani->JY * Ani->GlobalDeltaTime; */
  Uni->Pos = PointTransform(Uni->Pos, MatrRotate((50 * Ani->JY * Ani->GlobalDeltaTime), Right));
  Uni->Pos = PointTransform(Uni->Pos, MatrRotateY(10 * Ani->JX * Ani->GlobalDeltaTime));
   

  if (Ani->Keys[VK_LBUTTON])
  {
    Uni->Pos = PointTransform(Uni->Pos, MatrRotateY(10 * Ani->Mdx * Ani->GlobalDeltaTime));
    Uni->Pos = PointTransform(Uni->Pos, MatrRotateX(10 * Ani->Mdy * Ani->GlobalDeltaTime));
  }
  View.X += Ani->JZ / 10;
  View.Z += Ani->JR / 10;
  Uni->Pos = PointTransform(Uni->Pos, MatrRotateY(10 * Ani->Keys[VK_RIGHT] * Ani->GlobalDeltaTime));
  Uni->Pos = PointTransform(Uni->Pos, MatrRotateY(-10 * Ani->Keys[VK_LEFT] * Ani->GlobalDeltaTime));

  r = VecLen(Uni->Pos);
  Uni->Pos = VecMulNum(Uni->Pos, (r + (-Ani->Mdz) * Ani->DeltaTime * 1.0) / r);
  
  MP2_RndMatrView = MatrView(VecAddVec(Uni->Pos, View), View, VecSet(0, 1, 0));
}
Exemple #10
0
/* Функция обновления межкадровых параметров объекта анимации.
 * АРГУМЕНТЫ:
 *   - указатель на "себя" - сам объект анимации:
 *       ao5UNIT_CTRL *Uni;
 *   - указатель на контекст анимации:
 *       ao5ANIM *Ani;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
static VOID AO5_AnimUnitResponse( ao5UNIT_CTRL *Uni, ao5ANIM *Ani )
{
  VEC Move, Dir, At;
  if (Ani->Keys[VK_ESCAPE])
    AO5_AnimDoExit();
  if (Ani->KeysClick['F'])
    AO5_AnimFlipFullScreen();
  if (Ani->KeysClick['P'])
    AO5_AnimSetPause(!Ani->IsPause);
  /* позиционирование корабля */
  //Uni->Omega = -3000 * Ani->JX * Ani->DeltaTime;
  //Uni->Head += -3 * 30 * Ani->JR * Ani->DeltaTime;
  Dir = VectorTransform(VecSet(0, 0, 1), MatrRotateY(Uni->Head));
  //Uni->V += -3 * Ani->JY * Ani->DeltaTime;
  //Uni->V *= max(1 - Ani->GlobalDeltaTime, 0);
  if(Ani->Keys['D'])
    Uni->Head -= 1;
  if(Ani->Keys['A'])
    Uni->Head += 1;
  if(Ani->Keys['W'])
    Uni->V = -5;
  else if(Ani->Keys['S'])
    Uni->V = 5;
  else
    Uni->V = 0;
  Uni->Pos = VecAddVec(Uni->Pos, VecMulNum(Dir, Uni->V * Ani->DeltaTime)); 

  Uni->Pos = VecAddVec(Uni->Pos, VecMulNum(VectorTransform(Dir, MatrRotateY(-90)), Uni->V));
  //Uni->Pos.Y += 30 * (Ani->JButs[1] - Ani->JButs[2]) * Ani->DeltaTime; 

  Uni->At = VecSubVec(Uni->Pos, VecMulNum(Dir, 100));
  Uni->At.Y += 10;
  Move = VecSubVec(Uni->At, Uni->CPos);
  Uni->CPos = VecAddVec(Uni->CPos, VecMulNum(Move, Ani->DeltaTime));
  AO5_RndMatrView = MatrView(Uni->CPos,
                             Uni->Pos,
                             VecSet(0, 1, 0)); 
  AO5_RndMatrWorld = MatrMulMatr(MatrMulMatr(MatrRotateY(Uni->Head), MatrTranslate(Uni->Pos.X, Uni->Pos.Y, Uni->Pos.Z)), MatrScale(0.1, 0.1, 0.1)); 
} /* End of 'AO5_AnimUnitResponse' function */
Exemple #11
0
/* Camera rotation by camera-axes-Up function.
 * ARGUMENTS:
 *   - Angle:
 *       DBL Angle;
 * RETURNS: None.
 */
VOID II2_RndCameraRotateUp( ii2CAMERA *Cam, DBL Angle )
{
  MATR RotMat;

  Cam->Dir = VecSubVec(Cam->At, Cam->Loc);
  Cam->Right = VecCrossVec(VecNormalize(Cam->Dir), Cam->Up);

  II2_RndCameraNormalize(Cam);

  RotMat = II2_RndCameraGetMatrix(Cam);
  RotMat = MatrMulMatr(MatrRotateY(Angle), RotMat);

  Cam->At = VecAddVec(Cam->Loc, VecSet(RotMat.A[0][0], RotMat.A[0][1], RotMat.A[0][2]));
}  /* End of 'II2_RndCameraRotateUp' funciton */
Exemple #12
0
/* Функция построения объекта анимации.
 * АРГУМЕНТЫ:
 *   - указатель на "себя" - сам объект анимации:
 *       ak1UNIT_BALL *Uni;
 *   - указатель на контекст анимации:
 *       ak1ANIM *Ani;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
static VOID AK1_AnimCowRender( ak1UNIT_COW *Uni, ak1ANIM *Ani )
{
  int i, l = -1;
  DBL X1 = Ani->PosX;
  AK1_RndMatrWorld = MatrMulMatr(MatrMulMatr(MatrRotateX(Ani->AngleX), MatrRotateY(Ani->AngleY)), MatrScale(10, 10, 10));
  AK1_RndMatrView = MatrView(VecSet(8, 8, 8), VecSet(0, 0, 0), VecSet(0, 1, 0));
  SetDCPenColor(Ani->hDC, RGB(255, 255, 255));
//  AK1_RndGObjDraw(&Uni->Model);
  for (i = 0; i < 3; i++)
  {
    Ani->PosX = X1 + (i + l) * 600;
    AK1_RndGObjDraw(&Uni->Model);
  }
  Ani->PosX = X1;
} /* End of 'ak1_AnimUnitRender' function */
Exemple #13
0
/* Camera rotation by camera-axes-Up function.
 * ARGUMENTS:
 *   - Angle:
 *       DBL Angle;
 * RETURNS: None.
 */
VOID RK2_RndCameraRotateUp( rk2CAMERA *Cam, DBL Angle )
{
  rk2MATR4x4 RotMat;

  Cam->Dir = VecSubVec(Cam->At, Cam->Loc);
  Cam->Right = VecCrossVec(VecNormalize(Cam->Dir), Cam->Up);

  RK2_RndCameraNormalize(Cam);

  RotMat = RK2_RndCameraGetMatrix(Cam);
  RotMat = MatrMultMatr(MatrRotateY(MatrDefault(), Angle), RotMat);

  RK2_RndCameraSet(Cam, Cam->Loc,                                                                  /* Location */
                   VecSumVec(Cam->Loc, 
                             VecSet(RotMat.A[0][0], RotMat.A[0][1], RotMat.A[0][2])),              /* At */
                   Cam->Up);                                                                       /* Up */
}  /* End of 'RK2_RndCameraRotateUp' funciton */
Exemple #14
0
static VOID CubeUnitRender( as4UNIT_CUBE *Unit, as4ANIM *Ani )
{
  VEC p = {1, 0, 0};
  /*POINT pt;*/

  /*AS4_RndMatrView = MatrViewLookAt(VecSet(5, 5, 5), VecSet(0, 0, 0), VecSet(0, 1, 0));
  AS4_RndMatrWorld = MatrRotateY(Ani->Time * 30);*/

  AS4_RndMatrView = MatrViewLookAt(VecTransform(VecSet(0, 0, 15), MatrRotateX(0)), VecSet(0, 0, 0), VecSet(0, 1, 0));
  AS4_RndMatrWorld = MatrRotateY(-cl.x / 3.0);
  AS4_RndMatrWorld = MatrMulMatr(AS4_RndMatrWorld, MatrRotateX(-cl.y / 3.0));
  AS4_RndMatrWorld = MatrMulMatr(AS4_RndMatrWorld, MatrScale(3.5 - AS4_Anim.JPOV / 8.0, 3.5 - AS4_Anim.JPOV / 8.0, 3.5 - AS4_Anim.JPOV / 8.0));

  SelectObject(Ani->hDC, GetStockObject(NULL_PEN));
  SetDCBrushColor(Ani->hDC, RGB(0, 0, 0));
  AS4_RndGObjDraw(&Unit->Cow, Ani->hDC);
} /* End of 'CubeUnitRender' function */
Exemple #15
0
/* Draw object functioln.
 * ARGUMENTS:
 *   - context of the window:
 *       HDC hDC;
 *   - the size of the window:
 *       INT W, H;
 * RETURNS: None.
 */
VOID ObjDraw( HDC hDC, INT X, INT Y, DWORD Color, PK2ANIM *Ani )
{
  INT i;
  DBL x = sin(30);

  srand(30);
  for (i = 0; i < ObjNumOfV; i++)
  {
    if (!Ani->IsPause)
      ObjV[i] = VecMulMatr3(ObjV[i], MatrMulMatr(MatrRotateY(sin(Ani->Time * 0.5)), MatrRotateX(sin(Ani->Time * 3))));
    else
      ObjV[i] = VecMulMatr3(ObjV[i], MatrIdentity());

    SetDCBrushColor(hDC, Color);
    Ellipse(hDC,X + ObjV[i].X - 4, Y - ObjV[i].Y - 4, X + ObjV[i].X + 4, Y - ObjV[i].Y + 4);
  }

} /* End of 'ObjDraw' function */
Exemple #16
0
/* Функция построения объекта анимации.
 * АРГУМЕНТЫ:
 *   - указатель на "себя" - сам объект анимации:
 *       vg4UNIT_MODEL *Uni;
 *   - указатель на контекст анимации:
 *       vg4ANIM *Ani;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
static VOID VG4_AnimUnitRender( vg4UNIT_MODEL *Uni, vg4ANIM *Ani )
{
  INT i;

  VG4_RndMatrView = MatrView(VecSet(8, 8, 8),
                             VecSet(0, 0, 0),
                             VecSet(0, 1, 0));

  for (i = 0; i < 8; i++)
  {
    VG4_RndMatrWorld =
      MatrMulMatr(MatrMulMatr(MatrMulMatr(
        MatrTranslate(Ani->JX * 59, Ani->JY * 88, 0),
        MatrScale(0.1, 0.1, 0.1)),
        MatrRotateY(30 * Ani->Time + Ani->JR * 180)),
        MatrTranslate((i - 2) * 2, 0, 100 * Ani->JZ));
    VG4_RndGObjDraw(&Uni->Model);
  }
} /* End of 'VG4_AnimUnitRender' function */
Exemple #17
0
/* Функция построения объекта анимации.
* АРГУМЕНТЫ:
*   - указатель на "себя" - сам объект анимации:
*       as3UNIT_MODEL *Uni;
*   - указатель на контекст анимации:
*       as3ANIM *Ani;
* ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
*/
static VOID AS3_AnimUnitRender(as3UNIT_MODEL *Uni, as3ANIM *Ani)
{
    static INT i = 0, j = 0, k = 0;
    if (Ani->JR > 0)
        k += 105;
    if (Ani->JR < -0.0002)
        k -= 105;
    if (Ani->JZ > 0)
        i += 105;
    if (Ani->JZ < -0.0002)
        i -= 105;
    if (Ani->JY > 0)
        j += 1000;
    AS3_RndMatrView = MatrView(VecSet(600 + k, 600 + k, 600 + k), VecSet(i, 0, i), VecSet(0, 1, 0));


    if (Ani->KeysClick['W'])
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    if (Ani->KeysClick['Q'])
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    if (Ani->KeysClick['S'])
        j = 1;
    glEnable(GL_DEPTH_TEST);
    AS3_RndMatrWorld =
        MatrMulMatr(MatrMulMatr(MatrMulMatr(
                                    MatrRotate(0.00001141552511 * 365 * j * Ani->Time, 0, 1, 0),  //Земля
                                    MatrScale(100, 100, 100)),
                                MatrTranslate(0, -50, 1200)),
                    MatrRotateY(0.00001141552511 * j * Ani->Time));
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, Uni->TextId);
    AS3_GeomDraw(&Uni->Geom[0]);
    AS3_RndMatrWorld =
        MatrMulMatr(MatrMulMatr(MatrMulMatr(
                                    MatrRotate(0, 0, 1, 0),  //Солнце
                                    MatrScale(800, 800, 800)),
                                MatrTranslate(0, 0, 0)),
                    MatrRotateY(0));
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, Uni->TextId1);
    AS3_GeomDraw(&Uni->Geom[1]);
    AS3_RndMatrWorld =
        MatrMulMatr(MatrMulMatr(MatrMulMatr(
                                    MatrRotate(0.6 * 0.0004 * j *  Ani->Time, 0, 1, 0),  //Меркурий
                                    MatrScale(30, 30, 30)),
                                MatrTranslate(0, 0, 800)),
                    MatrRotateY(0.0004 * j * Ani->Time));
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, Uni->TextId2);
    AS3_GeomDraw(&Uni->Geom[2]);
    AS3_RndMatrWorld =
        MatrMulMatr(MatrMulMatr(MatrMulMatr(
                                    MatrRotate(-1.1 * 0.0001 * j * Ani->Time, 0, 1, 0),  //Венера
                                    MatrScale(100, 100, 100)),
                                MatrTranslate(0, 0, 1000)),
                    MatrRotateY(0.0001 * j * Ani->Time));
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, Uni->TextId3);
    AS3_GeomDraw(&Uni->Geom[3]);
    AS3_RndMatrWorld =
        MatrMulMatr(MatrMulMatr(MatrMulMatr(
                                    MatrRotate(669 * 0.000006 * j * Ani->Time, 0, 1, 0),  //Марс
                                    MatrScale(90, 90, 90)),
                                MatrTranslate(0, 0, 1500)),
                    MatrRotateY(0.000006 * j * Ani->Time));
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, Uni->TextId4);
    AS3_GeomDraw(&Uni->Geom[4]);
    AS3_RndMatrWorld =
        MatrMulMatr(MatrMulMatr(MatrMulMatr(
                                    MatrRotate(10683 * 0.0000009 * j * Ani->Time, 0, 1, 0),  //Юпитер
                                    MatrScale(500, 500, 500)),
                                MatrTranslate(0, 0, 1800)),
                    MatrRotateY(0.0000009 * j * Ani->Time));
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, Uni->TextId5);
    AS3_GeomDraw(&Uni->Geom[5]);
    AS3_RndMatrWorld =
        MatrMulMatr(MatrMulMatr(MatrMulMatr(
                                    MatrRotate(21170 * 0.0000004 * j * Ani->Time, 0, 1, 0),  //Сатурн
                                    MatrScale(400, 400, 400)),
                                MatrTranslate(0, 0, 2500)),
                    MatrRotateY(0.0000004 * j * Ani->Time));
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, Uni->TextId6);
    AS3_GeomDraw(&Uni->Geom[6]);
    /*
    AS3_RndMatrWorld =
        MatrMulMatr(MatrMulMatr(MatrMulMatr(
        MatrRotate(100 * Ani->Time, 0, 1, 0),  //0.004050925925925926
        MatrScale(10, 8, 10)),
        MatrTranslate(0, 0, 2500)),
        MatrRotateX(-90));
      glActiveTexture(GL_TEXTURE0);
      glBindTexture(GL_TEXTURE_2D, Uni->TextId61);
      AS3_GeomDraw(&Uni->Geom[7]);
    */
    AS3_RndMatrWorld =
        MatrMulMatr(MatrMulMatr(MatrMulMatr(
                                    MatrRotate(43800 * 0.0000001 * j * Ani->Time, 0, 1, 0),  //Уран
                                    MatrScale(350, 350, 350)),
                                MatrTranslate(0, 0, 3000)),
                    MatrRotateY(0.0000001 * j * Ani->Time));
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, Uni->TextId7);
    AS3_GeomDraw(&Uni->Geom[8]);
    AS3_RndMatrWorld =
        MatrMulMatr(MatrMulMatr(MatrMulMatr(
                                    MatrRotate(86036 * 0.00000007 * j * Ani->Time, 0, 1, 0),  //Нептун
                                    MatrScale(350, 350, 350)),
                                MatrTranslate(0, 0, 3500)),
                    MatrRotateY(0.00000007 * j * Ani->Time));
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, Uni->TextId8);
    AS3_GeomDraw(&Uni->Geom[9]);
    AS3_RndMatrWorld =
        MatrMulMatr(MatrMulMatr(MatrMulMatr(
                                    MatrRotate(0, 0, 1, 0),  // nebo
                                    MatrScale(20000, 20000, 20000)),
                                MatrTranslate(0, 0, 0)),
                    MatrRotateY(0));
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, Uni->TextId9);
    AS3_GeomDraw(&Uni->Geom[10]);

} /* End of 'AS3_AnimUnitRender' function */
Exemple #18
0
/* ‘ункци¤ построени¤ объекта анимации.
 * ј–√”ћ≈Ќ“џ:
 *   - указатель на "себ¤" - сам объект анимации:
 *       ok2UNIT_CUBE *Unit;
 *   - указатель на контекст анимации:
 *       ok2ANIM *Ani;
 * ¬ќ«¬–јўј≈ћќ≈ «Ќј„≈Ќ»≈: Ќет.
 */
static VOID CubeUnitRender( ok2UNIT_CUBE *Unit, ok2ANIM *Ani )
{                                                               
  /*
  INT i, s = 5, N = 0;
  VEC p = {1, 0, 0};

  static FLT Delta = 0.1;
  MATR WVP;

  Delta += Ani->JZ * Ani->GlobalDeltaTime;

  //Ani->MatrWorld = MatrRotateY(30);
  //Ani->MatrView = MatrLookAt(VecSet(15, 15, 15), VecSet(0, 0, 0), VecSet(0, 1, 0));
  Ani->MatrView = MatrLookAt(PointTransform(VecSet(20, 20, Ani->JX * Delta + 20), MatrRotateX(80 * Ani->JY)), VecSet(0, 0, 0), VecSet(0, 1, 0));
  Ani->MatrWorld = MatrMulMatr(Ani->MatrWorld, MatrRotateX(Ani->DeltaTime * 80));
  

  for (i = 0; i < 12; i++)
  {
    
    Ani->MatrWorld = MatrMulMatr(MatrTranslate(0.0, 5.0, 0.0), Ani->MatrWorld);
    Ani->MatrWorld = MatrMulMatr(MatrRotate(30, 1.0, 0.0, 1.0), Ani->MatrWorld);
    
    WVP = MatrMulMatr(Ani->MatrWorld,
      MatrMulMatr(Ani->MatrView, Ani->MatrProjection));
    glLoadMatrixf(WVP.A[0]);
    OK2_RndGObjDraw(&Unit->Cow, Ani->hDC);
  }
  
  //OK2_RndGObjDraw(&Unit->Cow, Ani->hDC); 
  
  */

  
  INT i;
  MATR WVP;
  static DBL time;

  /* оси и позици¤ наблюдател¤ */
  Ani->MatrWorld = MatrIdenity();
  Ani->MatrView =
    MatrLookAt(
    PointTransform(PointTransform(VecSet(25, 25, 25), MatrRotateY(Ani->JR * 180)), MatrRotateZ(Ani->JY * 180)),
      VecSet(0, 0, 0), VecSet(0, 1, 0));
  WVP = MatrMulMatr(OK2_Anim.MatrWorld, MatrMulMatr(OK2_Anim.MatrView, OK2_Anim.MatrProjection));
  glLoadMatrixf(WVP.A[0]);

  glLineWidth(3);
  glBegin(GL_LINES);
    glColor3d(1, 0.5, 0.5);
    glVertex3d(-3, 0, 0);
    glVertex4d(1, 0, 0, 0);
    glColor3d(0.5, 1, 0.5);
    glVertex3d(0, -3, 0);
    glVertex4d(0, 1, 0, 0);
    glColor3d(0.5, 0.5, 1);
    glVertex3d(0, 0, -3);
    glVertex4d(0, 0, 1, 0);
  glEnd();
  glColorMask(1, 1, 1, 0);
  for (i = -3; i < 30; i++)
  {
    glBegin(GL_TRIANGLE_STRIP);
    glVertex3d(-0.1, -0.1, i);
    glVertex3d(-0.1,  0.1, i);
    glVertex3d( 0.1, -0.1, i);
    glVertex3d( 0.1,  0.1, i);
    glEnd();
  }

  /* –исуем примитивы */
  time += Ani->GlobalDeltaTime;
  if (time > 1)
  {
    time = 0;
    OK2_ShadProgClose(OK2_ShaderProg);
    OK2_ShaderProg = OK2_ShadProgInit("a.vert", "a.frag");
  }


  glLineWidth(1);
  if (Ani->Keys['Q'])
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
  else
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

  //Ani->MatrWorld = MatrTranslate(0, 0, 0.30 * sin(Ani->Time));
  Ani->MatrWorld = MatrMulMatr(Ani->MatrWorld, MatrRotateY(30.0 * Ani->Time));
  /*
  for (i = 0; i < 12; i++)
  {
    Ani->MatrWorld = MatrMulMatr(MatrRotate(30.0, 0.0, 1.0, 0.0), Ani->MatrWorld);
    Ani->MatrWorld = MatrMulMatr(MatrTranslate(1.0, 0.0, 0.0), Ani->MatrWorld);
    OK2_GeomDraw(&Unit->Geom);
  }
  */
  /*
  for (i = 0; i < 6; i++)
    DrawUnitInPosition(&Unit->Geom[i], Ani, Unit->Scale`[i], 10.0, 30.0);
  */
  Ani->MatrWorld = MatrMulMatr(Ani->MatrWorld, MatrScale(0.001, 0.001, 0.001));

  for (i = 0; i < 12; i++)
  {
    Ani->MatrWorld = MatrMulMatr(MatrRotate(30.0, 0.0, 1.0, 0.0), Ani->MatrWorld);
    Ani->MatrWorld = MatrMulMatr(MatrTranslate(20000.0, 0.0, 0.0), Ani->MatrWorld);
    //Ani->MatrWorld = MatrMulMatr(MatrRotate(30.0, 0.0, 1.0, 0.0), Ani->MatrWorld);
    OK2_GeomDraw(&Unit->Geom[3]);
    Ani->MatrWorld = MatrMulMatr(MatrTranslate(-20000.0, 0.0, 0.0), Ani->MatrWorld);
    
  }
  //Ani->MatrWorld = MatrMulMatr(Ani->MatrWorld, MatrScale(50, 50, 50));
   
} /* End of 'OK2_AnimUnitRender' function */
Exemple #19
0
/* Функция обновления межкадровых параметров объекта анимации.
 * АРГУМЕНТЫ:
 *   - указатель на "себя" - сам объект анимации:
 *       vg4UNIT_CTRL *Uni;
 *   - указатель на контекст анимации:
 *       vg4ANIM *Ani;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
static VOID VG4_AnimUnitResponse( vg4UNIT_CTRL *Uni, vg4ANIM *Ani )
{
  VEC Dir, Move;
  static FLT y = -0.067452297, z = 2.6340842;
  static DBL time = 5;

  time += VG4_Anim.GlobalDeltaTime;
  if (time > 5)
  {
    time = 0;
    VG4_ShaderFree(Uni->Axes.ProgId);
    VG4_ShaderFree(Uni->Helic.ProgId);
    Uni->Helic.ProgId = VG4_ShaderLoad("HELIC");
    Uni->Axes.ProgId = VG4_ShaderLoad("AXIS");
    Uni->Sph.ProgId = Uni->Axes.ProgId;
  }

  /* позиционирование вертолета */
  Uni->Omega = -3000 * Ani->JR * Ani->DeltaTime;
  Uni->Head += -3 * 30 * Ani->JR * Ani->DeltaTime;

  Dir = VecMulMatr3(VecSet(0, 0, 1), MatrRotateY(Uni->Head));

  Uni->V += -30 * Ani->JY * Ani->DeltaTime;
  Uni->V *= max(1 - Ani->GlobalDeltaTime, 0);
  Uni->Pos = VecAddVec(Uni->Pos, VecMulNum(Dir, Uni->V * Ani->DeltaTime));

  Uni->Pos = VecAddVec(Uni->Pos, VecMulNum(VecMulMatr3(Dir, MatrRotateY(-90)), 30 * Ani->JX * Ani->DeltaTime));

  Uni->Pos.Y += 30 * (Ani->JButs[1] - Ani->JButs[2]) * Ani->DeltaTime;

  /* точка "интереса" */
  Uni->At = VecSubVec(Uni->Pos, VecMulNum(Dir, 9));
  Uni->At.Y += 5.30;

  Move = VecSubVec(Uni->At, Uni->CPos);
  Uni->CPos = VecAddVec(Uni->CPos, VecMulNum(Move, Ani->DeltaTime));



  VG4_RndMatrView = MatrView(Uni->CPos,
                             Uni->Pos,
                             VecSet(0, 1, 0));

  if (Ani->KeysClick['W'])
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
  if (Ani->KeysClick['Q'])
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  if (Ani->Keys[VK_ESCAPE])
    VG4_AnimDoExit();
  if (Ani->KeysClick['F'])
    VG4_AnimFlipFullScreen();
  if (Ani->KeysClick['P'])
    VG4_AnimSetPause(!Ani->IsPause);

  /* анимация вертолета */
  Uni->Helic.Prims[2].M = MatrRotateY(999 * Ani->Time);
  Uni->Helic.Prims[4].M = MatrMulMatr(MatrMulMatr(MatrTranslate(0, y, z), MatrRotateX(888 * Ani->Time)), MatrTranslate(0, -y, -z));
  y += Ani->Keys[VK_ADD] * Ani->GlobalDeltaTime * 0.1 - Ani->Keys[VK_SUBTRACT] * Ani->GlobalDeltaTime * 0.1;
  z += Ani->Keys['A'] * Ani->GlobalDeltaTime * 0.1 - Ani->Keys['Z'] * Ani->GlobalDeltaTime * 0.1;
} /* End of 'VG4_AnimUnitResponse' function */
Exemple #20
0
  mtl.Ka = VecSet(0.1, 0.1, 0.1);
  mtl.Kd = VecSet(1, 1, 1);
  mtl.Ks = VecSet(0, 0, 0);
  mtl.Phong = 30;
  mtl.Trans = 1;
  mtl.TexNo = 0;
  mtl.MapD[0] = 0;
  strcpy(mtl.MapD, "map2-hf.bmp");
  strcpy(mtl.Name, "Height Field Material");
  prim.Mtl = VG4_GeomAddMaterial(&Unit->Obj, &mtl);

  VG4_GeomAddPrim(&Unit->Obj, &prim);

. . .

  Ani->MatrWorld = MatrIdentity();
  Ani->MatrView =
    MatrViewLookAt(
      VecMulMatr(VecMulMatr(VecSet(25, 25, 25), MatrRotateY(Ani->JR * 180)), MatrRotateZ(Ani->JY * 180)),
      VecSet(0, 0, 0), VecSet(0, 1, 0));
  WVP = MatrMulMatr(VG4_Anim.MatrWorld,
    MatrMulMatr(VG4_Anim.MatrView, VG4_Anim.MatrProjection));
  glLoadMatrixf(WVP.A[0]);
. . .
  Ani->MatrWorld = MatrMulMatr(MatrRotateX(-0), MatrTranslate(0, 0, 0.30 * sin(Ani->Time)));
  VG4_GeomDraw(&Unit->Obj);