• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=Dienes;44702165]What does your code look like?[/QUOTE] This is what I have (pastebin): [B]header files[/B] [url=http://pastebin.com/Q09R9gNj]Core.h[/url] [url=http://pastebin.com/b8VHvjiu]HPTime.h[/url] [url=http://pastebin.com/X7ttD6sE]Loader.h[/url] [url=http://pastebin.com/VMuQx720]Math.h[/url] [url=http://pastebin.com/WMdUrkAD]Primitives.h[/url] [url=http://pastebin.com/FYrSfmWj]Transformation.h[/url] [B]Source[/B] [url=http://pastebin.com/1VyTePf7]Core.cpp[/url] (This contains some stuff that doesn't work as intended but works without error on it's own without these extra classes) [url=http://pastebin.com/sYTY5uxn]HPTime.cpp[/url] [url=http://pastebin.com/pJGNvi0S]Loader.cpp[/url] [url=http://pastebin.com/Gjh5WPWv]Math.cpp[/url] [url=http://pastebin.com/S8BSqSCJ]Primitives.cpp[/url] [url=http://pastebin.com/mC1mU9wA]Transformation.cpp[/url] It's still wip so there's unfinished parts of it, but they don't throw out errors when I compile.
[QUOTE=Pat.Lithium;44702352]This is what I have (pastebin): [B]header files[/B] [URL="http://pastebin.com/Q09R9gNj"]Core.h[/URL] [URL="http://pastebin.com/b8VHvjiu"]HPTime.h[/URL] [URL="http://pastebin.com/X7ttD6sE"]Loader.h[/URL] [URL="http://pastebin.com/VMuQx720"]Math.h[/URL] [URL="http://pastebin.com/WMdUrkAD"]Primitives.h[/URL] [URL="http://pastebin.com/FYrSfmWj"]Transformation.h[/URL] [B]Source[/B] [URL="http://pastebin.com/1VyTePf7"]Core.cpp[/URL] (This contains some stuff that doesn't work as intended but works without error on it's own without these extra classes) [URL="http://pastebin.com/sYTY5uxn"]HPTime.cpp[/URL] [URL="http://pastebin.com/pJGNvi0S"]Loader.cpp[/URL] [URL="http://pastebin.com/Gjh5WPWv"]Math.cpp[/URL] [URL="http://pastebin.com/S8BSqSCJ"]Primitives.cpp[/URL] [URL="http://pastebin.com/mC1mU9wA"]Transformation.cpp[/URL] It's still wip so there's unfinished parts of it, but they don't throw out errors when I compile.[/QUOTE] Which cpp file does trigger the errors? Edit: Everything compiles for me (with SDL specific stuff commented out) Is the missing # in Core.cpp a copy&paste error in pastebin?
[QUOTE=Dienes;44702509]Which cpp file does trigger the errors? Edit: Everything compiles for me (with SDL specific stuff commented out) Is the missing # in Core.cpp a copy&paste error in pastebin?[/QUOTE]I accidentally didn't copy the # in Core.cpp but its there. The errors are coming from cmath [editline]2nd May 2014[/editline] oh fuck it was from having a header file called "Math.h" that did it...
[QUOTE=Pat.Lithium;44702636]I accidentally didn't copy the # in Core.cpp but its there. The errors are coming from cmath[/QUOTE] I don't think they are. They just manifest in cmath, because you seem to include it in some weird spot. That's because I asked which specific cpp file you need to compile to get those errors. Knowing the cpp lets us narrow down the places to look for mistakes. As I said, all cpp files do compile fine for me.
[QUOTE=Pat.Lithium;44702636] oh fuck it was from having a header file called "Math.h" that did it...[/QUOTE] yeah -.- i had the same problem months ago :D
[QUOTE=Pappschachtel;44702669]yeah -.- i had the same problem months ago :D[/QUOTE] What exactly is the problem in having a Math.h? The files names should be case sensitive so this should not collide with math.h, right?
[QUOTE=Dienes;44702676]What exactly is the problem in having a Math.h? The files names should be case sensitive so this should not collide with math.h, right?[/QUOTE] seems like it does... i changed my Math.h to Mathematics.h, which solved the problem. Edit: i use MinGW in QT.
Woo after fixing a few other build errors it successfully built, now I can test all my functions. Thanks to everyone who has helped me with my assignment, I'll be back later with more problems.
[QUOTE=Pat.Lithium;44702765]I'll be back later with more problems.[/QUOTE] Okay :D
[QUOTE=Dienes;44702676]What exactly is the problem in having a Math.h? The files names should be case sensitive so this should not collide with math.h, right?[/QUOTE] On Windows, they aren't treated as case sensitive. While [url=http://support.microsoft.com/kb/100625]NTFS itself is case sensitive[/url], the Win32 subsystem only preserves case when creating files. Opening files is case insensitive.
[QUOTE=Alternative Account;44703790]On Windows, they aren't treated as case sensitive. While [url=http://support.microsoft.com/kb/100625]NTFS itself is case sensitive[/url], the Win32 subsystem only preserves case when creating files. Opening files is case insensitive.[/QUOTE] So it is only win32 or win64 too ?
I'm trying to build a GCC cross compiler for an operating system I plan on developing. However, cygwin's gcc is pissing me off because it complains about "target i586-pe is not supported" or "target i686-pe" is not supported. I can't find a gcc source version that supports the pentium based PE format target. Can someone point me to one please?
[QUOTE=Tamschi;44701995]You could try the other token version, maybe it behaves differently.[/QUOTE] I think I'll try that in a bit but in the mean time I found a work-around. If I use 'dropbox' mode which means the folder is public and anyone can upload a session token is not required, so I can just upload to that folder with no limits.
So I have two Arrays. One Array is 20 PictureBoxes and one Array is 20 Images. I can randomly assign one of the 20 images to each PictureBox. The problem I am having is once I assign an image I do not want to use that image again. Basically I only want to use each image once. If someone could point me in the right direction that would be great. Maybe I shouldn't even use Arrays for this? Trying to do this as much on my own as possible. I am using C#
- Choose a random number between 0 and 19, set it to the first picturebox. - Swap that element with the last element in the array. - Choose a random number between 0 and 18, set it to the second picturebox. - Swap that element with the second-to-last element in the array. Repeat until all pictureboxes have been set. Might not be the most optimal, but it'll get the job done.
My rotation matrices don't give the right result. [code] // Identity matrix Mat4::Mat4() { // Row 1 this->data[0] = 1; this->data[1] = 0; this->data[2] = 0; this->data[3] = 0; // Row 2 this->data[4] = 0; this->data[5] = 1; this->data[6] = 0; this->data[7] = 0; // Row 3 this->data[8] = 0; this->data[9] = 0; this->data[10] = 1; this->data[11] = 0; // Row 4 this->data[12] = 0; this->data[13] = 0; this->data[14] = 0; this->data[15] = 1; } // vector Vec4::Vec4(float x, float y, float z, float w) { this->x = x; this->y = y; this->z = z; this->w = w; } // Multiply matrix by vector Vec4 Mat4::operator*(const Vec4& v) const { Vec4 tmp; tmp.x = (this->data[0] * v.x) + (this->data[1] * v.x) + (this->data[2] * v.x) + (this->data[3] * v.x); tmp.y = (this->data[4] * v.y) + (this->data[5] * v.y) + (this->data[6] * v.y) + (this->data[7] * v.y); tmp.z = (this->data[8] * v.z) + (this->data[9] * v.z) + (this->data[10] * v.z) + (this->data[11] * v.z); tmp.w = (this->data[12] * v.w) + (this->data[13] * v.w) + (this->data[14] * v.w) + (this->data[15] * v.w); return tmp; } // Rotate on X axis Mat4 Mat4::rotateX(float degrees) { Mat4 tmp; float rad = Math::toRadians(degrees); tmp.data[5] = cos(rad); tmp.data[6] = sin(rad); tmp.data[9] = -tmp.data[6]; tmp.data[10] = tmp.data[5]; return tmp; } [/code] If I do: [code]Vec4 trans = Vec4(10, 20, 10, 1); Vec4 trans2 = Mat4::rotateX(30) * trans; cout << trans2.x << " " << trans2.y << " " << trans2.z << " " << trans2.w << "\n";[/code] I get [quote]x = 10 y = 27.3205 z = 3.66025 w = 1[/quote] [editline]3rd May 2014[/editline] expected result is [quote] [10, -6.79529, 21.3031, 1][/quote]
did u try the transposed matrix ?
?
[QUOTE=robmaister12;44708690]- Choose a random number between 0 and 19, set it to the first picturebox. - Swap that element with the last element in the array. - Choose a random number between 0 and 18, set it to the second picturebox. - Swap that element with the second-to-last element in the array. Repeat until all pictureboxes have been set. Might not be the most optimal, but it'll get the job done.[/QUOTE] I'm not familiar with C# but I imagine it would have a function to shuffle an array? That would do the same thing and be less work and less error-prone. Just shuffle the image array and assign image[i] to pictureBox[i] for each one.
[URL="http://stackoverflow.com/questions/273313/randomize-a-listt-in-c-sharp"]SO has a good discussion on this.[/URL]
I've been looking at some code for implementing the LZW algorithm and I've gotten confused. The code I looked at created a class called ByteArray and I'm not sure if I need to have it. This is what I have so far: [CODE]class Encoder{ public static void encode(InputStream in, OutputStream out) throws IOException{ Map<ByteArray, Integer> dictionary = new HashMap<ByteArray, Integer>(); for(int i = 0; i < 256; i++){ dictionary.put(new ByteArray((byte) i), i); } InputStream bufferedIn = new BufferedInputStream(in); Output compressedOutput = new Output(new BufferedOutputStream(out), 12); int firstByte = bufferedIn.read(); ByteArray w = new ByteArray((byte) firstByte); int code = 256; int k; while((k = bufferedIn.read()) != -1){ ByteArray wk = new ByteArray(w).append((byte) k); if(dictionary.containsKey(wk)) w = wk; else{ compressedOutput.write(dictionary.get(w)); if(code < (1 << 12) - 1) dictionary.put(wk, code++); w = new ByteArray((byte) k); } } compressedOutput.write(dictionary.get(w)); compressedOutput.flush(); compressedOutput.close(); }[/CODE] Do I need that ByteArray class for LZW or can I use something else? The first step of encoding LZW is to initialize the dictionary to strings of length 1 so I'm not sure what ByteArray is doing
[QUOTE=Pat.Lithium;44711817]?[/QUOTE] M^T like i already said before, there is a column-major order and a row-major order which is basicly this: [URL="https://www.wolframalpha.com/input/?i={{1%2C2%2C3%2C4}%2C{5%2C6%2C7%2C8}%2C{9%2C10%2C11%2C12}%2C{13%2C14%2C15%2C16}}^T"]https://www.wolframalpha.com/input/?i={{1%2C2%2C3%2C4}%2C{5%2C6%2C7%2C8}%2C{9%2C10%2C11%2C12}%2C{13%2C14%2C15%2C16}}^T[/URL] in openGL it does not matter which version you use, because as soon as you send the matrix to the shader, you have a bool you can set to transpose the matrix. You should care about that stuff :)
[QUOTE=Pappschachtel;44711980]M^T like i already said before, there is a column-major order and a row-major order which is basicly this: [URL="https://www.wolframalpha.com/input/?i={{1%2C2%2C3%2C4}%2C{5%2C6%2C7%2C8}%2C{9%2C10%2C11%2C12}%2C{13%2C14%2C15%2C16}}^T"]https://www.wolframalpha.com/input/?i={{1%2C2%2C3%2C4}%2C{5%2C6%2C7%2C8}%2C{9%2C10%2C11%2C12}%2C{13%2C14%2C15%2C16}}^T[/URL] in openGL it does not matter which version you use, because as soon as you send the matrix to the shader, you have a bool you can set to transpose the matrix. You should care about that stuff :)[/QUOTE] I'm not using openGL. I still don't understand, what is the issue with my matrices? Are they ordered incorrectly? [editline]4th May 2014[/editline] I'm working on my .obj loader, what do I put in for the file directory? If the file is "assets/cube.obj" never mind I didn't put my assets folder in my project. [editline]4th May 2014[/editline] Next question about loading an obj file: I load the vertex with this code: [code] Mesh m; // Open the file ifstream f(path); if (!f.is_open()) { cerr << path << " opening failed." << endl; return m; } string Line; string Name; while (std::getline(f, Line)){ if (Line == "" || Line[0] == '#') continue; std::istringstream LineStream(Line); LineStream >> Name; // Vertex if (Name == "v"){ float x, y, z, w; sscanf(Line.c_str(), "%*s %f %f %f %f", &x, &y, &z, &w); w = (w == 0) ? 1 : w; cout << x << " " << y << " " << z << " " << w << "\n"; Vert v(x, y, z, w, x, y, z, w); m.push_back(v); } // Face if (Name == "f"){ } }; f.close(); return m;[/code] Which works for the vertices as they are saved as v float float float, but a face is stored as f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 v4/vt4/vn4 I only want to get the v1, v2, v3 and v4 values out of this string. How do I do so?
divide your string and take the stuff you need
[QUOTE=Fredo;44711858]I'm not familiar with C# but I imagine it would have a function to shuffle an array? That would do the same thing and be less work and less error-prone. Just shuffle the image array and assign image[i] to pictureBox[i] for each one.[/QUOTE] Not built-in, but you could throw this extension method somewhere in your project: [url]http://stackoverflow.com/questions/273313/randomize-a-listt-in-c-sharp[/url] I'm doing exactly the same thing, except I'm setting the picturebox inline with the shuffle.
I'm a beginner to iPhone development and Objective-C and I'm trying to get my head around how to anchor UI elements (specifically in a UITableViewCell). What I'm trying to do here is set the location of 2 images either side of the view and then anchor the labels in between them in such a way that adjusting them in future for larger screens would be a small alteration. Any idea how would be best to work out the x and y in relation to the view without making explicit coordinate references (i.e. using frame.x.origin + a gap or something). I'm just finding it really hard to get my head around it and I swear it must be really simple and that I'm thinking of it visually in my head the wrong way. I also wouldn't mind knowing how one might implement AutoLayout for an alternative solution too if anyone knows about that. [code] #import "FeedViewCell.h" @implementation FeedViewCell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code self.imgType = [[UIImageView alloc] init]; [self.contentView addSubview:self.imgType]; self.lblUser = [[UILabel alloc] initWithFrame:CGRectZero]; [self.contentView addSubview:self.lblUser]; self.lblPName = [[UILabel alloc] initWithFrame:CGRectZero]; [self.contentView addSubview:self.lblPName]; self.lblPDetails1 = [[UILabel alloc] initWithFrame:CGRectZero]; [self.contentView addSubview:self.lblPDetails1]; self.lblPDetails2 = [[UILabel alloc] initWithFrame:CGRectZero]; [self.contentView addSubview:self.lblPDetails2]; self.ImgProduct = [[UIImageView alloc] init]; [self.contentView addSubview:self.imgProduct]; } return self; } -(void)layoutSubviews { [super layoutSubviews]; CGRect rect = self.contentView.frame; float gap1 = 13; [self.imgType setFrame:CGRectMake(self.imgType.frame.origin.x + gap1, self.imgType.frame.origin.y + gap1, 75, 75)]; [self.textLabel setFrame:CGRectMake(self.imgType.frame.origin.x + gap1 + self.imgType.frame.size.width, 0, rect.size.width, rect.size.height)]; [self.lblUser setFrame:CGRectMake(0, 0, rect.size.width, rect.size.height)]; [self.lblPName setFrame: CGRectMake(0, 0, rect.size.width, rect.size.height)]; [self.lblPDetails1 setFrame: CGRectMake(0, 0, rect.size.width, rect.size.height)]; [self.lblPDetails2 setFrame: CGRectMake(0, 0, rect.size.width, rect.size.height)]; [self.imgProduct setFrame: CGRectMake(self.imgProduct.frame.origin.x , 0, 38, 38)]; } @end [/code]
Where the hell is strncmpi for visual studio? I've included string.h but any combination of strncmpi gives 'undefined identifier strncmpi'
I'm shit at C++. I want to get better at it, and I'm setting myself a goal. The only things I know right now are the absolute basics: simple arrays, file input/output, functions, loops and so on. My goal is to be able to draw a rotating 3D cube on a Windows computer. Doesn't need to have textures or anything. While the concept sounds simple to me, I know that it'll probably be complicated as hell to me, but I'm willing to learn. The problem is I have no idea where to even start. I need good material to read, things to study.
[QUOTE=AlphaGunman;44722984]I'm shit at C++. I want to get better at it, and I'm setting myself a goal. The only things I know right now are the absolute basics: simple arrays, file input/output, functions, loops and so on. My goal is to be able to draw a rotating 3D cube on a Windows computer. Doesn't need to have textures or anything. While the concept sounds simple to me, I know that it'll probably be complicated as hell to me, but I'm willing to learn. The problem is I have no idea where to even start. I need good material to read, things to study.[/QUOTE] Download Visual Studio (express is fine, maybe check out dreamspark.com for a higher version with plugin support if you fancy those kind of things) Start at: [url]http://www.learncpp.com/[/url] read preferably the whole thing including the Appendix B. Its a pretty good tutorial/book it just isn't very indepth, if there is anything you don't understand head over here: [url]http://cpptutorials.freeforums.org/video-index-t31.html[/url] The video tutorials the guy makes are mainly somewhat interesting at the start, he gives a good explanation of pointers, memory and some things like that. After you learned some basic CPP i suggest starting with SFML, which is a simple 2d Graphics library: [url]http://www.sfml-dev.org/tutorials/2.1/start-vc.php[/url] Don't start huge projects, do something small, make pong or a game where you click on waldo. If you're really set on the 3d stuff, you could look at Ogre3D or Irrlicht, both are crossplatform very simple 3d graphics engine, they'll let you draw cubes (or any kind of shape you like) but i wouldn't suggest trying to learn any graphics programming inside/with/from them.
How do I apply a translate matrix to a vector? If I multiply it like my other matrices it just works the same as my scale matrix.
Sorry, you need to Log In to post a reply to this thread.