[Add] Body: GetRadius method.
[Add] Calculate bounding sphere radius from AABB's of geoms. [Add] Make use of the existing GetRadius methods. [Change] Moved object viewer key to f10. [Add] A couple new image icons.
							
								
								
									
										
											BIN
										
									
								
								icons/object_planet_co2.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 3.1 KiB  | 
| 
		 Before Width: | Height: | Size: 275 B After Width: | Height: | Size: 2.9 KiB  | 
| 
		 Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 5.3 KiB  | 
| 
		 Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 4.9 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								icons/object_planet_methane.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 3.2 KiB  | 
| 
		 Before Width: | Height: | Size: 323 B After Width: | Height: | Size: 3.3 KiB  | 
| 
		 Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 4.4 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								icons/object_planet_volcanic.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 3.2 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								icons/object_planet_water_n2.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 3.3 KiB  | 
@ -15,6 +15,7 @@ public:
 | 
				
			|||||||
  virtual Object::Type GetType(void) { return Object::BODY; }
 | 
					  virtual Object::Type GetType(void) { return Object::BODY; }
 | 
				
			||||||
  virtual void SetPosition(vector3d p) = 0;
 | 
					  virtual void SetPosition(vector3d p) = 0;
 | 
				
			||||||
  virtual vector3d GetPosition(void) = 0; /* Within frame. */
 | 
					  virtual vector3d GetPosition(void) = 0; /* Within frame. */
 | 
				
			||||||
 | 
					  virtual double GetRadius(void) const = 0 ;
 | 
				
			||||||
  virtual void Render(const Frame* camFrame) = 0;
 | 
					  virtual void Render(const Frame* camFrame) = 0;
 | 
				
			||||||
  virtual void SetFrame(Frame* f) { m_frame = f; }
 | 
					  virtual void SetFrame(Frame* f) { m_frame = f; }
 | 
				
			||||||
  /* return true if to we do collision response and apply damage. */
 | 
					  /* return true if to we do collision response and apply damage. */
 | 
				
			||||||
 | 
				
			|||||||
@ -7,6 +7,7 @@
 | 
				
			|||||||
#include <SDL_image.h>
 | 
					#include <SDL_image.h>
 | 
				
			||||||
#include <ode/ode.h>
 | 
					#include <ode/ode.h>
 | 
				
			||||||
#include <float.h>
 | 
					#include <float.h>
 | 
				
			||||||
 | 
					#include <limits>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _WIN32
 | 
					#ifdef _WIN32
 | 
				
			||||||
#include <windows.h>
 | 
					#include <windows.h>
 | 
				
			||||||
 | 
				
			|||||||
@ -154,7 +154,7 @@ void L3D::HandleEvents(void) {
 | 
				
			|||||||
    case SDL_KEYDOWN:
 | 
					    case SDL_KEYDOWN:
 | 
				
			||||||
      if(event.key.keysym.sym == SDLK_q) L3D::Quit();
 | 
					      if(event.key.keysym.sym == SDLK_q) L3D::Quit();
 | 
				
			||||||
      if(event.key.keysym.sym == SDLK_F11) SDL_WM_ToggleFullScreen(L3D::scrSurface);
 | 
					      if(event.key.keysym.sym == SDLK_F11) SDL_WM_ToggleFullScreen(L3D::scrSurface);
 | 
				
			||||||
      if(event.key.keysym.sym == SDLK_F12) L3D::SetView(L3D::objectViewerView);
 | 
					      if(event.key.keysym.sym == SDLK_F10) L3D::SetView(L3D::objectViewerView);
 | 
				
			||||||
      L3D::keyState[event.key.keysym.sym] = 1;
 | 
					      L3D::keyState[event.key.keysym.sym] = 1;
 | 
				
			||||||
      L3D::onKeyPress.emit(&event.key.keysym);
 | 
					      L3D::onKeyPress.emit(&event.key.keysym);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
				
			|||||||
@ -62,6 +62,32 @@ vector3d ModelBody::GetPosition(void) {
 | 
				
			|||||||
  return vector3d(pos[0], pos[1], pos[2]);
 | 
					  return vector3d(pos[0], pos[1], pos[2]);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					double ModelBody::GetRadius(void) const {
 | 
				
			||||||
 | 
					  /* Calculate single AABB containing all geoms. */
 | 
				
			||||||
 | 
					  dReal aabbAll[6] = {
 | 
				
			||||||
 | 
					    std::numeric_limits<double>::max(),
 | 
				
			||||||
 | 
					    std::numeric_limits<double>::min(),
 | 
				
			||||||
 | 
					    std::numeric_limits<double>::max(),
 | 
				
			||||||
 | 
					    std::numeric_limits<double>::min(),
 | 
				
			||||||
 | 
					    std::numeric_limits<double>::max(),
 | 
				
			||||||
 | 
					    std::numeric_limits<double>::min()
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for(size_t i = 0; i < geoms.size(); ++i) {
 | 
				
			||||||
 | 
					    dReal aabbGeom[6];
 | 
				
			||||||
 | 
					    dGeomGetAABB(geoms[i], aabbGeom);
 | 
				
			||||||
 | 
					    aabbAll[0] = std::min(aabbAll[0], aabbGeom[0]);
 | 
				
			||||||
 | 
					    aabbAll[1] = std::max(aabbAll[1], aabbGeom[1]);
 | 
				
			||||||
 | 
					    aabbAll[2] = std::min(aabbAll[2], aabbGeom[2]);
 | 
				
			||||||
 | 
					    aabbAll[3] = std::max(aabbAll[3], aabbGeom[3]);
 | 
				
			||||||
 | 
					    aabbAll[4] = std::min(aabbAll[4], aabbGeom[4]);
 | 
				
			||||||
 | 
					    aabbAll[5] = std::max(aabbAll[5], aabbGeom[5]);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Return size of largest dimension. */
 | 
				
			||||||
 | 
					  return std::max(aabbAll[1] - aabbAll[0], std::max(aabbAll[3] - aabbAll[2], aabbAll[5] - aabbAll[4]));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ModelBody::SetRotation(const matrix4x4d& r) {
 | 
					void ModelBody::SetRotation(const matrix4x4d& r) {
 | 
				
			||||||
  dMatrix3 _m;
 | 
					  dMatrix3 _m;
 | 
				
			||||||
  r.SaveToOdeMatrix(_m);
 | 
					  r.SaveToOdeMatrix(_m);
 | 
				
			||||||
 | 
				
			|||||||
@ -15,6 +15,7 @@ public:
 | 
				
			|||||||
  virtual void SetRotation(const matrix4x4d& r);
 | 
					  virtual void SetRotation(const matrix4x4d& r);
 | 
				
			||||||
  /* Not valid to SetVelocity on these. If you want them to move, use a DynamicBody. */
 | 
					  /* Not valid to SetVelocity on these. If you want them to move, use a DynamicBody. */
 | 
				
			||||||
  vector3d GetPosition(void);
 | 
					  vector3d GetPosition(void);
 | 
				
			||||||
 | 
					  virtual double GetRadius(void) const;
 | 
				
			||||||
  void TransformToModelCoords(const Frame* camFrame);
 | 
					  void TransformToModelCoords(const Frame* camFrame);
 | 
				
			||||||
  void ViewingRotation(void);
 | 
					  void ViewingRotation(void);
 | 
				
			||||||
  void GetRotMatrix(matrix4x4d& m);
 | 
					  void GetRotMatrix(matrix4x4d& m);
 | 
				
			||||||
 | 
				
			|||||||
@ -60,6 +60,11 @@ void ObjectViewerView::Update(void) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  char buf[128];
 | 
					  char buf[128];
 | 
				
			||||||
  Body* body = L3D::player->GetNavTarget();
 | 
					  Body* body = L3D::player->GetNavTarget();
 | 
				
			||||||
 | 
					  if(body && body != lastTarget) {
 | 
				
			||||||
 | 
					    /* Reset view distance for new target. */
 | 
				
			||||||
 | 
					    viewingDist = body->GetRadius() * 2.0f;
 | 
				
			||||||
 | 
					    lastTarget = body;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  snprintf(buf, sizeof(buf), "View dist: %.2f   Object: %s", viewingDist, (body ? body->GetLabel().c_str() : "<none>"));
 | 
					  snprintf(buf, sizeof(buf), "View dist: %.2f   Object: %s", viewingDist, (body ? body->GetLabel().c_str() : "<none>"));
 | 
				
			||||||
  m_infoLabel->SetText(buf);
 | 
					  m_infoLabel->SetText(buf);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -15,5 +15,6 @@ private:
 | 
				
			|||||||
  matrix4x4d viewingRotation;
 | 
					  matrix4x4d viewingRotation;
 | 
				
			||||||
  float viewingDist;
 | 
					  float viewingDist;
 | 
				
			||||||
  Gui::Label* m_infoLabel;
 | 
					  Gui::Label* m_infoLabel;
 | 
				
			||||||
 | 
					  const Body* lastTarget;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,7 @@ public:
 | 
				
			|||||||
  virtual void SetPosition(vector3d p);
 | 
					  virtual void SetPosition(vector3d p);
 | 
				
			||||||
  virtual vector3d GetPosition(void);
 | 
					  virtual vector3d GetPosition(void);
 | 
				
			||||||
  void SetRadius(double radius);
 | 
					  void SetRadius(double radius);
 | 
				
			||||||
  double GetRadius(void) { return sbody.radius; }
 | 
					  virtual double GetRadius(void) const { return sbody.radius; }
 | 
				
			||||||
  virtual void Render(const Frame* camFrame);
 | 
					  virtual void Render(const Frame* camFrame);
 | 
				
			||||||
  virtual void SetFrame(Frame* f);
 | 
					  virtual void SetFrame(Frame* f);
 | 
				
			||||||
  virtual bool OnCollision(Body* b, Uint32 flags) { return true; }
 | 
					  virtual bool OnCollision(Body* b, Uint32 flags) { return true; }
 | 
				
			||||||
 | 
				
			|||||||
@ -11,7 +11,7 @@ public:
 | 
				
			|||||||
  virtual void SetPosition(vector3d p);
 | 
					  virtual void SetPosition(vector3d p);
 | 
				
			||||||
  virtual vector3d GetPosition(void);
 | 
					  virtual vector3d GetPosition(void);
 | 
				
			||||||
  void SetRadius(double radius) { this->radius = radius; }
 | 
					  void SetRadius(double radius) { this->radius = radius; }
 | 
				
			||||||
  double GetRadius(void) { return radius; }
 | 
					  virtual double GetRadius(void) const { return radius; }
 | 
				
			||||||
  virtual void Render(const Frame* camFrame);
 | 
					  virtual void Render(const Frame* camFrame);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
 | 
				
			|||||||