Advertisement Jump to content
  • Advertisement

SapphireStorm

Member
  • Content Count

    20
  • Joined

  • Last visited

Community Reputation

140 Neutral

About SapphireStorm

  • Rank
    Member
  1. SapphireStorm

    Texture Coordinates

    Thanks for the post Bob. That's basically the kind of post I needed. Something like, "Hey. You should be able to do this. Your code is broken. Go fix it." So, I started with textures, all the way back to my DDS reader. Loaded up a sample DDS in an external viewer and rendered some full screen quads using a tex coordinates scheme from directX. The quad looked upside down as expected and as I remembered testing the code originally. If I go out and change change the tex coordinates to match how OpenGL works, the textures match. At this point, I was pretty confident the texture pipeline was alright. As long as you account for the different orientation of the V-axis, you should be in the clear. Then, I started digging a little deeper, into the models themselves. I really stumbled up the actual problem by pure luck. I was messing around with triangle winding and eventually noticed the textures looked correct on the back faces of all the triangles in the model. Which is when I remembered I never actually accounted for the handedness difference between the two renderers. Well, that's not entirely true. I basically just hand waived at it. I was like, "Well, instead of the default pose of a model looking at me, it will be looking away from me. So, who really cares? I'll just have the camera and lights be oriented from the other side of Z and be done with it." And, honestly, that worked pretty well. However, something else happens, which at the conceptual level I still don't fully understand. The best way to describe it is it causes your models to render inside-out. If someone can clarify exactly what happens, I would like to know. But anyways, the actual solution was, as you initially read in data, negate the Z in all model position vectors and negate the I and J in all the model quaternions.
  2. Hi guys, I'm rendering assets originally created for a D3D pipeline with OpenGL. To account for the texture coordinate differences between the two API's, I am applying a simple transform to all V coordinates per vertex, namely V = 1.0f - V. Now, this sort of works. However, I don't think it's quite right. The U values seem to be reflected after this transform. For most models, the human visual system is not acute enough to actually tell a difference. Models which have text on them, however, clearly illustrate the problem. They look as if you wrote a sentence in MS Paint and then clicked 'flip horizontally'. I'm just wondering if this side effect makes sense or maybe I'm doing something else wrong entirely.
  3. SapphireStorm

    Animation File Format

    Hi guys, I'm trying to reverse engineer an animation pipeline and I've ran into a problem. I have three types of files. The first represents the geometry of a model in its default pose. The second file contains bone information for the model. This file contains all bone names, absolute orientations (as quaternions), and absolute positions (as vectors) for the model in its default pose. At this point, I can go out and render a model with its default bones as cubes in the same scene and everything appears correct. The bones appear to align in positions a character rigger would want to place them for the animators. Finally, I have a file containing an actual animation. It has all the key frames for the animation where each key frame contains a quaternion and a vector for each bone. This is where I'm stuck. I don't know how this data correlates to the default pose data or what I should be doing with it. Some random information about the data: - rendering as if it were absolute appears as garbage. - converting to absolute using the root bone as the starting point and then rendering appears as garbage. So, I don't know really what else to say. I am kind of hoping there's "standard" procedure everyone uses for this. I'm kind of assuming you need to convert the bone representations into the same space and then do something.
  4. SapphireStorm

    GLSL Skeletal Animation Shader

    Thanks!
  5. Does this skeletal animation shader make sense? uniform mat4 u_WorldView; uniform mat4 u_WorldViewProjection; uniform mat4 u_BoneTransform[128]; in vec3 in_Position; in vec3 in_Normal; in vec2 in_TexCoords; in int in_BoneID[4]; in vec4 in_Weights; out vec3 v_ViewSpacePosition; out vec3 v_VertexToLight; out vec3 v_Normal; out vec2 v_TexCoords; void main(void) { // Transform the vertex information based on bones. vec3 position = (in_Weights[0] * (u_BoneTransform[ in_BoneID[0] ] * vec4(in_Position, 0.0)).xyz) + (in_Weights[1] * (u_BoneTransform[ in_BoneID[1] ] * vec4(in_Position, 0.0)).xyz) + (in_Weights[2] * (u_BoneTransform[ in_BoneID[2] ] * vec4(in_Position, 0.0)).xyz) + (in_Weights[3] * (u_BoneTransform[ in_BoneID[3] ] * vec4(in_Position, 0.0)).xyz); vec3 normal = (in_Weights[0] * (u_BoneTransform[ in_BoneID[0] ] * vec4(in_Normal, 0.0)).xyz) + (in_Weights[1] * (u_BoneTransform[ in_BoneID[1] ] * vec4(in_Normal, 0.0)).xyz) + (in_Weights[2] * (u_BoneTransform[ in_BoneID[2] ] * vec4(in_Normal, 0.0)).xyz) + (in_Weights[3] * (u_BoneTransform[ in_BoneID[3] ] * vec4(in_Normal, 0.0)).xyz); // The normal graphic's pipeline transform. gl_Position = u_WorldViewProjection * vec4( position, 1.0 ); // Only take to view space v_Normal = ( normalize( u_WorldView * vec4(normal, 0.0) ) ).xyz; . . . If you need any other information, let me know. I have never done skeletal animation before and my current attempt does not work. I can load and render my models fine with just a phong shader. However, this vertex shader does not transform anything based on the bones. It just outputs the models in their default pose as if I was only transforming vertices by world, view, and projection matrices. I'm just trying to narrow down the possibilities of what is wrong in my code at the moment. It is also probable I'm not handling my skeletal and animation data correctly on the CPU side. Thanks.
  6. SapphireStorm

    Marching cube

    Input: - A 3D grid where points on the grid contain a scalar value. (This is provided by the type of problem you're trying to visualize.) - A scalar value to reconstruct against. (This is provided by the application or the user.) Output: - A triangle list representing the surface contained in the grid of data corresponding to the second input value. - You can also output other things, like normals. The algorithms required for those are different than marching cubes. However, they generally go hand in hand.
  7. Can you write values outside of the range of 0.0-1.0 to a render target? I was going to use a pixel shader to compute some position information and store it in a texture. However, most of the data falls outside of the normal color range and gets clamped.
  8. SapphireStorm

    Approaching Engine Design

    First, write games. Next, one approach to support multiple renderers is to inherit the implementation of each renderer from a single, abstract class. This allows your higher level logic to interact with the rendering sections of your game without knowing or caring which underlying API it is using. For example, // Base Class class __declspec(novtable) AbstractRenderer { AbstractRenderer(void) {}; virtual ~AbstractRenderer() {}; virtual bool InitDevice() = 0; virtual bool InitSwapChain() = 0; virtual bool OnResizedSwapChain() = 0; virtual void OnDraw() = 0; // etc. }; // Derived Class class D3D9Renderer : public AbstractRenderer { D3D9Renderer(void); ~D3D9Renderer(); bool InitDevice(); bool InitSwapChain(); // etc. }; // Somewhere in higher level code land... std::shared_ptr<AbstractRenderer> renderer; renderer = std::shared_ptr<D3D9Renderer>( new D3D9Renderer() ); // Or Maybe... // renderer = std::shared_ptr<D3D10Renderer>( new D3D10Renderer() ); // renderer = std::shared_ptr<D3D11Renderer>( new D3D11Renderer() ); // renderer = std::shared_ptr<OpenGLRenderer>( new OpenGLRenderer() ); // etc. bool result = renderer->InitDevice(); If you want to pursue something like this further, check out Ogre3D. I'm pretty sure this is how they support directX and openGL. Finally, in terms of modularity, I'm hesitant to link this, but, I'm going to link it anyways. It's pretty overkill for what you asked, however, I think it's a good example of modular design. Their systems are decoupled in such a way they can begin to attack the problem of concurrency. I wouldn't be worried about building a concurrent engine. However, decoupling a game's underlying systems would be a reasonable goal.
  9. SapphireStorm

    Marching cube algorithm problem

    val[8] are the isovalues of your surface at the eight vertices in a grid cube. I'm not familiar with voxel terrain, however, in 3D animation and medical imaging your isovalues come from Metaball/Blobby algorithms and CT/MRI machines respectively. In other words, there's a computational step / algorithm you compute prior to marching cubes which generates a nice block of 3D data for you. This data becomes your isovalues in your grid of cubes. Then, you pick a target isovalue, run marching cubes against that target value, and it will generate a surface corresponding to that value from your data block.
  10. SapphireStorm

    Returning a local pointer. C++

    Thanks everyone. I understand this topic much better than I did four days ago. It's funny how things you think are trivial and often dismiss, sometimes have a lot more going on than what is initially apparent.
  11. SapphireStorm

    Returning a local pointer. C++

    Sorry for the ambiguity. Consider this. Object Foo( Object &param ) { // copy construct a local object Object result = param; // do some work on 'result' return result; } To my understanding, 'result' will be destroyed when 'Foo' exists causing the return value of 'Foo' to be undefined or garbage. Now, consider Object* Foo( Object &param ) { // init the pointer to the passed variable Object* result = &param; // do some work on 'result' return result; } Again, I think this case should be identical to the first. The 'result' pointer should be destroyed when the function exits corrupting the returned value. However, in one my projects this type of function works. So, did I just get lucky? More specifically, did the compiler automatically fix the second case? Did the optimizer inline 'Foo' and remove the locals entirely? Or, is there something deeper going on which actually makes this type of function alright?
  12. Hi guys and gals. I have a technical C++ question for you. If I return a local object in some arbitrary function, the compiler warns about returning local variables since they will be deallocated when the function exits. Alright. That is fine. However, if I allocate a local pointer to a variable and return the pointer, the compiler is fine with it and the code works. What's exactly going on?
  13. SapphireStorm

    Entity System ( Component System )

    Quote: ...problem where you can not access the children classes methods when they dont belong to the parent. You can solve this by type casting. It's the same as casting doubles to integers only now it's between pointers. Here's a simple example: class Base { public: Base() {}; virtual void foo() = 0; }; class Derived : public Base { public: Derived(){}; void foo() { // do something } void DerviedOnlyFoo() { // do something } }; int main() { Derived myClass; Base *myBasePointer = &myClass; // Virtual function call myBasePointer->foo(); // myBasePointer->DerviedOnlyFood(); // does not work and your problem. // Solution: Pointer Casting. Derived *myDerviedPointer; myDerviedPointer = static_cast<Derived*>(myBasePointer); myDerviedPointer->DerviedOnlyFoo(); // Note: This is also valid. myDerviedPointer->foo(); return 0; } First, I feel like I'm pushing you into implementing your system in this manner. That was not my intent; know there are other perfectly valid ways of implementing component systems which the other posters touched on. Second, if you do go this route, it may be very beneficial for you to actually review and gain a strong understanding of Virtual Inheritance and Polymorphism. I do not know your career goals, however, if you want to program games or develop software for a large company, chances are you are going to have a few technical interviews. These topics do show up in these interviews and will extinguish the hopes and aspirations of a few potential candidates. I bring this up because I personally do not use these techniques too much in my own code. So, if they are going to be an essential part of your system, now might be a good time to learn all the gory details which are going on in the back end. Quote: how would you have the rendering component not render? I would not worry about this right now. Just get in the mindset of having your render component store information on how things should be rendered. Get your component system working first. Then, worry about integrating it into a larger project. This way, at the end of the day, you can say you have a working component system as apposed to a multiple system, coding nightmare where nothing works and everything is broken. However, if rendering is imperative, check out lightbringer's post. He's a describing a solution where data from the component system is passed back up the abstraction. Another approach might be to pass a pointer of the graphic's system down the abstraction into the component system. Then, the component system could interact with the graphic's system on a functional level instructing it on how to render objects.
  14. SapphireStorm

    Entity System ( Component System )

    void EntityManager::addComponent(int id, std::string name) { if(name == "Rendering") { m_rendering->getList().push_back(new RenderingComp(id)); } } This sort of implementation is generally thought of as bad. What if you or another programmer wants to go out and add another component? He/She is going to have to add logic here and probably at a lot of other places to mesh their new component into this system. Not only does that make things a pain but a large project will quickly become unmaintainable. I would recommend checking out std::map. With this data structure you can associate an id directly to the object in the map. So, an arbitrary get function might look something like: // Assume "std::map<std::string,Component> myComponentMap;" declared somewhere else. Component& EntityManager::getComponent(std::string name) { return &myComponentMap[name]; } Here, the data structure handles all the "if" logic for you. More importantly, this approaches allows you to write functions once and change them extremely infrequently. Finally, on an unrelated note, making a discrete, uncoupled systems is generally good practice. So, having the actual rendering logic in your component system might not be too good. To be clear, having a render component is fine. Having the render component actually do the rendering is questionable. However, depending on the size and goals of your project it might be just fine. Overall, good work so far and keep on coding.
  15. SapphireStorm

    What's your favorite StarCraft 2 unit?

    I like Hellions and flaming worker lines. VaaaaaaROOOOOOOOOM!
  • 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!