LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-01-2012, 03:20 PM   #1
Soulkeeper1987
LQ Newbie
 
Registered: Jul 2012
Posts: 1

Rep: Reputation: Disabled
Question Microsoft Visual C++, Reading from File, Reading an XFile not heirarchy


i am trying to figure out how to read an xfile into vectors and structures. What i am trying to do is take an xfile, and extract the vertices of the polygons in the xfile. I am using this for bounding box purposes, but my character will actually be inside the xfile, which is why i need the vertices. Every xfile gives the number of vertices, number of polygons, number of normals, but when i try to read the file normally, i get errors. The project that this will be used by requires Direct X9, and i seem to lose functionality of the string class when direct x is implemented. I can find tutorials on how to read the xfile heirarchy for animation purposes and bounding boxes on the outside, but nothing for inside. I really need any help that can be offered. Xfile is attached below as a pdf
Code:
#include <d3d9.h>
#include <d3dx9.h>
#include <ifstream>
#include <string>
#include <vector>
using namespace std;

struct point()
{
int x;//x coordinate of each vertice int y;//y coordinate of each vertice int z;//z coordinate of each vertice
}; stuct polygon() {
vector<point> vertices;//polygon can have 4 or 5 vertices, hence the vector
}; struct room() {
string name;//will be derived from the xfile vector<polygons> sides;//most of the rooms have about 180 polygons to them
}; void main() {
ifstream xfile("Alpa aon 1.x")//i have tried both the .x file and .txt file with no success string readline; if(!xfile.isopen()) {
cerr<<"File will not open";
}
else {
while(!xfile.eof()){
getline(xfile,readline);//i was using this for testing purposes, but for some reason, my executable get stuck in an endless loop or cout<<readline<<endl;//this line outputs hexadecimal characters instead of the line it read
}
} }
if anyone has any ideas about what i need to change or an easier way to do this please let me know. i appreciate all the help i can get
Attached Files
File Type: pdf Alfa_Aon_1.pdf (165.8 KB, 3 views)

Last edited by Soulkeeper1987; 07-01-2012 at 04:37 PM. Reason: Removed email as requested, attached xfile as pdf due to sizing issues as txt
 
Old 07-01-2012, 04:09 PM   #2
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware{,64}-{14.1,current} on a Lenovo Thinkpad T61 6457-4XG
Posts: 4,035

Rep: Reputation: 974Reputation: 974Reputation: 974Reputation: 974Reputation: 974Reputation: 974Reputation: 974Reputation: 974
Hi, welcome to LQ.

Please edit your post to erase your email address as no email address should appear in a post. Furthermore you will receive a lot of spam.

Instead you can ask people to send you private messages, or use e.g. pastebin to post the content of your file and then link to it here.

Additionally you can post your xfile here just rename it to use alphanumeric characters only and make it ending in .txt
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Reading from file odstderek Linux - Newbie 9 11-06-2011 11:17 AM
My dvd drive is not mounting and reading. No udf based dvd is not reading. anjanatsuse Linux - Newbie 1 10-15-2010 12:54 PM
scanf reading newline into char array while reading 1 char at a time austinium Programming 6 09-26-2010 11:27 PM
problem in reading Microsoft word as a binary file ljqu_happy Programming 15 02-02-2005 10:10 AM
Reading Media off the Microsoft Windows 98 Partition saturninus Linux - Newbie 7 08-28-2003 11:35 AM


All times are GMT -5. The time now is 09:51 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration