Jump to content

Another game physics related question


Recommended Posts

Well first you have to convert it to the Torque Game Engine model format which is apparently .DTS! Then, check this out, John is kind of cute..:P

 

much easier than trying to do anything even remotely similar in C++................

 

Just for your personal comparison and for the amusement of others here is my simple code used just to index the .x(direct x file format) file in C++!

 

.cpp

#include "XFilez.h"

bool CMeshFile::LoadXFile(string file)
{
Index.mesh_file = file;
ifsMeshFile.open("C:/Projects/Naomies Moon/Roz_XSI/Roz.x");

while(!(ifsMeshFile.eof()))
{
	getline(ifsMeshFile,line);
	vMeshFile.push_back(line);
}

ifsMeshFile.close();

if (!ifsMeshFile.bad() && !ifsMeshFile.fail())
{

	//find templates_index_end index
	file_itterator=2;			
	while (!(vMeshFile.at(file_itterator).find("Frame") == 0))	
	{
		file_itterator++;
	}

	Index.scene_index_begin=file_itterator;

	//Index Hierarchy
	while (!(vMeshFile.at(file_itterator).find("}") == 0))	
	{

		if(vMeshFile.at(file_itterator).find("Frame") == 1)
		{

			Index.frame_index_begin.push_back(file_itterator);

			while(!(vMeshFile.at(file_itterator).find("}") == 1))
			{
				file_itterator++;
			}

		}

		else
			file_itterator++;

	}

}
else 
	return false;

return true;

}

 

.h

#ifndef X_FILEZ
#define X_FILEZ

#if _WIN32
#pragma once
#endif

#include <windows.h>

#include <fstream>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

class CMeshFileIndex
{
public:
string mesh_file;

static const int header = 0;

static const int templates_index_begin = 1;

int scene_index_begin;

vector<int> frame_index_begin;

};

class CMeshFile
{
public:
bool LoadXFile(string file);

private:
CMeshFileIndex Index;

ifstream ifsMeshFile;

string line;

vector <string> vMeshFile;

int file_itterator;

};

#endif

 

tabbing not so easily copied and pasted.........

Edited by buttacup
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.