# DgekGD

Member

25

374 Neutral

• Rank
Member

2. ## Deactivate a rigid body in Bullet

I guess, you can use btRigidBody::setFlags method and set proper flags to configure behavior for your rigid body. Here is a list of all flags(line 117).
3. ## Missile Pathing for 2D game

Okay. Imagine you missile is going to the right (1, 0) - x and y coordinates accordingly. Currently it has position (200, 200). It's target lies in the point (300, 200), so target angle between missile direction and X axis is zero(targetOrientation = 0) and current angle of missile direction and X axis is zero(missile.orientation = 0)    Next frame your target moves to the position (200, 100), probably you won't have such a huge jumps in just a single frame, but i try to show you an idea. So your desired direction for a missile is (0,1) now which make angle of Pi/2 (90 degrees) with X axis. So you start to rotate your missile. Your maxAngularAcceleration value should be already is defined for each missile, so you increase its rotation :missile.rotation += missile.angularAcceleration * time  and than orientation (or angle between direction and X axis) :  missile.orientation += missile.rotation * time.    Than you use current angle to get movement direction. Start with creating Z axis rotation matrix (Z axis goes into your screen or out of your screen) and multiply vector (1, 0) with this matrix. As a result you will get rotated vector. That you can multiply it by speed scalar. You can read this small tutorial if you still have some questions regarding retrieving direction from current angle.    I hope it helps ;) Let me know if you still have some questions :)
4. ## Missile Pathing for 2D game

Yep, atan2 function will work, perhaps you have to swap deltaX and deltaY arguments to get an angle from X axis.      Orientation - is a desired angle or current angle ( position for movement )   Rotation - is a speed orientation is changed (velocity for movement )   angularAcceleration - is a speed rotation is changed (acceleration for movement)    I hope everything is clear now:)
5. ## Missile Pathing for 2D game

Basically, when your missile updates it's target position(it's not necessary to do every single frame) find target angle of rotation, so that missile points in right direction (with the help of atan2 function). And than update missile rotation as you update its position. Here is an example: missile.angularAcceleration = targetOrientation - missile.orientation; if (missile.angularAcceleration < 0) missile.angularAcceleration = -maxAngularAcceleration; else missile.angularAcceleration = maxAngularAcceleration; missile.orientation += missile.rotation * time; missile.rotation += missile.angularAcceleration * time; if (missile.rotation > maxRotation) missile.rotation = maxRotation; It's far not ideal implementation, just to give you an idea. Actually, you can make your rotation even smoother with the use of slow down radius for example(when angle to rotate remains small it starts to slow down a little bit). Also, maybe you fill need some radius of satisfaction(it's doubtful that your object will rotate EXACTLY at the angle you need and it will end up in flickering).

Actually, there are a lot of things that can go wrong in your code and i don't see any explicit error here. In pixel shader try return float4(1.0f, 1.0f, 1.0f, 1.0f); If you see your object white, probably problem lies in binding texture resource (DefaultTexture in your shader code). If still nothing appears, check that you update constant buffers with matrices correctly for the vertex shader and bind right render target for your pixel shader. Or maybe you placed vertices in the wrong order and rasterizer culls your geometry, try D3D11_CULL_NONE.
7. ## BulletPhysics Question

Hi! When using Bullet Physics in your game you implement some BulletInternalTickCallback( btDynamicsWorld * const world, btScalar const timeStep ) method bullet uses as internal callback. dynamicsWorld->setInternalTickCallback( BulletInternalTickCallback ); dynamicsWorld declared as btDynamicsWorld* In this method you want to make loop like that: // look at all contacts btDispatcher * const pDispatcher = world->getDispatcher(); for ( int manifoldInd=0; manifoldIdx<pDispatcher->getNumManifolds(); manifoldInd++ ) { //get manifold btPersistentManifold const * const pManifold = pDispatcher->getManifoldByIndexInternal( manifoldInd ); assert( manifold ); // get colliding bodies btRigidBody const * const pBody0 = static_cast<btRigidBody const *>(pManifold->getBody0()); btRigidBody const * const pBody1 = static_cast<btRigidBody const *>(pManifold->getBody1()); ... So you acquired pointers to your colliding bodies. The next thing you want to do is: make an external list of colliding pairs of objects and update it every frame. So you can compare if the pair of colliding objects is already in the list, so you have continuous contact, otherwise they are just collided. Other data about collision you can get from btPersistentManifold object. For keeping material data of the object you can create external wrapper for every physics body like: struct PhysicsBody { btRigidBody const * const pBody; enum Material m_Mat; };
8. ## Physics engine book

Usually every physics engine has full documentation how to use it. If you want to really know how physics engines work I would recommend this book.

I cannot see any problem right now, but you can check exact value of 'r' after executing this function. It contains value that can point you to an error. Take a look here.
10. ## DirectX 9.0a SDK

You can download sdk from here . It includes everything you need for directx programming(9, 10, 11);
11. ## Calculating In-Game map positions

One of the approaches is to make two more render passes for your scene. The first new one would render to texture everything from the camera which is located in the sky. In the second new render pass you render this texture to the place on the screen you want.
12. ## Texture UnorderedAccessView problem (compute shader)

Indeed, it would have helped to find error in my program faster. Now, i create device with debug layer enabled in debug mode;) I appreciate your explanation. By the way, i managed to rapair my shader to work correctly. It suffered the same problem, I didn't unbound first texture's RTV before binding resource as SRV in the Compute Shader
13. ## Texture UnorderedAccessView problem (compute shader)

Setting NULL UAV for the place of UAV of my texture helped! Before that, i tried to set the compute shader itself to NULL, it didn't help me. My gaussian filter still does't worked corretly, but I think I can handle it as the main problem solved:) Thanks for your help!
14. ## Texture UnorderedAccessView problem (compute shader)

Yep, I heard that to read and write simultaneously I need to cast format to D3D11_FORMAT_R32_UINT for UAV... But I don't read and write to the resource at the same time. 1)For the first render pass i don't use the second texture at all. 2)Than in Compute Shader I use the first texture for reading (shader resource view) and the second one for writing (unordered access view). 3)Final pass: I use the second texture for reading as shader resource view Or maybe i misunderstand something ...