コード例 #1
0
WorldModelGroup::WorldModelGroup( std::string path, int groupIndex ) : GroupIndex(groupIndex), MOBA(NULL), IsBad(false)
{
    Data = new ChunkedData(path);
    if (!Data->Stream)
    {
        IsBad = true;
        return;
    }
    Chunk* mainChunk = Data->GetChunkByName("MOGP");
    int32 firstSub = mainChunk->FindSubChunkOffset("MOPY");
    if (firstSub == -1)
        return;

    Name = Utils::GetPlainName(path.c_str());

    FILE* stream = mainChunk->GetStream();
    fseek(stream, firstSub, SEEK_SET);
    SubData = new ChunkedData(stream, mainChunk->Length - firstSub);

    ReadHeader();
    ReadMaterials();
    ReadTriangles();
    ReadVertices();
    ReadNormals();
    ReadLiquid();
    ReadBatches();
}
コード例 #2
0
ファイル: subgraphvertex.cpp プロジェクト: CodEnFisH/Dryad
void DryadSubGraphVertex::Initialize(UInt32 numberOfInputChannels,
                                     UInt32 numberOfOutputChannels)
{
    DrError err;

    DryadMetaData* metaData = GetMetaData();

    if (metaData == NULL)
    {
        ReportError(DryadError_VertexInitialization,
                    "No MetaData In Start Command");
        return;
    }

    DryadMetaDataRef graphData;
    err = metaData->LookUpMetaData(DryadTag_GraphDescription, &graphData);
    if (err != DrError_OK)
    {
        ReportError(DryadError_VertexInitialization,
                    "No GraphDescription Tag");
        return;
    }

    ReadVertices(graphData);

    if (NoError() == false)
    {
        return;
    }

    ReadEdges(graphData);
}
コード例 #3
0
int main(){

  //PARTICLE pd,pnd;
  PARTICLE *p,*pn;
  p=malloc(sizeof(PARTICLE)); //need to allocate memory to pointer

  tVertex v;

  ReadVertices(p);
  ReadEdges(p);

 
    float     x0, y0, z0, x1, y1, z1;
    tEdge   e;
    
    e = p->edges;
    do{
        x0=e->endpts[0]->v[X];
        y0=e->endpts[0]->v[Y];
        z0=e->endpts[0]->v[Z];
        x1=e->endpts[1]->v[X];
        y1=e->endpts[1]->v[Y];
        z1=e->endpts[1]->v[Z];
        printf("%.2f  %.2f  %.2f  %.2f  %.2f  %.2f\n",x0,y0,z0,x1,y1,z1);
        e=e->next;
    } while(e != p->edges);

/*
	double dDelta,t,tmax;
  int i;
  dDelta=0.01;
  t=0;
  tmax=15;

  vecZero(p->r);
  vecSet(p->v,0.5,0.,0);
  vecZero(p->a);
  p->mass=1.;
  p->rad=0.5;

  while (t<tmax){

		  //printf("%f  %f  %f  %f\n",t,p->r[0],p->r[1],p->r[2]);
  
    for (i=0;i<3;i++){
      p->v[i]=p->v[i]+(0.5*dDelta*p->a[i]); //kick
    }

    for (i=0;i<3;i++){
  	  p->r[i]=p->r[i]+(dDelta*p->v[i]); //drift
    }
    
    for (i=0;i<3;i++){
      p->v[i]=p->v[i]+(0.5*dDelta*p->a[i]); //kick
    }
    t+=dDelta;
  }
*/
  return 0;
}
コード例 #4
0
void C3DSLoader::ReadNextObjChunk(t3DModel *pModel, t3DObject *pObject, tChunk *pPreChunk)   
{      
	int buffer[50000] = {0};              
	m_CurrentChunk = new tChunk;   
  
	while (pPreChunk->bytesRead < pPreChunk->length)   
	{      
		ReadChunk(m_CurrentChunk);   
  
		switch (m_CurrentChunk->ID)   
		{   
		case OBJ_MESH:                   
			ReadNextObjChunk(pModel, pObject, m_CurrentChunk);   
			break;   
		case OBJ_VERTICES:             
			ReadVertices(pObject, m_CurrentChunk);   
			break;   
		case OBJ_FACES:                  
			ReadVertexIndices(pObject, m_CurrentChunk);   
			break;   
		case OBJ_MATERIAL:              
			ReadObjMat(pModel, pObject, m_CurrentChunk);               
			break;   
		case OBJ_UV:                      
			ReadUVCoordinates(pObject, m_CurrentChunk);   
			break;   
		default:     
			m_CurrentChunk->bytesRead += fread(buffer, 1, m_CurrentChunk->length - m_CurrentChunk->bytesRead, m_FilePointer);   
			break;   
		}      
		pPreChunk->bytesRead += m_CurrentChunk->bytesRead;   
	}   
	delete m_CurrentChunk;   
	m_CurrentChunk = pPreChunk;   
}   
コード例 #5
0
bool M3DLoader::LoadM3d(const std::string& filename, 
						std::vector<Vertex::PosNormalTexTan>& vertices,
						std::vector<USHORT>& indices,
						std::vector<MeshGeometry::Subset>& subsets,
						std::vector<M3dMaterial>& mats)
{
	std::ifstream fin(filename);

	UINT numMaterials = 0;
	UINT numVertices  = 0;
	UINT numTriangles = 0;
	UINT numBones     = 0;
	UINT numAnimationClips = 0;

	std::string ignore;

	if( fin )
	{
		fin >> ignore; // file header text
		fin >> ignore >> numMaterials;
		fin >> ignore >> numVertices;
		fin >> ignore >> numTriangles;
		fin >> ignore >> numBones;
		fin >> ignore >> numAnimationClips;
 
		ReadMaterials(fin, numMaterials, mats);
		ReadSubsetTable(fin, numMaterials, subsets);
	    ReadVertices(fin, numVertices, vertices);
	    ReadTriangles(fin, numTriangles, indices);
 
		return true;
	 }
    return false;
}
コード例 #6
0
ファイル: tri.c プロジェクト: Bmcentee148/C-Programming
main()
{
   ReadVertices();
   PrintVertices();
   printf("%%Area of polygon = %g\n", 0.5 * AreaPoly2() );
   Triangulate();
   printf("showpage\n%%%%EOF\n");
}
コード例 #7
0
ファイル: 3ds.cpp プロジェクト: Vordok/Projects
void CLoad3DS::ProcessNextObjectChunk(t3DModel *pModel, t3DObject *pObject, tChunk *pPreviousChunk)
{
	// The current chunk to work with
	tChunk currentChunk = {0};

	// Continue to read these chunks until we read the end of this sub chunk
	while (pPreviousChunk->bytesRead < pPreviousChunk->length)
	{
		// Read the next chunk
		ReadChunk(&currentChunk);

		// Check which chunk we just read
		switch (currentChunk.ID)
		{
		case OBJECT_MESH:					// This lets us know that we are reading a new object
		
			// We found a new object, so let's read in it's info using recursion
			ProcessNextObjectChunk(pModel, pObject, &currentChunk);
			break;

		case OBJECT_VERTICES:				// This is the objects vertices
			ReadVertices(pObject, &currentChunk);
			break;

		case OBJECT_FACES:					// This is the objects face information
			ReadVertexIndices(pObject, &currentChunk);
			break;

		case OBJECT_MATERIAL:				// This holds the material name that the object has
			
			// This chunk holds the name of the material that the object has assigned to it.
			// This could either be just a color or a texture map.  This chunk also holds
			// the faces that the texture is assigned to (In the case that there is multiple
			// textures assigned to one object, or it just has a texture on a part of the object.
			// Since most of my game objects just have the texture around the whole object, and 
			// they aren't multitextured, I just want the material name.

			// We now will read the name of the material assigned to this object
			ReadObjectMaterial(pModel, pObject, &currentChunk);			
			break;

		case OBJECT_UV:						// This holds the UV texture coordinates for the object

			// This chunk holds all of the UV coordinates for our object.  Let's read them in.
			ReadUVCoordinates(pObject, &currentChunk);
			break;

		default:  

			// Read past the ignored or unknown chunks
			currentChunk.bytesRead += fread(gBuffer, 1, currentChunk.length - currentChunk.bytesRead, m_FilePointer);
			break;
		}

		// Add the bytes read from the last chunk to the previous chunk passed in.
		pPreviousChunk->bytesRead += currentChunk.bytesRead;
	}
}
コード例 #8
0
ファイル: Model_Loader.cpp プロジェクト: sknutson/Base_Repo
void ModelLoader::ProcessNextObjectChunk(Model3DS *pModel, Object3DS *pObject, Chunk *pPreviousChunk)
{
	// The current chunk to work with
	Chunk currentChunk = {0};

	// Continue to read these chunks until we read the end of this sub chunk
	while (pPreviousChunk->bytesRead < pPreviousChunk->length){
		// Read the next chunk
		ReadChunk(&currentChunk);

		// Check which chunk we just read
		switch (currentChunk.ID){
		case OBJECT_MESH:
		
			// This case means we hit a new object, so jump in again and read this next chunk
			ProcessNextObjectChunk(pModel, pObject, &currentChunk);
			break;

		case OBJECT_VERTICES:
			// Object vertices
			ReadVertices(pObject, &currentChunk);
			break;

		case OBJECT_FACES:
			// Object faces
			ReadVertexIndices(pObject, &currentChunk);
			break;

		case OBJECT_MATERIAL:

			// This chunk stores both texture information, or color information
			// depending on the object.  At the moment we'll just support textures
			// so we'll read in the name of the texture and build it later.  If there
			// is just color we'll not bother then.

			ReadObjectMaterial(pModel, pObject, &currentChunk);			
			break;

		case OBJECT_UV:
			// UV coordinates
			ReadUVCoordinates(pObject, &currentChunk);
			break;

		default:  

			// Ignored chunk, read past it.
			currentChunk.bytesRead += fread(m_Buffer, 1, currentChunk.length - currentChunk.bytesRead, m_FilePointer);
			break;
		}

		// Add the bytes read from the last chunk to the previous chunk passed in.
		pPreviousChunk->bytesRead += currentChunk.bytesRead;
	}
}
コード例 #9
0
ファイル: Loader3ds.c プロジェクト: deweerdt/TSP
void ProcessNextObjectChunk(Loader3ds *pt3ds,tChunk *pPreviousChunk) 
{
	tChunk currentChunk = {0}; 
 
	while (pPreviousChunk->bytesRead < pPreviousChunk->length) 
	{ 
		// Read the next chunk 
		ReadChunk(pt3ds,&currentChunk); 
		switch (currentChunk.ID) 
		{ 
		case OBJECT_MESH:
 
			// We found a new object so use recursion 
			ProcessNextObjectChunk(pt3ds,&currentChunk); 
			break; 
 
		case OBJECT_VERTICES:				// 4110This is the objects vertices 
 
			ReadVertices(pt3ds,&currentChunk); 
			break; 
 
		case OBJECT_FACES:					// 4120This is the objects face information 
 
			ReadVertexIndices(pt3ds,&currentChunk); 
			break; 
 
		case OBJECT_MATERIAL:		

			ReadObjectMaterial(pt3ds,&currentChunk);			 
			break; 
 
		case OBJECT_UV:						// 4140This holds the UV texture coordinates for the object 
 
			ReadUVCoordinates(pt3ds,&currentChunk); 
			break; 
 
		case OBJECT_TRANSF:					// 4160 
 
			ReadObjectTransf(pt3ds,&currentChunk); 
			break; 
 
		default:   
 
			currentChunk.bytesRead += fread(pt3ds->gBuffer, 1, currentChunk.length - currentChunk.bytesRead, pt3ds->FilePointer); 
			break; 
		} 
 
		pPreviousChunk->bytesRead += currentChunk.bytesRead; 
	} 
} 
コード例 #10
0
void CLoad3DS::ProcessNextObjectChunk(t3DModel *pModel, t3DObject *pObject, tChunk *pPreviousChunk)
{
//	int buffer[50000] = {0};
//	int *buffer = new int[50000];

	m_CurrentChunk = new tChunk;

	while (pPreviousChunk->bytesRead < pPreviousChunk->length)
	{
	
		ReadChunk(m_CurrentChunk);

		switch (m_CurrentChunk->ID)
		{
		case OBJECT_MESH:				
			ProcessNextObjectChunk(pModel, pObject, m_CurrentChunk);
			break;

		case OBJECT_VERTICES:		
			ReadVertices(pObject, m_CurrentChunk);
			break;

		case OBJECT_FACES:				
			ReadVertexIndices(pObject, m_CurrentChunk);
			break;

		case OBJECT_MATERIAL:
			ReadObjectMaterial(pModel, pObject, m_CurrentChunk);			
			break;

		case OBJECT_UV:	
			ReadUVCoordinates(pObject, m_CurrentChunk);
			break;

		default:  
//			m_CurrentChunk->bytesRead += ASSET_READ(buffer, 1, m_CurrentChunk->length - m_CurrentChunk->bytesRead, m_FilePointer);
			ASSET_SEEK(m_FilePointer, m_CurrentChunk->length - m_CurrentChunk->bytesRead, SEEK_CUR);
			m_CurrentChunk->bytesRead += (m_CurrentChunk->length - m_CurrentChunk->bytesRead);
			break;
		}

		pPreviousChunk->bytesRead += m_CurrentChunk->bytesRead;
	}

	delete m_CurrentChunk;
	
	m_CurrentChunk = pPreviousChunk;
//	delete []buffer;
}
コード例 #11
0
ファイル: ACAMTLoader.cpp プロジェクト: dgadens/ActionEngine
bool ACAMTLoader::LoadFromFile( const CHAR* path, AMT_MODEL* outModel)
{
	// open the file
	mpFile = fopen( path, "rb" );
	if( !mpFile ) return false;

	ReadHeader(outModel);    
	ReadVertices(outModel);  
	ReadFaces(outModel);     
	ReadMesh(outModel);      
	ReadMaterials(outModel);
	ReadJoints(outModel);
	ReadAnimations(outModel);

	return CloseFile( true );
};
コード例 #12
0
//  下面的函数处理所有的文件中对象的信息
void CLoad3DS::ReadNextObjChunk(t3DModel *pModel, t3DObject *pObject, tChunk *pPreChunk)
{ 
	int buffer[50000] = {0};     // 用于读入不需要的数据
	// 对新的块分配存储空间
	m_CurrentChunk = new tChunk;

	// 继续读入块的内容直至本子块结束
	while (pPreChunk->bytesRead < pPreChunk->length)
	{ // 读入下一个块
		ReadChunk(m_CurrentChunk);
		// 区别读入是哪种块
		switch (m_CurrentChunk->ID)
		{
		case OBJ_MESH:     // 正读入的是一个新块
			// 使用递归函数调用,处理该新块
			ReadNextObjChunk(pModel, pObject, m_CurrentChunk);
			break;
		case OBJ_VERTICES:    // 读入是对象顶点
			ReadVertices(pObject, m_CurrentChunk);
			break;
		case OBJ_FACES:     // 读入的是对象的面
			ReadVertexIndices(pObject, m_CurrentChunk);
			break;
		case OBJ_MATERIAL:    // 读入的是对象的材质名称
			// 该块保存了对象材质的名称,可能是一个颜色,也可能是一个纹理映射。同时在该块中也保存了
			// 纹理对象所赋予的面
			// 下面读入对象的材质名称
			ReadObjMat(pModel, pObject, m_CurrentChunk);   
			break;
		case OBJ_UV:      // 读入对象的UV纹理坐标
			// 读入对象的UV纹理坐标
			ReadUVCoordinates(pObject, m_CurrentChunk);
			break;
		default:  
			// 略过不需要读入的块
			m_CurrentChunk->bytesRead += fread(buffer, 1, m_CurrentChunk->length - m_CurrentChunk->bytesRead, m_FilePointer);
			break;
		}
		// 添加从最后块中读入的字节数到前面的读入的字节中
		pPreChunk->bytesRead += m_CurrentChunk->bytesRead;
	}
	// 释放当前块的内存空间,并把当前块设置为前面块
	delete m_CurrentChunk;
	m_CurrentChunk = pPreChunk;
}
コード例 #13
0
ファイル: Model.cpp プロジェクト: madisodr/legacy-core
Model::Model( std::string path ) : IsCollidable(false), IsBad(false)
{
    Stream = MPQHandler->GetFile(Utils::FixModelPath(path));
    if (!Stream)
    {
        IsBad = true;
        return;
    }
    Header.Read(Stream);
    if (Header.OffsetBoundingNormals > 0 && Header.OffsetBoundingVertices > 0 &&
        Header.OffsetBoundingTriangles > 0 && Header.BoundingRadius > 0.0f)
    {
        IsCollidable = true;
        ReadVertices();
        ReadBoundingNormals();
        ReadBoundingTriangles();
    }
}
コード例 #14
0
ファイル: chull_3d.c プロジェクト: rballouz/SoftPolyhedra
int main()
{
    ReadVertices();
    DoubleTriangle();
    ConstructHull();
    PrintFaces();
    
    /*
    tVertex v;
    v=vertices;
    do  {
    
        printf("%d  %d  %d\n",v->v[X],v->v[Y],v->v[Z]);
        v=v->next;
    } while (v!=vertices);
    */
    
    return 0;
}
コード例 #15
0
ファイル: line.cpp プロジェクト: PNCG/neuron
void MultiLineComp::Read (istream& in) {
    VerticesComp::Read(in);
    Coord* x, *y;
    int count;

    ReadVertices(in, x, y, count);
    SF_MultiLine* ml = new SF_MultiLine(x, y, count);
    delete x;
    delete y;

    ml->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    ml->SetColors(fg, bg);
    ml->SetBrush(ReadBrush(in));
    ml->SetPattern(ReadPattern(in));

    Transformer* t = ReadTransformer(in);
    ml->SetTransformer(t);
    Unref(t);

    SetGraphic(ml);
}
コード例 #16
0
ファイル: spline.c プロジェクト: LambdaCalculus379/SLS-1.02
void SplineComp::Read (istream& in) {
    VerticesComp::Read(in);
    Coord* x, *y;
    int count;

    ReadVertices(in, x, y, count);
    SFH_OpenBSpline* spline = new SFH_OpenBSpline(x, y, count);
    delete x;
    delete y;

    spline->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    spline->SetColors(fg, bg);
    spline->SetBrush(ReadBrush(in));
    spline->SetPattern(ReadPattern(in));

    Transformer* t = ReadTransformer(in);
    spline->SetTransformer(t);
    Unref(t);

    SetGraphic(spline);
}
コード例 #17
0
ファイル: ModelLoader.cpp プロジェクト: Ragzid/BomberClient
void Loaders::t3DSLoader::ProcessNextObjectChunk(t3DModel *pModel, t3DObject *pObject, tChunk *pPreviousChunk)
{
    m_CurrentChunk = new tChunk;

    while (pPreviousChunk->bytesRead < pPreviousChunk->length)
    {
        ReadChunk(m_CurrentChunk);

        switch (m_CurrentChunk->ID)
        {
        case OBJECT_MESH:
            ProcessNextObjectChunk(pModel, pObject, m_CurrentChunk);
            break;
        case OBJECT_VERTICES:
            ReadVertices(pObject, m_CurrentChunk);
            break;
        case OBJECT_FACES:
            ReadVertexIndices(pObject, m_CurrentChunk);
            break;
        case OBJECT_MATERIAL:
            ReadObjectMaterial(pModel, pObject, m_CurrentChunk);
            break;
        case OBJECT_UV:
            ReadUVCoordinates(pObject, m_CurrentChunk);
            break;
        default:
            m_CurrentChunk->bytesRead += fread(gBuffer, 1, m_CurrentChunk->length - m_CurrentChunk->bytesRead, m_FilePointer);
            break;
        }

        pPreviousChunk->bytesRead += m_CurrentChunk->bytesRead;
    }

    delete m_CurrentChunk;
    m_CurrentChunk = pPreviousChunk;
}
コード例 #18
0
ファイル: sw_maprd.cpp プロジェクト: avontd2868/OU_Final_Year
bool CMapReader::Read(FILE *fp)
{
	ReadHeader(fp);
	
	ReadTerrainCells(fp);
	
	if(CheckBlockEnd(0x00,fp) == false)
		return false;

	ReadQuadUVFaces(fp); SkipExtraData(800,18,fp);

	if(CheckBlockEnd(0x01,fp) == false)
		return false;

	ReadTriUVFaces(fp); SkipExtraData(800,16,fp);

	if(CheckBlockEnd(0x02,fp) == false)
		return false;

	ReadVertices(fp); SkipExtraData(2000,10,fp);

	if(CheckBlockEnd(0x03,fp) == false)
		return false;

	ReadTriFaces(fp); SkipExtraData(2000,32,fp);

	if(CheckBlockEnd(0x04,fp) == false)
		return false;

	ReadMeshes(fp); SkipExtraData(120,36,fp);

	if(CheckBlockEnd(0x05,fp) == false)
		return false;

	ReadBlockG(fp); SkipExtraData(4000,6,fp);

	if(CheckBlockEnd(0x06,fp) == false)
		return false;
	
	ReadBlockH(fp); SkipExtraData(10,32,fp);

	if(CheckBlockEnd(0x07,fp) == false)
		return false;

	ReadBlockI(fp); SkipExtraData(3500,16,fp);

	if(CheckBlockEnd(0x08,fp) == false)
		return false;

	ReadQuadFaces(fp); SkipExtraData(2000,40,fp);

	if(CheckBlockEnd(0x09,fp) == false)
		return false;

	ReadBlockK(fp); SkipExtraData(50,54,fp);

	if(CheckBlockEnd(0x0A,fp) == false)
		return false;

	ReadNavipoints(fp); SkipExtraData(50,36,fp);

	if(CheckBlockEnd(0x0B,fp) == false)
		return false;

	ReadBlockM(fp); SkipExtraData(50,36,fp);

	if(CheckBlockEnd(0x0C,fp) == false)
		return false;

	ReadBlockN(fp); SkipExtraData(1000,6,fp);

	if(CheckBlockEnd(0x0D,fp) == false)
		return false;

	ReadBlockO(fp); SkipExtraData(600,14,fp);

	if(CheckBlockEnd(0x0E,fp) == false)
		return false;

	ReadBlockP(fp);

	if(CheckBlockEnd(0x0F,fp) == false)
		return false;

	ReadBlockQ(fp);

	if(CheckBlockEnd(0x10,fp) == false)
		return false;

	ReadBlockR(fp);

	if(CheckBlockEnd(0x11,fp) == false)
		return false;

	return true;
}