• Advertisement

terrysworkstations

Member
  • Content count

    22
  • Joined

  • Last visited

Everything posted by terrysworkstations

  1. Camera on Vehicle

    I want to attach a camera on a vehicle like so that it will be in the cockpit of the car. I tried messing around with the target position of the view camera. I know there is a current position and target in a view matrix. So I multiplied x and z components of target(view matrix) by 100 to give farther viewing capabilities. This did not work so I was wondering how to attach a a view camera to a vehicle. I just need a general idea on how to do it. | / | / | / CurrentPosition --*100--->target position View Matrix thank you
  2. Shader Resource Binding

    Hello, I am trying to set some shader values in a cbuffer. Im not getting any response or values. My code is: cbuffer MatrixBuffer : register(b0) { float4 test; }; ------------------------------------------------- #pragma pack(push,1) struct CB_GBUFFER_UNPACK { D3DXVECTOR4 test; }; #pragma pack(pop) ------------------------------------------------- D3D11_BUFFER_DESC cbDesc; ZeroMemory( &cbDesc, sizeof(cbDesc) ); cbDesc.Usage = D3D11_USAGE_DYNAMIC; cbDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; cbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; cbDesc.ByteWidth = sizeof( CB_GBUFFER_UNPACK ); device->CreateBuffer( &cbDesc, NULL, &m_pGBufferUnpackCB ); D3D11_MAPPED_SUBRESOURCE MappedResource; ic->Map( m_pGBufferUnpackCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &MappedResource ); CB_GBUFFER_UNPACK* pGBufferUnpackCB = ( CB_GBUFFER_UNPACK* )MappedResource.pData; pGBufferUnpackCB->test.x = 10.0f; pGBufferUnpackCB->test.y = 10.0f; pGBufferUnpackCB->test.z = 10.0f; pGBufferUnpackCB->test.w = 0.0f; ic->Unmap( m_pGBufferUnpackCB, 0 ); ic->PSSetConstantBuffers( 0, 1, &m_pGBufferUnpackCB ); What is wrong?
  3. Assimp Object

    Ok seem to get the distortion working now. No stretching. Is there a way to invert indices on assimp?
  4. Assimp Object

    I switched to Assimp for loading models in directx 11. The image seems to strectch and stuff for some reason.In the picture , the tail like gets real big and the front of the image gets smaller when it gets closer to the camera than it should be. Does anyone know why this Is happening. Also I can see through the fish on certain angles. Does this have to do with left/right handed coordinate systems?
  5. Precision Problems with bouding sphere

    I tried to make two spheres with bounding sphere to detect collision so they stop when they collide. But it seems that im having a precision issue. They stey stuck together because of small decimal keeping it stuck. Is there a way around this? Since they are in a 3d space, adding or subtracting a little off seems impossible and expensive. How can I solve these precision issues? The code I used. oldleftright = leftright, oldupdown = updown; if(GetAsyncKeyState(VK_RIGHT)) leftright += 0.0001; if(GetAsyncKeyState(VK_LEFT)) leftright -= 0.0001; if(GetAsyncKeyState(VK_DOWN)) updown -= 0.0001; if(GetAsyncKeyState(VK_UP)) updown += 0.0001; collide = test.Intersect(test2); if (collide) { leftright = oldleftright; updown = oldupdown; } collide = false;
  6. System memory copy of vertices/mesh

    I needed a system memory copy of the vertices for AABB Collision so I can update there min/max because I only have static vertices access. How can I do this. Im in directx 11. c++. As my object translates, I need to calculale the new AABB min/max and I cant get to the vertices. void IvAABB::Set( const IvPoint3* points, unsigned int numPoints) { ASSERT( points); // compute minimal and maximal bounds mMinima.Set(points[0]); mMaxima.Set(points[0]); for (unsigned int i = 1; i < numPoints; ++i) { if (points[i].x < mMinima.x) mMinima.x = points[i].x; else if (points[i].x > mMaxima.x) mMaxima.x = points[i].x; if (points[i].y < mMinima.y) mMinima.y = points[i].y; else if (points[i].y > mMaxima.y) mMaxima.y = points[i].y; if (points[i].z < mMinima.z) mMinima.z = points[i].z; else if (points[i].z > mMaxima.z) mMaxima.z = points[i].z; } }
  7. Textures in Directx 11

    Im in DirectX 11 using the D3DX11CreateShaderResourceViewFromFile for textures. I have to rotate texture file 180 and flip horizontal in Mspaint for the texture to fit on the object. SO when I have a .obj object with text, it will be backwards like in the image. I have to rotate and flip with all objects that have textures.Does anyone know how to fix the issue?
  8. Bone offsets Matrix

    Trying to get Bone Offsets. I have blend weights and indices. How can I get bone offsets.
  9. Have to rotate 180 and flip horizontal to work

    I solved it. Thx
  10. Im downloading .obj to put in a game. I have to rotate and flip the texture for it to look right on the object! So when there is text on the object, it will be backwards. Im in Blender. How can I fix this issue? Im in directx 11 also
  11. Textures in Directx 11

    Alright h8cplusplusGuru, got it. thx
  12. Textures in Directx 11

    I still cannot get it to work even after the steps above. BTW, im using blender.
  13. Textures in Directx 11

    I use the regular image now(not rotated or flipped), and negated the x. Did not work though. I negated the y uv and almost works accept as seen, the text is backwards.
  14. Precision Problems with bouding sphere

    Alright, I got to work. thx
  15. Bounding Sphere for collision Detection

    I want to know the steps so I can create a bounding sphere on a object so when I get close, it will collide and will not intersect the object. I think my main question is..Will I get the distance of the radius and the center of my object to detect this? Second, do I run this function below on all the vertices of the object? I just need the steps. The code snippet I got is: void IvBoundingSphere::Set( const IvVector3* points, unsigned int numPoints ) { ASSERT( points ); // compute minimal and maximal bounds IvVector3 min(points[0]), max(points[0]); unsigned int i; for ( i = 1; i < numPoints; ++i ) { if (points[i].x < min.x) min.x = points[i].x; else if (points[i].x > max.x ) max.x = points[i].x; if (points[i].y < min.y) min.y = points[i].y; else if (points[i].y > max.y ) max.y = points[i].y; if (points[i].z < min.z) min.z = points[i].z; else if (points[i].z > max.z ) max.z = points[i].z; } // compute center and radius mCenter = 0.5f*(min + max); float maxDistance = ::DistanceSquared( mCenter, points[0] ); for ( i = 1; i < numPoints; ++i ) { float dist = ::DistanceSquared( mCenter, points[i] ); if (dist > maxDistance) maxDistance = dist; } mRadius = ::IvSqrt( maxDistance ); } Just need a basic idea on how to do this. Thank you
  16. Bounding Sphere for collision Detection

    Alright _Silence_,MarcusASeth, got it to collide right. Thx
  17. Particle system

    Im trying to do some particle like system of a disc like shape. More of a cube shape comes out though. Vertex vertices[1500]; for (unsigned int i = 0; i < 1500; ++i) { vertices[i].Color = (const float*)&Colors::Red; vertices[i].Pos.x = GenSpherePointCorrect().x; vertices[i].Pos.y = GenSpherePointCorrect().y; vertices[i].Pos.z = GenSpherePointCorrect().z; } s GenSpherePointCorrect() { float r = IvSqrt(rng.RandomFloat()); float theta = kTwoPI*rng.RandomFloat(); float sintheta, costheta; IvSinCos(theta, sintheta, costheta); Vector3 randomPos(2.0f*r*costheta, 2.0f*r*sintheta, 0.0f); return randomPos; }
  18. Particle system

    Alright KburtHard84,Zao, I seem to get it working now. Thx
  19. Ray casting Picking

    Ive converted some code from opengl and need someone to look over the code to see if there are any mistakes. Im in Directx 11 with a LH coordinate system. GetPickRay( float sx, float sy, float fov, float width, float height ) { float d = 1.0f/IvTan(fov*kPI/360.0f); float aspect = width/height; Vector3 viewPoint( 2.0f*aspect*sx/width - aspect, -2.0f*sy/height + 1.0f, d ); viewPoint = mViewToWorldMatrix.TransformPoint( viewPoint ); return viewPoint - mEyePoint; } OnMouseDown(WPARAM btnState, int x, int y) { mLastMousePos.x = x; mLastMousePos.y = y; Vector3 ray = GetPickRay( (float) x, (float) y, 45.0f,(float) mClientWidth,(float)mClientHeight ); // compute intersection with z=0 plane float t = -mEyePoint.z/ray.z; mClick = mEyePoint + t*ray; moveIT = XMMatrixTranslation(mClick.x,mClick.y,mClick.z); SetCapture(mhMainWnd); } Vector3 mUp(0.0f,1.0f,0.0f); Vector3 view = Vector3(0.0f,0.0f,0.0f) - mEyePoint; Vector3 right; Vector3 viewUp; view.Normalize(); right = view.Cross( mUp ); right.Normalize(); viewUp = right.Cross( view ); viewUp.Normalize(); Matrix33 rotate; //almost similar to a view matrix accept no negating eye point and dotting with uvw rotate.SetRows( right, viewUp, view ); mViewToWorldMatrix.Rotation(rotate); // set translation (eye position) mViewToWorldMatrix(0,3) = mEyePoint.x; mViewToWorldMatrix(1,3) = mEyePoint.y; mViewToWorldMatrix(2,3) = mEyePoint.z;
  20. Not clipping properly

    Im been trying to get this clipping thing right for quite awhile. The triangle is not getting clipped correctly .Here are some images. The second image is how it should clipped while the first is wrong. Click here for video The algorithm is: ClipVertex( const Vector3& end ) { float BCend = mPlane.Test(end); bool endInside = ( BCend >= 0.0f ); if (!mFirstVertex) { // if one of the points is inside if ( mStartInside || endInside ) { // if the start is inside, just output it if (mStartInside) mClipVertices[mNumVertices++] = mStart; // if one of them is outside, output clip point if ( !(mStartInside && endInside) ) { float t; Vector3 output; if (endInside) { t = BCend/(BCend - mBCStart); output = end - t*(end - mStart); } else { t = mBCStart/(mBCStart - BCend); output = mStart + t*(end - mStart); } mClipVertices[mNumVertices++] = output; } } } mStart = end; mBCStart = BCend; mStartInside = endInside; mFirstVertex = false; } And the plane or the normal is Plane clipPlane( 1.0f, 0.0f, 0.0f, 0.0f ); Are there any mistakes you can spot?
  21. Not clipping properly

    Cant be the Sutherland–Hodgman algorithm,(I checked to see if the vertices were right and they are).I try alittle harder.
  22. Steering Behavior Seeking code malfunction

    I got some code that im tweaking. Ive almost got it to work. It doesn't seem to work right though. First when it first starts in my INIT function that I set to target 50,0,0, it jets off way to fast. Here is what im doing. seek(IvVector3 target) { IvVector3 desired = target - position; desired.Normalize(); desired = desired * maxspeed; IvVector3 steer = desired - velocity; if(steer.LengthSquared() > maxforce * maxforce) { steer.Normalize(); steer *= maxforce; } applyForce(steer); } void applyForce(IvVector3 Force) { acceleration = Force; } In my update Function velocity += acceleration; if(GetKeyState(0x31)) { seek(IvVector3(0,0,50)); } if(GetKeyState(0x32)) { seek(IvVector3(-50,0,0)); } position += (velocity * mTimer.DeltaTime()); TESTS = XMMatrixTranslation(position.x,0,position.z); // Reset acceleration to 0 each cycle acceleration.IsZero(); Also when it reaches the target, it completey stops instead of going back and forth
  • Advertisement