Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 29 Apr 2002
Offline Last Active Yesterday, 07:23 PM

#5312936 Why do new engines change their file extensions and formats all the time?

Posted by on 27 September 2016 - 06:19 PM

Probably to add features existing formats dont have, compression, mipmaps precalculated, HDR, could be a million things other formats dont support or dont do well enought for them.

#5311740 correct modeling for game developement (poly count)

Posted by on 21 September 2016 - 12:32 AM

Thats pretty much correct, the baking youre referring to is common to generate a normal map (and other maps, AO, etc). The general idea is you have a low poly and a high poly that essentially match/lineup except they have different poly counts, and therefore the higher poly one is more detailed. You "bake" these high poly details into a texture (like a normal map) and then apply the normal map to the low poly in game for lighting calcs, etc.


Youre missing steps in the sense that it can be a little more involved, depends on the tools/process used, normal map output depends on the target engine/software format, conventions, etc. and as I understand it, its not exactly hard to generate bad maps containing errors if the input models are not what/where they need to be.


a program called x-normal is often used for the "bake" process.


As for poly counts, again its sort of target dependent, what are they for, I believe the characters in doom 3 if I remember were somewhere between 1500-3000, thats probably on

the lower end these days, but again its depends on the target use and the effects that will be applied to it, it really could be anything. Two triangles for a wall in the world with a lot

of effects on it might do the job. For the high poly bake source, ive seen extremely high counts, 100s of thousands or more depending. But again it depends on whats needed.

#5308759 GLSL: Incorrect WorldPosition

Posted by on 30 August 2016 - 06:44 PM

Im not sure what "matTotal" is or how youre building it, is "matTotal" the combined world * view * proj matrix? if it is you might be transforming object space verts (vertexPos) into world (WorldPos) and then transforming world space pos "WorldPos" by world again, as part of the world view proj matrix "matTotal".

"matTotal" is an odd name, might wanna name it what it is, MVP or VP.

#5284809 How to find the center of a modelview matrix?

Posted by on 02 April 2016 - 07:27 PM

Imagine a stack of matrices, in this case the "model_view" matrix stack activated with a call to glMatrixMode()


glPushMatrix() copies the matrix on the top, and then makes it the new top


this essentially saves matrix1 (any transforms youve done) and creates a copy, which you might then follow with a call that modifies the top matrix further, such as

glTranslate*() -> builds a translation matrix and multiplies it into the top of the current stack (the matrix 1 copy) further transforming matrix 1
glScale() -> same thing, but a scale matrix is multipled into top
glRotate()  -> same thing, but a rotation matrix it multipled into top
glLoadIdentity() -> clear top to identity
glMultMatrix() -> you provide the matrix already built

[matrix1copy] *= Trans|Scale|Rot Matrix

now you draw, its use the top, then when you are done drawing, you call PopMatrix(), which removes the top and goes back to the original


simple example, want to draw an object at 10 down +x, at 20 down +x, and 5 up +y



[matrix0.identity] <- glPushMatrix()

[matrix0.(10, 0, 0)] <- PushMatrix(), *= glTranslate(10, 0, 0), now draws at 10 down x

[matrix0.(20, 0, 0)] <- PushMatrix(), *= glTranslate(10, 0, 0), now draws at 20 down x
[matrix0.(10, 0, 0)]
[matrix0.identity] <- drawing now draws at origin

PopMatrix(), PopMatrix()

[matrix0.identity] <- drawing now draws at origin

[matrix0.(0, 5, 0)] <- PushMatrix(), *= glTranslate(0, 5, 0), now draws at 5 up y

thats the general idea anyway, think of pushmatrix as transform save point, a fork in the road you might want to come back to before applying more transforms.
Its the model view matrix because you generally put the view matrix (inverse of the cameras matrix) at the bottom (first) which brings an objects model matrix (world matrix)
into the cameras "view space". These are all old opengl calls, but the idea can still be important to understand.

#5272940 Recommendations for a Text Editor

Posted by on 27 January 2016 - 10:03 PM

Not sure if its what you need, https://code.visualstudio.com/

I use it for quick shader editing, it has highlighting and extensions, not sure about heavy plugins

#5271629 Resolving Creative Differences

Posted by on 17 January 2016 - 07:55 PM


#5257744 Question regarding game mechanics and dynamic allocation

Posted by on 17 October 2015 - 09:02 PM

You could also make the observation that your weapon likely has an ammo capacity, which you could pre-allocate at start up or creation time, and simply fire one out of the list placing it in a "used" or "fired" list of some sort and get a new one next time from the unused/loaded list. Once a used bullet dies, hitting an object or traveling too far, recycle it back into the unused list.

If you need infinite ammo, your weapon probably has a rate of fire, and the bullets probably have a max travel distance limit, you could again use this info to allocate the max bullets you might ever need, and just keep firing and recycling.

What you can do is sorta dependent on what youre making, but it could be as simple as pre allocating an array of bullets, and maintaining a fired/loaded link list of bullets where each bullet has a pointer to the next, where next is either fired or loaded depending on which list the bullet is in.

#5246816 Perspective projection makes triangle disapear

Posted by on 15 August 2015 - 08:49 PM

Well your view matrix is at (0, 0, 0) looking at (0, 0, -1) on the z with y up, wheres your triangle data and indices? Im guessing not in view between 0 and -1 on the z. Your model matrix is identity so its not moving the vertices from what they were defined as.

#5224361 OpenGL View Matrix that rotates the camera

Posted by on 19 April 2015 - 03:01 PM

What part are you hung up on? what are you trying? There are a few ways to get a view matrix depending on your setup.

If you treat a camera as a regular object like any other, the view matrix is simply the inverse of that objects world matrix. Controlling it with pitch yaw roll (p-y-r), first thing youll want to do is track these values and wrap them at 360.

Once you have p-y-r angles, make rotations out of them (using quaternions, matrices) around each axis from the axis|angle, roll around z, yaw around y etc. Concatenate them, world = roll * (yaw * pitch), invert and convert to matrix if not already, and load it as the view matrix.

Other options, track the y-p-r values, use the angles to rotate the x-y-z axis, use the resulting vectors to create the vectors for the lookat function, at = pos + zaxis, up = yaxis. You could also use the final matrix from the first option to rotate the x-y-z axis, and build the lookat vectors from the results.

#5223061 Skeletal animation with COLLADA

Posted by on 13 April 2015 - 07:35 PM

Im going to refer to bones as joints, where a joint is a local xform (transform, xf), which when combined with its parent joints world xform, produces the joints world xform, Where a transform is often a matrix, or individual translation, scale, rotations that make up the xform.

Youll have to sort out the matrix conventions based on what you do in your code and what you get from the file. I would get it working on the cpu and then moving the skinning to the gpu when you have it working.

joint_local_xf = given from file, an offset from the parent joints xform (no parent, local = world)
joint_world_xf = parent_joint_world_xf * joint_local_xf

So you have........

original_vertices = model consisting of a list of vertices (and indices)
bind_shape_matrix = from creation package, when the model was created and bound to skeleton
inv_bind_pose_matrix[] = array of matrices, 1 for each joint (assuming, or identity)
weight_list[] = list of weights associated with a joint, how much the joint affects the vertex
animation_key_times[] = array of frame times, when you land between two key times, you interpolate using some method
animation_key_data = lists of matrices that refer to what a joints transform should be at a given time, sometimes stored as matrices, often easier to work with as separate translation, scale and rotation

After the model is loaded, you have the original vertices.
The bind_shape_matrix is applied every frame and doesnt change, so you can apply it once at load, save the result and use it for skinning.
    bind_shape_vertex[i] = bind_shape_matrix * original_vertex[i]
Each joint (bone) has a xform from the scene, this is probably the pose for frame zero (first frame). You can think of these local xforms as the local xforms to use for the animation if the joint didnt move during the animation.
Ex. An arm up in the air, but only the wrist joint moving left to right, the elbow and shoulder would be up in the air at the start, but wouldnt animate, only the wrist joint would change.

During the scene loop

1) advance the animation time, clamp or wrap time to stop or repeat, scale to speed up down, etc
2) use the current animation time to interpolate between two animation key frames local transforms producing a new local transform for a given joint
this is where data as vec3s and quaternions for rotations might be easier to work with, rather then matrices
   interpolated_anim_data_xf = lerp(anim_data_xf[n], anim_data_xf[n+1])
3) set this interpolated local xform from 2) as current for the joint (replacing the one from the frame 0 pose from the scene, or not maybe if the joint has no animation data)
   joint_local_xf = interpolated_anim_data_xf
4) update the joints world xform using its new interpolated local transform, root -> leaf
   joint_world_xf = parent_joint_world_xf * (interpolated_)joint_local_xf
5) create a skinning matrix for each joint from the new world matrix
   joint_skin_matrix = joint_world_matrix * joint_inv_bind_pose_matrix
6) do the skinning using the bind_shape_vertices[] and each joint_skin_matrix

ForEach bind_shape_vertex[] v
   skinned_vertex_pos = vec3(0.0, 0.0, 0.0)
   ForEach joint j affecting vertex v
      skinned_vertex_pos += (joint_skin_matrix[j] * bind_shape_vertex[v]) * joint_weight[]          // this is done positions and normals, remember to normalize if things look weird
   skinned_vertex[v] = skinned_vertex_pos

7) Draw the skinned_vertex[] list

Thats the general idea of how the data is used

#5222669 How to create a circular orbit and an angry bird space like orbit ?

Posted by on 11 April 2015 - 05:36 PM

Well if youve got it attracting to the planet you just need to go around it now. Simplest way would be to just apply a force to move perpendicular to the vector from the object to the planet.


vec2 dirToPlant = normalize(planetPos - objectPos);

side = vec2(-dirToPlant.y, dirToPlant.x);

object.AddForce(side * someForce);            // <-- recalc side and do this each frame while inside the attracting region

#5221530 Issues with IDE Linker? Why is this happening, and how do i fix it?

Posted by on 05 April 2015 - 04:56 PM

Maybe the include guards on lines 21, 22, 46, 47 and the #endif at the end of the file are messing things up, maybe they shouldnt be there at all after you moved things around?

Also where is this Object class?

#5221378 Resizing high resolution textures without software?

Posted by on 04 April 2015 - 01:19 PM

Image Magick cmd line tool?

#5217533 Mantle programming guide and white paper released

Posted by on 18 March 2015 - 08:48 PM




From whats being said about the new apis coming, this should give an early look at whats to come

#5214147 Vulkan is Next-Gen OpenGL

Posted by on 03 March 2015 - 03:20 AM