Jump to content
  • Advertisement

skauert

Member
  • Content Count

    25
  • Joined

  • Last visited

Posts posted by skauert


  1. Hiya people. :)

    After working on this for about 2 weeks now, I'm -almost- there, but not quite. At the moment I'm quite lost, so I'm turning here for some assistance. I'm sorta confident that I have done the skinning correctly, and that I'm just screwing up my animation somehow. These are the results I have at the moment:

    PIcox.png

    Left: Skinned model in bind pose.
    Right: Skinned model being animated.

    Following is the animation code that I'm using for this:

    http://pastie.org/pr...iqovc1imh6mp8lg

    The joints are transformed hierarchically during the rendering of the model, so that has already been taken care of. As far as I understand, animation should be on a per-joint basis, without regard to what they are connected to. This is what I had in mind when I wrote this code.

    I'm using Assimp to import a COLLADA model for this particular case. The model is a sample model from their test model bank.

    EDIT: I should also mention that the animation contains non-zero rotation quaternions from keyframe 0 (which should more or less be the bind pose). To me this seems a bit odd, but someone more versed in this area might be able to clarify this. I can also confirm that the model animates fine in the Assimp Viewer program, so the problem should be on my end.

    Any help is greatly appreciated!

    EDIT #2: I might have posted this in the wrong forum. Sorry for any inconvenience. =/

  2. Hey guys.

    Sorry for not replying right away. I spent yesterday and all of today working on my converter.

    @phantom: Your way sounds very clean. If I were doing a bigger project, I would probably look into something like it. My current approach isn't very optimized at all, but the fact that my project is so small makes it not really that bad. ;o I also feel like I'm learning a bit more by doing it in a very straight-forward way -- but maybe I'm just imagining things.

    Right now, I've gotten it to a point where I use Assimp in my converter tool to import any kind of format it supports, and then I export the data into a binary file with the following format:


    <magic_number>
    <mesh_identifier> // Can appear multiple times per model
    <material_id>
    <num_vertices>
    <vertex_data>
    <vX,vY,vZ>
    <nX,nY,nZ>
    <tS,tT>
    <num_bones>
    <bone_data>
    <bone_id>
    <weight>
    <material_identifier> // Can appear multiple times per model
    <mat_data>
    <id>
    <ambient:R,G,B>
    <diffuse:R,G,B>
    <specular:R,G,B>
    <shininess:float>
    <texture_strlen>
    <texture_string>
    <bump_strlen>
    <bump_string>
    <normal_strlen>
    <normal_string>
    <skeleton_identifier>
    <num_bones>
    <bone_data>
    <id>
    <transform:mat4>
    <animation_identifier>
    ...


    I've only tested it with a sample OBJ file I downloaded from gfx-3d-model.com (http://www.gfx-3d-mo...el-3/#more-1075), and it seems to render it just fine. This means that mesh and material data is working as it should. Your input has been very valuable in all of this. Thanks! ^_^

    The only thing remaining is skeleton and animation data. This is a project for tomorrow and onwards. As you can see, I've barely started the design of how I want skeleton/animation data to be stored. From what I've learned when reading up on these topics, I feel like the following -should- work (in theory):

    - The skeleton will start out with a root node, and each node will have a list of child nodes, as well as a rotation matrix. When animating, the rotation matrices will be modified recursively in respect of their parents' matrix.
    - Each vertex will contain a list of bones that they are connected to, with weights affecting exactly how big of an effect it is. In the vertex shader, I will simply multiply gl_Position with the matrix of each bone, in addition to the mvp matrix.
    - As for animation... I have to admit I have not read up very much about that yet. :(

    It's a little bit off-topic, but if there are some tips in regards of skeletons/animation that you guys can provide, I'd love to hear it! :)

  3. Hey! Thanks for the response.

    By dictionary, I assume you mean having a header which contains locations of specific data. Is that correct?

    I thought a bit about it, and I came up with this way of doing it:


    <magic_number>
    <mesh_identifier>
    <num_vertices>
    <vertex_data>
    <material_identifier>
    <sub_material_identifier #1>
    <material_data>
    <sub_material_identifier #2>
    <material_data>
    ...
    <texture_identifier>
    <texture_dimensions>
    <texture_data>
    <skeleton_identifier>
    ...
    <animation_identifier>
    ...


    I guess it looks a tiny bit like XML. This is not intended, and is only for clarity in this example.

    As for the rest, it is entirely up to you.[/quote]
    Yeah, that's the essence of creating your own model format. I am however (in my opinion) enough in the dark when it comes to this that I'm looking for some input on whether I'm actually going in the right direction or not. One of the main issues I'm trying to work around with these binary files is how to design it so that data can optionally be present or not. If all data was required to be there all the time, this wouldn't be a problem, but alas. The other is obviously the fact that I have not done skeletal animation before, so some of the approaches I'm doing with e.g. the mesh might be invalid in this case. :/

    I read your article, by the way. Very interesting, and definitely something I will consider in the future. For now, space is not a very big issue, as I'm mainly focusing on getting something -working- for my upcoming projects (which are all PC/Windows projects), which shouldn't be that heavy on models either.

  4. Hello guys.

    After doing a lot of research on what people tend to do with their model assets and the likes, I decided that what I want to do for my game engine is to create a new tool that allows me to convert certain formats (such as COLLADA and OBJ) to my own binary format that will be used by my engine. This seems to make the most sense for both convenience and performance, however I am more or less in the dark when it comes to this because it's all very new to me. For this reason, I would greatly appreciate if I could get some input here to push me in the right direction.

    OBJs have worked so far for me. The only reason I'm doing this now is because I'm looking into doing skeletal animation (from Maya). I'll probably end up going with COLLADA, since MD5 is apparently not very supported by Assimp, which is what I'm using to import model/scene data into my converter tool. While reading this, please assume that I'm looking to do this in one of the simplest ways possible. I do not wish to extend this too much, as it will become very time demanding - which I'm rather short on at the moment. :-(

    Anyway, enough ranting.

    This is the current format I have thought out for my binary file. At the moment it's very basic, and I have no doubt that it's missing stuff.


    <magic_number>
    <uint:meshLocation>
    <uint:materialLocation>
    <uint:textureLocation>
    <uint:skeletonLocation>
    <uint:animationLocation>
    <data:mesh>
    <data:material>
    <data:texture>
    <data:skeleton>
    <data:animation>


    The location header data would simply be 0 for data that isn't used. When something is non-zero, the importer would go to that location and start reading data. I was thinking of simply putting in tightly packed floating point values, for example "vX,vY,vZ,nX,nY,nZ,tS,tT" for mesh vertex data.

    Since I have never done animation before, I do not know if this approach is viable for skeletal and animation data.

    Every little piece of advice is helpful! This area of programming has probably bewildered me the most out of all of them until now.

  5. Thanks for the responses, guys.

    I've had experience with COLLADA in the past, and while it was a successful experience, it was not a pleasant one. To be honest, I was hoping to discover formats more convenient than COLLADA, but it seems like it could be a worthy choice. On that note, I have a couple of more questions.

    1. When I used COLLADA last (1.4 I think), I worked with the DOM directly. Are there SDKs/tools that people use these days to make the interaction with COLLADA more convenient?

    2. I did a bit of research on exporters, and I came across something called ColladaMaya NextGen. Should I experiment with this, or is there something even more recent that I should be looking into?

  6. Hi.

    I'm looking to venture into the world of 3D animation. Currently I am using OpenGL/GLSL and VBOs to render my meshes, and simply loading vertex data from OBJ files.

    After searching the web for information on what some popular formats are, the one that pops up the most is MDX (MD5 seems to be the most recent one). I am however sceptical about the export process tied in with this format. My assets come from a modeller that really only uses Maya (2011/2012), so I'm interested in finding a format that can be (conveniently?) exported using this program.

    In addition to that, I do not want to rely on any sort of SDK, and -preferably- no external libraries to do this.

    With all that being said, I would like to ask you guys at gamedev.net for suggestions on file formats for skeletal animation that compliment my current situation. Any suggestion will be greatly appreciated. :)

  7. Thanks a lot, sprite! What you provided turns out to be exactly what I needed. What's odd is that I tried working with _just_ vertices yesterday and I still couldn't get it to draw. As far as I can recall, my code was very similar to what you provided here. Then again, I was going into my 6th hour of trying to get it to work, so my head might not have been functioning sufficiently. :/

    So just to make sure I fully understand this -- to associate data from C/C++ with the shader program, all I need to do is use VBOs to store the data and then use glVertexAttribPointer() and glEnableVertexAttribArray() to associate it with the appropriate attribute ID?

    EDIT: Oh, and sorry about the matrix stuff in there. The points were not actually supposed to be transformed in any way. At the moment I was simply trying to get -something- to display on the screen. I just pre-emptively put some transformation there to test out my home-made matrix library. :-)

  8. Hello Gamedev.

    For the past couple of days, I have been studying GLSL and I've been looking to try and implement it myself. However, despite continuous effort, I have been unable to get anything to draw on the screen. At the moment, as far as I can see, I am out of options. For this reason, I decided to ask for help here.

    My current implementation isn't very big. It's available here: http://pastebin.com/Wp76fQDP

    The shaders I'm using are here: http://pastebin.com/7xpZncuS

    A lot of this is very similar to the 5th edition of the OpenGL Superbible, as that is what I've used to learn shader programming.

    The shaders seem to compile and link just fine, and there are no OpenGL errors. As far as I can see, I must be doing something very wrong with geometry storing and/or linking them with the shader programs.

    Any help is greatly appreciated. :-)

  9. After some more fiddling, I actually managed to make this work by also storing the projection matrix after transforming the camera position and orientation. I'm pretty surprised that my professor also missed this little detail. Personally, I'm not quite there yet when it comes to graphic theory behind the different matrices, apart from basic understanding. I guess I will inquire him about it next week.

  10. Hello all. :)

    A recent project for my university course has me developing a 3D matching pairs game. As with all my other projects, I've taken this one too a few steps further. The player is able to navigate the world by free roaming, as they would as an observer in an FPS game for example.

    Everything was going fine until my professor introduced ray tracing for the purpose of picking objects. I started trying to implement a method of converting mouse coordinates from the 2D viewport to the 3D world, and this gave me much more problems than I thought it would. In fact, my professor was a bit lost on this one too.

    Here's a screenshot of my algorithms in action: http://i.imgur.com/1ezdN.png

    Those lines (rays) are a result of me clicking in different areas on the island in front of me. If the code was working as it should, those rays should have been cast from the "camera"'s position, towards the island. Instead, they originate from *below* the island and shoot diagonally upwards, away from the "camera".

    For the sake of trying to be as thorough as possible, I will include relevant bits of code.

    The following code is used to convert screen coordinates at mouse point X and Y (mpX, mpY) into world space coordinates, as well as creating a Ray between the near plane and the far plane. It should be noted that the modelview matrix has already been stored prior to calling this method in the GLRenderer class. I will explain that later on.


    Ray GLRenderer::getRayFromMouseCoords(int mpX, int mpY)
    {
    Ray r;
    double pjMatrix[16];
    double x, y, z;
    int viewPort[4];

    glGetIntegerv(GL_VIEWPORT, viewPort);
    glGetDoublev(GL_PROJECTION_MATRIX, pjMatrix);

    gluUnProject(mpX, viewPort[3] - mpY, 0, modelviewMatrix, pjMatrix, viewPort, &x, &y, &z);

    r.origin = CVector((float)x, (float)y, (float)z);

    gluUnProject(mpX, viewPort[3] - mpY, 1, modelviewMatrix, pjMatrix, viewPort, &x, &y, &z);

    r.direction.x = (float)(x - r.origin.x);
    r.direction.y = (float)(y - r.origin.y);
    r.direction.z = (float)(z - r.origin.z);

    return r;
    }



    The code below is from the main loop. The camera position and orientiation are the *only* transformations that occur before the modelview matrix is stored.


    ...

    // Rotate according to the camera orientation.
    glRotatef(camera.angle.x, 0.0f, 1.0f, 0.0f);
    glRotatef(camera.angle.y, MathLib::cosL(camera.angle.x), 0.0f, MathLib::sinL(camera.angle.x));

    // Translate according to the camera position.
    glTranslatef(camera.pos.x, camera.pos.y, camera.pos.z);

    // Store the modelview matrix.
    glrObj->storeMVMatrix();

    ...


    I would be grateful if someone could help me out with this problem, or at least push me in the right direction, as it's been driving me insane in the last couple of days. I'm also sorry if I posted this in the wrong area.

  11. Quote:
    Original post by Erik Rufelt
    Just as you read your colors from the pixels array, you could write colors to another array which represents an image the size of the screen or window you are drawing to. Then you can create a texture with the colors in that image and draw it as a single quad.

    Curious about this... When you talk about textures and quads, do you mean the concept of them, or actually invoking OpenGL's texture and quad utilities? I know we're not allowed to use OpenGL's texture binding methods and GL_QUADS for this assignment.

  12. Hello.

    We've been given an assignment in the course I'm taking to develop a simple asteroids game which may or may not contain sprites. The limitation is that we can only use OpenGL/SDL to: open a window, handle double buffering and drawing a single point/pixel. Everything else that has to do with rendering has to be programmed by ourselves.

    Today I was tinkering with reading pixel data from memory and plotting pixels accordingly with glColor4ub(). The following code seems to work for non-scaled images:


    void Image::draw(float x, float y)
    {
    glBegin(GL_POINTS);

    unsigned int pixel;
    GLubyte r, g, b, a;

    for (int iy = 0; iy < h; ++iy)
    {
    for (int ix = 0; ix < w; ++ix)
    {
    pixel = pixels[(((h - 1) - iy) * w) + ix];

    r = pixel & 0xFF;
    g = (pixel >> 8) & 0xFF;
    b = (pixel >> 16) & 0xFF;
    a = (pixel >> 24) & 0xFF;

    glColor4ub(r, g, b, a);
    glVertex2f(x + (float)ix, y + (float)iy);
    }
    }

    glEnd();
    }



    The problem I'm having now is something that I imagined would be an issue from the very beginning: it's very slow.

    What kind of methods should I look into to speed something like this up? Also keeping in mind the limitations of the project. I have yet to confirm with my professor if we're able to use other methods than GL_POINTS for plotting pixels, but it could be a possibility as long as the concept remains the same.

  13. Hello everyone. So I'm trying to wrap my head around how the Midpoint/RK2 method works for numerical integration in a physics engine setting. I've sort of worked something out, but it doesn't feel very correct. Currently, I'm sitting with this: http://i46.tinypic.com/20si14z.png Where X is position, V is velocity, a is acceleration and dT is the timestep. Any input to help sort my thoughts out would be greatly appreciated. :)

  14. So I'm at the stage with my game where I want to create some visual effects. The one that I've been specifically interested in is radial blur. This might or might not be hindered by the biggest limitation of my game: it's not using any form of acceleration such as OpenGL or DirectX, just normal bitmaps. I've done some searching already, and most of the documents I've found are implementation using either of those two. As a last resort, I want to ask you guys. Is there a good way to create a radial blur effect in C# on a Bitmap without the use of OGL/DX/XNA? If not radial, what about other blurs?

  15. Oh wow, just after posting this, I realized that I had made the stupid mistake of always drawing the top-left corner at a specific x,y position. This entire issue is fixed if I specify the location of the middle pixel, and then draw the top-left corner at mid_x - width/2, mid_y - height/2.

    I feel kind of silly now. :(

    This topic became useless pretty quick... I suppose if anyone has any tips in terms of this kind of coding practice and optimization around Bitmap transformations, I'll happily accept them.

  16. Hello fellow Gamedevs. I'm preparing a basic engine setup for my game project that I'm going to do in C#. This is an assignment for university, and we've been instructed to not use APIs such as OpenGL and DirectX. I've made a basic image rendering class which is almost complete, I just haven't fully completed the method for rotating a Bitmap. Personally, I don't feel like I'm 100% educated in terms of rotation logic and such. What I'm hoping is that the reponses to this, code samples or not, will help shed some light on the issue at hand. I'm aware of how rotation works for matrices and such, just not how to properly apply them to a bitmap. The rotation function that I've used is courtesy of vcskicks.com.
           private System.Drawing.Image RotateImage(System.Drawing.Image inputImg, double degreeAngle)
            {
                //Corners of the image
                PointF[] rotationPoints = { new PointF(0, 0),
                                            new PointF(inputImg.Width, 0),
                                            new PointF(0, inputImg.Height),
                                            new PointF(inputImg.Width, inputImg.Height)};
    
                //Rotate the corners
                PointMath.RotatePoints(rotationPoints, new PointF(inputImg.Width / 2.0f, inputImg.Height / 2.0f), degreeAngle);
    
                //Get the new bounds given from the rotation of the corners
                //(avoid clipping of the image)
                Rectangle bounds = PointMath.GetBounds(rotationPoints);
    
                //An empy bitmap to draw the rotated image
                Bitmap rotatedBitmap = new Bitmap(bounds.Width, bounds.Height);
    
                using (Graphics g = Graphics.FromImage(rotatedBitmap))
                {
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
    
                    //Transformation matrix
                    Matrix m = new Matrix();
                    m.RotateAt((float)degreeAngle, new PointF(inputImg.Width / 2.0f, inputImg.Height / 2.0f));
                    m.Translate(-bounds.Left, -bounds.Top, MatrixOrder.Append); //shift to compensate for the rotation
    
                    g.Transform = m;
                    g.Clear(Color.White);
                    g.DrawImage(inputImg, 0, 0);
                }
                return (System.Drawing.Image)rotatedBitmap;
            }
    
    
    
    
        public static class PointMath
        {
            private static double DegreeToRadian(double angle)
            {
                return Math.PI * angle / 180.0;
            }
    
            public static PointF RotatePoint(PointF pnt, double degreeAngle)
            {
                return RotatePoint(pnt, new PointF(0, 0), degreeAngle);
            }
    
            public static PointF RotatePoint(PointF pnt, PointF origin, double degreeAngle)
            {
                double radAngle = DegreeToRadian(degreeAngle);
    
                PointF newPoint = new PointF();
    
                double deltaX = pnt.X - origin.X;
                double deltaY = pnt.Y - origin.Y;
    
                newPoint.X = (float)(origin.X + (Math.Cos(radAngle) * deltaX - Math.Sin(radAngle) * deltaY));
                newPoint.Y = (float)(origin.Y + (Math.Sin(radAngle) * deltaX + Math.Cos(radAngle) * deltaY));
    
                return newPoint;
            }
    
            public static void RotatePoints(PointF[] pnts, double degreeAngle)
            {
                for (int i = 0; i < pnts.Length; i++)
                {
                    pnts = RotatePoint(pnts, degreeAngle);
                }
            }
    
            public static void RotatePoints(PointF[] pnts, PointF origin, double degreeAngle)
            {
                for (int i = 0; i < pnts.Length; i++)
                {
                    pnts = RotatePoint(pnts, origin, degreeAngle);
                }
            }
    
            public static Rectangle GetBounds(PointF[] pnts)
            {
                RectangleF boundsF = GetBoundsF(pnts);
                return new Rectangle((int)Math.Round(boundsF.Left),
                                     (int)Math.Round(boundsF.Top),
                                     (int)Math.Round(boundsF.Width),
                                     (int)Math.Round(boundsF.Height));
            }
    
            public static RectangleF GetBoundsF(PointF[] pnts)
            {
                float left = pnts[0].X;
                float right = pnts[0].X;
                float top = pnts[0].Y;
                float bottom = pnts[0].Y;
    
                for (int i = 1; i < pnts.Length; i++)
                {
                    if (pnts.X < left)
                        left = pnts.X;
                    else if (pnts.X > right)
                        right = pnts.X;
    
                    if (pnts.Y < top)
                        top = pnts.Y;
                    else if (pnts.Y > bottom)
                        bottom = pnts.Y;
                }
    
                return new RectangleF(left,
                                      top,
                                     (float)Math.Abs(right - left),
                                     (float)Math.Abs(bottom - top));
            }
        }
    
    
    This produces the following result: 0 degrees: http://i47.tinypic.com/r8cxhd.png 22.5 degrees: http://i46.tinypic.com/hsoxo9.png 45 degrees: http://i50.tinypic.com/vy6q8z.png From what I can see, the produced Bitmap only extends its boundaries towards the right and the bottom, while it should also extend in the other 2 directions to make the image rotate properly around the center. I spent quite a while playing around with the method, and in the end I was unable to produce the desired result. The background of the produced Bitmap is colored white simply to be able to see its real size. Any form of assistance is gladly appreciated. :)

  17. What you've written makes sense. As this is my first time making something like this, I'll probably have to spend some time experimenting with how I'm going to base my engine around it. The sphere sounds like a really cool idea, but I don't know if it's possible to do with windows forms alone, as I'm not implementing this with DX/OGL. I'll probably either make a background that works well for looping, or have a black background and just dynamically generate background objects/particles, since I plan for the game to take place in outer space.

    This will probably get me very far. Thanks a lot, smc. :)

    EDIT: Oh, and just out of curiosity, what does the 't' variable represent in your movement algorithm?

  18. Apologies for the vague title, as I couldn't think of a better way to describe it. I'm also sorry if I posted this in the wrong forum. I'm currently planning to create a game that makes use of a type of screen scrolling similar to that of Asteroids. This is an entirely new area for me to explore, and while I think I have a very basic idea of how to do it, I would love some input from more experienced developers. To explain how exactly I'm picturing my game layout to be, I've included some lame MS Paint illustrations. http://i47.tinypic.com/wlw49j.png The blue triangle represents the player ship, while the red circles are enemies. The portion of the game area that's currently displayed is marked with a black rectangle. As the player ship moves around, the screen will follow it due to the full area size being larger than what the screen covers. This is simple enough for me to handle, but this is where it gets a bit tricky for me. http://i50.tinypic.com/15f0scn.png When the screen rectangle's coverage exceeds that of the complete area, it's supposed to kind of loop to the opposite side, so you get the illusion of a repeating world. This holds true for both the X and the Y axis, so in the worst case scenario, the screen will cover all 4 corners. In addition, as I've attempted to display in the picture above, the enemy chooses the path closest to the player when attempting to fire at them, even if the player ship is technically on the other side of the screen. This part I'm basically lost on how to do, so I'm happy for any kind of help/feedback on the matter. I'm developing this using C#, but any non-code related theory on the matter is very welcome. Many thanks in advance for any help that may be provided. :)

  19. Is it actually possible to programmatically change the font of a C# console window? :o After some research, it doesn't seem like it. Unless you mean manually changing it in the system, which I doubt I have access to anyway. :/

    And I did test it both with and without a different code page. No matter what I do, I can't seem to get it working on the university's computers. I don't think it was meant to be. Though it's such a simple and pointless little thing anyway. :)

    Again, thanks for all the input.

  20. Darn. :/ Oh well.

    I'll just go with a stock solution for this particular project. At least it's the only one of its kind, so I shouldn't have to deal with this problem again.

    Thanks for the help you've provided. :D

  21. Yup, I'm pretty sure Unicode has what I want. The problem is that the Windows console (or the font it uses) doesn't seem to support it. At least not in my experience. Most of the time it prints a character that isn't related to what I want, or most of the time just a "?".

    Am I doing something wrong? :(

  22. Hello everyone. I'm writing a Snake game for my Year 1 of Computer Games Development course, and it is in my interest to use a couple of special ASCII characters for art in the game. The game is supposed to be console-based. From what I understand, there's a code page mismatch between my development computer and the university computers which are supposed to run the game. The university computers seem to use IBM850. Both IBM437 and ISO-8859-1 include the characters that I'm interested in, such as ASCII 236 and 221. Most of the ASCII that I want is also included in IBM850, but the ones I mentioned do not seem to be. I've tried to enforce the code page using the following:
    Console.OutputEncoding = System.Text.Encoding.GetEncoding("IBM437");
    
    If this isn't the way to go about it, please tell. However, even with this, it has no effect on the results when I run my application on any of the university computers. It's not a security issue, as I've had it tested with a local administrator account as well. Could it be that the code pages I need simply aren't installed on the computers? If so, is there any way I can work around this? Keeping in mind that I have limited access to functionality within these computers.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!