Jump to content
  • Advertisement

Sagito

Member
  • Content count

    74
  • Joined

  • Last visited

Community Reputation

129 Neutral

About Sagito

  • Rank
    Member
  1. Sagito

    Motion Capture Animation

    Hi all, Our lab is working on a game development project, but we don't (yet) have the necessary equipment for performing motion capture based animation. I have tried looking for possible equipment (OrganicMotion, OptiTrack, Vicon, Xsens, etc...) but I can't find any prices neither for buying nor for renting them (is renting even possible?). Do you have any idea what the costs are, especially of the Xsens MVN? That seems by far the most interesting system due to its portability, but I can't seem to find a price sheet anywhere. Thanks in advance!
  2. Hello, I'm trying to build a manual parser for .X files, without using the DirectX specific functions for loading, just to learn by practicing how skinning and animation works. I am already able to present the mesh on the screen, and I'm pretty sure that all of the data in the file is being loaded correctly (including animation data). I'm now trying to reproduce the animation set contained in a sample .x file, but I can't seem to get it right. Each bone saves its matrix, children bones, the vertices it affects and their weight. Then, before drawing a mesh I update it and try to perform the transformations given by the bones. To do so, for each bone, I get the bone matrix, multiply it by the keyframe matrix (a matrix that is interpolated from two consecutive keyframes) and transform each vertex affected by the bone by the resulting matrix * the weight for that vertex. Something like: foreach (Bone bone in bones) matrix boneMatrix = bone->matrix; matrix animMatrix = animation->getCurrentMatrix(); //I'm hoping that this gives me the bone position in a given moment matrix result = boneMatrix * animMatrix; foreach (Vertex v in vertices) matrix weightedMatrix = result * bone->getWeight(v); v = weightedMatrix * v; end end However, doing something like this simply destroys the mesh and the animation is nothing like what it should be. I'm probably missing something very evident here, but I can't seem to find what... Thanks in advance...
  3. Sagito

    Collision detection

    Thanks for your replies! I will try to put every wall in its distinct object and perform collision with that method. I thought about that in the beginning, but I thought there was a better way... xD Is that the method used by companies who develop commercial games? I mean, everything that is scenario (except terrain) will have each triangle tested individually? Thanks again! :D
  4. Sagito

    Collision detection

    Thanks for the reply! :D The article is quite interesting, I've just read it (and the one that follows) and it will surely help. However, this next question should be rather noob... How do you choose where to put the portals? In a BSP tree, my problem is where to put the first hyperplane, the rest would be easy since they are computed directly... Btw, I have implemented an octree as you mentioned. However, it can only go up to 7 subdivisions of space. I understand that this is already a lot of data to work with, since it is not optimized yet, but I think that normal octrees go much deeper in recursion, am I right? Thanks again!
  5. Hi everyone... I have been creating a graphical engine for a small 3D game and I want to implement collision detection in-game. I have been reading lots of articles about this, from simple bounding boxes, AABB, OBB, BSP Trees, Octrees, etc. and I understand these techniques. However, these methods seem to focus on collisions between two "separate" objects. But what if I want to test if a character that is inside a room or a ball inside a box hits the walls? Couldn't figure out what technique to use if an object is contained inside another... Any advice would be greatly appreciated! Thanks in advance...
  6. Hi everyone... I've seen some posts on this matter, even on gamedev, but none seemed to be able to solve this problem. I have an airplane which has its own up, look and right vectors. In order to make it fly, I perform a pitching rotation first (X-axis) and then, according to the user input I turn it left or right with D3DXMatrixRotationAxis. Then, I transform the up, look and right vectors according to this matrix, like this: D3DXMatrixIdentity(&pitchMatrix); D3DXMatrixRotationX(&pitchMatrix, pitchAngle); D3DXMatrixIdentity(&turnMatrix); D3DXMatrixRotationAxis(&turnMatrix, yawAngle); D3DXMatrixIdentity(&this->transformMatrix); D3DXMatrixMultiply(&this->transformMatrix, &pitchMatrix, &turnMatrix); this->look = D3DXVECTOR3(0.0f, 0.0f, 1.0f); this->right = D3DXVECTOR3(1.0f, 0.0f, 0.0f); this->up = D3DXVECTOR3(0.0f, 1.0f, 0.0f); //This is probably a nasty hack to remove translation from the matrix, but I //don't even think this will ever be used D3DXMATRIX translationless = this->transformMatrix; translationless._41 = 0.0f; translationless._42 = 0.0f; translationless._43 = 0.0f; translationless._44 = 1.0f; D3DXVec3TransformNormal(&this->look, &this->look, &translationless); D3DXVec3TransformNormal(&this->right, &this->right, &translationless); D3DXVec3TransformNormal(&this->up, &this->up, &translationless); D3DXVec3Normalize(&this->look, &this->look); D3DXVec3Cross(&this->right, &this->up, &this->look); D3DXVec3Normalize(&this->right, &this->right); D3DXVec3Cross(&this->up, &this->look, &this->right); D3DXVec3Normalize(&this->up, &this->up); The problem here is that after 90 or -90 degrees the airplane just spins out of control, because the up vector seems to be transformed somehow incorrectly... Am I doing something wrong here? I don't think there is a Gimbal lock here, but I may obviously be wrong... Thanks in advance! P.S.: If it helps, I can post a video of what happens in youtube or something...
  7. Sagito

    GenerateAdjacency error

    Seems to be something inside the mesh (as it seems to fall inside it memory address interval), but the debugger is unable to point clearly what this is... : About the DWORD, thanks a lot... xD I had coded this in some other way and forgot to correct that... :P Thanks for your reply!
  8. Hi everyone... I have built a simple function to load meshes from a custom format and store them in a ID3DXMesh*. I start by converting a FVF to a vertex declaration: D3DVERTEXELEMENT9 vertexDeclaration[MAX_FVF_DECL_SIZE]; hr = D3DXDeclaratorFromFVF(VERTEX_FORMAT, vertexDeclaration); Then, I create the mesh: //Faces, vertices, hr = D3DXCreateMesh(this->faces.size(), this->vertices.size(), D3DXMESH_MANAGED, vertexDeclaration, this->device, &this->mesh); After this, I fill in the vertex and index buffers accordingly (and I try to make sure there are no negative pointers and etc while doing it...). I don't think that part is relevant, so I'm not posting it now (if you think otherwise, let me know and I will put here). Finally, I'm trying to do this: DWORD* adjacency = new DWORD[3 * this->faces.size() * sizeof(DWORD)]; hr = this->mesh->GenerateAdjacency(0.0001f, adjacency); It never returns to the HRESULT variable because it just throws an exception that I can't find where is coming from: "Unhandled exception at 0x5f43de7d in Conspiracy.exe: 0xC0000005: Access violation reading location 0x03ec67e4." I have run the dx debugger and I don't see anything special, so I'm really lost... Help anyone? Thanks in advance!
  9. Sagito

    Getting Started

    You can try something like Irrlicht: Irrlicht Site It helped me a lot to start developing games, as it brings a whole world of features and it is appropriate for building shooters. It also features a whole lot of tutorials and it is widely used as an open 3D engine... :D
  10. Sagito

    ID3DXMesh Problem

    Hmm, tried using PIX here now and it just crashes... PIX's debug shows random places each time I ran it... Once in the mesh creation, another time in light creation (which is completely out of bounds), keyboard handling (also completely out of bounds), etc... Could this be a bad pointer somewhere, memory leak, or something like that?
  11. Hi, After parsing and loading an external file with a 3D model, I'm trying to use the data I have read to build an ID3DXMesh*. I'm doing the following: DWORD vertexFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1; D3DXCreateMeshFVF(nfaces, nfaces * 3, D3DXMESH_DYNAMIC, vertexFVF, this->device, &this->mesh); EObjVertex* vBuffer = NULL; WORD* vIBuffer = NULL; if (FAILED(this->mesh->LockVertexBuffer(NULL, (void**)&vBuffer))) return; int index = 0; for (int a = 0; a < objects.size(); a++) { vector<EObjFace*> faces = objects[a]->getFaces(); for (int i = 0; i < faces.size(); i++) { EObjFace* actFace = faces; EObjVertex* v1 = &actFace->ov1; EObjVertex* v2 = &actFace->ov2; EObjVertex* v3 = &actFace->ov3; memcpy(&vBuffer[index++], v1, sizeof(EObjVertex)); memcpy(&vBuffer[index++], v2, sizeof(EObjVertex)); memcpy(&vBuffer[index++], v3, sizeof(EObjVertex)); } } this->mesh->UnlockVertexBuffer(); //Take care of the index buffer if (FAILED(this->mesh->LockIndexBuffer(NULL, (void**)&vIBuffer))) return; for (int a = 0; a < objects.size(); a++) { vector<EObjFace*> faces = objects[a]->getFaces(); for (int i = 0; i < faces.size(); i++) { WORD in = i * 3; vIBuffer[in] = i * 3; vIBuffer[in + 1] = in + 1; vIBuffer[in + 2] = in + 2; } } this->mesh->UnlockIndexBuffer(); //Attempt to define subsets DWORD* id; if (FAILED(this->mesh->LockAttributeBuffer(D3DLOCK_DISCARD, &id))) return; for (int a = 0; a < objects.size(); a++) { vector<EObjFace*> faces = objects[a]->getFaces(); for (int i = 0; i < faces.size(); i++) { EObjFace* actFace = faces; int materialID = 0; for (unsigned int e = 0; e < materials.size(); e++) { if (materials[e].name == actFace->materialname) { materialID = e; break; } } *id = 0; id++; } } this->mesh->UnlockAttributeBuffer(); The problem is that if I draw it like the following code snippet, the mesh is renderer correctly: this->mesh->GetVertexBuffer(&vb); this->mesh->GetIndexBuffer(&ib); this->device->SetStreamSource(0, vb, 0, sizeof(EObjVertex)); this->device->SetFVF(vertexFVF); this->device->SetIndices(ib); this->device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 3 * nfaces, 0, nfaces); But if I call this->mesh->DrawSubset(0) (I'm putting everything in the same subset for now), the mesh is rendered with random vertex positions, all scrambled up... Any ideia why this is happening? Thanks in advance...
  12. Sagito

    Mesh Clicking

    Hi there... :) That is called Picking or Selection. In DirectX you can use the D3DXIntersect function to check if a ray (which can be calculated from the mouse coordinates) hit an object in your scene. Those calculations are pretty easy to do. Here is some source code from my graphical engine Enoch 3.0: pickingData EPicking::testPicking(EObject* obj) { //Our picking ray must have a direction and an origin D3DXVECTOR3 direction; D3DXVECTOR3 origin; //Fetch the cursor position from the window POINT ptCursor = w->getMousePosition(); //Get some very needed matrices used to perform 2D to 3D conversion D3DXMATRIX View; D3DXMATRIX World; D3DXMATRIX Projection; //Fill the matrices device->GetTransform(D3DTS_VIEW, &View); device->GetTransform(D3DTS_WORLD, &World); device->GetTransform(D3DTS_PROJECTION, &Projection); //Calculate the picking ray D3DXVECTOR3 v; v.x = ( ( ( 2.0f * ptCursor.x ) / w->getWidth() ) - 1 ) / Projection._11; v.y = -( ( ( 2.0f * ptCursor.y ) / w->getHeight() ) - 1 ) / Projection._22; v.z = 1.0f; D3DXMATRIX mWorldView = World * View; D3DXMATRIX m; D3DXMatrixInverse(&m, NULL, &mWorldView); direction.x = v.x*m._11 + v.y*m._21 + v.z*m._31; direction.y = v.x*m._12 + v.y*m._22 + v.z*m._32; direction.z = v.x*m._13 + v.y*m._23 + v.z*m._33; origin.x = m._41; origin.y = m._42; origin.z = m._43; pickingRay ray; ray.destiny = direction; ray.origin = origin; pickingData pd; //Ok, ray is calculated. It's time to see if this ray intersected anything D3DXIntersect(obj->getLowLevelMesh(), &ray.origin, &ray.destiny, &pd.wasHit, &pd.face, &pd.u, &pd.v, &pd.distance, NULL, NULL); return pd; } Hope this helps ;)
  13. Sagito

    Render to Texture

    Thanks for your reply, Everything in the code was correct and you were completely right! After your suggestion, I tried PIX and saw the render texture after rendering to it and before being applied and it was correct. The only thing that was missing were the texture coords of the cube mesh. For some reason the importer forgot that they existed and clamped the texture... Never thought of that... Thanks again! :D
  14. Hi, I've been trying to create a render-to-texture effect within my game engine, but I can't seem to get it working. I've been following this tutorial from two kings: http://www.two-kings.de/tutorials/dxgraphics/dxgraphics16.html However, the whole code stops working when I chand the pyramids by a sphere object (although it is the same size and in the same position as the pyramid). The code I'm using is the following: at main.cpp: scene->beginRenderToTexture(renderTex, EColor(0, 255, 255, 0)); skull->draw(); scene->endRenderToTexture(); scene->begin(EColor(50, 50, 200, 0)); renderTex->applyTexture(); cube->draw(); skull->draw(); scene->end(); at EScene.cpp: bool EScene::beginRenderToTexture(ETexture* tex, EColor backgroundColor) { IDirect3DDevice9* device = this->window->getVideoDevice()->getVideoDriver(); if (!tex->isRenderTarget()) return false; LPDIRECT3DSURFACE9 pRenderSurface = NULL; tex->getLowLevelTexture()->GetSurfaceLevel(0, &pRenderSurface); device->GetRenderTarget(0, &this->pBackBuffer); device->SetRenderTarget(0, pRenderSurface); this->begin(backgroundColor); return true; } //End render to texture using active camera void EScene::endRenderToTexture() { IDirect3DDevice9* device = this->window->getVideoDevice()->getVideoDriver(); device->EndScene(); device->SetRenderTarget(0, this->pBackBuffer); device->SetTransform(D3DTS_PROJECTION, &this->cameras[this->activeCamera]->getProjectionMatrix()); } Texture is being created with: if (renderTarget) Usage |= D3DUSAGE_RENDERTARGET; this->device->CreateTexture((UINT)width, (UINT)height, 1, Usage, D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &this->texture, NULL); The render texture is being filled with the clear color I specify, but the objects in the scene do not appear to be rendered to it. Any idea why? What am I doing wrong in here? =X Thanks...
  15. Sagito

    How Much C++ ?

    It might be useful to learn some W32 API first though, because you will most likely have to launch your own window, receive events or something like it (unless you use DXUT, but nevertheless, learning W32 API can become very useful).
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!