资源简介

OPenGL采用LOD等技术对地形进行时适渲染.该程序为一论坛中下载保存,感觉不错.需要的朋友可参考.

资源截图

代码片段和文件信息

/*
   Class Name:

      CCommandscript.h.

   Created by:

      Allen Sherrod (Programming Ace of www.UltimateGameProgramming.com).

   Description:

      This class represents a simple command scripting system.
*/


#include“CCommandscript.h“
#include

using std::ifstream;
using std::filebuf;
using std::ios;


CCommandscript::CCommandscript() : totalscriptLines(0) currentLine(0)
                                   currentLineChar(0) m_script(0)
{
}


CCommandscript::~CCommandscript()
{
   Shutdown();
}


bool CCommandscript::LoadscriptFile(char *filename)
{
   ifstream input input2;
   char tempLine[MAX_LINE_SIZE];
   
   input.open(filename);
   if(!input.is_open()) 
   return false;
   
   Shutdown();

   // Open and get number of lines.
   while(!input.eof())
      {
         input.getline(tempLine MAX_LINE_SIZE ‘\n‘);
         totalscriptLines++;
      }
   
   input.close();
   
   input2.open(filename);
   if(!input2.is_open()) return false;

   // Load in every line of text.   
   m_script = new char*[totalscriptLines];
   
   for(int i = 0; i < totalscriptLines; i++)
      {
         m_script[i] = new char[MAX_LINE_SIZE + 1];
         input2.getline(m_script[i] MAX_LINE_SIZE ‘\n‘);
      }
   
   input2.close();
   return true;
}


void CCommandscript::ParseCommand(char *destCommand)
{
   // This function will take the first word of the current
   // line and save it in destCommand.

   int commandSize = 0;

   // If destcommand is NULL or if we run out of lines or at the end
   // of the current line then we return.
   if(!destCommand) return;
   if(currentLine >= totalscriptLines) return;
   if(currentLineChar >= (int)strlen(m_script[currentLine]))
      {
         // Its easier to just treat it as a comment.
         destCommand[0] = ‘#‘;
         destCommand[1] = ‘\0‘;
         return;
      }

   // Init string.
   destCommand[0] = ‘\0‘;
   
   // Since commands start each line we can say that if there is
   // a # at the start of the line then this is a comment.
   if(IsLineComment())
      {
         destCommand[0] = ‘#‘;
         destCommand[1] = ‘\0‘;
         return;
      }

   // Loop through every character until you find a space or newline.
   // That means we are at the end of a command.
   while(currentLineChar < (int)strlen(m_script[currentLine]))
      {
         if(m_script[currentLine][currentLineChar] == ‘ ‘ ||
            m_script[currentLine][currentLineChar] == ‘\n‘)
            break;

         // Save the text in the array.
         destCommand[commandSize] = m_script[currentLine][currentLineChar];
         commandSize++;
         currentLineChar++;
      }

   // Skip next space or newline.
   currentLineChar++;
   destCommand[commandSize] = ‘\0‘;
}


void CCommandscript::ParseStringParam(char *destString)
{
   // This function will take a text inside “ and “ and sa

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       8955  2007-03-06 22:22  地层时适渲染(LOD)\APP.CPP

     文件       8663  2007-03-06 22:16  地层时适渲染(LOD)\CAMERA.CPP

     文件       1549  2007-03-06 21:57  地层时适渲染(LOD)\CAMERA.H

     文件       8807  2007-03-05 18:45  地层时适渲染(LOD)\CCommandscript.cpp

     文件       1188  2006-12-12 18:43  地层时适渲染(LOD)\CCommandscript.h

     文件        475  2007-03-07 15:03  地层时适渲染(LOD)\CONFIG.INI

     文件       4085  2007-03-06 20:07  地层时适渲染(LOD)\CTgaLoader.cpp

     文件        853  2007-03-05 19:36  地层时适渲染(LOD)\CTgaLoader.h

     文件    1050625  2007-02-12 23:10  地层时适渲染(LOD)\DATA\1.RAW

     文件     197147  2000-12-11 21:13  地层时适渲染(LOD)\DATA\Colour0.tga

     文件     196626  2001-03-04 14:26  地层时适渲染(LOD)\DATA\Colour1.tga

     文件    3145728  2009-05-22 18:03  地层时适渲染(LOD)\DATA\Colour1024.raw

     文件     196626  2001-02-16 23:52  地层时适渲染(LOD)\DATA\Colour2.tga

     文件     196626  2001-03-04 15:27  地层时适渲染(LOD)\DATA\Colour3.tga

     文件     786971  2000-11-13 15:17  地层时适渲染(LOD)\DATA\DETAIL.TGA

     文件     196626  2001-03-05 13:18  地层时适渲染(LOD)\DATA\sky.tga

     文件    1050625  2009-05-22 17:57  地层时适渲染(LOD)\DATA\vars.raw

     文件       4449  2005-11-25 15:01  地层时适渲染(LOD)\Demo.cpp

     文件      84672  2005-11-25 14:59  地层时适渲染(LOD)\DEMO.DAT

     文件       1698  2005-11-25 14:55  地层时适渲染(LOD)\Demo.h

     文件        775  2004-02-25 15:28  地层时适渲染(LOD)\Doc\threadmarks.files\FEATURES.CSS

     文件       4858  2004-02-25 15:27  地层时适渲染(LOD)\Doc\threadmarks.files\turner_01.gif

     文件       5865  2004-02-25 15:27  地层时适渲染(LOD)\Doc\threadmarks.files\turner_02.gif

     文件       5925  2004-02-25 15:27  地层时适渲染(LOD)\Doc\threadmarks.files\turner_03a.gif

     文件       7538  2004-02-25 15:27  地层时适渲染(LOD)\Doc\threadmarks.files\turner_03b.gif

     文件       9654  2004-02-25 15:27  地层时适渲染(LOD)\Doc\threadmarks.files\turner_03c.gif

     文件      13278  2004-02-25 15:28  地层时适渲染(LOD)\Doc\threadmarks.files\turner_04.gif

     文件       7498  2004-02-25 15:28  地层时适渲染(LOD)\Doc\threadmarks.files\turner_05a.gif

     文件      13438  2004-02-25 15:28  地层时适渲染(LOD)\Doc\threadmarks.files\turner_05b.gif

     文件      16779  2004-02-25 15:28  地层时适渲染(LOD)\Doc\threadmarks.files\turner_05c.gif

............此处省略43个文件信息

评论

共有 条评论