• Content count

  • Joined

  • Last visited

Community Reputation

131 Neutral

About GaMEFRo

  • Rank
  1. Hi all,   I'm writing an iPhone application where I'd like the user to be able to push a button and be able to rotate / stretch a rectangle with regards to the red point in the picture below:     As you can see I'd like to be able to rotate around the red dot (or half way down the y axis) and would also be able to stretch the rectangle with it still being anchored to the red point (doesn't move).   I should mention that in iPhone, that anchor point is initially set to the center of the object.   I struggle badly with transformations, but was able to figure out the rotation:           self.rotateView.transform = CGAffineTransformTranslate(self.rotateView.transform, self.rotateView.bounds.size.width / 2, 0);     self.rotateView.transform = CGAffineTransformRotate(self.rotateView.transform, M_PI / 180);     self.rotateView.transform = CGAffineTransformTranslate(self.rotateView.transform, self.rotateView.bounds.size.width  / 2, 0);     How to scale something is obvious, what I'm having trouble with is correctly translating the object before and after I scale it, and then doing all of this within the context of the rotation so that they both can work out when applied together.    Anyone might be able to point me in the right direction on how to approach this?   Thanks,   GaMEFRo  
  2. Bump - I made the post a lot more concise and a little more descriptive. Any help would be appreciated, thanks.
  3. I'm developing a game for the iPhone, and I have a situation where I have a graphic that the user can drag around the screen and there are some buttons the user can push to both rotate it and enlarge it. The graphic is located within a UIView, which is just a rectangular shape that fits tightly around it. The thing I'm having trouble with is rotating the graphic, and then translating it so it fits within the UIView correctly. When the user pushes the button to rotate, the first thing I'm doing is calculating the correct size the UIView frame needs to be to fit the rotated object. Then I do the following: [CODE] - (CGAffineTransform) transform { CGAffineTransform transform = CGAffineTransformIdentity; transform = CGAffineTransformRotate(transform, (M_PI * self.graphicRotationAngle) / 180); transform = CGAffineTransformScale(transform, self.graphicSize.width / self.graphic.size.width, self.graphicSize.height / self.graphic.size.height); transform = CGAffineTransformTranslate(transform, self.graphicSize.width - self.frame.size.width, self.graphicSize.height - self.frame.size.height); return transform; } [/CODE] It makes sense to me that in order to translate the object back to the upper left corner (0,0), i have to subtract the new size of the frame width and height value, minus the non rotated images width and height, and that should give me the translation I need. Yet it's not working, do I have the correct order of operations? Any help would be appreciated.
  4. nm for your reference I just had to include <windows.h> and it wokred fine. However, now its saying though cannot find image.h with my "#include <gl/image.h>". Are there any other headers I need to include for this, or is it just a matter of me googling this and finding it somewhere on the net and adding it to my project? GaMEFRo
  5. Hi, does anyone know any equations for generating a nice marble texture? For instance I'm using openGL with perlin.h, I have it set up like this: #define TexWidth 512 #define TexHeight 512 static GLubyte textureImage[TexHeight][TexWidth][4]; static GLuint texName; ImprovedNoise noise; double PlainNoise(int x, int y) { double scale = 0.05; double n; n = noise.noise(x * scale , y * scale, 11.5); return n; } void CreateTexture() { //-- local variables int i,j, k; double n, mult; double min = 0, max = 0; //-- second iteration to compute texture and scale accordingly for (i=0 ; i < TexHeight; i++) for (j=0; j < TexWidth; j++) { n = PlainNoise(i,j); n = ( n - 1) / ( 2 ); //<-- need help here textureImage[i][j][0] = (GLubyte) (n * 255); textureImage[i][j][1] = (GLubyte) (n * 255); textureImage[i][j][2] = (GLubyte) (n * 255); } } Any help would be appreciated thanks. GaMEFRo
  6. Hi, I'm trying to use libwave, which allows you to read obj files and draw them in your program, but I keep getting a lot of errors when I try to do a build on my project in MS visual studio 2003. I know the problem is with gl.h, that is where all my errors are coming from and specifically a lot are coming from int apientry and WGDAPI. Has anyone who's used libwave had the same problems or would anyone know how to fix this? I appreciate any help you guys can give, thanks. GaMEFRo
  7. Hi, I am trying to make it in my program so that I display what it looks like with per face normals without per vertex normals and vice versa. I am not calculating these attributes manually, I am using the GML class by Nate Robbins and his glmFacetNormals(.obj, degrees) and glmVertexNormals(.obj) for the .obj files I am using. Whenever I take away glmFacetNormals() for a particular .obj file, I get a run time error that kills the program it says asstertion fails: facet norms so I am unable to display what it would look like with just per vertx normals. Does anyone know how to fix this? I appreciate your help, thanks FRo
  8. Hi, I was just wondering if anyone had any wavefront object terrains (flat land, mountains, desert, whatever), or knew of any links to find some? For whatever reason they're impossible to find on google. Thanks... GaMEFRo
  9. Hey, Thanks to you guys I got my glm up and running, and now I am trying to read in the simple cube.obj file that is all over the internet. I am getting the cube to appear on the screen in 3D, but its being painted in all white. How do I get the cube to be painted the way its supposed to be? I also tried the f-16 from nate Robbins tutorial program with the mtl file and it's also being painted white. Just not sure how to manage this, here is the code: #include "glut.h" #include <stdio.h> #include <math.h> #include "glm.h" GLMmodel* pmodel = NULL; GLfloat angle1 = 0.0; void init(void) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1, 1, -1, 1, 1, 7); glClearColor (0.0, 0.0, 0.0, 0.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gluLookAt(0, 3, 3, 0.0, 0.0, 0, 0.0, 1.0, 0.); pmodel = glmReadOBJ("cube.obj"); glmUnitize(pmodel); glmFacetNormals(pmodel); glmVertexNormals(pmodel, 90); glmDraw(pmodel, GLM_SMOOTH); glutSwapBuffers(); } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glEnable(GL_DEPTH_TEST); glutInitWindowPosition(100,100); glutInitWindowSize(500,500); glutCreateWindow("Project 2"); glutDisplayFunc(display); init(); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }
  10. Hi, I'm wondering if anyone has any links to any sites that have a big collection of already made obj waveforms. I've googled and have only found a couple here and there. Any help would be appreciated thanks. GaMEFRo
  11. OpenGL Problems with GLM

    Thanks Nychold, renaming the file to .cpp worked like a charm =D
  12. Hi I was just wondering if any of you had run into this problem before using openGL with glm. For starters I'm using Microsoft Visual Studio 2005 and I have glut.h, glut32.lib, and glut32.dll in my project directory. I've turned off precompiled headers and added glut32.lib to my addtional dependencies under link so opengl is working fine. I'm running into problems with glm which I'm trying to use to read in obj waveforms. I downloaded "Source package + Windows executables ( 1.24MB) " from nate robbins web site which has the glm.h and glm.c files I need and also some of his tutorials. I added glm.h to my project in "header files" and I added glm.c to "source f iles". I compile glm.c and it works but with like 66 warnings. I change <gl/glut.h> to "glut.h" whereever needed. I'm using his "projection.c" tutorial to test to see if the glm object reader works. When I compile this it works fine, then when I run it the build fails and I get the following errors: error LNK2019: unresolved external symbol "void __cdecl glmDraw(struct _GLMmodel *,unsigned int)" (?glmDraw@@YAXPAU_GLMmodel@@I@Z) referenced in function "void __cdecl drawmodel(void)" (?drawmodel@@YAXXZ) 1>cse470project2.obj : error LNK2019: unresolved external symbol "void __cdecl glmVertexNormals(struct _GLMmodel *,float)" (?glmVertexNormals@@YAXPAU_GLMmodel@@M@Z) referenced in function "void __cdecl drawmodel(void)" (?drawmodel@@YAXXZ) 1>cse470project2.obj : error LNK2019: unresolved external symbol "void __cdecl glmFacetNormals(struct _GLMmodel *)" (?glmFacetNormals@@YAXPAU_GLMmodel@@@Z) referenced in function "void __cdecl drawmodel(void)" (?drawmodel@@YAXXZ) 1>cse470project2.obj : error LNK2019: unresolved external symbol "float __cdecl glmUnitize(struct _GLMmodel *)" (?glmUnitize@@YAMPAU_GLMmodel@@@Z) referenced in function "void __cdecl drawmodel(void)" (?drawmodel@@YAXXZ) 1>cse470project2.obj : error LNK2019: unresolved external symbol "struct _GLMmodel * __cdecl glmReadOBJ(char *)" (?glmReadOBJ@@YAPAU_GLMmodel@@PAD@Z) referenced in function "void __cdecl drawmodel(void)" (?drawmodel@@YAXXZ) This is driving me insane, any help would be strongly appreciated. Thanks. GaMEFRo