Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 18 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


Member Since 21 Apr 2006
Offline Last Active Jun 09 2013 04:03 PM

Topics I've Started

Rotation in a sub node.

03 May 2013 - 03:40 PM

I am making a tool that rotates a model.  This tool needs to not care which direction the model is facing.  It just needs to rotate on world coordinate.  Like a rotate tool you would use in 3d studio max.  The problem comes up after the parent node has been rotated.  When the parent is not aligned with the world the children rotate on a different axis.


Rotating the parent is fine.  Rotating just the child is fine.

But if the parent is not on the identity for the axis then the child is rotated incorrectly.


This is the code I use on the parent.


if(dz == 0 && dy == 0)
   D3DXMatrixRotationX(&rotationMat, D3DXToRadian(node->rn_eulerOffset->x));
else if(dx == 0 && dz == 0)
    D3DXMatrixRotationY(&rotationMat, D3DXToRadian(node->rn_eulerOffset->y));
else if(dx == 0 && dy == 0)
    D3DXMatrixRotationZ(&rotationMat, D3DXToRadian(node->rn_eulerOffset->z));

if(node->parent == NULL)
  D3DXMATRIX localRotation(*node->rn_matrix);
  D3DXMATRIX localTranslation;
  localTranslation(3,0) = localRotation(3,0);
  localTranslation(3,1) = localRotation(3,1);
  localTranslation(3,2) = localRotation(3,2);

  localRotation(3,0) = 0;
  localRotation(3,1) = 0;
  localRotation(3,2) = 0;
  localTransformation = localRotation*rotationMat*localTranslation; 



I tried to remove the parent rotation from the child before rotating and to use world space but I didnt have much luck.


Thanks ahead of time for any help.




I am having trouble with intersecting a ray and sprite

23 October 2008 - 02:45 PM

Hi everyone, I am trying to do collision detection. I am: clicking on the screen returning the point that I clicked on turning the point into a ray turning 4 points into a plane, the 4 points of a sprite seeing if the ray intersects with the plane I have never done this before and I have been looking on the net for how to do it. Something is going wrong. If anyone can point me to a correct example or if they see something wrong can you please help me. The idea of how to do it came from this example http://answers.google.com/answers/threadview?id=18979 Thanks in advance to anyone that sees what I am doing wrong. -Vincent int mousex; //your current mouse positions int mousey; //Calculate a picking ray from the mouse positions //I am using directX //i need to get the projection matrix D3DXMATRIX proj; g_d3ddevice->GetTransform(D3DTS_PROJECTION, &proj); //I need the viewport D3DVIEWPORT9 vp; g_d3ddevice->GetViewport(&vp); //this will get me my points p.x = (((2.0f*x) / vp.Width) - 1.0f) / proj(0,0); p.y = (((-2.0f*y) / vp.Height) + 1.0f) / proj(1,1); p.z = 1.0f; //Ray is a struct containing 2, 3d vectors, the origin o and the direction d Ray myRay; myRay.o = D3DXVECTOR3(g_nScreenWidth/2.0f, 384.0f, -350.0f); myRay.d = D3DXVECTOR3(p.x, p.y, p.z); //I need to transform the ray from view space to world space to do that I need //to get the inverse of the view transformation matrix D3DXMATRIX view; g_d3ddevice->GetTransform(D3DTS_VIEW, &view); //inverse of the view matrix D3DXMATRIX vI; //viewInverse D3DXMatrixInverse(&vI, 0, &view) Ray tRay; //temp ray tRay.d.x = myRay->d.x*vI->_11 + myRay->d.y*vI->_21 + myRay->d.z*vI->_31; tRay.d.y = myRay->d.x*vI->_12 + myRay->d.y*vI->_22 + myRay->d.z*vI->_32; tRay.d.z = myRay->d.x*vI->_13 + myRay->d.y*vI->_23 + myRay->d.z*vI->_33; myRay->o.x = vI->_41; myRay->o.y = vI->_42; myRay->o.z = vI->_43; myRay->d.x = tRay.d.x; myRay->d.y = tRay.d.y; myRay->d.z = tRay.d.z; //Now my ray needs to be transformed from world to object space D3DXMATRIX world; device->GetTransform(D3DTS_WORLD, &world); D3DXMATRIX matWorldInverse; D3DXMatrixInverse(&matWorldInverse,NULL,&world); D3DXVECTOR3 rayObjOrigin,rayObjDirection; D3DXVec3TransformCoord(&myRay.o,&myRay.o,&matWorldInverse); D3DXVec3TransformNormal(&myRay.d,&myRay.d,&matWorldInverse); D3DXVec3Normalize(&myRay.d,&myRay.d); //So now my ray is finished //I am trying to click on barney, barney is a sprite //Created using this function /* ID3DXSprite::Draw Adds a sprite to the list of batched sprites. HRESULT Draw( LPDIRECT3DTEXTURE9 pTexture, CONST RECT * pSrcRect, CONST D3DXVECTOR3 * pCenter, CONST D3DXVECTOR3 * pPosition, D3DCOLOR Color ); */ //barney is a 256x256 image so I gave him a bounding square //The position he is originally given in the draw function is this // x = 256 /2.0f; // y = 256; // z = 500; // and I think that these points are the top left corner of the image // so I define these vectors to represent the image D3DXVECTOR3 barneyP1 = D3DXVECTOR3(128, 256, 500); D3DXVECTOR3 barneyP2 = D3DXVECTOR3(384, 256, 500); D3DXVECTOR3 barneyP3 = D3DXVECTOR3(384, 0, 500); D3DXVECTOR3 barneyP4 = D3DXVECTOR3(128, 0, 500); //defining these points in a clock wise order as a bounding rectangle //for barney //Now I am going to turn these vectors into a plane //I saw an example saying to use cramer's rule float A = barneyP1.y * (barneyP2.z - barneyP3.z) + barneyP2.y * (barneyP3.z - barneyP1.z) + barneyP3.y * (barneyP1.z - barneyP2.z); float B = barneyP1.z * (barneyP2.x - barneyP3.x) + barneyP2.z * (barneyP3.x - barneyP1.x) + barneyP3.z * (barneyP1.x - barneyP2.x); float C = barneyP1.x * (barneyP2.y - barneyP3.y) + barneyP2.x * (barneyP3.y - barneyP1.y) + barneyP3.x * (barneyP1.y - barneyP2.y); float D = -barneyP1.x * (barneyP2.y * barneyP3.z - barneyP3.y * barneyP2.z) - barneyP2.x * (barneyP3.y * barneyP1.z - barneyP1.y * barneyP3.z) - barneyP3.x * (barneyP1.y * barneyP2.z - barneyP2.y * barneyP1.z); //then create the plane and substitute the ray into plane and solve for t //o is for origin //d is for direction float t = -(A * myRay.o.x + B*myRay.o.y + C*myRay.o.z + D) / (A*myRay.d.x + B*myRay.d.y + C*myRay.d.z); //then get your intersection point D3DXVECTOR3 intersectionPoint = D3DXVECTOR3((myRay.o.x) + (myRay.d.x * t), (myRay.o.y) + (myRay.d.y * t), (myRay.o.z) + (myRay.d.z * t)); //Now we need to trim the x and y axis on the plane and test for intersection //we can do this using //create a vector from A to the Intersection //create a vector from C to the Intersection D3DXVECTOR3 V3 = intersectionPoint - barneyP1; D3DXVECTOR3 V4 = intersectionPoint - barneyP3; //a vector from A to B //a vector from C to D D3DXVECTOR3 V1 = barneyP2 - barneyP1; D3DXVECTOR3 V2 = barneyP4 - barneyP3; //Normalize those vectors D3DXVec3Normalize(&V1,&V1); D3DXVec3Normalize(&V2,&V2); D3DXVec3Normalize(&V3,&V3); D3DXVec3Normalize(&V4,&V4); //dot product them float a = D3DXVec3Dot(&V1,&V4); float b = D3DXVec3Dot(&V3,&V5); if(a>0 && b>0) return true //for intersection to be true

Cost / Time analysis in Casino Games

21 April 2006 - 03:17 PM

I am a computer science student, and I have 1 year experience in programming video games in DirectX and C++. I recently applied for a job at an up and coming casino game company. They outsourced all of the software development to other companies and they dont have the rights to any of the source code. They dont have a lot of money and they dont want to outsource for their software anymore. They have told me that they need a jack of all trades, programmer, director, and manager. They have told me to figure out how long I need to develop a video keno game and how many employees I think I need. I have no experience developing a game from the ground up, but I have access to a game engine that I have used in the past. My job would be converting the engine from C++ to C#, or possibly trying to just port it over using a dll because the casino machines are set up for C#. The next job would be making the keno game. It is going to be all 2D with billboarding. It is going to need to be really pretty, using shaders and cool lighting. But it is just a keno game. I know that no one can give a solid estimate on time. But, if you were a programmer with 3 years experience in C++ and 1 year experience in game programming how long do you think it would take you to do it. I would also have help from my game programming professor because he is thinking about doing consulting on the game. Also I need to tell them how much I want as an hourly wage, I was going to say 15, but some people tell me 30, others say 25, and I kind of want to say 20 an hour. -Vince P.S. I am very very afraid