# arbuckle911

Member

130

139 Neutral

• Rank
Member
1. ## My Matrix class. How well is it implemented?

checkout tvmet http://tvmet.sourceforge.net/ unless you're just learning to write C++ by implementing matrices. Otherwise the foundation of any graphics library would be a solid math library.
2. ## vertex skinning normal transformations (broken code)

I'm writing a set of classes to load and display doom3 md5 model and anim files. I'm able to animate them on the cpu and generate normal from scratch on each frame, but that's slow and inefficient. My ultimate goal is to be able to animate and light the models on the GPU. Right now I'm trying to simulate exactly what a shader would do but on the cpu to make debugging easier. My problem right now is that I can't animate the normals along with the model. I got this off another site: ------------------ Precomputing normals You will probably need to compute normal vectors, for example for lighting. Here is how to compute them in order to get “weight normals”, like the weight positions (this method also works for tangents and bi-tangents): First, compute all model's vertex positions in bind-pose (using the bind-pose skeleton). Compute the vertex normals. You now have the normals in object space for the bind-pose skeleton. For each weight of a vertex, transform the vertex normal by the inverse joint's orientation quaternion of the weight. You now have the normal in joint's local space. Then when calculating the final vertex positions, you will be able to do the same for the normals, except you won't have to translate from the joint's position when converting from joint's local space to object space. ----------------- So the first step is to compute bind pos normals, that's done and here is the screen to prove it: http://img151.imageshack.us/my.php?image=bindnormalsrd5.jpg here is the code I used to try to compute the joint's local space: //For each mesh do: for(unsigned int v = 0;v<mesh->numVerts;v++) { vmml::Vector3f finalnormal; Vertex *vert = &mesh->verts[v]; vmml::Vector3f normal = mesh->normals[v]; unsigned int start = vert->weightIndex; for(unsigned int w = 0;w<vert->weightElem;w++) { Weight *weight = &mesh->weights[w+start]; Joint *joint = &joints[weight->jointIndex]; vmml::Quaternionf invQuat = joint->quat; invQuat.invert(); finalnormal = invQuat.rotPoint(normal); //normal = joint->quat.rotPoint(normal); } mesh->normals[v] = finalnormal; } and just for reference the code to transform the verts into object space: There are no bugs in this code however. //vertBuffer is a temporary buffer to hold verts for bind pos normal calculations. vmml::Vector3f *vertBuffer = new vmml::Vector3f[mesh->numVerts]; for(unsigned int v = 0;v<mesh->numVerts;v++) { vmml::Vector3f final; final.set(0,0,0); unsigned int start = mesh->verts[v].weightIndex; for(unsigned int w = 0;w<mesh->verts[v].weightElem;w++) { Weight *weight = &mesh->weights[start + w]; Joint *joint = &joints[weight->jointIndex]; vmml::Vector3f wv; wv = joint->quat.rotPoint(weight->pos); final += (joint->position + wv) * weight->weightValue; } vertBuffer[v] = final; } and here is the code I use to transform the normals into world space for animating: void MD5Mesh::Render(Joint *joints) { glColor3f(1.0f, 1.0f, 1.0f); for(unsigned int m = 0;m<numMeshes;m++) { Mesh *mesh = &meshes[m]; vmml::Vector3f *vertBuffer = new vmml::Vector3f[mesh->numVerts]; vmml::Vector3f *normalBuffer = new vmml::Vector3f[mesh->numVerts]; for(unsigned int v = 0;v<mesh->numVerts;v++) { vmml::Vector3f final, normal; final.set(0,0,0); normal = mesh->normals[v]; unsigned int start = mesh->verts[v].weightIndex; for(unsigned int w = 0;w<mesh->verts[v].weightElem;w++) { Weight *weight = &mesh->weights[start + w]; Joint *joint = &joints[weight->jointIndex]; vmml::Vector3f wv; wv = joint->quat.rotPoint(weight->pos); normal = joint->quat.rotPoint(normal); final += (joint->position + wv) * weight->weightValue; } vertBuffer[v] = final; normalBuffer[v] = normal; } glEnable(GL_LIGHTING); glBindTexture(GL_TEXTURE_2D, mesh->diffTex); glBegin(GL_TRIANGLES); for(unsigned int t = 0;t<mesh->numTris;t++) { vmml::Vector3f one, two, three; one = vertBuffer[mesh->tris[t].x]; two = vertBuffer[mesh->tris[t].y]; three = vertBuffer[mesh->tris[t].z]; vmml::Vector3f n1, n2, n3; n1 = normalBuffer[mesh->tris[t].x]; n2 = normalBuffer[mesh->tris[t].y]; n3 = normalBuffer[mesh->tris[t].z]; glNormal3f(n1.x, n1.y, n1.z); glVertex3f(one.x, one.y, one.z); glNormal3f(n2.x, n2.y, n2.z); glVertex3f(two.x, two.y, two.z); glNormal3f(n3.x, n3.y, n3.z); glVertex3f(three.x, three.y, three.z); } glEnd(); delete [] vertBuffer; delete [] normalBuffer; } ///The rest of the method is just for kicks and overlays lines to represent bones and joints. glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); glColor3f(0.0f, 1.0f, 0.0f); glBegin(GL_LINES); for(unsigned int j = 0;j<numJoints;j++) { if(joints[j].parentIndex>=0) { glVertex3f(joints[j].position.x, joints[j].position.y, joints[j].position.z); glVertex3f(joints[joints[j].parentIndex].position.x, joints[joints[j].parentIndex].position.y, joints[joints[j].parentIndex].position.z); } } glEnd(); glEnable(GL_DEPTH_TEST); } and here are the results: http://img148.imageshack.us/my.php?image=brokennormalskw3.jpg This image has two meshes in it. A bind pos and an animated model. Notice that the bind pos normals are broken as well :S thanks for reading :)
3. ## stupid ortho problem

If I do that the pixel stays at the same place when I scale Y. I would have expected it to stay 10 pixels from the bottom no matter what.
4. ## stupid ortho problem

I'm trying to setup a ortho projection. The problem is that with the code below when I resize the y component of the window a point drawn at 10,10 moves in the opposite direction of the resize. the x resizes have no effect on the raster position of 10,10 in world coords. I'll post all the resize and drawing code here: void Application::Resize(int width, int height) { Application::height = height; Application::width = width; Application::halfHeight = height/2; Application::halfWidth = width/2; if(height == 0) { height = 1; halfHeight = 1; } glViewport(0,0,width,height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0f,width,height,0,-1.0f,1.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void Application::Render() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glBegin(GL_POINTS); glVertex2d(10.0, 10.0); glEnd(); glFlush(); } the initial window setup works fine until the y component of the window is changed, then the point is no longer at 10,10 pixels from the top left.
5. ## need a screen from VC++ 2005 express

I'm trying to figure out a problem with the SP1 for Visual Studio C++ 2005 express edition. It says it installs but if I goto Help->About it isn't listed under installed products. Could somebody who has the same setup take a screen and post it so I can see what numbers/version are there when it's properly installed? thanks.
6. ## mouse input for opengl in win32

I just ended up using directx. I wanted to avoid a dependency on such a huge library just for one small part of it, but it's so common anyway I guess it's no big deal. Anyway, I'm really impressed with it, and I'd recommend directx to anybody working on a big project.
7. ## OpenGL mouse input for opengl in win32

I've been using win32 GET_X_MOUSE_POS macros to get the mouse position then I've been setting it back to the center of the screen so it doesn't get stuck on the edges, but I was wondering if there was a better way, because the code for re-centering is really ugly and some times the mouse seems to get stuck. I'd rather not use direct input for this job, since the rest of the game is in opengl. thanks.
8. ## custom memory allocator

ok, I did some reading I get what you mean now. I'll probly just end up creating a "Factory" class that just dishes whatever class I need out from a fixed size array.
9. ## custom memory allocator

Quote: It's a good idea to use operator new for the particular datatype. That's the only way to ensure proper alignment. Ok but, what if I want to make SURE that all the data is in one chunk? Are you saying it would be best to make an array for each object type? If there is an array for each object type, wouldn't there be fragmentation between each array?
10. ## Unity custom memory allocator

I'm going to be writing a custom memory allocator, and I wanted to run my idea by the community first. I've never written one before but the fact that I want to benefit from the speed this kind of thing can offer I decided it would be a good idea. Basically I want to write a C++ class Called MemoryPool. On creation MemoryPool will run memory = new char[sizeInByes]; where memory is defined as char *memory; During usage that memory chunk will be divided on the basis of what types it's going to store. For example, I'd like to use it for octree and scene object management. So I would do: On level load: MemoryPool pool(neededBytes); //creates the block of memory pool.CreateBank(sizeof(StaticMapObject), numObjects); //Sets a pointer to a place in memory where numObjects of StaticMapObjects can live in the char array. A counter returns sucessive pointers as they are requested. pool.CreateBank(sizeof(OctreeNode), numNodes); //Same as other, but for OctreeNodes and in another place in the pool. Here are my questions: Is it a good idea to use a char array? Should I use an unsigned char array? is malloc better for this application? should the object "banks" be closely packed together? would it matter if the first bank had a 100 meg empty space between it and the next bank? If the spacing between bank affects speed, how can I reduce the space between the banks? How should I handle deleted objects? make a list of pointers to locations of deleted ojects for reuse? That about sums it up. If anybody knows of any resources that do this already please let me know. Also if there are any optimizations I could make here I would be glad if they were pointed out. Thanks in advance.
11. ## Game Programming video/audio tuts

Thanks for reply. I quickly watched one of the vids on that site you linked to. not bad, however I noticed there were an awful lot of pauses while the author typed in generic accessor functions. I was thinking about something a litte more fast paced, with bits of code pre-prepared, and some graphics to aid in the visualization of data structures etc. Also i'm really not sure what you mean by "Thing is about programming tutorials related to games (espically video ones I think), they are to much where you just must do it there way." Another question I ment to ask was: "Are torrents a good way to go with hosting this kind of video?"
12. ## My math course

If you're looking at 3d game programming calculus one, two (and three but it's not terribly useful) are good ones. linear algebra is beyond and doubt the absolute most important. In fact, some game companies say a strong knowledge in this area is a must. Could you give some more information on the courses? "Algebra and Trigonometry 2" is fairly generic.
13. ## Game Programming video/audio tuts

I watched a video tutorial for 3ds modeling, and i was very impressed. It sure beat reading tutorials on the net and trying to carry it over into 3ds max. Also I found that listening to somebody talk so that you can model at the same time really handy. This makes perfect sense for visual arts, because there is actually a lot the person doing the teaching needs to show during the tutorial. It made me wonder how useful video tutorials for programming would be. I know there is no direct reason for having video for programming the way there is a need for video while learning 3ds max, however I can think of a few indirect ways video would help while learning to program. For instance, when trying to do something complicated for the first time, the code one would have sort through is really large, and half the time you're just looking for those one or two lines in the mist of setup code that are important. Also, with video/audio programming it makes it easier to follow along rather than just copy/paste bits of a tutorial. I'm actually interested in starting a site that would host audio and video programming tutorials for games, but there don't seem to be any around today and I'm starting to wonder why. Is it because people would rather read about programming? is it because videos would take up too much bandwidth? I'm just looking for opinions/comments/suggestions on the idea. I'm posting this in the beginners section because beginners here are probly constantly on the lookout for a good tutorial, and are familiar with the problems of learning to program. thanks for your input.
14. ## FBO problem - renders only the blue component

i couldn't find any problems with your code, except that you don't need that genMipmaps command, since you're not setting up your texture with mipmaps, also it uses like 100% cpu to generate them every frame anyway. As for the colour not showing up, have you made sure that lighting is disabled? I thought maybe the two other verts are not lit for some reason. p.s. I'm also kinda surprised to see you're from around where I live...what are the odds? EDIT: Here is my FBO setup code....the only difference is that i used GL_RBGA8 in texture creation, and that could actually be the problem, it took me forever to get fbos working and i found them to be very finicky. Good luck. bool Framebuffer::Init(unsigned int width, unsigned int height, bool depthTexture, bool colourTexture, bool stencilBuffer) { if(fbID!=0) return false; Framebuffer::width = width; Framebuffer::height = height; if(width==height) target = GL_TEXTURE_2D; else target = GL_TEXTURE_RECTANGLE_ARB; glGenFramebuffersEXT (1, &fbID); glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fbID); if(depthTexture) { glGenTextures(1, &depthTex); glBindTexture (target, Framebuffer::depthTex); glTexImage2D (target, 0, GL_DEPTH_COMPONENT24, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, target, depthTex, 0); } else { glGenRenderbuffersEXT(1, &depthRenderBuffer); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthRenderBuffer); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthRenderBuffer); } if(colourTexture) { glGenTextures(1, &colourTex); glBindTexture(target, colourTex); glTexImage2D(target, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexParameterf(target, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameterf(target, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, target, colourTex, 0); } if(stencilBuffer) { //I'll include this one I figure out how to use the stencil buffer } if(depthTexture&&!colourTexture&&!stencilBuffer) { glDrawBuffer (GL_FALSE); glReadBuffer (GL_FALSE); } glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0); if(getStatus()) return true; else //for some reason the config given resulted in an incomplete/invalid FBO { if(colourTex!=0) glDeleteTextures(1, &colourTex); if(depthTex!=0) glDeleteTextures(1, &depthTex); if(depthRenderBuffer!=0) glDeleteRenderbuffersEXT(1, &depthRenderBuffer); if(stencilRenderBuffer!=0) glDeleteRenderbuffersEXT(1, &stencilRenderBuffer); if(fbID!=0) glDeleteFramebuffersEXT(1, &fbID); Framebuffer::colourTex = 0; Framebuffer::depthRenderBuffer = 0; Framebuffer::depthTex = 0; Framebuffer::fbID = 0; Framebuffer::stencilRenderBuffer = 0; Framebuffer::width = 0; Framebuffer::height = 0; return false; } };
15. ## OpenGL with SDL

nehe has a complete SDL-opengl vs.net setup. here is the link http://nehe.gamedev.net/counter.asp?file=files/basecode/nehegl_sdl.zip I've tried it in both windows and linux and it worked perfectly right out of the box. You actually may need to move some image files around if it crashes, but the log files it generates are really helpful.