⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 castlescene.h

📁 Ion Team Lord Of The Rings Demo 模拟指环王的3D游戏 VS.NET编译 里面提供高级渲染算法
💻 H
📖 第 1 页 / 共 2 页
字号:
#define NUMBER_OF_GANDALF_CASTLE_MOVEMENTS 50
#define NUMBER_OF_KNIGHT_MOVEMENTS 50


#define SAURON_POSESSES_MONSTER 0
#define ENDED_FADE 1
#define GANDALF_SPELL1 2
#define GANDALF_SPELL2 3
#define SAURON_SPELL 4

#define SOUND_DISTANCE_FACTOR 0.5

BezCam caCam(0.01f,0.75f);
CMap caMap;
//FSOUND_SAMPLE *caGandySpell1, *caGandySpell2, *caKnightSpell;
int caParticleSystem[10];

bool caFlags[NUMBER_OF_FLAGS];

Md2Model caGandalf, caKnight,caKnightWeapon;
CharMovement caGandalfMovements[NUMBER_OF_GANDALF_CASTLE_MOVEMENTS];
CharMovement caKnightMovements[NUMBER_OF_KNIGHT_MOVEMENTS];
float caGandalfAnimationFraction, caKnightAnimationFraction;
int caGandalfMovementIndex, caKnightMovementIndex, Sauron, BarrierTex;



void CastleSceneInit()
{

  caMap.Init("Data/Castle.cmf");
  caGandalf.Load("Data/ModelsAndSkins/Gandalf/Gandalf.md2", "Data/ModelsAndSkins/Gandalf/GandalfThePurple.jpg");
  caGandalf.SetAnimation("Stand");
  caKnight.Load("Data/ModelsAndSkins/KnightOfEvil/Knight.md2", "Data/ModelsAndSkins/KnightOfEvil/KnightGood.jpg");
  caKnight.SetAnimation("stand");
  caKnightWeapon.Load("Data/ModelsAndSkins/KnightOfEvil/Weapon.md2", "Data/ModelsAndSkins/KnightOfEvil/Weapon.jpg");
  caKnightWeapon.SetAnimation("stand");

  caKnight.Animations[caKnight.iNumOfAnims].Name="death1";
  caKnight.Animations[caKnight.iNumOfAnims].Start=178;
  caKnight.Animations[caKnight.iNumOfAnims].End=183;
  caKnight.iNumOfAnims++;

  caCam.LoadFromFile("Data/Paths/Barad_Dur.path");
  //caCam.LoadFromFile("Data/Record.path");

  Sauron = LoadTexture("Data/Images/Sauron.jpg",CT_FIND);
	BarrierTex = LoadTexture("Data/Images/MagicBarrier.jpg",CT_FIND);
  for (int i=0;i<NUMBER_OF_FLAGS;i++)
    caFlags[i]=false;

/*	caGandySpell1 = Sound.Load("Data/Sounds/Chicken.wav",true,CS_WAV);
	caGandySpell1 = Sound.Load("Data/Sounds/GandySpell1.mp3",true,CS_MP3);
	caGandySpell2 = Sound.Load("Data/Sounds/GandySpell2.mp3",true,CS_MP3);
	caKnightSpell = Sound.Load("Data/Sounds/KnightSpell.mp3",true,CS_MP3);*/

	glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);			// Set The Texture Generation Mode For S To Sphere Mapping ( NEW )
	glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);			// Set The Texture Generation Mode For T To Sphere Mapping ( NEW )


#include "CastleSceneKnightMovements.h"
#include "CastleSceneGandalfMovements.h"
}


void CastleSceneRenderNextFrame(float Milliseconds)
{
  static bool Record=false, DrawPath=false;
  static int FrameCount, FrameRate;
  static float Second=0.0f;
  static bool started=false;
  if (!started)
    {
      started=true;
      LightManager.Enable(GL_LIGHT1);
      LightManager.SetAmbientColor(GL_LIGHT1,0.7f,0.7f,0.7f,1.0f);
      LightManager.SetDiffuseColor(GL_LIGHT1,1.0f,1.0f,1.0f,1.0f);
      fpvCam.StartRecord("Data\\Record.path");

#include "CastleSceneParticles.h"

    }



  // UPDATE!

  static float temptime=0.0f, TotalTime=0.0f, CamPointTime=0.0f;
  temptime+=Milliseconds;
  Second+=Milliseconds;
  FrameCount++;
  if (Second>=1000.0f)
    {
      Second=0.0f;
      FrameRate=FrameCount;
      FrameCount=0;
    }
 
  TotalTime+=Milliseconds;
  PGod.Update(Milliseconds);

 






      caCam.LookAtNextPoint(Milliseconds*0.05);
      caCam.Position();

  LightManager.SetPosition(GL_LIGHT1,13.5f,2.0f,6.0f);
	if (TotalTime<10000.0f)
	{
		float t=TotalTime*0.0001f;
		LightManager.SetAmbientColor(GL_LIGHT1,0.7f*t,0.7f*t,0.7f*t,1.0f);
		LightManager.SetDiffuseColor(GL_LIGHT1,1.0f*t,1.0f*t,1.0f*t,1.0f);
	}
	else if (!caFlags[ENDED_FADE])
	{
		caFlags[ENDED_FADE]=true;
    LightManager.SetAmbientColor(GL_LIGHT1,0.7f,0.7f,0.7f,1.0f);
    LightManager.SetDiffuseColor(GL_LIGHT1,1.0f,1.0f,1.0f,1.0f);
	}
	caMap.Draw();
  if (DrawPath)
    {
      caCam.DrawCurves();
      caCam.DrawPoints();
    }

  glPushMatrix();
  caKnightAnimationFraction+=Milliseconds*caKnightMovements[caKnightMovementIndex].TimeFactor;
  if (caKnightAnimationFraction>=0.99f)
    {
      caKnightMovementIndex++;
      caKnightAnimationFraction=0.0f;
      if (caKnightMovements[caKnightMovementIndex].ChangeAnimation)
        {
          if (caKnightMovements[caKnightMovementIndex].NewAnimation!="")
            {
              caKnight.SetAnimation(caKnightMovements[caKnightMovementIndex].NewAnimation);
              caKnightWeapon.SetAnimation(caKnightMovements[caKnightMovementIndex].NewAnimation);
            }
          else
            {
              caKnight.SetFrames(caKnightMovements[caKnightMovementIndex].Frame1,caKnightMovements[caKnightMovementIndex].Frame2);
              caKnightWeapon.SetFrames(caKnightMovements[caKnightMovementIndex].Frame1,caKnightMovements[caKnightMovementIndex].Frame2);
            }
        }
    }
  glTranslatef(	caKnightMovements[caKnightMovementIndex].Position.Coords[0] +((caKnightMovements[caKnightMovementIndex+1].Position.Coords[0]-caKnightMovements[caKnightMovementIndex].Position.Coords[0])*caKnightAnimationFraction),
                caKnightMovements[caKnightMovementIndex].Position.Coords[1]+((caKnightMovements[caKnightMovementIndex+1].Position.Coords[1]-caKnightMovements[caKnightMovementIndex].Position.Coords[1])*caKnightAnimationFraction),
                caKnightMovements[caKnightMovementIndex].Position.Coords[2]+((caKnightMovements[caKnightMovementIndex+1].Position.Coords[2]-caKnightMovements[caKnightMovementIndex].Position.Coords[2])*caKnightAnimationFraction));
  glScalef(0.06f,0.06f,0.06f);
  glRotatef(caKnightMovements[caKnightMovementIndex].Rotation.Coords[0],1,0,0);
  glRotatef(caKnightMovements[caKnightMovementIndex].Rotation.Coords[1],0,1,0);
  glRotatef(caKnightMovements[caKnightMovementIndex].Rotation.Coords[2],0,0,1);
  if (!caKnightMovements[caKnightMovementIndex].TwoFrameInterpolation)
    if (caKnightMovementIndex!=3 && caKnightMovementIndex!=10 && caKnightMovementIndex!=11 && caKnightMovementIndex!=16 && caKnightMovementIndex!=22) // if this is a looping frame :)
      {
        caKnight.Animate(caKnightAnimationFraction,true);
        if (TotalTime>25000.0f && TotalTime<108900.0f)
          caKnightWeapon.Animate(caKnightAnimationFraction,true);
      }
    else
      {
        caKnight.Animate(caKnightAnimationFraction,false);
        if (TotalTime>25000.0f && TotalTime<108900.0f)
          caKnightWeapon.Animate(caKnightAnimationFraction,false);
      }
  else
    {
      caKnight.TwoFrameInterpolate(caKnightAnimationFraction, //Interpolate two frames
                                   caKnightMovements[caKnightMovementIndex].Frame1,
                                   caKnightMovements[caKnightMovementIndex].Frame2);
      
			if (TotalTime>25000.0f && TotalTime<108900.0f 
					&& caKnightMovements[caKnightMovementIndex].Frame1<caKnightWeapon.Header.iNumFrames
					&& caKnightMovements[caKnightMovementIndex].Frame2<caKnightWeapon.Header.iNumFrames) //if the weapon should and can be drawn :)
        caKnightWeapon.TwoFrameInterpolate(caKnightAnimationFraction,
                                           caKnightMovements[caKnightMovementIndex].Frame1,
                                           caKnightMovements[caKnightMovementIndex].Frame2);
    }
  glPopMatrix();

  glPushMatrix();
  caGandalfAnimationFraction+=Milliseconds*caGandalfMovements[caGandalfMovementIndex].TimeFactor;
  if (caGandalfAnimationFraction>=0.99f)
    {
      caGandalfMovementIndex++;
      caGandalfAnimationFraction=0.0f;
      if (caGandalfMovements[caGandalfMovementIndex].ChangeAnimation)
        caGandalf.SetAnimation(caGandalfMovements[caGandalfMovementIndex].NewAnimation);
    }
  glTranslatef(	caGandalfMovements[caGandalfMovementIndex].Position.Coords[0] +((caGandalfMovements[caGandalfMovementIndex+1].Position.Coords[0]-caGandalfMovements[caGandalfMovementIndex].Position.Coords[0])*caGandalfAnimationFraction),
                caGandalfMovements[caGandalfMovementIndex].Position.Coords[1]+((caGandalfMovements[caGandalfMovementIndex+1].Position.Coords[1]-caGandalfMovements[caGandalfMovementIndex].Position.Coords[1])*caGandalfAnimationFraction),
                caGandalfMovements[caGandalfMovementIndex].Position.Coords[2]+((caGandalfMovements[caGandalfMovementIndex+1].Position.Coords[2]-caGandalfMovements[caGandalfMovementIndex].Position.Coords[2])*caGandalfAnimationFraction));
  glScalef(0.06f,0.06f,0.06f);
  glRotatef(caGandalfMovements[caGandalfMovementIndex].Rotation.Coords[0],1,0,0);
  glRotatef(caGandalfMovements[caGandalfMovementIndex].Rotation.Coords[1],0,1,0);
  glRotatef(caGandalfMovements[caGandalfMovementIndex].Rotation.Coords[2],0,0,1);
  if (!caGandalfMovements[caGandalfMovementIndex].TwoFrameInterpolation)
    caGandalf.Animate(caGandalfAnimationFraction,false);

  else
    caGandalf.TwoFrameInterpolate(caGandalfAnimationFraction,
                                  caGandalfMovements[caGandalfMovementIndex].Frame1,
                                  caGandalfMovements[caGandalfMovementIndex].Frame2);
  glPopMatrix();




  if (TotalTime>18000.0f)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -