Exemplo n.º 1
0
TAstNode::ValueReturned TAstNodeForSentence::Execute() const
{
	auto secondChild = m_firstChild->GetSibling();
	auto thirdChild = secondChild->GetSibling();

	auto firstValue = m_firstChild->Execute();
	auto sencondValue = secondChild->Execute();
	//auto thirdValue = thirdChild->Execute();

	auto scope = GetScope();
	auto name = m_firstChild->GetFirstChild()->GetToken()->Name();
	auto type = TVariateManager::GetInstance()->GetVariateSrollUp(scope, name)->GetType();

	UpdateValue(type, scope, name, firstValue.value);
	
	if (GetValue(type, scope, name)<sencondValue.value)
	{
		Context::interpreterContext.SetNextNode(thirdChild->GetSibling().get());
	}
	else
	{
		Context::interpreterContext.SetNextNode(FindNextValidNode());
	}

	return ValueReturned{ 0, SYMBOL_TYPE::TYPE_VOID };
}
Exemplo n.º 2
0
  void LightComponent::Update(float dt)
  {
    Transform* tr = (Transform*)GetSibling(CT_Transform);
    Graphics* gSys = (Graphics*) Engine::GetCore()->GetSystem(ST_Graphics);
    Vector3 curPos = tr->GetPosition();
    if(gSys->GetSceneConstants().rotate)
    {
      //have to update this shit because it says so.
      
      tr->SetPosition(RotateAround(Vector3(0.0f, 1.0f, 0.0f), dt / 10.0f, curPos));
    }


    curPos = tr->GetPosition();
    switch(light_type_)
    {
      case WickedSick::LightType::SpotLight:
        if(curPos != info_.spot.position)
        {
          Dirty();
          info_.spot.position = curPos;
        }
        break;
      case WickedSick::LightType::PointLight:
        if(curPos != info_.point.position)
        {
          Dirty();
          info_.point.position = curPos;
        }
        break;
      default:
        break;
    }
  }
Exemplo n.º 3
0
list<TimeThread*>::iterator PlayerManager::ReuniteThread(TimeThread *t)
{
    TimeThread *t1, *t2;
    list<TimeThread*>::iterator it;

    t1 = t;
    t2 = GetSibling(t1);

    if (!t2) {
        printf("FAILED TO FIND SIBLING OF TIMETHREAD\n");
        getchar();
        return _threads.end();
    }

    t = TimeThread::Reunite(t1, t2, _scene);
    _threads.push_back(t);

    if (_playThread == t1 || _playThread == t2) {
        _playThread = t;
    }

    it = EraseThread(t1);
    it = EraseThread(t2);
    delete t1;
    delete t2;

    return it;
}
Exemplo n.º 4
0
// special internal version
const CXmlItem* CXmlItem::FindItemEx(const CString& sItemName, const CString& sItemValue, BOOL bSearchChildren) const
{
	// check our name and value
	if (m_sName.CompareNoCase(sItemName) == 0 && m_sValue.Compare(sItemValue) == 0)
		return this;
	
	const CXmlItem* pFound = NULL;
	
	// search all our children
	if (bSearchChildren)
	{
		POSITION pos = GetFirstItemPos();
		
		while (pos && !pFound)
		{
			const CXmlItem* pXIChild = GetNextItem(pos);
			ASSERT (pXIChild);
			
			pFound = pXIChild->FindItemEx(sItemName, sItemValue, TRUE); // child will search its own siblings
		}
	}
	
	// then our siblings
	if (!pFound)
	{
		// only get first sibling as each sibling does its own
		const CXmlItem* pXISibling = GetSibling();
		
		if (pXISibling)
			pFound = pXISibling->FindItemEx(sItemName, sItemValue, TRUE);
	}
	
	return pFound;
}
Exemplo n.º 5
0
 PHYSICSDLL_API void OrbitComponent::Update(float dt)
 {
   if (targeting_)
   {
     Transform* tr = (Transform*)GetSibling(CT_Transform);
     Vector3 forceVec = current_dir_;
     Vector3 toTarget = target_ - tr->GetPosition();
     float bias = toTarget.Length() / target_dist_;
     forceVec += toTarget.GetNormalized() * bias;
     PhysicsComponent* pComp = (PhysicsComponent*)GetSibling(CT_PhysicsComponent);
     if (pComp)
     {
       pComp->GetRigidBody()->AddForce(forceVec);
       current_dir_ = pComp->GetRigidBody()->GetState().Velocity.GetNormalized();
       pComp->GetRigidBody()->GetState().Velocity = pComp->GetRigidBody()->GetState().Velocity.GetNormalized() * 2.0f;
     }
   }
 }
Exemplo n.º 6
0
BOOL CXmlItem::SetName(const CString& sName)
{
	// can't have any siblings
	if (!sName || !(*sName) || GetSibling())
		return FALSE;
	
	m_sName = sName;
	return TRUE;
}
Exemplo n.º 7
0
  void ModelComponent::Update(float dt)
  {
    Graphics* gSys = (Graphics*)Engine::GetCore()->GetSystem(ST_Graphics);
    gSys->AddDebugModel(this);

    Input* input = (Input*) Engine::GetCore()->GetSystem(ST_Input);
    InputHandler* handler = input->GetHandler();
    Transform* tr = (Transform*)GetSibling(CT_Transform);
    PhysicsComponent* phys = (PhysicsComponent*) GetSibling(CT_PhysicsComponent);
    if(handler->Check("MoveRight"))
    {
      tr->SetPosition(tr->GetPosition() + Vector3(1.0f,0.0f,0.0f) * dt);
      phys->Reset();
    }
    Model* newModel = gSys->GetModel(model_);
    if(newModel && base_ != newModel)
    {
      base_->RemoveInstance(this);
      base_ = newModel;
      base_->AddInstance(this);
    }


  }
Exemplo n.º 8
0
void TAstNodeForSentence::ParseSemantic() const
{
	auto type1 = TAstNodeOperator::GetSymbolType(m_firstChild->GetFirstChild()->GetSibling());
	auto type2 = TAstNodeOperator::GetSymbolType(m_firstChild->GetSibling());
	auto type3 = TAstNodeOperator::GetSymbolType(m_firstChild->GetSibling()->GetSibling());

	if ((type1 != SYMBOL_TYPE::TYPE_INTERGER && type1 != SYMBOL_TYPE::TYPE_DOUBLE)
		|| (type2 != SYMBOL_TYPE::TYPE_INTERGER && type2 != SYMBOL_TYPE::TYPE_DOUBLE)
		|| (type3 != SYMBOL_TYPE::TYPE_INTERGER && type3 != SYMBOL_TYPE::TYPE_DOUBLE))
	{
		throw TInterpreterException(TInterpreterException::FOR_SENTENCE_SHOULD_USE_INTERGER_OR_DOUBLE, m_firstChild->GetToken()->LineNumber());
	}

	auto child = m_firstChild->GetSibling()->GetSibling()->GetSibling();
	while (child)
	{
		child->ParseSemantic();
		child = child->GetSibling();
	}
}
  GRAPHICSDLL_API void CameraController::Update(float dt)
  {
    Input* input = (Input*)Engine::GetCore()->GetSystem(ST_Input);
    InputHandler* handler = input->GetHandler();

    
    if (handler->Check("Rotate"))
    {
      if(last_mouse_pos_ == Vector2i(-1, -1))
      {
        last_mouse_pos_ = handler->GetMousePos();
      }
      else if(handler->GetMousePos() != last_mouse_pos_)
      {
        Vector2i curPos = handler->GetMousePos();
        Vector2 amountToRotate = (curPos - last_mouse_pos_).to_f() * dt;
        CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
        Vector3 lookAt = cameraComp->GetLookAt();
        Transform* tr = (Transform*)GetSibling(CT_Transform);
        Vector3 view = lookAt - tr->GetPosition();
        view.Normalize();
        
        
        view = RotateAround(Vector3(0, 1, 0), amountToRotate.x, view);
        view.Normalize();
        Vector3 right = Vector3(0,1,0).Cross(view);
        right.Normalize();
        view = RotateAround(right, amountToRotate.y, view);

        
        lookAt = (tr->GetPosition() + view);


        cameraComp->SetLookAt(lookAt);
        last_mouse_pos_ = Vector2i(-1, -1);
      }
    }
    else if(handler->Check("Move"))
    {
      if (last_mouse_pos_ == Vector2i(-1, -1))
      {
        last_mouse_pos_ = handler->GetMousePos();
      }
      else if (handler->GetMousePos() != last_mouse_pos_)
      {
        Vector2i curPos = handler->GetMousePos();
        Vector2 amountToMove = (curPos - last_mouse_pos_).to_f() * dt;
        CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
        Vector3 lookAt = cameraComp->GetLookAt();
        Transform* tr = (Transform*)GetSibling(CT_Transform);

        Vector3 view = lookAt - tr->GetPosition();
        view.Normalize();
        Vector3 right = Vector3(0.0f,1.0f,0.0f).Cross(view);
        right.Normalize();
        Vector3 up = view.Cross(right);
        up.Normalize();

        Vector3 pos = tr->GetPosition();
        amountToMove *= 5.0f;
        pos += right * -amountToMove.x;
        pos += up * amountToMove.y;

        lookAt += right * -amountToMove.x;
        lookAt += up * amountToMove.y;
        tr->SetPosition(pos);
        cameraComp->SetLookAt(lookAt);

        last_mouse_pos_ = Vector2i(-1, -1);
      }
    }
    else if (handler->Check("ZoomIn"))
    {
      CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
      Vector3 lookAt = cameraComp->GetLookAt();
      Transform* tr = (Transform*)GetSibling(CT_Transform);
      Vector3 view = lookAt - tr->GetPosition();
      view.Normalize();
      view *= dt;
      tr->SetPosition(tr->GetPosition() += view );
      cameraComp->SetLookAt(lookAt += view );
      
    }
    else if (handler->Check("ZoomOut"))
    {
      CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
      Vector3 lookAt = cameraComp->GetLookAt();
      Transform* tr = (Transform*)GetSibling(CT_Transform);
      Vector3 view = lookAt - tr->GetPosition();
      view.Normalize();
      view *= dt;
      tr->SetPosition(tr->GetPosition() -= view);
      cameraComp->SetLookAt(lookAt -= view);

    }
    else if (handler->GetScrollPos())
    {
      CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
      Vector3 lookAt = cameraComp->GetLookAt();
      Transform* tr = (Transform*)GetSibling(CT_Transform);
      Vector3 view = lookAt - tr->GetPosition();
      view.Normalize();
      view *= dt;
      tr->SetPosition(tr->GetPosition() + view * (float)handler->GetScrollPos());
      cameraComp->SetLookAt(lookAt + view * (float)handler->GetScrollPos());

    }
    else
    {
      last_mouse_pos_ = Vector2i(-1, -1);
    }

    
  }
Exemplo n.º 10
0
void
DwarfDie::AdvanceToSibling()
{
	*this = GetSibling();
}
Exemplo n.º 11
0
 Vector3 CameraComponent::GetRotation()
 {
   Transform* tr = static_cast<Transform*>(GetSibling(CT_Transform));
   return tr->GetRotation();
 }
Exemplo n.º 12
0
 void CameraComponent::SetRotation(const Vector3 & rot)
 {
   Transform* tr = static_cast<Transform*>(GetSibling(CT_Transform));
   tr->SetRotation(rot);
   //rotation_ = rot;
 }
Exemplo n.º 13
0
  std::vector<Vertex> ModelComponent::GetDebugVerts()
  {

    Graphics* gSys = (Graphics*)Engine::GetCore()->GetSystem(ST_Graphics);
    Matrix4 modelToWorld;
    Camera* camera = gSys->GetCamera();
    Transform* tr = (Transform*) GetSibling(CT_Transform);

    std::vector<Vertex> endVerts;
    switch(draw_type_)
    {
      case DrawType::VertexNormals:
      {
        std::vector<Vertex> verts = base_->GetVerts();
        Vertex newVert;
        endVerts.reserve(verts.size() * 2);
        for(auto it = verts.begin(); it != verts.end(); ++it)
        {
          endVerts.push_back(*it);
          newVert.normal = it->normal;
          newVert.position = it->position;
          newVert.position.x += (1.0f / tr->GetScale().x) * newVert.normal.x * 0.5f;
          newVert.position.y += (1.0f / tr->GetScale().y) * newVert.normal.y * 0.5f;
          newVert.position.z += (1.0f / tr->GetScale().z) * newVert.normal.z * 0.5f;
          endVerts.push_back(newVert);
          //it = verts.insert(it, newVert);
        }

        break;
      }
      case DrawType::FaceNormals:
      {
        std::vector<Vertex> verts = base_->GetVerts();
        Vertex newVert;
        //std::vector<Face> faces = base_->GetFaces();
        //endVerts.reserve(faces.size() * 2);
        //Vector3 v0v1;
        //Vector3 v0v2;
        //for(auto it = faces.begin(); it != faces.end(); ++it)
        //{
        //  newVert.position =  (verts[it->indices[0]].position + 
        //                       verts[it->indices[1]].position +
        //                       verts[it->indices[2]].position) * (1.0f / 3.0f);
        //  
        //
        //  v0v1 = (verts[it->indices[1]].position - verts[it->indices[0]].position).GetNormalized();
        //  v0v2 = (verts[it->indices[2]].position - verts[it->indices[0]].position).GetNormalized();
        //  newVert.normal =  v0v1.Cross(v0v2);
        //  endVerts.push_back(newVert);
        //  newVert.position.x += (1.0f/tr->GetScale().x) * newVert.normal.x * 0.5f;
        //  newVert.position.y += (1.0f/tr->GetScale().y) * newVert.normal.y * 0.5f;
        //  newVert.position.z += (1.0f/tr->GetScale().z) * newVert.normal.z * 0.5f;
        //  endVerts.push_back(newVert);
        //}

        
        break;
      }
      case DrawType::Wireframe:
      {
        break;
      }
      case DrawType::Default:
      default:
        return std::vector<Vertex>();
        break;
    }
    return endVerts;
  }