Some mistakes I found...

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

    • Some mistakes I found...

      In BaseGameLogic.h
      bool VInit(void);

      should be(?)
      virtual bool VInit(void);

      in TransformComponent.cpp

      Source Code

      1. bool TransformComponent::VInit(TiXmlElement* pData)
      2. {
      3. GCC_ASSERT(pData);
      4. // [mrmike] - this was changed post-press - because changes to the TransformComponents can come in partial definitions,
      5. // such as from the editor, its better to grab the current values rather than clear them out.
      6. [B] Vec3 yawPitchRoll = m_transform.GetYawPitchRoll();
      7. yawPitchRoll.x = RADIANS_TO_DEGREES(yawPitchRoll.x);
      8. yawPitchRoll.y = RADIANS_TO_DEGREES(yawPitchRoll.y);
      9. yawPitchRoll.z = RADIANS_TO_DEGREES(yawPitchRoll.z);
      10. Vec3 position = m_transform.GetPosition(); [/B]
      11. TiXmlElement* pPositionElement = pData->FirstChildElement("Position");
      12. if (pPositionElement)
      13. {
      14. double x = 0;
      15. double y = 0;
      16. double z = 0;
      17. pPositionElement->Attribute("x", &x);
      18. pPositionElement->Attribute("y", &y);
      19. pPositionElement->Attribute("z", &z);
      20. position = Vec3(x, y, z);
      21. }
      22. TiXmlElement* pOrientationElement = pData->FirstChildElement("YawPitchRoll");
      23. if (pOrientationElement)
      24. {
      25. double yaw = 0;
      26. double pitch = 0;
      27. double roll = 0;
      28. pOrientationElement->Attribute("x", &yaw);
      29. pOrientationElement->Attribute("y", &pitch);
      30. pOrientationElement->Attribute("z", &roll);
      31. yawPitchRoll = Vec3(yaw, pitch, roll);
      32. }
      33. Mat4x4 translation;
      34. translation.BuildTranslation(position);
      35. Mat4x4 rotation;
      36. rotation.BuildYawPitchRoll((float)DEGREES_TO_RADIANS(yawPitchRoll.x), (float)DEGREES_TO_RADIANS(yawPitchRoll.y), (float)DEGREES_TO_RADIANS(yawPitchRoll.z));
      37. /**
      38. // This is not supported yet.
      39. TiXmlElement* pLookAtElement = pData->FirstChildElement("LookAt");
      40. if (pLookAtElement)
      41. {
      42. double x = 0;
      43. double y = 0;
      44. double z = 0;
      45. pLookAtElement->Attribute("x", &x);
      46. pLookAtElement->Attribute("y", &y);
      47. pLookAtElement->Attribute("z", &z);
      48. Vec3 lookAt((float)x, (float)y, (float)z);
      49. rotation.BuildRotationLookAt(translation.GetPosition(), lookAt, g_Up);
      50. }
      51. TiXmlElement* pScaleElement = pData->FirstChildElement("Scale");
      52. if (pScaleElement)
      53. {
      54. double x = 0;
      55. double y = 0;
      56. double z = 0;
      57. pScaleElement->Attribute("x", &x);
      58. pScaleElement->Attribute("y", &y);
      59. pScaleElement->Attribute("z", &z);
      60. m_scale = Vec3((float)x, (float)y, (float)z);
      61. }
      62. **/
      63. m_transform = rotation * translation;
      64. return true;
      65. }
      Display All


      Part in bold seems to be misplaced seeing as the variables are overwritten from file right after.
    • RE: Some mistakes I found...

      Originally posted by Shanee
      In BaseGameLogic.h
      bool VInit(void);

      should be(?)
      virtual bool VInit(void);

      No, this function should not be virtual since it should never be overridden and is only called by a system when instantiating the concrete logic class. I didn't update the name to remove the 'V', so I'll do that now.


      in TransformComponent.cpp

      Source Code

      1. bool TransformComponent::VInit(TiXmlElement* pData)
      2. {
      3. GCC_ASSERT(pData);
      4. // [mrmike] - this was changed post-press - because changes to the TransformComponents can come in partial definitions,
      5. // such as from the editor, its better to grab the current values rather than clear them out.
      6. [B] Vec3 yawPitchRoll = m_transform.GetYawPitchRoll();
      7. yawPitchRoll.x = RADIANS_TO_DEGREES(yawPitchRoll.x);
      8. yawPitchRoll.y = RADIANS_TO_DEGREES(yawPitchRoll.y);
      9. yawPitchRoll.z = RADIANS_TO_DEGREES(yawPitchRoll.z);
      10. Vec3 position = m_transform.GetPosition(); [/B]
      11. TiXmlElement* pPositionElement = pData->FirstChildElement("Position");
      12. if (pPositionElement)
      13. {
      14. double x = 0;
      15. double y = 0;
      16. double z = 0;
      17. pPositionElement->Attribute("x", &x);
      18. pPositionElement->Attribute("y", &y);
      19. pPositionElement->Attribute("z", &z);
      20. position = Vec3(x, y, z);
      21. }
      22. TiXmlElement* pOrientationElement = pData->FirstChildElement("YawPitchRoll");
      23. if (pOrientationElement)
      24. {
      25. double yaw = 0;
      26. double pitch = 0;
      27. double roll = 0;
      28. pOrientationElement->Attribute("x", &yaw);
      29. pOrientationElement->Attribute("y", &pitch);
      30. pOrientationElement->Attribute("z", &roll);
      31. yawPitchRoll = Vec3(yaw, pitch, roll);
      32. }
      33. Mat4x4 translation;
      34. translation.BuildTranslation(position);
      35. Mat4x4 rotation;
      36. rotation.BuildYawPitchRoll((float)DEGREES_TO_RADIANS(yawPitchRoll.x), (float)DEGREES_TO_RADIANS(yawPitchRoll.y), (float)DEGREES_TO_RADIANS(yawPitchRoll.z));
      37. /**
      38. // This is not supported yet.
      39. TiXmlElement* pLookAtElement = pData->FirstChildElement("LookAt");
      40. if (pLookAtElement)
      41. {
      42. double x = 0;
      43. double y = 0;
      44. double z = 0;
      45. pLookAtElement->Attribute("x", &x);
      46. pLookAtElement->Attribute("y", &y);
      47. pLookAtElement->Attribute("z", &z);
      48. Vec3 lookAt((float)x, (float)y, (float)z);
      49. rotation.BuildRotationLookAt(translation.GetPosition(), lookAt, g_Up);
      50. }
      51. TiXmlElement* pScaleElement = pData->FirstChildElement("Scale");
      52. if (pScaleElement)
      53. {
      54. double x = 0;
      55. double y = 0;
      56. double z = 0;
      57. pScaleElement->Attribute("x", &x);
      58. pScaleElement->Attribute("y", &y);
      59. pScaleElement->Attribute("z", &z);
      60. m_scale = Vec3((float)x, (float)y, (float)z);
      61. }
      62. **/
      63. m_transform = rotation * translation;
      64. return true;
      65. }
      Display All


      Part in bold seems to be misplaced seeing as the variables are overwritten from file right after.

      That block sets up a default. If no YawPitchRoll element is found in the XML file, those defaults will never be overwritten since they're inside the if (pOrientationElement) block.

      Setting up defaults like this is a very good practice to guard against omitted data. This is especially important when you add new data elements. Mike added this element after the transform component stuff was done. Creating a reasonable default allowed him to do so without editing all the actor XML files. It wouldn't have been a big deal on a game like this with so few data files, but when you work on a huge game, it's critical. For example, The Sims has thousands upon thousands of tuning XML files for actors, interactions, objects, and everything else in the game. If we had to edit every file for each tuning element we added, we would never finish the game.

      -Rez
    • Ok, makes sense. Thank you :)

      By the way, why is there no support for scaling saved? After all isn't it just:

      Source Code

      1. Vector4 Matrix::GetScale() const
      2. {
      3. Vector4 scale;
      4. scale.x = Vector4(_11, _12, _13, 1.0f).Length();
      5. scale.y = Vector4(_21, _22, _23, 1.0f).Length();
      6. scale.z = Vector4(_31, _32, _33, 1.0f).Length();
      7. return scale;
      8. }


      to get the scale value of a matrix? Or is it more due to physics/rendering reasons I might have overlooked. (I know Havok for examples didn't approve of scaling matrices)

      The post was edited 1 time, last by Shanee ().

    • We didn't add it because we didn't need it. If you need it, feel free to add it. :)

      -Rez
    • It turns out to be a little tricky for exactly the reason you suggest. The transform for physics and render geometry are related, but they aren't the same. When you attempt to apply a scale factor wacky stuff results.

      I tried while writing the physics chapter to work out all the details but ran out of time.

      If you want to play with this - the best spot to set up a test is try to scale the teapot cannonballs first - once you get that right move on to something asymmetric, like the Grids.
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • Hey Mike. I am afraid I am not actually compiling the game or the engine, I already made a version of my engine with a lot of ideas and concepts based on GCC3 and now I am taking things I like from fourth edition and trying to learn more.

      I used Havok Physics in my engine which has the same limitation but you can in fact give it a scale matrix on physics body creation to get it to work. This does mean that if an object scales in-game then you need to edit/recreate his physic object.
    • That might work, but the include file should be findable with the Include file path settings - rather than copy it there it would be better to find out what happened to the path settings....

      When you open up the TeapotWars_2010.sln file in Visual Studio 2010, and go to the VC++ Directories in confugration properties you should see this:

      $(SolutionDir);$(SolutionDir)..\..\GCC4\3rdParty\bullet-2.79\src;$(SolutionDir)..\..\GCC4\3rdParty\DXUT11\Optional;$(SolutionDir)..\..\GCC4\3rdParty\DXUT11\Core;$(SolutionDir)..\..\GCC4\3rdParty\libogg-1.3.0\include;$(SolutionDir)..\..\GCC4\3rdParty\libvorbis-1.3.2\include;$(SolutionDir)..\..\GCC4\3rdParty\luaplus51-all\Src\LuaPlus;$(SolutionDir)..\..\GCC4\3rdParty\tinyxml_2_6_2;$(SolutionDir)..\..\GCC4\3rdParty\zlib-1.2.5;$(DXSDK_DIR)\Include;$(IncludePath)
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • Originally posted by bad habit
      And sorry Mike Rez, haven't started reading the book yet, I have to complete Mass Effect 3 first, on insanity.


      Understood.

      -Rez
    • First of all, i got the book last week,and i love it. I "devoured" it in three days. An excellent upgrade from the excellent third edition.

      I found a little piece in the source code that does not seem right.

      On Graphics3D\Scene.cpp in ~Scene

      Source Code

      1. //
      2. // Scene::~Scene - Chapter 16, page 539
      3. //
      4. Scene::~Scene()
      5. {
      6. // [mrmike] - event delegates were added post-press!
      7. IEventManager* pEventMgr = IEventManager::Get();
      8. pEventMgr->VRemoveListener(MakeDelegate(this, &Scene::NewRenderComponentDelegate), EvtData_New_Render_Component::sk_EventType);
      9. pEventMgr->VRemoveListener(MakeDelegate(this, &Scene::DestroyActorDelegate), EvtData_Destroy_Actor::sk_EventType);
      10. pEventMgr->VRemoveListener(MakeDelegate(this, &Scene::MoveActorDelegate), EvtData_Move_Actor::sk_EventType);
      11. pEventMgr->VRemoveListener(MakeDelegate(this, &Scene::ModifiedRenderComponentDelegate), EvtData_New_Render_Component::sk_EventType);
      12. SAFE_RELEASE(m_MatrixStack);
      13. SAFE_DELETE(m_LightManager);
      14. }
      Display All


      The part

      Source Code

      1. pEventMgr->VRemoveListener(MakeDelegate(this, &Scene::ModifiedRenderComponentDelegate), EvtData_New_Render_Component::sk_EventType);


      should instead be:

      Source Code

      1. pEventMgr->VRemoveListener(MakeDelegate(this, &Scene::ModifiedRenderComponentDelegate), EvtData_Modified_Render_Component::sk_EventType);


      Hope this is helpful ;)

      The post was edited 1 time, last by Guilherme Silva ().

    • I noticed another small copy&paste error as well.

      In the GameOptions::Init method you check the supplied width to make sure it is greater than 800.
      Then you proceed to check the height to make sure it is greater than 600, only you actually check the width again.

      line 210 through 220 in Initialization.cpp

      Source Code

      1. if (pNode->Attribute("width"))
      2. {
      3. m_ScreenSize.x = atoi(pNode->Attribute("width"));
      4. if (m_ScreenSize.x < 800) m_ScreenSize.x = 800;
      5. }
      6. if (pNode->Attribute("height"))
      7. {
      8. m_ScreenSize.y = atoi(pNode->Attribute("height"));
      9. if (m_ScreenSize.x < 600) m_ScreenSize.x = 600;
      10. }
      Display All
    • Thanks guys, these have both been fixed and checked into google code. If you synch up, you'll get the changes.

      -Rez