Example #1
0
/// Objective function: calculates the objective value (ignore gradient calculation)
/// Keep track of how many times this function has been called, and report current
/// chi^2 (or other objective-function value) every 20 calls
/// Note that parameters n and grad are unused, but required by the NLopt interface.
double myfunc_nlopt_gen( unsigned n, const double *x, double *grad, void *my_func_data )
{
  ModelObject *theModel = (ModelObject *)my_func_data;
  // following is a necessary kludge bcs theModel->GetFitStatistic() won't accept 
  // const double*
  double  *params = (double *)x;
  double  fitStatistic;
  nlopt_result  junk;
  
  fitStatistic = theModel->GetFitStatistic(params);
  
  // feedback to user
  funcCallCount++;
  if (verboseOutput > 0) {
    if ((funcCallCount % FUNCS_PER_REPORTING_STEP) == 0) {
      printf("\tN-M simplex: function call %d: objective = %f\n", funcCallCount, fitStatistic);
      if ( (verboseOutput > 1) && ((funcCallCount % (REPORT_STEPS_PER_VERBOSE_OUTPUT*FUNCS_PER_REPORTING_STEP)) == 0) ) {
        PrintParametersSimple(theModel, params);
      }
    }
  }
  
  if (isnan(fitStatistic)) {
    fprintf(stderr, "\n*** NaN-valued fit statistic detected (N-M optimization)!\n");
    fprintf(stderr, "*** Terminating the fit...\n");
    junk = nlopt_force_stop(theOptimizer);
  }

  return(fitStatistic);
}
Example #2
0
void Level::findObjectsInRadius( TGameObjectVec& out_objects, const rtti::TypeInfo* type, const mkVec3& search_origin, float radius, bool allow_derived /*= true*/ )
{
    MK_ASSERT(out_objects.empty());

    m_objectsMgr.findObjectsOfType(out_objects, type, allow_derived);

    for (size_t i = 0; i < out_objects.size(); ++i)
    {
        bool accept = false;

        GameObject* go = out_objects[i];
        if (go->getTypeInfo()->isDerivedOrExact(&ModelObject::Type))
        {
            ModelObject* mo = static_cast<ModelObject*>(go);
            float dist_sq = (mo->getWorldPosition() - search_origin).length();

            if (dist_sq <= radius)
                accept = true;
        }

        if (!accept)
            out_objects[i] = NULL;
    }

    fast_remove_val_from_vec(out_objects, (GameObject*)NULL);
}
Example #3
0
bool Model::IsOverlapping(ModelObject &left, ModelObject &right)
{
  Shape::Sphere circle_left = { left.position(), left.radius() };
  Shape::Sphere circle_right = { right.position(), right.radius() };

  return (Overlap::IsOverlapping(circle_left, circle_right));
}
// Set parent object id (after reading from model emf-file)
void
BoundaryCondition::updateParentId()
{
  // If parent object type is a normal boundary, replace the
  // parent object with the boundary-group object
  //
  if ( parentEmfType != OT_ELEMENT_GROUP ) {

    ModelObject* obj = model->getModelObjectByTag(parentEmfType, parentEmfTag);
    if ( obj != NULL ) {
      BodyElement* be = (BodyElement*)obj;
      parentEmfTag = be->getElementGroupTag();
      parentEmfType = OT_ELEMENT_GROUP;
    } else {
      parentEmfTag = NO_INDEX;
      parentEmfType = OT_NONE;
    }
  }

  ModelObject* obj = model->getModelObjectByTag(parentEmfType, parentEmfTag);

  if ( obj != NULL ) {
    parentId = obj->Id();
  }
}
Example #5
0
void RenderQueue::Enqueue(const mat4x4 &world, ModelHandle& model){
	ModelObject* obj = new ModelObject();
	obj->Model = model;
	obj->World = world;
	obj->SetType( RENDER_TYPE::MODEL);
	m_CurrentScene->Objects.push_back(obj);
	m_CurrentScene->Programs.push_back(nullptr); //default program
}
Example #6
0
 ModelObject ParentObject_Impl::clone(Model model) const
 {
   ModelObject newParentAsModelObject = ModelObject_Impl::clone(model);
   ParentObject newParent = newParentAsModelObject.cast<ParentObject>();
   for (ModelObject child : children())
   {
     ModelObject newChild = child.clone(model);
     newChild.setParent(newParent);
   }
   return newParentAsModelObject;
 }
Example #7
0
TEST_F(ModelFixture, Construction_Clone)
{
  Model library;

  // Create some materials
  StandardOpaqueMaterial exterior(library);
  AirGap air(library);
  StandardOpaqueMaterial interior(library);

  OpaqueMaterialVector layers;
  layers.push_back(exterior);
  layers.push_back(air);
  layers.push_back(interior);

  EXPECT_EQ(static_cast<unsigned>(3), library.getModelObjects<Material>().size());

  Construction construction(layers);
  ASSERT_EQ(static_cast<unsigned>(3), construction.layers().size());

  // Clone into same model
  ModelObject clone = construction.clone(library);

  // Material ResourceObject instances are shared resources so they have not been cloned
  EXPECT_EQ(static_cast<unsigned>(3), library.getModelObjects<Material>().size());

  // New handle for cloned construction
  EXPECT_FALSE(clone.handle() == construction.handle());
  ASSERT_TRUE(clone.optionalCast<Construction>());

  ASSERT_EQ(static_cast<unsigned>(3), clone.cast<Construction>().layers().size());

  // Clone into a differnt model
  Model model;

  auto clone2 = construction.clone(model).cast<Construction>();
  EXPECT_EQ(static_cast<unsigned>(3), model.getModelObjects<Material>().size());

  EXPECT_EQ(static_cast<unsigned>(1), model.getModelObjects<Construction>().size());

  // Make sure materials are still hooked up
  ASSERT_EQ(static_cast<unsigned>(3), clone2.cast<Construction>().layers().size());

  // Clone again
  auto clone3 = construction.clone(model).cast<Construction>();
  EXPECT_EQ(static_cast<unsigned>(3), model.getModelObjects<Material>().size());

  EXPECT_EQ(static_cast<unsigned>(2), model.getModelObjects<Construction>().size());

  // Make sure materials are still hooked up
  ASSERT_EQ(static_cast<unsigned>(3), clone3.cast<Construction>().layers().size());

  EXPECT_FALSE(clone2.handle() == clone3.handle());
}
Example #8
0
ContainersTemp get_output_containers(const ModelObjectsTemp &mo) {
  ContainersTemp ret;
  for (unsigned int i = 0; i < mo.size(); ++i) {
    ModelObject *o = mo[i];
    Container *p = dynamic_cast<Container *>(o);
    if (p)
      ret.push_back(p);
    else {
      ret += get_output_containers(o->get_inputs());
    }
  }
  return ret;
}
Example #9
0
ParticlesTemp get_output_particles(const ModelObjectsTemp &mo) {
  ParticlesTemp ret;
  for (unsigned int i = 0; i < mo.size(); ++i) {
    ModelObject *o = mo[i];
    Particle *p = dynamic_cast<Particle *>(o);
    if (p)
      ret.push_back(p);
    else {
      ret += get_output_particles(o->get_inputs());
    }
  }
  return ret;
}
Example #10
0
void OSIntegerEdit::refreshTextAndLabel() {
  if (m_modelObject) {
    QString textValue;
    ModelObject modelObject = m_modelObject.get();
    std::stringstream ss;

    if (m_isAutosizedProperty) {
      Attribute autosized = modelObject.getAttribute(*m_isAutosizedProperty).get();
      if (autosized.valueAsBoolean()) {
        textValue = QString("autosize");
      }
    }

    if (m_isAutocalculatedProperty) {
      Attribute autocalculated = modelObject.getAttribute(*m_isAutocalculatedProperty).get();
      if (autocalculated.valueAsBoolean()) {
        textValue = QString("autocalculate");
      }
    }

    OptionalAttribute attribute = modelObject.getAttribute(m_property);
    if (attribute) {
      int value = attribute->valueAsInteger();
      if (m_isScientific) {
        ss << std::scientific;
      }
      else {
        ss << std::fixed;
      }
      if (m_precision) {
        ss << std::setprecision(*m_precision);
      }
      ss << value;
      textValue = toQString(ss.str());
      ss.str("");
    }

    this->setText(textValue);

    if (m_isDefaultedProperty) {
      Attribute defaulted = modelObject.getAttribute(*m_isDefaultedProperty).get();
      if (defaulted.valueAsBoolean()) {
        this->setStyleSheet("color:green");
      }
      else {
        this->setStyleSheet("color:black");
      }
    }
  }
}
Example #11
0
  bool Node_Impl::isConnected(const ModelObject & modelObject)
  {
    if( auto mo = outletModelObject() ) {
      if( modelObject.handle() == mo->handle() ) {
        return true;
      }
    }
    if( auto mo = inletModelObject() ) {
      if( modelObject.handle() == mo->handle() ) {
        return true;
      }
    }

    return false;
  }
TEST_F(ModelFixture, ModelObject_Attributes)
{
  Model model;

  OptionalWorkspaceObject oObject = model.addObject(IdfObject(IddObjectType::OS_Version));
  ASSERT_TRUE(oObject);
  ModelObject version = oObject->cast<ModelObject>();
  StringVector versionAttributeNames = version.attributeNames();
  ASSERT_EQ(static_cast<unsigned>(3),versionAttributeNames.size());
  EXPECT_EQ("iddObjectType",versionAttributeNames[0]);
  EXPECT_EQ("handle",versionAttributeNames[1]);
  EXPECT_EQ("name",versionAttributeNames[2]);

  EXPECT_FALSE(version.getAttribute("N a m e"));
}
unsigned ZoneHVACEquipmentList_Impl::coolingPriority(const ModelObject & equipment)
{
  boost::optional<unsigned> result;

  std::vector<IdfExtensibleGroup> groups = extensibleGroups();

  for( std::vector<IdfExtensibleGroup>::iterator it = groups.begin();
       it != groups.end();
       ++it )
  {
    boost::optional<WorkspaceObject> wo = it->cast<WorkspaceExtensibleGroup>().getTarget(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipment);

    OS_ASSERT(wo);

    if( wo->handle() == equipment.handle() )
    {
      result = it->getUnsigned(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentCoolingSequence);

      break;
    }
  }

  OS_ASSERT(result);

  return result.get();
}
WorkspaceExtensibleGroup ZoneHVACEquipmentList_Impl::getGroupForModelObject(const ModelObject & modelObject)
{
  boost::optional<WorkspaceExtensibleGroup> result;

  std::vector<IdfExtensibleGroup> groups = extensibleGroups();

  for( std::vector<IdfExtensibleGroup>::iterator it = groups.begin();
       it != groups.end();
       ++it )
  {
    boost::optional<WorkspaceObject> wo = it->cast<WorkspaceExtensibleGroup>().getTarget(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipment);

    OS_ASSERT(wo);

    if( wo->handle() == modelObject.handle() )
    {
      result = it->cast<WorkspaceExtensibleGroup>();

      break;
    }
  }

  OS_ASSERT(result);

  return result.get();
}
ExternalInterfaceFunctionalMockupUnitImportToActuator::ExternalInterfaceFunctionalMockupUnitImportToActuator(const ModelObject& modelObject,
                                                                                                             const std::string& actuatedComponentType,
                                                                                                             const std::string& actuatedComponentControlType,
                                                                                                             const ExternalInterfaceFunctionalMockupUnitImport& fMUFile,
                                                                                                             const std::string& fMUInstanceName,
                                                                                                             const std::string& fMUVariableName,
                                                                                                             double initialValue)
  : ModelObject(ExternalInterfaceFunctionalMockupUnitImportToActuator::iddObjectType(), modelObject.model())
{
  OS_ASSERT(getImpl<detail::ExternalInterfaceFunctionalMockupUnitImportToActuator_Impl>());

  bool ok = setActuatedComponentUnique(modelObject);
  if (!ok) {
    remove();
    LOG_AND_THROW("Unable to set " << briefDescription() << "'s ActuatedComponentUnique to "
      << modelObject.nameString() << ".");
  }
  setActuatedComponentType(actuatedComponentType);
  setActuatedComponentControlType(actuatedComponentControlType);
  ok = setFMUFile(fMUFile);
  if (!ok) {
    remove();
    LOG_AND_THROW("Unable to set " << briefDescription() << "'s FMUFileName to "
      << fMUFile.fMUFileName() << ".");
  }
  setFMUInstanceName(fMUInstanceName);
  setFMUVariableName(fMUVariableName);
  setInitialValue(initialValue);
}
Example #16
0
// Adds the force exerted on each body to each body's net force
void NBodySimulator::AddForcesBetween(ModelObject &b1, ModelObject &b2)
{
  Gravity::PointMass m1 = { b1.mass(), b1.position() };
  Gravity::PointMass m2 = { b2.mass(), b2.position() };

  Vector3 force = Gravity::force(m1, m2, gravity_);
  b1.set_force(b1.force() + force);
  b2.set_force(b2.force() + force * -1);
}
Example #17
0
double ImfitSolver::EnergyFunction( double *trial, bool &bAtSolution )
{
  double  fitStatistic;
  
  fitStatistic = theModel->GetFitStatistic(trial);

  return(fitStatistic);
}
TEST_F(ModelFixture, DefaultConstructionSet_CloneBadName)
{
  Model model;

  DefaultSurfaceConstructions defaultSurfaceConstructions(model);
  defaultSurfaceConstructions.setName("Easy name");
  ModelObject clone = defaultSurfaceConstructions.clone(model);
  EXPECT_EQ("Easy name 1", clone.name().get());
  clone = defaultSurfaceConstructions.clone(model);
  EXPECT_EQ("Easy name 2", clone.name().get());

  defaultSurfaceConstructions = DefaultSurfaceConstructions(model);
  defaultSurfaceConstructions.setName("Harder 1-8_(name)");
  clone = defaultSurfaceConstructions.clone(model);
  EXPECT_EQ("Harder 1-8_(name) 1", clone.name().get());
  clone = defaultSurfaceConstructions.clone(model);
  EXPECT_EQ("Harder 1-8_(name) 2", clone.name().get());

  defaultSurfaceConstructions = DefaultSurfaceConstructions(model);
  defaultSurfaceConstructions.setName("*H.a.r.d.e.s.t*^\\1|-|8/_#($name$)?#");
  clone = defaultSurfaceConstructions.clone(model);
  EXPECT_EQ("*H.a.r.d.e.s.t*^\\1|-|8/_#($name$)?# 1", clone.name().get());
  clone = defaultSurfaceConstructions.clone(model);
  EXPECT_EQ("*H.a.r.d.e.s.t*^\\1|-|8/_#($name$)?# 2", clone.name().get());
}
Example #19
0
File: IO.cpp Project: alexrj/Slic3r
bool
STL::read(std::string input_file, Model* model)
{
    TriangleMesh mesh;
    if (!STL::read(input_file, &mesh)) return false;
    
    if (mesh.facets_count() == 0)
        throw std::runtime_error("This STL file couldn't be read because it's empty.");
    
    ModelObject* object = model->add_object();
    object->name        = boost::filesystem::path(input_file).filename().string();
    object->input_file  = input_file;
    
    ModelVolume* volume = object->add_volume(mesh);
    volume->name        = object->name;
    
    return true;
}
Example #20
0
  bool ModelObjectList_Impl::addModelObject(const ModelObject& modelObject ) {
    WorkspaceExtensibleGroup eg = getObject<ModelObject>().pushExtensibleGroup().cast<WorkspaceExtensibleGroup>();

    bool ok = eg.setPointer(OS_ModelObjectListExtensibleFields::ModelObject,modelObject.handle());

    if( !ok ) {
      getObject<ModelObject>().eraseExtensibleGroup(eg.groupIndex());
    }
    return ok;
  }
Example #21
0
 bool ComponentData_Impl::registerObject(const ModelObject& object) {
   IdfExtensibleGroup eg = pushExtensibleGroup(StringVector());
   bool result = !eg.empty();
   if (result) {
     ModelExtensibleGroup meg = eg.cast<ModelExtensibleGroup>();
     result = result && meg.setPointer(OS_ComponentDataExtensibleFields::NameofObject,
                                       object.handle());
   }
   return result;
 }
Example #22
0
ScheduleRule::ScheduleRule(ScheduleRuleset& scheduleRuleset, const ScheduleDay& daySchedule)
  : ParentObject(ScheduleRule::iddObjectType(), scheduleRuleset.model())
{
  OS_ASSERT(getImpl<detail::ScheduleRule_Impl>());

  bool result = setPointer(OS_Schedule_RuleFields::ScheduleRulesetName, scheduleRuleset.handle());
  OS_ASSERT(result); 

  ModelObject clone = daySchedule.clone(scheduleRuleset.model());
  result = setPointer(OS_Schedule_RuleFields::DayScheduleName, clone.handle());
  OS_ASSERT(result); 
  if (OptionalScheduleTypeLimits limits = scheduleRuleset.scheduleTypeLimits()) {
    clone.cast<ScheduleDay>().setScheduleTypeLimits(*limits);
  }

  this->setRuleIndex(std::numeric_limits<int>::max());
  result = scheduleRuleset.setScheduleRuleIndex(*this, 0);
  OS_ASSERT(result);
}
Example #23
0
void
Model::duplicate_objects_grid(size_t x, size_t y, coordf_t dist)
{
    if (this->objects.size() > 1) throw std::runtime_error("Grid duplication is not supported with multiple objects");
    if (this->objects.empty()) throw std::runtime_error("No objects!");

    ModelObject* object = this->objects.front();
    object->clear_instances();

    Sizef3 size = object->bounding_box().size();

    for (size_t x_copy = 1; x_copy <= x; ++x_copy) {
        for (size_t y_copy = 1; y_copy <= y; ++y_copy) {
            ModelInstance* instance = object->add_instance();
            instance->offset.x = (size.x + dist) * (x_copy-1);
            instance->offset.y = (size.y + dist) * (y_copy-1);
        }
    }
}
Example #24
0
void
Model::convert_multipart_object()
{
    if (this->objects.empty()) return;
    
    ModelObject* object = this->add_object();
    object->input_file = this->objects.front()->input_file;
    
    for (const ModelObject* o : this->objects) {
        for (const ModelVolume* v : o->volumes) {
            ModelVolume* v2 = object->add_volume(*v);
            v2->name = o->name;
        }
    }
    for (const ModelInstance* i : this->objects.front()->instances)
        object->add_instance(*i);
    
    while (this->objects.size() > 1)
        this->delete_object(0);
}
Example #25
0
void Torre::calcular_viga_cruzada(ModelObject& mo, const glm::vec3& p0, const glm::vec3& p1) {
	mo.set_model_matrix(
		ModelObject::adjust_z(
		ModelObject::line(
			glm::vec3(p0[0], p0[1], p0[2]*z_factor),
			glm::vec3(p1[0], p1[1], p1[2]*z_factor),
			0.1,
			0.1, 1.0/z_factor), 
			z_factor)
	);
}
Example #26
0
File: IO.cpp Project: alpha6/Slic3r
bool
STL::read(std::string input_file, Model* model)
{
    // TODO: encode file name
    // TODO: check that file exists
    
    TriangleMesh mesh;
    if (!STL::read(input_file, &mesh)) return false;
    
    if (mesh.facets_count() == 0)
        throw std::runtime_error("This STL file couldn't be read because it's empty.");
    
    ModelObject* object = model->add_object();
    object->name        = input_file;  // TODO: use basename()
    object->input_file  = input_file;
    
    ModelVolume* volume = object->add_volume(mesh);
    volume->name        = input_file;   // TODO: use basename()
    
    return true;
}
void ZoneHVACEquipmentList_Impl::removeEquipment(const ModelObject & equipment)
{
  std::vector<ModelObject> coolingVector = equipmentInCoolingOrder();
  std::vector<ModelObject> heatingVector = equipmentInHeatingOrder();

  std::vector<IdfExtensibleGroup> groups = extensibleGroups();

  for( std::vector<IdfExtensibleGroup>::iterator it = groups.begin();
       it != groups.end();
       ++it )
  {
    boost::optional<WorkspaceObject> wo = it->cast<WorkspaceExtensibleGroup>().getTarget(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipment);

    OS_ASSERT(wo);

    if( wo->handle() == equipment.handle() )
    {
      getObject<ModelObject>().eraseExtensibleGroup(it->groupIndex());

      break;
    }
  }

  coolingVector.erase(std::find(coolingVector.begin(),coolingVector.end(),equipment));
  heatingVector.erase(std::find(heatingVector.begin(),heatingVector.end(),equipment));

  unsigned priority = 1;

  for( std::vector<ModelObject>::iterator it = coolingVector.begin();
       it != coolingVector.end();
       ++it )
  {
    WorkspaceExtensibleGroup eg = getGroupForModelObject(*it);

    eg.setUnsigned(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentCoolingSequence,priority);

    priority++;
  }

  priority = 1;

  for( std::vector<ModelObject>::iterator it = heatingVector.begin();
       it != heatingVector.end();
       ++it )
  {
    WorkspaceExtensibleGroup eg = getGroupForModelObject(*it);

    eg.setUnsigned(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentHeatingorNoLoadSequence,priority);

    priority++;
  }

}
  ModelObject ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl::clone(Model model) const
  {
    ModelObject terminalClone = ZoneHVACComponent_Impl::clone(model);

    HVACComponent fanClone = supplyAirFan().clone(model).cast<HVACComponent>();

    CoilCoolingDXVariableRefrigerantFlow coolingCoilClone = coolingCoil().clone(model).cast<CoilCoolingDXVariableRefrigerantFlow>();

    CoilHeatingDXVariableRefrigerantFlow heatingCoilClone = heatingCoil().clone(model).cast<CoilHeatingDXVariableRefrigerantFlow>();

    terminalClone.getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setSupplyAirFan(fanClone);

    terminalClone.getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setCoolingCoil(coolingCoilClone);

    terminalClone.getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setHeatingCoil(heatingCoilClone);

    // TODO Move this into base clase
    terminalClone.setString(OS_ZoneHVAC_TerminalUnit_VariableRefrigerantFlowFields::TerminalUnitAirInletNode,"");
    terminalClone.setString(OS_ZoneHVAC_TerminalUnit_VariableRefrigerantFlowFields::TerminalUnitAirOutletNode,"");

    return terminalClone;
  }
Example #29
0
void
ModelObject::cut(Axis axis, coordf_t z, Model* model) const
{
    // clone this one to duplicate instances, materials etc.
    ModelObject* upper = model->add_object(*this);
    ModelObject* lower = model->add_object(*this);
    upper->clear_volumes();
    lower->clear_volumes();
    upper->input_file = "";
    lower->input_file = "";
    
    for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) {
        ModelVolume* volume = *v;
        if (volume->modifier) {
            // don't cut modifiers
            upper->add_volume(*volume);
            lower->add_volume(*volume);
        } else {
            TriangleMesh upper_mesh, lower_mesh;
            
            if (axis == X) {
                TriangleMeshSlicer<X>(&volume->mesh).cut(z, &upper_mesh, &lower_mesh);
            } else if (axis == Y) {
                TriangleMeshSlicer<Y>(&volume->mesh).cut(z, &upper_mesh, &lower_mesh);
            } else if (axis == Z) {
                TriangleMeshSlicer<Z>(&volume->mesh).cut(z, &upper_mesh, &lower_mesh);
            }
            
            upper_mesh.repair();
            lower_mesh.repair();
            upper_mesh.reset_repair_stats();
            lower_mesh.reset_repair_stats();
            
            if (upper_mesh.facets_count() > 0) {
                ModelVolume* vol    = upper->add_volume(upper_mesh);
                vol->name           = volume->name;
                vol->config         = volume->config;
                vol->set_material(volume->material_id(), *volume->material());
            }
            if (lower_mesh.facets_count() > 0) {
                ModelVolume* vol    = lower->add_volume(lower_mesh);
                vol->name           = volume->name;
                vol->config         = volume->config;
                vol->set_material(volume->material_id(), *volume->material());
            }
        }
    }
}
void RendererBase::loadScene()
{
	m_camera->setPosDir(glm::vec3(0.0f, 5.0f, 0.0f), glm::vec2(TO_RADIANS(175.0f), 0.0f));


	ModelObject *ground = new ModelObject(&m_modelCube);
	ground->scale(glm::vec3(200.0f, 1.0f, 200.0f));
	ground->pos(glm::vec3(0.0f, 0.0f, 0.0f));

	m_modelObjects.push_back(ground);

	int index = 0;
	for (int x = 0; x < 8; x++) {
		for (int y = 0; y < 8; y++) {
			LightPoint *lp = new LightPoint;
			lp->position = glm::vec3(-10.0f + (x*  12 ), 5.0f, -20.0f + (y*  12 ));

			ModelObject *teapot = new ModelObject(&m_modelTeapot);
			teapot->scale(glm::vec3(20.0f, 20.0f, 20.0f));
			teapot->pos(glm::vec3(lp->position.x-1.0f,
								  0.5f,
								  lp->position.z));

			m_pointLights.push_back(lp);

			m_modelObjects.push_back(teapot);
		}
	}
	
	// Textures
	m_textureGround.load("Ground_SmoothRocks_1k_d.tga", 16);
	m_textureGround.setTextTile(50.0f);
	m_textureGround.setKd(glm::vec3(1.0f));
	m_textureGround.setShininess(100.0f);
	m_textureGround.setSpec(0.1f);

	m_textureTeapot.load("Metal_WallPanel_1k_d.tga", 16);
	m_textureTeapot.setTextTile(4.0f);
	m_textureTeapot.setKd(glm::vec3(1.0f));
	m_textureTeapot.setShininess(100.0f);
	m_textureTeapot.setSpec(2.7f);

	
	m_textureColorTerrain.setKd(glm::vec3(0.0f, 0.0f, 1.0f));
	m_textureColorTerrain.setShininess(100.0f);
	m_textureColorTerrain.setSpec(2.7f);

	std::vector<glm::vec3> verticesList;
	std::vector<glm::vec3> normalsList;
	std::vector<glm::vec2> tcList;
	std::vector<GLushort> indices;

	CreateCube(1, verticesList, normalsList, tcList, indices);
	m_terrainCube.fillVertecies(verticesList, normalsList, tcList, indices);

	m_terrainCube.pos(glm::vec3(0.0f, 1.0f, 0.0f));
	m_terrainCube.scale(glm::vec3(4.0f));
}