void StaticModel::SetModel(Model* model)
{
    if (model == model_)
        return;

    // If script erroneously calls StaticModel::SetModel on an AnimatedModel, warn and redirect
    if (GetType() == AnimatedModel::GetTypeStatic())
    {
        ATOMIC_LOGWARNING("StaticModel::SetModel() called on AnimatedModel. Redirecting to AnimatedModel::SetModel()");
        AnimatedModel* animatedModel = static_cast<AnimatedModel*>(this);
        animatedModel->SetModel(model);
        return;
    }

    // Unsubscribe from the reload event of previous model (if any), then subscribe to the new
    if (model_)
        UnsubscribeFromEvent(model_, E_RELOADFINISHED);

    model_ = model;

    if (model)
    {
        SubscribeToEvent(model, E_RELOADFINISHED, ATOMIC_HANDLER(StaticModel, HandleModelReloadFinished));

        // Copy the subgeometry & LOD level structure
        SetNumGeometries(model->GetNumGeometries());
        const Vector<Vector<SharedPtr<Geometry> > >& geometries = model->GetGeometries();
        const PODVector<Vector3>& geometryCenters = model->GetGeometryCenters();
        const Matrix3x4* worldTransform = node_ ? &node_->GetWorldTransform() : (const Matrix3x4*)0;
        for (unsigned i = 0; i < geometries.Size(); ++i)
        {
            batches_[i].worldTransform_ = worldTransform;
            geometries_[i] = geometries[i];
            geometryData_[i].center_ = geometryCenters[i];

            // ATOMIC BEGIN
            geometryData_[i].enabled_ = true;
            geometryData_[i].batchGeometry_ = 0;
            // ATOMIC END

        }

        SetBoundingBox(model->GetBoundingBox());
        ResetLodLevels();
    }
    else
    {
        SetNumGeometries(0);
        SetBoundingBox(BoundingBox());
    }

    MarkNetworkUpdate();
}
Beispiel #2
0
void Node::SetSize(const Size &size)
{
	//if (_Size == size) return;

	_Size = size;
	SetBoundingBox();
}
Beispiel #3
0
void Node::SetScaleY(float scaleY)
{
	//if (_Scale.y == scaleY) return;

	_Scale.y = scaleY;
	SetBoundingBox();
}
Beispiel #4
0
void Node::SetScaleX(float scaleX)
{
	//if (_Scale.x == scaleX) return;

	_Scale.x = scaleX;
	SetBoundingBox();
}
Beispiel #5
0
void Node::SetSizeWidth(float width)
{
	//if (_Size.width == width) return;

	_Size.width = width;
	SetBoundingBox();
}
Beispiel #6
0
void Node::SetScale(const Point &scale)
{
	//if (_Scale == scale) return;

	_Scale = scale;
	SetBoundingBox();
}
Beispiel #7
0
void Node::SetSizeHeight(float height)
{
	//if (_Size.height == height) return;

	_Size.height = height;
	SetBoundingBox();
}
EDA_RECT PL_EDITOR_LAYOUT::ComputeBoundingBox()
{
    EDA_RECT bbox;

    SetBoundingBox( bbox );
    return bbox;
}
Beispiel #9
0
void Node::SetScale(float scaleFactor)
{
	//if (_Scale.x == scaleFactor && _Scale.y == scaleFactor) return;

	_Scale.x = _Scale.y = scaleFactor;
	SetBoundingBox();
}
Beispiel #10
0
void Node::SetScale(float scaleWidth, float scaleHeight)
{
	//if (_Scale.x == scaleWidth && _Scale.y == scaleHeight) return;

	_Scale.x = scaleWidth;
	_Scale.y = scaleHeight;
	SetBoundingBox();
}
Beispiel #11
0
FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetTrimBox(FPDF_PAGE page,
                                                   float left,
                                                   float bottom,
                                                   float right,
                                                   float top) {
  SetBoundingBox(CPDFPageFromFPDFPage(page), pdfium::page_object::kTrimBox,
                 CFX_FloatRect(left, bottom, right, top));
}
Beispiel #12
0
void Node::SetSize(float width, float height)
{
	//if (_Size.width == width && _Size.height == height) return;

	_Size.width = width;
	_Size.height = height;
	SetBoundingBox();
}
Beispiel #13
0
void MapBlock::GenerateTerrain(ROSE::ZON* zon){
	BoundingBox tmp;

	Range<float> blockHeight(9999.0f, -9999.0f);

	mVertexBuffer = new VertexBuffer<V3F_UV0_UV1_UV2>();
	mVertexBuffer->SetSize(16*16*5*5);
	for(int ix = 0; ix < 16; ++ix){
		for(int iy = 0; iy < 16; ++iy){
			int idx = iy + ix*16;
			Range<float> patchHeight(9999.0f, -9999.0f);

			ROSE::ZON::Tile* tile = zon->GetTile(mTilemap->GetTile(ix, iy));
			mLayer1[idx] = zon->GetTexture(tile->mLayer1 + tile->mOffset1)->GetTextureID();
			mLayer2[idx] = zon->GetTexture(tile->mLayer2 + tile->mOffset2)->GetTextureID();

			for(int jy = 0; jy < 5; ++jy){
				for(int jx = 0; jx < 5; ++jx){
					int dx4 = ix * 4 + jx;
					int dy4 = iy * 4 + jy;

					V3F_UV0_UV1_UV2 vert;
					vert.pos.x = dx4 * 2.5f;
					vert.pos.y = -(dy4 * 2.5f);
					vert.pos.z = mHeightmap->GetHeight(dx4, dy4);

					vert.uv0.x = float(dx4) / 64.0f;
					vert.uv0.y = float(dy4) / 64.0f;
					vert.uv1.x = vert.uv2.x = float(jx) / 4.0f;
					vert.uv1.y = vert.uv2.y = float(jy) / 4.0f;

					tile->RotateUV(vert.uv2.x, vert.uv2.y);

					mVertexBuffer->AddVertex(&vert);

					blockHeight.AddValue(vert.pos.z);
					patchHeight.AddValue(vert.pos.z);
				}
			}


			BoundingBox bbox;
			bbox.mMin = Vector3(float(ix * 4) * 2.5f, -(float((iy * 4) + 4) * 2.5f), patchHeight.mMin);
			bbox.mMax = Vector3((float(ix * 4) + 4) * 2.5f, -(float(iy * 4) * 2.5f), patchHeight.mMax);

			BoundingBox bboxTransformed;
			bboxTransformed.AddTransformedBox(bbox, mTransform);

			mQuadTree.SetIdxBox(idx, bboxTransformed);
		}
	}

	mQuadTree.Calculate();

	tmp.AddPoint(Vector3(0.0f, -160.0f, blockHeight.mMin));
	tmp.AddPoint(Vector3(160.0f, 0.0f, blockHeight.mMax));
	SetBoundingBox(tmp);
}
Beispiel #14
0
void Node::RotateBy(float degree)
{
	_RotAngle += degree;
	if (_RotAngle > 360.f)
	{
		_RotAngle -= 360.0f;
	}
	SetBoundingBox();
}
Beispiel #15
0
void StaticModel::SetModel(Model* model)
{
    if (model == model_)
        return;

    if (!node_)
    {
        URHO3D_LOGERROR("Can not set model while model component is not attached to a scene node");
        return;
    }

    // Unsubscribe from the reload event of previous model (if any), then subscribe to the new
    if (model_)
        UnsubscribeFromEvent(model_, E_RELOADFINISHED);

    model_ = model;

    if (model)
    {
        SubscribeToEvent(model, E_RELOADFINISHED, URHO3D_HANDLER(StaticModel, HandleModelReloadFinished));

        // Copy the subgeometry & LOD level structure
        SetNumGeometries(model->GetNumGeometries());
        const ea::vector<ea::vector<ea::shared_ptr<Geometry> > >& geometries = model->GetGeometries();
        const ea::vector<Vector3>& geometryCenters = model->GetGeometryCenters();
        const Matrix3x4* worldTransform = node_ ? &node_->GetWorldTransform() : nullptr;
        for (unsigned i = 0; i < geometries.size(); ++i)
        {
            batches_[i].worldTransform_ = worldTransform;
            geometries_[i] = geometries[i];
            geometryData_[i].center_ = geometryCenters[i];
        }

        SetBoundingBox(model->GetBoundingBox());
        ResetLodLevels();
    }
    else
    {
        SetNumGeometries(0);
        SetBoundingBox(BoundingBox());
    }

    MarkNetworkUpdate();
}
Beispiel #16
0
void Node::SetAnchorPoint(const Point &pos)
{
	_Center = Point(pos.x * _Size.width, pos.y * _Size.height);

	//if (_AnchorPoint != pos)
	//{
		_AnchorPoint = pos;
		SetBoundingBox();
	//}
}
Beispiel #17
0
void Node::SetAnchorPoint(float anchorPos)
{
	_Center = Point(anchorPos * _Size.width, anchorPos * _Size.height);

	//if (_AnchorPoint.x != anchorPos && _AnchorPoint.y != anchorPos)
	//{
		_AnchorPoint.x = _AnchorPoint.y = anchorPos;
		SetBoundingBox();
	//}
}
Beispiel #18
0
void CScriptPlayerActor::SetupOnlineModelData() {
  if (x310_loadedCharIdx != x2e8_suitRes.GetCharacterNodeId() || !x64_modelData || !x64_modelData->HasAnimData()) {
    x2e8_suitRes.SetCharacterNodeId(x310_loadedCharIdx);
    SetModelData(std::make_unique<CModelData>(x2e8_suitRes));
    CAnimPlaybackParms parms(x2e8_suitRes.GetDefaultAnim(), -1, 1.f, true);
    x64_modelData->AnimationData()->SetAnimation(parms, false);
    if (x354_24_setBoundingBox)
      SetBoundingBox(x64_modelData->GetBounds(GetTransform().getRotation()));
  }
}
Beispiel #19
0
static void ComputeTurntableBoundingBox( track_p trk )
{
	struct extraData *xx = GetTrkExtraData(trk);
	coOrd hi, lo;
	hi.x = xx->pos.x+xx->radius;
	lo.x = xx->pos.x-xx->radius;
	hi.y = xx->pos.y+xx->radius;
	lo.y = xx->pos.y-xx->radius;
	SetBoundingBox( trk, hi, lo );
}
Beispiel #20
0
void Node::SetRotAngle(float degree)
{
	if (360.0f < degree)
		degree -= 360.0f;
	if (-360.0f > degree)
		degree += 360.0f;

	_RotAngle = degree;

	SetBoundingBox();
}
Beispiel #21
0
DLLEXPORT void STDCALL FPDFPage_SetCropBox(FPDF_PAGE page,
                                           float left,
                                           float bottom,
                                           float right,
                                           float top) {
  CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
  if (!pPage)
    return;

  SetBoundingBox(pPage, "CropBox", left, bottom, right, top);
}
Beispiel #22
0
static void con_geometry_define_point_cb(Fl_Widget *w, void *data)
{
  add_point(GModel::current()->getFileName(),
            FlGui::instance()->geoContext->input[2]->value(),
            FlGui::instance()->geoContext->input[3]->value(),
            FlGui::instance()->geoContext->input[4]->value(),
            FlGui::instance()->geoContext->input[5]->value());
  FlGui::instance()->resetVisibility();
  GModel::current()->setSelection(0);
  SetBoundingBox();
  drawContext::global()->draw();
}
Beispiel #23
0
void Node::SetAnchorPoint(float x, float y)
{
	_Center = Point(x * _Size.width, y * _Size.height);

	//if (_AnchorPoint.x != x && _AnchorPoint.y != y)
	//{

		_AnchorPoint.x = x;
		_AnchorPoint.y = y;
		SetBoundingBox();
	//}
}
VSectorVisibilityZone::VSectorVisibilityZone(VTerrainSector *pSector)
{
  m_pSector = pSector;
  m_pTerrain = pSector->GetSectorManager()->m_pTerrain;

//  m_pVisibilityInfo = NULL;

  SetZoneFlags(GetZoneFlags() | VIS_VISIBILITYZONEFLAGS_FALLBACKZONE | VIS_VISIBILITYZONEFLAGS_INFINITEHEIGHTFORASSIGNMENT);
  hkvAlignedBBox visBox(m_pSector->GetBoundingBox());
  visBox.m_vMax.z += m_pTerrain->m_Config.m_fVisibilityHeightOverTerrain;
  visBox.m_vMin.z -= m_pTerrain->m_Config.m_fVisibilityHeightOverTerrain;
  SetBoundingBox(visBox);
}
void VSectorVisibilityZone::Serialize( VArchive &ar )
{
  // version 6 does not save the connections to neighbor zones to avoid recursion
  // Note: when exporting the mobile replacement version of the terrain (one vmesh for each sector) the connection
  //       between neighbor zones must be serialized, because there is actually no terrain in the mobile exported version
  //       from which the neighbor zone information can be re-consturcted.
#if !defined(_VISION_MOBILE)
  if (ar.IsSaving() && !m_pTerrain->SectorManager().IsTerrainMeshExportInProgress())
    m_pSector->ConnectNeighborZones(false);
#endif

  VisVisibilityZone_cl::Serialize(ar);

  if (!(GetZoneFlags()&VIS_VISIBILITYZONEFLAGS_INFINITEHEIGHTFORASSIGNMENT))
  {
    SetZoneFlags(GetZoneFlags() | VIS_VISIBILITYZONEFLAGS_INFINITEHEIGHTFORASSIGNMENT);
    SetBoundingBox(m_BoundingBox);
  }
}
Beispiel #26
0
cSelectionBox::cSelectionBox(cResources* a_pResources)
   : cObject(a_pResources),
     m_pLeftArrowButton(NULL),
     m_pRightArrowButton(NULL),
     m_pTextBox(NULL),
     m_Options()
{
   SetType("SelectionBox");

   SetSolid(false);

   m_CurrentOption = m_Options.begin();

   // TextBox is created first so that it is under the buttons
   m_pTextBox = new cTextBox(GetResources());
   m_pLeftArrowButton = new cButton(GetResources());
   m_pLeftArrowButton->SetImage("Media/Title.ani", "ButtonLeft");
   m_pLeftArrowButton->SetPressedImage("Media/Title.ani", "ButtonLeftPressed");

   m_pRightArrowButton = new cButton(GetResources());
   m_pRightArrowButton->SetImage("Media/Title.ani", "ButtonRight");
   m_pRightArrowButton->SetPressedImage("Media/Title.ani", "ButtonRightPressed");

   SetBoundingBox(
      sf::Rect<int32_t>(
         0,
         0,
         m_pLeftArrowButton->GetBoundingBox().width + m_pTextBox->GetBoundingBox().width + m_pRightArrowButton->GetBoundingBox().width + 2,
         m_pTextBox->GetBoundingBox().height
         )
      );

   AddChild(m_pLeftArrowButton);
   AddChild(m_pRightArrowButton);
   AddChild(m_pTextBox);
}
Beispiel #27
0
	QuadObject::QuadObject(int min_x, int min_y, int max_x, int max_y)
	{
		SetBoundingBox(min_x, min_y, max_x, max_y);
		m_ParentNode = 0;
	}
Beispiel #28
0
void Mesh::SetBoundingBox(const Vector3& position, const Vector3& size)
{
	SetBoundingBox(BoundingBox(position, size));
}
Beispiel #29
0
Cube::Cube()
{
  Vector3<float> lowP(-1.1, -1.1, -1.1);
  Vector3<float> highP(1.1, 1.1, 1.1);
  SetBoundingBox(Bbox(lowP, highP));

  Matrix4x4<float> matrix;
  matrix(0,0) = 0.0;
  matrix(1,1) = 0.0;
  matrix(2,2) = 0.0;
  matrix(3,3) = 0.0;

  matrix(0,3) = 0.0;
  matrix(1,3) = 0.5;
  matrix(2,3) = 0.0;

  // Plane 1
  Quadric* q = new Quadric(matrix);
  q->Translate(0.0, 0.5, 0);
  q->SetBoundingBox(Bbox(lowP, highP));
  mPlanes.push_back(q);

  // Plane 2
  matrix(0,3) = 0.0;
  matrix(1,3) = -0.5;
  matrix(2,3) = 0.0;
  q = new Quadric(matrix);
  q->Translate(0.0, -0.5, 0);
  q->SetBoundingBox(Bbox(lowP, highP));
  mPlanes.push_back(q);

  // Plane 3
  matrix(0,3) = 0.5;
  matrix(1,3) = 0.0;
  matrix(2,3) = 0.0;
  q = new Quadric(matrix);
  q->Translate(0.5, 0.0, 0);
  q->SetBoundingBox(Bbox(lowP, highP));
  mPlanes.push_back(q);

  // Plane 4
  matrix(0,3) = -0.5;
  matrix(1,3) = 0.0;
  matrix(2,3) = 0.0;
  q = new Quadric(matrix);
  q->Translate(-0.5, 0, 0);
  q->SetBoundingBox(Bbox(lowP, highP));
  mPlanes.push_back(q);


  // Plane 5
  matrix(0,3) = 0.0;
  matrix(1,3) = 0.0;
  matrix(2,3) = 0.5;
  q = new Quadric(matrix);
  q->Translate(0.0, 0.0, 0.5);
  q->SetBoundingBox(Bbox(lowP, highP));
  mPlanes.push_back(q);

  // Plane 6
  matrix(0,3) = 0.0;
  matrix(1,3) = 0.0;
  matrix(2,3) = -0.5;
  q = new Quadric(matrix);
  q->Translate(0.0, 0, -0.5);
  q->SetBoundingBox(Bbox(lowP, highP));
  mPlanes.push_back(q);

}
PView *GMSH_LongituteLatitudePlugin::execute(PView *v)
{
  int iView = (int)LongituteLatitudeOptions_Number[0].def;

  PView *v1 = getView(iView, v);
  if(!v1) return v;
  PViewData *data1 = v1->getData();

  if(data1->isNodeData()){
    // tag all the nodes with "0" (the default tag)
    for(int step = 0; step < data1->getNumTimeSteps(); step++){
      for(int ent = 0; ent < data1->getNumEntities(step); ent++){
        for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){
          if(data1->skipElement(step, ent, ele)) continue;
          for(int nod = 0; nod < data1->getNumNodes(step, ent, ele); nod++)
            data1->tagNode(step, ent, ele, nod, 0);
        }
      }
    }
  }
  double gxmin = 180, gxmax = -180, gymin = 90, gymax = -90;
  // transform all "0" nodes
  for(int step = 0; step < data1->getNumTimeSteps(); step++){
    for(int ent = 0; ent < data1->getNumEntities(step); ent++){
      for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){
        if(data1->skipElement(step, ent, ele)) continue;
        int nbComp = data1->getNumComponents(step, ent, ele);
        double vin[3], vout[3];
        double xmin = M_PI, xmax = -M_PI;
        for(int nod = 0; nod < data1->getNumNodes(step, ent, ele); nod++){
          double x, y, z;
          int tag = data1->getNode(step, ent, ele, nod, x, y, z);
          if(data1->isNodeData() && tag) continue;
          double x2, y2, z2;
          z2 = sqrt(x * x + y * y + z * z);
          y2 = asin(z / z2);
          x2 = atan2(y, x);
          xmin=std::min(x2, xmin);
          xmax=std::max(x2, xmax);
          gxmin = std::min(x2 * 180 / M_PI, gxmin);
          gxmax = std::max(x2 * 180 / M_PI, gxmax);
          gymin = std::min(y2 * 180 / M_PI, gymin);
          gymax = std::max(y2 * 180 / M_PI, gymax);
          data1->setNode(step, ent, ele, nod, x2 * 180 / M_PI, y2 * 180 / M_PI, 0);
          if(data1->isNodeData()) data1->tagNode(step, ent, ele, nod, 1);
          if(nbComp == 3){
            for(int i = 0; i < 3; i++)
              data1->getValue(step, ent, ele, nod, i, vin[i]);
            vout[0] = -sin(x2) * vin[0] + cos(x2) * vin[1];
            vout[1] =
              -sin(y2) * (cos(x2) * vin[0] + sin(x2) * vin[1]) +
              cos(y2) * vin[2];
            vout[2] =
              cos(y2) * (cos(x2) * vin[0] + sin(x2) * vin[1]) +
              sin(y2) * vin[2];
            for(int i = 0; i < 3; i++)
              data1->setValue(step, ent, ele, nod, i, vout[i]);
          }
        }
        if(xmax - xmin > M_PI){ // periodicity check (broken for continuous views)
          for(int nod = 0; nod < data1->getNumNodes(step, ent, ele); nod++){
            double x, y, z;
            data1->getNode(step, ent, ele, nod, x, y, z);
            if(xmax * 180 / M_PI - x > 180) x += 360;
            data1->setNode(step, ent, ele, nod, x, y, z);
          }
        }
      }
    }
  }
  data1->destroyAdaptiveData();
  data1->finalize();
  SetBoundingBox();
  SBoundingBox3d bb(gxmin, gymin, 0, gxmax, gymax, 0);
  data1->setBoundingBox(bb);
  v1->setChanged(true);
  return v1;
}