コード例 #1
0
 void Label::Draw()
 {
     //If this assert is hit, it means there isn't a Shader set
     assert(m_Shader != nullptr);
 
     //Is the render target null
     if(m_RenderTarget != nullptr)
     {
         //Draw the render target
         m_RenderTarget->GetTextureFrame()->Draw(m_ModelMatrix);
     }
     else
     {
         //Draw the text with out the render target
         DrawText();
     }
     
     //Draw a debug label rect
     #if DRAW_LABEL_RECT
     Rect rect(GetWorldPosition().x, GetWorldPosition().y, GetWidth(), GetHeight());
     rect.SetIsFilled(false);
     rect.SetColor(DRAW_LABEL_RECT_COLOR);
     rect.SetAnchorPoint(GetAnchorPoint());
     rect.SetLocalAngle(GetWorldAngle());
     rect.SetLocalScale(GetWorldScale());
     rect.Draw();
     #endif
     
     //Draw the GameObject, which draws all the children
     GameObject::Draw();
 }
コード例 #2
0
ファイル: Light2DPoint.cpp プロジェクト: ArchyInf/HPL1Engine
	bool cLight2DPoint::UpdateBoundingBox()
	{
		mBoundingBox = cRect2f(cVector2f(GetWorldPosition().x,GetWorldPosition().y)-mfFarAttenuation,
				cVector2f(mfFarAttenuation*2));

		return true;
	}
コード例 #3
0
ファイル: ship.cpp プロジェクト: markettwp/Epiar
/**\brief Update function on every frame.
 */
void Ship::Update( lua_State *L ) {
	Sprite::Update( L ); // update momentum and other generic sprite attributes
	
	if( status.isAccelerating == false 
		&& status.isRotatingLeft == false
		&& status.isRotatingRight == false) {
		flareAnimation->Reset();
	}
	flareAnimation->Update();
	Coordinate momentum	= GetMomentum();
	momentum.EnforceMagnitude( shipStats.GetMaxSpeed()*engineBooster );
	// Show the hits taken as part of the radar color
	if(IsDisabled()) SetRadarColor( GREY );
	else SetRadarColor( RED * GetHullIntegrityPct() );
	
	// Ship has taken as much damage as possible...
	// It Explodes!
	if( status.hullDamage >=  (float)shipStats.GetHullStrength() ) {
		SpriteManager *sprites = Simulation_Lua::GetSimulation(L)->GetSpriteManager();
		Camera* camera = Simulation_Lua::GetSimulation(L)->GetCamera();

		// Play explode sound
		if(OPTION(int, "options/sound/explosions")) {
			Sound *explodesnd = Sound::Get("Resources/Audio/Effects/18384__inferno__largex.wav.ogg");
			explodesnd->Play( GetWorldPosition() - camera->GetFocusCoordinate());
		}

		// Create Explosion
		sprites->Add( new Effect( GetWorldPosition(), "Resources/Animations/explosion1.ani", 0) );

		// Remove this Sprite from the SpriteManager
		sprites->Delete( (Sprite*)this );
	}
コード例 #4
0
ファイル: UIObject.cpp プロジェクト: AlanWills/SpinOut_Source
//-----------------------------------------------------------------------------------------------------------------------------------
void UIObject::CheckVisible()
{
  if (GetType() == kScreen)
  {
    // If we have a screen UIObject we do not care about using it's collider to update visibility
    return;
  }

  if (GetShouldHaveCollider())
  {
    Vector2 worldPos;

    if (m_type == kScreen)
    {
      worldPos = GetWorldPosition();
    }
    else
    {
      // Translate into screen space
      worldPos = ScreenManager::GetCamera().GameToScreenCoords(GetWorldPosition());
    }

    SetVisible(ScreenManager::GetCamera().GetBoundingFrame().Contains(worldPos) != ContainmentType::DISJOINT);

    if (!IsVisible())
    {
      const Vector2& screenDimensions = ScreenManager::GetScreenDimensions();
      const Vector2& size = GetSize();

      if (size.x > screenDimensions.x || size.y > screenDimensions.y)
      {
        // If we have a really big object just set it's visibility to true for now - improves stability
        SetVisible(true);
        return;
      }

      float halfMaxDimensions = max(size.x, size.y) * 0.5f;

      if (worldPos.x <= 0)
      {
        worldPos.x += halfMaxDimensions;
      }
      else if (worldPos.x >= screenDimensions.x)
      {
        worldPos.x -= halfMaxDimensions;
      }

      if (worldPos.y <= 0)
      {
        worldPos.y += halfMaxDimensions;
      }
      else if (worldPos.y >= screenDimensions.y)
      {
        worldPos.y -= halfMaxDimensions;
      }

      SetVisible(ScreenManager::GetCamera().GetBoundingFrame().Contains(worldPos) != ContainmentType::DISJOINT);
    }
  }
}
コード例 #5
0
//-----------------------------------------------------------------------------
//  SetWorldPosition
//-----------------------------------------------------------------------------
//!!
void CPhysicObj::SetWorldPosition (const NxVec3 &vPos)
{
	NxVec3 displ = vPos - GetWorldPosition();
	for (int i=0; i<GetNumParts(); i++) {
		SetWorldPosition(i, GetWorldPosition(i) + displ);
	}
}
コード例 #6
0
ファイル: Area2D.cpp プロジェクト: Naddiseo/HPL1Engine
	bool cArea2D::UpdateBoundingBox()
	{
		mBoundingBox = cRect2f(cVector2f(GetWorldPosition().x-mvSize.x/2,
			GetWorldPosition().y-mvSize.y/2),mvSize);

		return true;
	}
コード例 #7
0
	void cPhysicsBodyNewton::AddImpulse(const cVector3f &a_vImpulse)
	{
		cVector3f vMassCentre = GetMassCentre();
		if (vMassCentre != cVector3f(0,0,0))
		{
			cVector3f vCentreOffset = cMath::MatrixMul(GetWorldMatrix().GetRotation(), vMassCentre);

			cVector3f vWorldPosition = GetWorldPosition() + vCentreOffset;
			NewtonBodyAddImpulse(m_pNewtonBody, a_vImpulse.v, vWorldPosition.v);
		}
		else
			NewtonBodyAddImpulse(m_pNewtonBody, a_vImpulse.v, GetWorldPosition().v);
	}
コード例 #8
0
//-----------------------------------------------------------------------------
//  GetWorldPosition
//-----------------------------------------------------------------------------
NxVec3  CPhysicObj::GetWorldPosition (void) const
{
    assert( m_bActivated );

    int     nNumParts = GetNumParts();
    // NOTA: Siempre tendremos que tener al menos 1 parte. 
    NxVec3  vResult = GetWorldPosition( 0 );
    // El resto de posiciones las agregamos
    for (int i = 1; i < nNumParts; i++)
    {
        vResult += GetWorldPosition( i );
    }

    return vResult / float(nNumParts);
}
コード例 #9
0
ファイル: Player.cpp プロジェクト: RedSray/JRPG
void Player::InitMovement()
{
	moveGoal = GetWorldPosition();
	moveGoal.x = (int)moveGoal.x;
	moveGoal.y = (int)moveGoal.y;
	worldPosition = moveGoal;
}
コード例 #10
0
//======================================================================
void TMComposer::LookAt(Point3f target,Vec3f up)
{	
	Point3f source = GetWorldPosition();
	Vec3f look = source - target; // target - source;
	normalize(look);

	Vec3f right = cross(look,up);
	normalize(right);

	Vec3f up_vec = cross(right,look);
	normalize(up_vec);

	m_local_tm[0][0] = right[0];
	m_local_tm[1][0] = right[1];
	m_local_tm[2][0] = right[2];
	m_local_tm[3][0] = 0.f;

	m_local_tm[0][1] = up_vec[0];
	m_local_tm[1][1] = up_vec[1];
	m_local_tm[2][1] = up_vec[2];
	m_local_tm[3][1] = 0.f;

	m_local_tm[0][2] = -look[0];
	m_local_tm[1][2] = -look[1];
	m_local_tm[2][2] = -look[2];
	m_local_tm[3][2] = 0.f;

	m_local_tm[0][3] = source[0];
	m_local_tm[1][3] = source[1];
	m_local_tm[2][3] = source[2];
	m_local_tm[3][3] = 1.f;
}
コード例 #11
0
ファイル: GameObject.cpp プロジェクト: AlanWills/SpinOut
//-----------------------------------------------------------------------------------------------------------------------------------
bool GameObject::CheckCollisionWithObjects(const std::list<GameObject*>& collisionObjects)
{
  if (!GetCollider() || m_noCollisions)
  {
    return false;
  }

  for (GameObject* gameObject : collisionObjects)
  {
    if (gameObject == this)
    {
      continue;
    }

    // Check distance away from object before doing proper collision detection
    if (Vector2::DistanceSquared(GetWorldPosition(), gameObject->GetWorldPosition()) >= (GetSize() * 0.5f).LengthSquared() + (gameObject->GetSize() * 0.5f).LengthSquared())
    {
      continue;
    }

    if (GetCollider()->CheckCollisionWith(gameObject->GetCollider()))
    {
      OnCollision();

      return true;
    }
  }

  return false;
}
コード例 #12
0
ファイル: WHDoor.cpp プロジェクト: uberpixel/The-White-House
	void Door::Update(float delta)
	{
		if(!_active && _counter < 1.0f)
		{
			Player *player = Player::GetSharedInstance();
			
			if(player->GetWorldPosition().GetDistance(GetWorldPosition() - GetForward()) <= 1.0f)
			{
				_active = true;
			}
		}
		else
		{
			Rotate(RN::Vector3(delta*70.0f, 0.0f, 0.0f));
			_counter += delta;
		}
		
		if(_counter > 1.0f && _active)
		{
			_active = false;
			RN::Kernel::GetSharedInstance()->ScheduleFunction([](){
				World *world = static_cast<World*>(RN::World::GetActiveWorld());
				world->SetLevel(world->GetLevel() + 1);
				world->DropSceneNodes();
				world->LoadOnThread(RN::Thread::GetCurrentThread(), nullptr);
			});
		}
	}
コード例 #13
0
ファイル: LetterChooser.cpp プロジェクト: kristofe/GameEngine
void LetterChooser::GridLayout()
{
	std::vector<IvAABB> blockedAreas;
	mGameLogic->GetBlockedDropletAreas(blockedAreas);
	
	mPositionList.clear();
	//float w = mGame.GetRenderer().GetWindowWidth();
	//float h = mGame.GetRenderer().GetWindowHeight();
	float x,y;
	x = mDisplayMin.x;
	y = mDisplayMin.y;

	int lettersPerRow = mSourceLetters.size()/mRows;
	IvVector2 dim = mDisplayMax - mDisplayMin;
	int yIncrement = dim.y/mRows;
	int xIncrement = dim.x/lettersPerRow;

	IvVector3 origin;
	GetWorldPosition(origin);
	for(int i = 0; i < mSourceLetters.size(); ++i)
	{
		LetterButton* l = mSourceLetters[i];
		IvVector3 pos;
		pos.Set(x,y,origin.z);
		mPositionList.push_back(pos);
		mPositionDB[l->mChar] = pos;
		x += xIncrement;
		if(x >= mDisplayMax.x)
		{
			y += yIncrement;
			x = mDisplayMin.x;	
		}
	}
	
}
コード例 #14
0
ファイル: BillBoard.cpp プロジェクト: AugRob/Innsmouth-Engine
cMatrixf* cBillboard::GetModelMatrix(cCamera3D *apCamera)
{
    if(apCamera==NULL)return &GetWorldMatrix();

    m_mtxTempTransform = GetWorldMatrix();
    cVector3f vForward, vRight, vUp;

    cVector3f vCameraForward = apCamera->GetPosition() - GetWorldPosition();
    vCameraForward.Normalise();

    if(mType == eBillboardType_Point)
        {
            vForward = vCameraForward;
            vRight = cMath::Vector3Cross(apCamera->GetViewMatrix().GetUp(), vForward);
            vUp = cMath::Vector3Cross(vForward,vRight);
        }
    else if(mType == eBillboardType_Axis)
        {
            vUp = cMath::MatrixMul(GetWorldMatrix().GetRotation(),mvAxis);
            vUp.Normalise();

            if(vUp == vForward)
                {
                    vRight = cMath::Vector3Cross(vUp, vCameraForward);
                    Warning("Billboard Right vector is not correct! Contact programmer!\n");
                }
            else
                vRight = cMath::Vector3Cross(vUp, vCameraForward);

            vRight.Normalise();
            vForward = cMath::Vector3Cross(vRight, vUp);

            //vForward.Normalise();
            //vUp.Normalise();
        }

    if(mfForwardOffset!=0)
        {
            cVector3f vPos = m_mtxTempTransform.GetTranslation();
            vPos +=  vCameraForward * mfForwardOffset;
            m_mtxTempTransform.SetTranslation(vPos);
        }

    //Set right vector
    m_mtxTempTransform.m[0][0] = vRight.x;
    m_mtxTempTransform.m[1][0] = vRight.y;
    m_mtxTempTransform.m[2][0] = vRight.z;

    //Set up vector
    m_mtxTempTransform.m[0][1] = vUp.x;
    m_mtxTempTransform.m[1][1] = vUp.y;
    m_mtxTempTransform.m[2][1] = vUp.z;

    //Set forward vector
    m_mtxTempTransform.m[0][2] = vForward.x;
    m_mtxTempTransform.m[1][2] = vForward.y;
    m_mtxTempTransform.m[2][2] = vForward.z;

    return &m_mtxTempTransform;
}
コード例 #15
0
void EditLineWidget::Render()
{
	WidgetBase::Render();
	LabelWidget::Render();

	Vec2 worldPos = GetWorldPosition();
	float textOpacity = GetTextOpacity();

	RGBA cursorColor;
	GetPropertyForCurrentState("text color", cursorColor);
	cursorColor.a() = static_cast<unsigned char>(cursorColor.a() * textOpacity);

	float textScale;
	GetPropertyForCurrentState("text scale", textScale);

	double time;
	GetPropertyForCurrentState("blink time", time);

	if ((m_currentBlinkTimeSeconds >= time) && m_canType) {
		Vec2 cursorSize = Vec2(1.f, textScale * 5.f);
		if (m_cursorIndex == 0) {
			RenderBackground(worldPos, cursorSize, cursorColor);
		}
		else {
			std::string leftOfCursor = m_fullText.substr(m_leftmostCharacterIndex, m_cursorIndex - m_leftmostCharacterIndex);
			float cursorOffset = m_fontRenderer->CalcTextWidth(leftOfCursor, cursorSize.y());
			RenderBackground(Vec2(worldPos.x() + cursorOffset, worldPos.y()), cursorSize, cursorColor);
		}
	}
	if (m_currentBlinkTimeSeconds >= (time * 2)) {
		m_currentBlinkTimeSeconds = 0.0;
	}
}
コード例 #16
0
ファイル: SWArea.cpp プロジェクト: Slin/SteamedWorlds
	void Area::Update(float delta)
	{
		if(GetWorldPosition().GetDistance(Player::GetSharedInstance()->GetWorldPosition()) < _radius)
		{
			if(!_isTriggered)
			{
				Player::GetSharedInstance()->EnterArea(_type);
				_isTriggered = true;
			}
		}
		
		if(GetWorldPosition().GetDistance(Player::GetSharedInstance()->GetWorldPosition()) > _radius*2.0f)
		{
			_isTriggered = false;
		}
	}
コード例 #17
0
ファイル: Zone.cpp プロジェクト: aosyang/existproj
void Zone::Update(unsigned long deltaTime)
{
	//Vector3f p = Transform().GetPosition();
	//SetPosition(p + m_Wind * deltaTime * 0.01f);

	if (m_NeedUpdateOBB)
	{
		float draw_radius = m_Radius / 10.0f;

		float ymax = Math::Max(0.0f, m_Altitude / 100.0f);
		float ymin = Math::Min(0.0f, m_Altitude / 100.0f);
		m_OBB.localMin = Vector3f(-draw_radius, ymin, -draw_radius);
		m_OBB.localMax = Vector3f(draw_radius, ymax, draw_radius);

		m_NeedUpdateOBB = false;
	}

	GameObjectBase::Update(deltaTime);

	Vector3f pos = GetWorldPosition();
	pos += m_Movement * deltaTime * 0.001f;
	SetPosition(pos);

	// 消亡判定
	if (m_Radius<=0.0f)
	{
		ZoneManager::Instance().RemoveZone(this);
		m_Scene->RemoveObject(this);
	}
}
コード例 #18
0
    void Label::ResetModelMatrix()
    {
        //Translate the anchor, then translate the position
        mat4 anchor = translate(mat4(1.0f), vec3(-GetWidth() * GetWorldScale().x * GetAnchorPoint().x, -GetHeight() * GetWorldScale().y * GetAnchorPoint().y, 0.0f));
        mat4 viewTranslate = translate(anchor, vec3(GetWorldPosition().x, GetWorldPosition().y, 0.0f));

        //Calculate the rotation based on the anchor point
        mat4 halfTranslate1 = translate(viewTranslate, vec3(GetWidth() * GetWorldScale().x * GetAnchorPoint().x, GetHeight() * GetWorldScale().y * GetAnchorPoint().y, 0.0f));
        mat4 viewRotation = rotate(halfTranslate1, GetWorldAngle(), vec3(0.0f, 0.0f, 1.0f));
        mat4 halfTranslate2 = translate(viewRotation, vec3(-GetWidth() * GetWorldScale().x * GetAnchorPoint().x, -GetHeight() * GetWorldScale().y * GetAnchorPoint().y, 0.0f));
        
        //Lastly the scale
        m_ModelMatrix = scale(halfTranslate2, vec3(GetWorldScale().x, GetWorldScale().y, 0.0f));
        
        //Reset the model matrix
        GameObject::ResetModelMatrix();
    }
コード例 #19
0
ファイル: gate.cpp プロジェクト: ebos/Epiar
void Gate::SendRandomDistance(Sprite* ship) {
	float distance = float(rand()%GATE_RADIUS);
	Trig *trig = Trig::Instance();
	float angle = static_cast<float>(trig->DegToRad( GetAngle() ));
	Coordinate destination = GetWorldPosition() +
		   Coordinate( trig->GetCos( angle ) * distance,
					  -trig->GetSin( angle ) * distance );
	ship->SetWorldPosition( destination );
}
コード例 #20
0
Vec2 ButtonWidget::GetTextLowerLeft(const std::string& text, float cellSize)
{
	Vec2 size;
	GetPropertyForCurrentState("size", size);
	float textWidth = m_fontRenderer->CalcTextWidth(text, cellSize);

	Vec2 worldPos = GetWorldPosition() + (size / 2) - (Vec2(textWidth, cellSize) / 2);
	return worldPos;
}
コード例 #21
0
ファイル: SpotLight.cpp プロジェクト: hsb0818/SOC_Framework
		bool SpotLight::Intersect(Intersection::Sphere &sphere)
		{
			if(angle < 1)				angle = 1;
			else if(angle > 179)		angle = 179;

			Cone cone(angle, range, forward, GetWorldPosition());

			return cone.Intersection(sphere);
		}
コード例 #22
0
void ProgressBarWidget::Render()
{
	Vec2 worldPos = GetWorldPosition();
	float progress;

	Vec2 size;
	GetPropertyForCurrentState("size", size);

	float borderSize;
	GetPropertyForCurrentState("border size", borderSize);

	float opacity = GetOpacity();

	RGBA backgroundColor;
	RGBA innerColor;
	GetPropertyForCurrentState("color", backgroundColor);
	GetPropertyForCurrentState("inner color", innerColor);

	backgroundColor.a() *= static_cast<unsigned char>(backgroundColor.a() * opacity);
	innerColor.a() = static_cast<unsigned char>(innerColor.a() * opacity);


	RenderBackground(worldPos, size, backgroundColor);
	GetPropertyForCurrentState("progress", progress);

	CardinalDir dir;
	GetPropertyForCurrentState("direction", dir);
	switch (dir) {
	case C_DIRECTION_EAST:
		RenderBackground(worldPos, Vec2(size.x() * progress, size.y()), innerColor);
		break;
	case C_DIRECTION_WEST: {
		Vec2 fillSize = Vec2(size.x() * progress, size.y());
		Vec2 leftEnd = Vec2(worldPos.x() + size.x() - fillSize.x(), worldPos.y());
		RenderBackground(leftEnd, fillSize, innerColor);
		break;
	}
	case C_DIRECTION_SOUTH: {
		Vec2 fillSize = Vec2(size.x(), size.y()  * progress);
		Vec2 top = Vec2(worldPos.x(), worldPos.y() + size.y() - fillSize.y());
		RenderBackground(top, fillSize, innerColor);
		break;
	}
	case C_DIRECTION_NORTH:
		RenderBackground(worldPos, Vec2(size.x(), size.y()  * progress), innerColor);
		break;
	}

	RenderOutline(worldPos, size, borderSize);

	WidgetBase::ProcessRenderEvent();
	/*
	RenderBackground(worldPos + (size * 0.25f), size * 0.5f, innerColor);
	RenderOutline(worldPos, size, borderSize);
	*/
}
コード例 #23
0
    void Polygon::ResetModelMatrix()
    {
        //Local variables used below
        float left = 0.0f;
        float right = 0.0f;
        float bottom = 0.0f;
        float top = 0.0f;
    
        //Cycle through and set the left, right, bottom and top vars
        for(unsigned int i = 0; i < m_Vertices.size(); i++)
        {
            left = fminf(left, m_Vertices.at(i).x);
            right = fmaxf(right, m_Vertices.at(i).x);
            bottom = fminf(bottom, m_Vertices.at(i).y);
            top = fmaxf(top, m_Vertices.at(i).y);
        }
    
        //Set the width and height
        float width = right - left;
        float height = top - bottom;

        //Translate the anchor, then translate the position
        mat4 anchor = translate(mat4(1.0f), vec3(-width * GetWorldScale().x * GetAnchorPoint().x, -height * GetWorldScale().y * GetAnchorPoint().y, 0.0f));
        mat4 viewTranslate = translate(anchor, vec3(GetWorldPosition().x, GetWorldPosition().y, 0.0f));

        //Calculate the rotation based on the anchor point
        mat4 halfTranslate1 = translate(viewTranslate, vec3(width * GetWorldScale().x * GetAnchorPoint().x, height * GetWorldScale().y * GetAnchorPoint().y, 0.0f));
        
    #if DRAW_POLYGON_ANCHOR_POINT
        vec4 transformedVector = halfTranslate1 * vec4(0.0f, 0.0f, 0.0f, 1.0);
        m_AnchorLocation = vec2(transformedVector.x, transformedVector.y);
    #endif
        
        mat4 viewRotation = rotate(halfTranslate1, GetWorldAngle(), vec3(0.0f, 0.0f, 1.0f));
        mat4 halfTranslate2 = translate(viewRotation, vec3(-width * GetWorldScale().x * GetAnchorPoint().x, -height * GetWorldScale().y * GetAnchorPoint().y, 0.0f));
        
        //Lastly the scale
        m_ModelMatrix = scale(halfTranslate2, vec3(GetWorldScale().x, GetWorldScale().y, 0.0f));
        
        //Reset the model matrix
        GameObject::ResetModelMatrix();
    }
コード例 #24
0
	void SelectionImage::Update()
	{
		Entity::Update();

		Vector2 diff = Input::GetWorldMousePosition() - GetWorldPosition();//position - Graphics::GetScreenCenter();
		float mag = (1.0f-(diff.GetMagnitude()/256.0f)) * 1.0f;
		if (mag < 0.5f) mag = 0.5f;
		if (mag > 1.25f) mag = 1.25f;
		scale = Vector2::one * mag;
		printf("scale %f, %f\n", scale.x, scale.y);
	}
コード例 #25
0
ファイル: VDSSubsystem.cpp プロジェクト: ShadyEM/Twister3D
// this will compute the local matrices for all the geometries
// so they can be used later when rendering the bodies
// only the body matrices need to be computed at each frame
void sVDSBodyDescriptor::ComputeLocalMatrices()
{
    for ( unsigned int i = 0; i <m_Geoms.size(); i++ )
    {
        VDSGeom* pGeom = m_Geoms[ i ];
        TSRMatrix4 worldMatrix;
        pGeom->GetWorldMatrix( worldMatrix );
        pGeom->m_BodyToGeomTransform = worldMatrix;
        pGeom->m_BodyToGeomTransform.GetLoc() -= GetWorldPosition();
    }
}
コード例 #26
0
ファイル: RSBase3D.cpp プロジェクト: MagistrAVSH/node3d
bool RSBase3D::IsFog(rvector camera_pos,float r)
{
	rvector pos = GetWorldPosition();

	camera_pos.z = 0;
	pos.z = 0;

	pos = camera_pos - pos;

	if(pos.GetMagnitude() > r) return true;
	return false;
}
コード例 #27
0
ファイル: CGuiLight.cpp プロジェクト: KalDragon/urde
CLight CGuiLight::BuildLight() const
{
    CLight ret = CLight::BuildLocalAmbient(zeus::CVector3f::skZero, zeus::CColor::skBlack);

    switch (xf8_type)
    {
    case ELightType::Spot:
        ret = CLight::BuildSpot(GetWorldPosition(), x34_worldXF.m_basis[1], xbc_color, xfc_spotCutoff);
        break;
    case ELightType::Point:
        ret = CLight::BuildPoint(GetWorldPosition(), xbc_color);
        break;
    case ELightType::Directional:
        ret = CLight::BuildDirectional(x34_worldXF.m_basis[1], xbc_color);
        break;
    default: break;
    }

    ret.SetAttenuation(x100_distC, x104_distL, x108_distQ);
    ret.SetAngleAttenuation(x10c_angleC, x110_angleL, x114_angleQ);
    return ret;
}
コード例 #28
0
void Critter::Update(float delta)
{
    RN::Entity::Update(delta);

    if(_isFixedAndCantHaveChildren)
        return;

    if(GetWorldPosition().GetDistance(_target) >= 1.5f)
    {
        LookAt(_target);
        TranslateLocal(RN::Vector3(0.0f, 0.0f, -6.0f) * delta);
    }
}
コード例 #29
0
	//------------------------------------------------------------------------------------------------------
	SelectableRotatingRing::Selected SelectableRotatingRing::IsSelected( const Rayf& r )
	{
		aabbox3df local = m_BindBox;
		local.SetCenter( GetWorldPosition() );
		m_XBind.SetCenter( GetWorldPosition() );
		m_YBind.SetCenter( GetWorldPosition() );
		m_ZBind.SetCenter( GetWorldPosition() );
		if ( ( local ).Intersection( r ) )
		{
			std::map< float, SelectableRotatingRing::Selected > rm;
			vector3f point;
			if(( m_XBind ).IntersectPointWithRay( r, point ) ) rm.insert( std::make_pair( (point - r.GetRayOrigin()).LengthPow(), SR_BY_X_AXIS ) );
			if(( m_YBind ).IntersectPointWithRay( r, point ) ) rm.insert( std::make_pair( (point - r.GetRayOrigin()).LengthPow(), SR_BY_Y_AXIS ) );
			if(( m_ZBind ).IntersectPointWithRay( r, point ) ) rm.insert( std::make_pair( (point - r.GetRayOrigin()).LengthPow(), SR_BY_Z_AXIS ) );
			if ( rm.empty() )
			{
				return SR_NON;
			}
			return rm.begin()->second;
		}
		return SR_NON;
	}
コード例 #30
0
	cFrustum* cLight3DSpot::GetFrustum()
	{
		if(mlFrustumMatrixCount != GetTransformUpdateCount() || mbFrustumUpdated || mbProjectionUpdated)
		{
			mpFrustum->SetViewProjMatrix(	GetProjectionMatrix(),
											GetViewMatrix(),
											mfFarAttenuation,mfNearClipPlane,
											mfFOV,mfAspect,GetWorldPosition(),false);
			mbFrustumUpdated = false;
			mlFrustumMatrixCount = GetTransformUpdateCount();
		}

		return mpFrustum;
	}