TeapotWars goes mad!

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • TeapotWars goes mad!

      Hello..

      As this is the first time i write to this forum i would like to mention that the book is really great with so much info it would take ages to find. I managed to compile and run the code within minutes thanks to ssiva and Kain from previous posts. One thing that worries me though, and I don't know if I am the only one, is that when I run TeapotWars, the game window goes mad flickering green and red rectangles everywhere, no matter what resolution I use. When I switch to the Direct3D Settings (F2) or place another window in frond of the game window however everything is normal.

      Any suggestions?

      Thanks and (you already know that but)...great work MrMike!
    • I have some pretty bad flickering issues when it's running in a window, but in fullscreen mode it's fine.

      I'm running it on an ATI Radeon 9800Pro All-in-Wonder.
      "Your job is not to die for your country. Your job is to make some other poor sod die for his."
    • Yikes. Hardware compatibility hell: The same software causing different result on different hardware configurations. This is the bane of every PC graphics programmer... when the parameters of operation do not completely fall within their jurisdiction.

      This would never have happened if Teapot Wars was on the Dreamcast! Why did they kill it!
    • I'm seeing the same flickering mad behavior on a GeForce 6600GT. When in windowed mode, the frame rate is displayed as 1000's per second. If I partially obsure the game with another window, the flickering stops and the frame rate is displayed as a believable 47fps. This is with the latest (version 77.77) nVidia drivers.

      There must be a difference with how DirectX interacts with a game when the window is partially obscured. Anyone have any ideas?
    • Further update. Compiling a debug version of TW shows failures on calls to Novodex's createActor from the VAddSphere and VAddBox routines. The number of successful calls before a failure seems to vary. Hmm, maybe I missed something when I ported the code to Novodex 2.2... Wonder if Mr. Mike can procure version 2.1 for download from this site, so that newbies like myself aren't immediately hit with a porting exercise?
    • Progress... createActor calls are no longer failing. Debug build is sort of playable (runs at ~400fps). When quitting a Debug build run, I see pTexture is invalid messages in the output window. Release build unplayable due to flickering (runs at ~2000fps). Partially obscuring the game window lowers the frame rate to a reasonable ~50fps.

      Below are the updates that I made to physics.cpp for Novo 2.2. Did I miss something?

      -------------------------
      Changed line 46 from:

      #pragma comment(lib, "NxFoundation" )

      to:

      #pragma comment(lib, "NxCooking")

      -------------------------

      Added after line 53:

      #include "UserAllocator.h"
      #include "Stream.h"
      #include "NxCooking.h"

      UserAllocator* gAllocator = NULL;

      --------------------------

      Added after line 600:

      // Create a memory allocator
      gAllocator = new UserAllocator;

      NxInitCooking();

      ---------------------------

      Changed line 602 from:

      m_pPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, 0, &m_PhysicsErrorStream);

      to:

      m_pPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, gAllocator, &m_PhysicsErrorStream);

      ----------------------------

      Changed lines starting at 620 from :

      PhsyicsMaterial *pMaterial = g_Materials;
      for (int i=0; i<PhysMat_MaxMaterials; ++i, ++pMaterial)
      {
      NxMaterial mat;
      mat.setToDefault();
      mat.restitution = pMaterial->m_Restitution;
      mat.staticFriction = pMaterial->m_StaticFrition;
      mat.dynamicFriction = pMaterial->m_DynamicFriction;
      m_pPhysicsSDK->setMaterialAtIndex(i, &mat);
      }

      // Create a scene
      NxSceneDesc sceneDesc;
      sceneDesc.gravity = m_DefaultGravity;
      sceneDesc.broadPhase = NX_BROADPHASE_COHERENT;
      sceneDesc.collisionDetection = true;
      sceneDesc.userContactReport = &m_ContactReport;

      m_pScene = m_pPhysicsSDK->createScene(sceneDesc);
      if (!m_pScene)
      return false;

      to:

      // Create a scene
      NxSceneDesc sceneDesc;
      sceneDesc.gravity = m_DefaultGravity;
      sceneDesc.broadPhase = NX_BROADPHASE_COHERENT;
      sceneDesc.collisionDetection = true;
      sceneDesc.userContactReport = &m_ContactReport;

      m_pScene = m_pPhysicsSDK->createScene(sceneDesc);
      if (!m_pScene)
      return false;

      PhsyicsMaterial *pMaterial = g_Materials;
      for (int i=0; i<PhysMat_MaxMaterials; ++i, ++pMaterial)
      {
      NxMaterial *pMat = m_pScene->getMaterialFromIndex(i);
      pMat->setRestitution(pMaterial->m_Restitution);
      pMat->setStaticFriction(pMaterial->m_StaticFrition);
      pMat->setDynamicFriction(pMaterial->m_DynamicFriction);
      }

      --------------------------------

      Changed lines starting at 711 from:

      actor->getGlobalPoseReference().getColumnMajor44((NxF32 *)trans);

      to:

      actor->getGlobalPose().getColumnMajor44((NxF32 *) &trans);

      --------------------------------

      Changed lines starting at 745 from:

      m_pScene->startRun(timeSlice);
      m_pScene->flushStream();
      m_pScene->finishRun();

      to:

      m_pScene->flushStream();
      m_pScene->simulate(timeSlice);
      m_pScene->fetchResults(NX_RIGID_BODY_FINISHED, true);

      -----------------------------------

      Changed line 882 from:

      convexDesc.flags = NX_MF_CONVEX|NX_MF_COMPUTE_CONVEX;

      to:

      convexDesc.flags = 0;

      -----------------------------------

      Changed line 885 from:

      convexShapeDesc.meshData = m_pPhysicsSDK->createTriangleMesh(convexDesc);

      to:

      MemoryWriteBuffer buf;

      bool status = NxCookTriangleMesh(convexDesc, buf);
      convexShapeDesc.meshData = m_pPhysicsSDK->createTriangleMesh(MemoryReadBuffer(buf.data));

      -------------------------------
    • Something tells me that physics ain't the problem - and that what were dealing with is a DirectX wackiness.

      Funny - I used the suggested DirectX 9 framework to avoid such a problem!
      Mr.Mike
      Author, Programmer, Brewer, Patriot