Ejemplo n.º 1
0
void UModel::PostLoad()
{
	Super::PostLoad();
	
	if( FApp::CanEverRender() && !HasAnyFlags(RF_ClassDefaultObject) )
	{
		UpdateVertices();
	}

	// If in the editor, initialize each surface to hidden or not depending upon
	// whether the poly flag dictates being hidden at editor startup or not
	if ( GIsEditor )
	{
		for ( TArray<FBspSurf>::TIterator SurfIter( Surfs ); SurfIter; ++SurfIter )
		{
			FBspSurf& CurSurf = *SurfIter;
			CurSurf.bHiddenEdTemporary = ( ( CurSurf.PolyFlags & PF_HiddenEd ) != 0 );
			CurSurf.bHiddenEdLevel = 0;
		}

#if WITH_EDITOR
		if (ABrush* Owner = Cast<ABrush>(GetOuter()))
		{
			OwnerLocationWhenLastBuilt = Owner->GetActorLocation();
			OwnerPrepivotWhenLastBuilt = Owner->GetPrePivot();
			OwnerScaleWhenLastBuilt = Owner->GetActorScale();
			OwnerRotationWhenLastBuilt = -Owner->GetActorRotation();
			bCachedOwnerTransformValid = true;
		}
#endif
	}
}
Ejemplo n.º 2
0
void UIDirect3D9Window::DrawTexture(D3D9Texture *Texture, QRectF *Dest, QSizeF *Size, bool &PositionChanged)
{
    static const float studiorange  = 219.0f / 255.0f;
    static const float studiooffset = 16.0f / 255.0f;

    if (!Texture || !Dest || !m_d3dDevice || !Size)
        return;

    SetBlend(true);

    if (PositionChanged || !Texture->m_verticesUpdated)
    {
        PositionChanged = false;
        UpdateVertices(Texture, Dest, Size);
    }

    // TODO some basic state tracking
    // TODO null pointer checks

    D3DXVECTOR4 color;
    color.x = m_transforms[m_currentTransformIndex].color;
    color.y = m_studioLevels ? studiorange : 1.0f;
    color.z = m_studioLevels ? studiooffset : 0.0f;
    color.w = m_transforms[m_currentTransformIndex].alpha;
    m_defaultShader->m_vertexConstants->SetMatrix(m_d3dDevice, "Projection", m_currentProjection);
    m_defaultShader->m_vertexConstants->SetMatrix(m_d3dDevice, "Transform", &m_transforms[m_currentTransformIndex].m);
    m_defaultShader->m_pixelConstants->SetVector(m_d3dDevice, "Color", &color);
    //uint index = m_defaultShader->m_pixelConstants->GetSamplerIndex("MySampler");
    m_d3dDevice->SetTexture(0, (LPDIRECT3DBASETEXTURE9)Texture->m_texture);
    m_d3dDevice->SetVertexShader(m_defaultShader->m_vertexShader);
    m_d3dDevice->SetPixelShader(m_defaultShader->m_pixelShader);
    m_d3dDevice->SetStreamSource(0, Texture->m_vertexBuffer, 0, 5 * sizeof(float));
    m_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 4);
}
///SS5の場合  SsPartのarrayIndexは、親子順(子は親より先にいない)と
///なっているためそのまま木構造を作らずUpdateを行う
void FSsAnimeDecoder::Update()
{
	int32 time = (int32)NowPlatTime;

	if(EffectUntreatedDeltaTime < 0.f)
	{
		ReloadEffects();
		EffectUntreatedDeltaTime = NowPlatTime;
	}

	int32 EffectUpdateTimes = (int32)EffectUntreatedDeltaTime;
	int32 EffectBaseTime = time - EffectUpdateTimes + 1;

	for(int i = 0; i < PartAnime.Num(); ++i)
	{
		FSsPart* part = PartAnime[i].Key;
		FSsPartAnime* anime = PartAnime[i].Value;

		if((part->Type == SsPartType::Effect) && (PartState[i].RefEffect))
		{
			// エフェクトは1フレーム単位でしか更新しない 
			// (1フレーム == 0.5フレームずつ2回更新) 
			if(0 == EffectUpdateTimes)
			{
				UpdateState(time, part, anime, &PartState[i]);
				UpdateMatrix(part, anime, &PartState[i]);
				PartState[i].RefEffect->Update(0.f);
			}
			else
			{
				for (int32 j = 0; j < (EffectUpdateTimes*2); ++j)
				{
					UpdateState(EffectBaseTime + j, part, anime, &PartState[i]);
					UpdateMatrix(part, anime, &PartState[i]);
					PartState[i].RefEffect->Update(
						PartState[i].RefEffect->GetFirstUpdated() ? .5f : 0.f
						);
				}
			}
		}
		else
		{
			UpdateState(time, part, anime, &PartState[i]);
			UpdateMatrix(part, anime, &PartState[i]);

			if (part->Type == SsPartType::Instance)
			{
				UpdateInstance(time, part, anime, &PartState[i]);
				UpdateVertices(part, anime, &PartState[i]);
			}
		}
	}
	EffectUntreatedDeltaTime -= EffectUpdateTimes;

	SortList.Sort();

}
Ejemplo n.º 4
0
void Drawable2D::OnWorldBoundingBoxUpdate()
{
    if (verticesDirty_)
    {
        UpdateVertices();

        boundingBox_.Clear();
        for (unsigned i = 0; i < vertices_.Size(); ++i)
            boundingBox_.Merge(vertices_[i].position_);
    }

    worldBoundingBox_ = boundingBox_.Transformed(node_->GetWorldTransform());
}
Ejemplo n.º 5
0
void UIDirect3D9Window::DrawTexture(D3D9Shader *Shader, D3D9Texture *Texture, QRectF *Dest, QSizeF *Size, bool &PositionChanged)
{
    if (!Shader || !Texture || !Dest || !m_d3dDevice || !Size)
        return;

    if (PositionChanged || !Texture->m_verticesUpdated)
    {
        PositionChanged = false;
        UpdateVertices(Texture, Dest, Size);
    }

    SetBlend(true);
    Shader->m_vertexConstants->SetMatrix(m_d3dDevice, "Projection", m_currentProjection);
    Shader->m_vertexConstants->SetMatrix(m_d3dDevice, "Transform", &m_transforms[m_currentTransformIndex].m);
    m_d3dDevice->SetTexture(0, (LPDIRECT3DBASETEXTURE9)Texture->m_texture);
    m_d3dDevice->SetVertexShader(Shader->m_vertexShader);
    m_d3dDevice->SetPixelShader(Shader->m_pixelShader);
    m_d3dDevice->SetStreamSource(0, Texture->m_vertexBuffer, 0, 5 * sizeof(float));
    m_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 4);
}
Ejemplo n.º 6
0
/*  Frustum implementation
//****************************************************************************/
void Frustum::FromCameraMatrix( const Mat4& cm )
{
    plLeft.a = cm.e03 + cm.e00;
    plLeft.b = cm.e13 + cm.e10;
    plLeft.c = cm.e23 + cm.e20;
    plLeft.d = cm.e33 + cm.e30;

    plRight.a = cm.e03 - cm.e00;
    plRight.b = cm.e13 - cm.e10;
    plRight.c = cm.e23 - cm.e20;
    plRight.d = cm.e33 - cm.e30;

    plBottom.a = cm.e03 + cm.e01;
    plBottom.b = cm.e13 + cm.e11;
    plBottom.c = cm.e23 + cm.e21;
    plBottom.d = cm.e33 + cm.e31;

    plTop.a = cm.e03 - cm.e01;
    plTop.b = cm.e13 - cm.e11;
    plTop.c = cm.e23 - cm.e21;
    plTop.d = cm.e33 - cm.e31;

    plNear.a = cm.e02;
    plNear.b = cm.e12;
    plNear.c = cm.e22;
    plNear.d = cm.e32;

    plFar.a = cm.e03 - cm.e02;
    plFar.b = cm.e13 - cm.e12;
    plFar.c = cm.e23 - cm.e22;
    plFar.d = cm.e33 - cm.e32;

    plLeft.Normalize();
    plRight.Normalize();
    plBottom.Normalize();
    plTop.Normalize();
    plNear.Normalize();
    plFar.Normalize();

    UpdateVertices();
} // Frustum::FromCameraMatrix
Ejemplo n.º 7
0
void UModel::PostLoad()
{
	Super::PostLoad();
	
	if( FApp::CanEverRender() && !HasAnyFlags(RF_ClassDefaultObject) )
	{
		UpdateVertices();
	}

	// If in the editor, initialize each surface to hidden or not depending upon
	// whether the poly flag dictates being hidden at editor startup or not
	if ( GIsEditor )
	{
		for ( TArray<FBspSurf>::TIterator SurfIter( Surfs ); SurfIter; ++SurfIter )
		{
			FBspSurf& CurSurf = *SurfIter;
			CurSurf.bHiddenEdTemporary = ( ( CurSurf.PolyFlags & PF_HiddenEd ) != 0 );
			CurSurf.bHiddenEdLevel = 0;
		}
	}
}
Ejemplo n.º 8
0
void Drawable2D::UpdateGeometry(const FrameInfo& frame)
{
    if (verticesDirty_)
        UpdateVertices();

    if (geometryDirty_ || vertexBuffer_->IsDataLost())
    {
        unsigned vertexCount = vertices_.Size() / 4 * 6;
        if (vertexCount)
        {
            vertexBuffer_->SetSize(vertexCount, MASK_VERTEX2D);
            Vertex2D* dest = reinterpret_cast<Vertex2D*>(vertexBuffer_->Lock(0, vertexCount, true));
            if (dest)
            {
                for (unsigned i = 0; i < vertices_.Size(); i += 4)
                {
                    dest[0] = vertices_[i + 0];
                    dest[1] = vertices_[i + 1];
                    dest[2] = vertices_[i + 2];

                    dest[3] = vertices_[i + 0];
                    dest[4] = vertices_[i + 2];
                    dest[5] = vertices_[i + 3];

                    dest += 6;
                }

                vertexBuffer_->Unlock();
            }
            else
                LOGERROR("Failed to lock vertex buffer");
        }
        geometry_->SetDrawRange(TRIANGLE_LIST, 0, 0, 0, vertexCount);

        vertexBuffer_->ClearDataLost();
        geometryDirty_ = false;
    }
}
Ejemplo n.º 9
0
HRESULT KModelSFXLineGrass::FrameMove()
{
	UpdateVertices();
	return S_OK;
}
Ejemplo n.º 10
0
void Rectangle::SetDepth(float depth_) {
    depth = depth_;
    UpdateVertices();
}
///現在の時間からパーツのアトリビュートの補間値を計算する
void	FSsAnimeDecoder::UpdateState( int nowTime , FSsPart* part , FSsPartAnime* anime , FSsPartState* state )
{
	//ステートの初期値を設定
	state->Init();
	state->InheritRates = part->InheritRates;
	if ( anime == 0 ){
		IdentityMatrix( state->Matrix );
		return ;
	}

	// 親の継承設定を引用する設定の場合、ここで参照先を親のものに変えておく。
	if (part->InheritType == SsInheritType::Parent)
	{
		if ( state->Parent )
		{
			state->InheritRates = state->Parent->InheritRates;
		}
	}

	bool	size_x_key_find = false;
	bool	size_y_key_find = false;

	state->IsVertexTransform = false;
	state->IsColorBlend = false;
	state->AlphaBlendType = part->AlphaBlendType;


	bool hidekey_find = false;

	if ( 0 < anime->Attributes.Num() )
	{
		for(int i = 0; i < anime->Attributes.Num(); ++i)
		{
			FSsAttribute* attr = &(anime->Attributes[i]);
			switch( attr->Tag )
			{
				case SsAttributeKind::Invalid:	///< 無効値。旧データからの変換時など
					break;
				case SsAttributeKind::Cell:		///< 参照セル
					{
						SsGetKeyValue( nowTime , attr , state->CellValue );
						state->NoCells = false;
					}
					break;
				case SsAttributeKind::Posx:		///< 位置.X
					SsGetKeyValue( nowTime , attr , state->Position.X );
					break;
				case SsAttributeKind::Posy:		///< 位置.Y
					SsGetKeyValue( nowTime , attr , state->Position.Y );
					break;
				case SsAttributeKind::Posz:		///< 位置.Z
					SsGetKeyValue( nowTime , attr , state->Position.Z );
					break;
				case SsAttributeKind::Rotx:		///< 回転.X
					SsGetKeyValue( nowTime , attr , state->Rotation.X );
					break;
				case SsAttributeKind::Roty:		///< 回転.Y
					SsGetKeyValue( nowTime , attr , state->Rotation.Y );
					break;
				case SsAttributeKind::Rotz:		///< 回転.Z
					SsGetKeyValue( nowTime , attr , state->Rotation.Z );
					break;
				case SsAttributeKind::Sclx:		///< スケール.X
					SsGetKeyValue( nowTime , attr , state->Scale.X );
					break;
				case SsAttributeKind::Scly:		///< スケール.Y
					SsGetKeyValue( nowTime , attr , state->Scale.Y );
					break;
				case SsAttributeKind::Alpha:	///< 不透明度
					SsGetKeyValue( nowTime , attr , state->Alpha );
					break;
				case SsAttributeKind::Prio:		///< 優先度
					SsGetKeyValue( nowTime , attr , state->Prio );
					break;
				case SsAttributeKind::Fliph:	///< 左右反転(セルの原点を軸にする)
					SsGetKeyValue( nowTime , attr , state->HFlip );
					break;
				case SsAttributeKind::Flipv:	///< 上下反転(セルの原点を軸にする)
					SsGetKeyValue( nowTime , attr , state->VFlip );
					break;
				case SsAttributeKind::Hide:		///< 非表示
					{
						int useTime = SsGetKeyValue( nowTime , attr , state->Hide );
						// 非表示キーがないか、先頭の非表示キーより手前の場合は常に非表示にする。
						if ( useTime > nowTime )
						{
							state->Hide = true;
						}
						// 非表示キーがあり、かつ最初のキーフレームを取得した
						else
						{
							hidekey_find = true;
						}
					}
					break;
				case SsAttributeKind::Color:	///< カラーブレンド
					SsGetKeyValue( nowTime , attr , state->ColorValue );
					state->IsColorBlend = true;
					break;
				case SsAttributeKind::Vertex:	///< 頂点変形
					SsGetKeyValue( nowTime , attr , state->VertexValue );
					state->IsVertexTransform = true;
					break;
				case SsAttributeKind::Pivotx:	///< 原点オフセット.X
					SsGetKeyValue( nowTime , attr , state->PivotOffset.X );
					break;
				case SsAttributeKind::Pivoty:	///< 原点オフセット.Y
					SsGetKeyValue( nowTime , attr , state->PivotOffset.Y );
					break;
				case SsAttributeKind::Anchorx:	///< アンカーポイント.X
					SsGetKeyValue( nowTime , attr , state->Anchor.X );
					break;
				case SsAttributeKind::Anchory:	///< アンカーポイント.Y
					SsGetKeyValue( nowTime , attr , state->Anchor.Y );
					break;
				case SsAttributeKind::Sizex:	///< 表示サイズ.X
					SsGetKeyValue( nowTime , attr , state->Size.X );
					size_x_key_find = true;
					break;
				case SsAttributeKind::Sizey:	///< 表示サイズ.Y
					SsGetKeyValue( nowTime , attr , state->Size.Y );
					size_y_key_find = true;
					break;
				case SsAttributeKind::Imgfliph:	///< イメージ左右反転(常にイメージの中央を原点とする)
					SsGetKeyValue( nowTime , attr , state->ImageFlipH );
					break;
				case SsAttributeKind::Imgflipv:	///< イメージ上下反転(常にイメージの中央を原点とする)
					SsGetKeyValue( nowTime , attr , state->ImageFlipV );
					break;
				case SsAttributeKind::Uvtx:		///< UVアニメ.移動.X
					SsGetKeyValue( nowTime , attr , state->UvTranslate.X );
					break;
				case SsAttributeKind::Uvty:		///< UVアニメ.移動.Y
					SsGetKeyValue( nowTime , attr , state->UvTranslate.Y );
					break;
				case SsAttributeKind::Uvrz:		///< UVアニメ.回転
					SsGetKeyValue( nowTime , attr , state->UvRotation );
					break;
				case SsAttributeKind::Uvsx:		///< UVアニメ.スケール.X
					SsGetKeyValue( nowTime , attr , state->UvScale.X );
					break;
				case SsAttributeKind::Uvsy:		///< UVアニメ.スケール.Y
					SsGetKeyValue( nowTime , attr , state->UvScale.Y );
					break;
				case SsAttributeKind::Boundr:	///< 当たり判定用の半径
					SsGetKeyValue(nowTime, attr, state->BoundingRadius);
					break;
				case SsAttributeKind::User:		///< Ver.4 互換ユーザーデータ
					break;
				case SsAttributeKind::Instance:	///インスタンスパラメータ
					SsGetKeyValue(nowTime, attr, state->InstanceValue);
					break;
			}
		}
	}



	// カラー値だけアニメが無いと設定されないので初期値を入れておく。
	// alpha はupdateで初期化されるのでOK
	// 当たり判定パーツ用のカラー。赤の半透明にする
	static const float sColorsForBoundsParts[] = {0.5f, 0.f, 0.f, 1.f};
	for (int i = 0; i < (4*4) ; ++i)
	{
		if (state->NoCells)
			state->Colors[i] = sColorsForBoundsParts[i & 3];
		else
			state->Colors[i] = 1.f;
	}

	// 継承
	if (state->Parent)
	{
		// α
		if (state->Inherits_(SsAttributeKind::Alpha))
		{
			state->Alpha *= state->Parent->Alpha;
		}

		// フリップの継承。継承ONだと親に対しての反転になる…ヤヤコシス
		if (state->Inherits_(SsAttributeKind::Fliph))
		{
			state->HFlip = state->Parent->HFlip ^ state->HFlip;
		}
		if (state->Inherits_(SsAttributeKind::Flipv))
		{
			state->VFlip = state->Parent->VFlip ^ state->VFlip;
		}

		// 引き継ぐ場合は親の値をそのまま引き継ぐ
		if (state->Inherits_(SsAttributeKind::Hide))
		{
			state->Hide = state->Parent->Hide;
		}
	}

	// 非表示キーがないか、先頭の非表示キーより手前の場合は常に非表示にする。(継承関係なし)
	if (!hidekey_find)
	{
		state->Hide = true;
	}

	// 頂点の設定
	if ( part->Type == SsPartType::Normal )
	{
		FSsCell * cell = state->CellValue.Cell;
		if (cell && anime)
		{
			//サイズアトリビュートが指定されていない場合、セルのサイズを設定する
			if ( !size_x_key_find ) state->Size.X = cell->Size.X;
			if ( !size_y_key_find ) state->Size.Y = cell->Size.Y;
		}
		UpdateVertices(part , anime , state);
	}

	if(part->Type == SsPartType::Effect)
	{
		bool reload = false;
		FSsEffectRenderer * effectRender = state->RefEffect;

		if(effectRender)
		{
			if(state->Hide)
			{
				if(effectRender->GetPlayStatus())
				{
					effectRender->Stop();
					effectRender->Reload();
				}
			}
			else
			{
				effectRender->SetSeed(GetRandomSeed());
				effectRender->SetLoop(false);
				effectRender->Play();
			}
		}
	}

}
Ejemplo n.º 12
0
void CSlideShowPic::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
{
  if (!m_pImage || !m_bIsLoaded || m_bIsFinished) return ;
  color_t alpha = m_alpha;
  if (m_iCounter <= m_transistionStart.length)
  { // do start transistion
    if (m_transistionStart.type == CROSSFADE)
    { // fade in at 1x speed
      alpha = (color_t)((float)m_iCounter / (float)m_transistionStart.length * 255.0f);
    }
    else if (m_transistionStart.type == FADEIN_FADEOUT)
    { // fade in at 2x speed, then keep solid
      alpha = (color_t)((float)m_iCounter / (float)m_transistionStart.length * 255.0f * 2);
      if (alpha > 255) alpha = 255;
    }
    else // m_transistionEffect == TRANSISTION_NONE
    {
      alpha = 0xFF; // opaque
    }
  }
  bool bPaused = m_bPause | (m_fZoomAmount != 1.0f);
  // check if we're doing a temporary effect (such as rotate + zoom)
  if (m_transistionTemp.type != TRANSISTION_NONE)
  {
    bPaused = true;
    if (m_iCounter >= m_transistionTemp.start)
    {
      if (m_iCounter >= m_transistionTemp.start + m_transistionTemp.length)
      { // we're finished this transistion
        if (m_transistionTemp.type == TRANSISTION_ZOOM)
        { // correct for any introduced inaccuracies.
          int i;
          for (i = 0; i < 10; i++)
          {
            if (fabs(m_fZoomAmount - zoomamount[i]) < 0.01*zoomamount[i])
            {
              m_fZoomAmount = zoomamount[i];
              break;
            }
          }
          m_bNoEffect = (m_fZoomAmount != 1.0f); // turn effect rendering back on.
        }
        m_transistionTemp.type = TRANSISTION_NONE;
      }
      else
      {
        if (m_transistionTemp.type == TRANSISTION_ROTATE)
          m_fAngle += m_fTransistionAngle;
        if (m_transistionTemp.type == TRANSISTION_ZOOM)
          m_fZoomAmount += m_fTransistionZoom;
      }
    }
  }
  // now just display
  if (!m_bNoEffect && !bPaused)
  {
    if (m_displayEffect == EFFECT_PANORAMA)
    {
      m_fPosX += m_fVelocityX;
      m_fPosY += m_fVelocityY;
    }
    else if (m_displayEffect == EFFECT_FLOAT)
    {
      m_fPosX += m_fVelocityX;
      m_fPosY += m_fVelocityY;
      float fMoveAmount = g_advancedSettings.m_slideshowPanAmount * m_iTotalFrames * 0.0001f;
      if (m_fPosX > fMoveAmount)
      {
        m_fPosX = fMoveAmount;
        m_fVelocityX = -m_fVelocityX;
      }
      if (m_fPosX < -fMoveAmount)
      {
        m_fPosX = -fMoveAmount;
        m_fVelocityX = -m_fVelocityX;
      }
      if (m_fPosY > fMoveAmount)
      {
        m_fPosY = fMoveAmount;
        m_fVelocityY = -m_fVelocityY;
      }
      if (m_fPosY < -fMoveAmount)
      {
        m_fPosY = -fMoveAmount;
        m_fVelocityY = -m_fVelocityY;
      }
    }
    else if (m_displayEffect == EFFECT_ZOOM)
    {
      m_fPosZ += m_fVelocityZ;
/*      if (m_fPosZ > 1.0f + 0.01f*CServiceBroker::GetSettings().GetInt("Slideshow.ZoomAmount"))
      {
        m_fPosZ = 1.0f + 0.01f * CServiceBroker::GetSettings().GetInt("Slideshow.ZoomAmount");
        m_fVelocityZ = -m_fVelocityZ;
      }
      if (m_fPosZ < 1.0f)
      {
        m_fPosZ = 1.0f;
        m_fVelocityZ = -m_fVelocityZ;
      }*/
    }
  }
  if (m_displayEffect != EFFECT_NO_TIMEOUT && bPaused && !m_bTransistionImmediately)
  { // paused - increment the last transistion start time
    m_transistionEnd.start++;
  }
  if (m_iCounter >= m_transistionEnd.start)
  { // do end transistion
//    CLog::Log(LOGDEBUG,"Transistioning");
    m_bDrawNextImage = true;
    if (m_transistionEnd.type == CROSSFADE)
    { // fade out at 1x speed
      alpha = 255 - (color_t)((float)(m_iCounter - m_transistionEnd.start) / (float)m_transistionEnd.length * 255.0f);
    }
    else if (m_transistionEnd.type == FADEIN_FADEOUT)
    { // keep solid, then fade out at 2x speed
      alpha = (color_t)((float)(m_transistionEnd.length - m_iCounter + m_transistionEnd.start) / (float)m_transistionEnd.length * 255.0f * 2);
      if (alpha > 255) alpha = 255;
    }
    else // m_transistionEffect == TRANSISTION_NONE
    {
      alpha = 0xFF; // opaque
    }
  }
  if (alpha != m_alpha)
  {
    m_alpha = alpha;
    m_bIsDirty = true;
  }
  if (m_displayEffect != EFFECT_NO_TIMEOUT || m_iCounter < m_transistionStart.length || m_iCounter >= m_transistionEnd.start || (m_iCounter >= m_transistionTemp.start && m_iCounter < m_transistionTemp.start + m_transistionTemp.length))
  {
    /* this really annoying.  there's non-stop logging when viewing a pic outside of the slideshow
    if (m_displayEffect == EFFECT_NO_TIMEOUT)
      CLog::Log(LOGDEBUG, "Incrementing counter (%i) while not in slideshow (startlength=%i,endstart=%i,endlength=%i)", m_iCounter, m_transistionStart.length, m_transistionEnd.start, m_transistionEnd.length);
    */
    m_iCounter++;
  }
  if (m_iCounter > m_transistionEnd.start + m_transistionEnd.length)
    m_bIsFinished = true;

  RESOLUTION_INFO info = g_graphicsContext.GetResInfo();

  // calculate where we should render (and how large it should be)
  // calculate aspect ratio correction factor
  float fOffsetX      = (float)info.Overscan.left;
  float fOffsetY      = (float)info.Overscan.top;
  float fScreenWidth  = (float)info.Overscan.right  - info.Overscan.left;
  float fScreenHeight = (float)info.Overscan.bottom - info.Overscan.top;
  float fPixelRatio   = info.fPixelRatio;

  // Rotate the image as needed
  float x[4];
  float y[4];
  float si = (float)sin(m_fAngle / 180.0f * M_PI);
  float co = (float)cos(m_fAngle / 180.0f * M_PI);
  x[0] = -m_fWidth * co + m_fHeight * si;
  y[0] = -m_fWidth * si - m_fHeight * co;
  x[1] = m_fWidth * co + m_fHeight * si;
  y[1] = m_fWidth * si - m_fHeight * co;
  x[2] = m_fWidth * co - m_fHeight * si;
  y[2] = m_fWidth * si + m_fHeight * co;
  x[3] = -m_fWidth * co - m_fHeight * si;
  y[3] = -m_fWidth * si + m_fHeight * co;

  // calculate our scale amounts
  float fSourceAR = m_fWidth / m_fHeight;
  float fSourceInvAR = 1 / fSourceAR;
  float fAR = si * si * (fSourceInvAR - fSourceAR) + fSourceAR;

  //float fOutputFrameAR = fAR / fPixelRatio;

  float fScaleNorm = fScreenWidth / m_fWidth;
  float fScaleInv = fScreenWidth / m_fHeight;

  bool bFillScreen = false;
  float fComp = 1.0f + 0.01f * g_advancedSettings.m_slideshowBlackBarCompensation;
  float fScreenRatio = fScreenWidth / fScreenHeight * fPixelRatio;
  // work out if we should be compensating the zoom to minimize blackbars
  // we should compute this based on the % of black bars on screen perhaps??
  //! @todo change m_displayEffect != EFFECT_NO_TIMEOUT to whether we're running the slideshow
  if (m_displayEffect != EFFECT_NO_TIMEOUT && fScreenRatio < fSourceAR * fComp && fSourceAR < fScreenRatio * fComp)
    bFillScreen = true;
  if ((!bFillScreen && fScreenWidth*fPixelRatio > fScreenHeight*fSourceAR) || (bFillScreen && fScreenWidth*fPixelRatio < fScreenHeight*fSourceAR))
    fScaleNorm = fScreenHeight / (m_fHeight * fPixelRatio);
  bFillScreen = false;
  if (m_displayEffect != EFFECT_NO_TIMEOUT && fScreenRatio < fSourceInvAR * fComp && fSourceInvAR < fScreenRatio * fComp)
    bFillScreen = true;
  if ((!bFillScreen && fScreenWidth*fPixelRatio > fScreenHeight*fSourceInvAR) || (bFillScreen && fScreenWidth*fPixelRatio < fScreenHeight*fSourceInvAR))
    fScaleInv = fScreenHeight / (m_fWidth * fPixelRatio);

  float fScale = si * si * (fScaleInv - fScaleNorm) + fScaleNorm;
  // scale if we need to due to the effect we're using
  if (m_displayEffect == EFFECT_PANORAMA)
  {
    if (m_fWidth > m_fHeight)
      fScale *= m_fWidth / fScreenWidth * fScreenHeight / m_fHeight;
    else
      fScale *= m_fHeight / fScreenHeight * fScreenWidth / m_fWidth;
  }
  if (m_displayEffect == EFFECT_FLOAT)
    fScale *= (1.0f + g_advancedSettings.m_slideshowPanAmount * m_iTotalFrames * 0.0001f);
  if (m_displayEffect == EFFECT_ZOOM)
    fScale *= m_fPosZ;
  // zoom image
  fScale *= m_fZoomAmount;

  // calculate the resultant coordinates
  for (int i = 0; i < 4; i++)
  {
    x[i] *= fScale * 0.5f; // as the offsets x[] and y[] are from center
    y[i] *= fScale * fPixelRatio * 0.5f;
    // center it
    x[i] += 0.5f * fScreenWidth + fOffsetX;
    y[i] += 0.5f * fScreenHeight + fOffsetY;
  }
  // shift if we're zooming
  if (m_fZoomAmount > 1)
  {
    float minx = x[0];
    float maxx = x[0];
    float miny = y[0];
    float maxy = y[0];
    for (int i = 1; i < 4; i++)
    {
      if (x[i] < minx) minx = x[i];
      if (x[i] > maxx) maxx = x[i];
      if (y[i] < miny) miny = y[i];
      if (y[i] > maxy) maxy = y[i];
    }
    float w = maxx - minx;
    float h = maxy - miny;
    m_bCanMoveHorizontally = (w >= fScreenWidth);
    m_bCanMoveVertically   = (h >= fScreenHeight);
    if (w >= fScreenWidth)
    { // must have no black bars
      if (minx + m_fZoomLeft*w > fOffsetX)
        m_fZoomLeft = (fOffsetX - minx) / w;
      if (maxx + m_fZoomLeft*w < fOffsetX + fScreenWidth)
        m_fZoomLeft = (fScreenWidth + fOffsetX - maxx) / w;
      for (int i = 0; i < 4; i++)
        x[i] += w * m_fZoomLeft;
    }
    if (h >= fScreenHeight)
    { // must have no black bars
      if (miny + m_fZoomTop*h > fOffsetY)
        m_fZoomTop = (fOffsetY - miny) / h;
      if (maxy + m_fZoomTop*h < fOffsetY + fScreenHeight)
        m_fZoomTop = (fScreenHeight + fOffsetY - maxy) / h;
      for (int i = 0; i < 4; i++)
        y[i] += m_fZoomTop * h;
    }
  }
  // add offset from display effects
  for (int i = 0; i < 4; i++)
  {
    x[i] += m_fPosX * m_fWidth * fScale;
    y[i] += m_fPosY * m_fHeight * fScale;
  }

  UpdateVertices(m_ax, m_ay, x, y, dirtyregions);

  // now render the image in the top right corner if we're zooming
  if (m_fZoomAmount == 1 || m_bIsComic)
  {
    const float empty[4] = {0};
    UpdateVertices(m_bx, m_by, empty, empty, dirtyregions);
    UpdateVertices(m_sx, m_sy, empty, empty, dirtyregions);
    UpdateVertices(m_ox, m_oy, empty, empty, dirtyregions);
    m_bIsDirty = false;
    return;
  }

  float sx[4], sy[4];
  sx[0] = -m_fWidth * co + m_fHeight * si;
  sy[0] = -m_fWidth * si - m_fHeight * co;
  sx[1] = m_fWidth * co + m_fHeight * si;
  sy[1] = m_fWidth * si - m_fHeight * co;
  sx[2] = m_fWidth * co - m_fHeight * si;
  sy[2] = m_fWidth * si + m_fHeight * co;
  sx[3] = -m_fWidth * co - m_fHeight * si;
  sy[3] = -m_fWidth * si + m_fHeight * co;
  // convert to the appropriate scale
  float fSmallArea = fScreenWidth * fScreenHeight / 50;
  float fSmallWidth = sqrt(fSmallArea * fAR / fPixelRatio); // fAR*height = width, so total area*far = width*width
  float fSmallHeight = fSmallArea / fSmallWidth;
  float fSmallX = fOffsetX + fScreenWidth * 0.95f - fSmallWidth * 0.5f;
  float fSmallY = fOffsetY + fScreenHeight * 0.05f + fSmallHeight * 0.5f;
  fScaleNorm = fSmallWidth / m_fWidth;
  fScaleInv = fSmallWidth / m_fHeight;
  fScale = si * si * (fScaleInv - fScaleNorm) + fScaleNorm;
  for (int i = 0; i < 4; i++)
  {
    sx[i] *= fScale * 0.5f;
    sy[i] *= fScale * fPixelRatio * 0.5f;
  }
  // calculate a black border
  float bx[4];
  float by[4];
  for (int i = 0; i < 4; i++)
  {
    if (sx[i] > 0)
      bx[i] = sx[i] + 1;
    else
      bx[i] = sx[i] - 1;
    if (sy[i] > 0)
      by[i] = sy[i] + 1;
    else
      by[i] = sy[i] - 1;
    sx[i] += fSmallX;
    sy[i] += fSmallY;
    bx[i] += fSmallX;
    by[i] += fSmallY;
  }

  fSmallX -= fSmallWidth * 0.5f;
  fSmallY -= fSmallHeight * 0.5f;

  UpdateVertices(m_bx, m_by, bx, by, dirtyregions);
  UpdateVertices(m_sx, m_sy, sx, sy, dirtyregions);

  // now we must render the wireframe image of the view window
  // work out the direction of the top of pic vector
  float scale;
  if (fabs(x[1] - x[0]) > fabs(x[3] - x[0]))
    scale = (sx[1] - sx[0]) / (x[1] - x[0]);
  else
    scale = (sx[3] - sx[0]) / (x[3] - x[0]);
  float ox[4];
  float oy[4];
  ox[0] = (fOffsetX - x[0]) * scale + sx[0];
  oy[0] = (fOffsetY - y[0]) * scale + sy[0];
  ox[1] = (fOffsetX + fScreenWidth - x[0]) * scale + sx[0];
  oy[1] = (fOffsetY - y[0]) * scale + sy[0];
  ox[2] = (fOffsetX + fScreenWidth - x[0]) * scale + sx[0];
  oy[2] = (fOffsetY + fScreenHeight - y[0]) * scale + sy[0];
  ox[3] = (fOffsetX - x[0]) * scale + sx[0];
  oy[3] = (fOffsetY + fScreenHeight - y[0]) * scale + sy[0];
  // crop to within the range of our piccy
  for (int i = 0; i < 4; i++)
  {
    if (ox[i] < fSmallX) ox[i] = fSmallX;
    if (ox[i] > fSmallX + fSmallWidth) ox[i] = fSmallX + fSmallWidth;
    if (oy[i] < fSmallY) oy[i] = fSmallY;
    if (oy[i] > fSmallY + fSmallHeight) oy[i] = fSmallY + fSmallHeight;
  }

  UpdateVertices(m_ox, m_oy, ox, oy, dirtyregions);
  m_bIsDirty = false;
}
Ejemplo n.º 13
0
const Vector<Vertex2D>& Drawable2D::GetVertices()
{
    if (verticesDirty_)
        UpdateVertices();
    return vertices_;
}
Ejemplo n.º 14
0
void Rectangle::SetPosition(glm::vec2 position_) {
    position = position_;
    UpdateVertices();
}
Ejemplo n.º 15
0
HRESULT KModelBelt::Render()
{
	SetMatrix();

	D3DXMATRIX MatCur = m_Matrix;
	g_pd3dDevice->GetTransform( D3DTS_WORLD , &MatCur);
	D3DXVECTOR3  A,B;
	D3DXVec3TransformCoord(&A,&m_BaseLine.A,&MatCur);
	D3DXVec3TransformCoord(&B,&m_BaseLine.B,&MatCur);

	m_CurLine.A = A;
	m_CurLine.B = B;


	if( m_bGotOne )		//初始化飘带
	{
		InitialBelt(m_CurLine);
		m_bGotOne = FALSE;
	}
/*	
	if(!m_bShow)		//非运动时飘带的状态
	{

		SRCLINE LineA = m_SrcLineList.front();

		UpdateAtRest(m_CurLine);
		UpdateExtend();

		LineA = m_SrcLineList.front();


		int j = 0;
	}
	else				//运动时飘带的状态
	{
		AddLine(m_CurLine);

	}
*/


//	AddLine(m_CurLine);
//	UpdateAtRest(m_CurLine);
	AddLine(m_CurLine);

	if(m_bExtend)
	{
		UpdateExtend();
	}

	D3DXMATRIX MatId;
	D3DXMatrixIdentity(&MatId);
	g_pd3dDevice->SetTransform( D3DTS_WORLD , &MatId);

	UpdateVertices();  

	KModel::SetMaterial(0);
	g_pd3dDevice->SetStreamSource( 0, m_lpVBuf,0, sizeof( VFormat::FACES_DIFFUSE_TEXTURE1 ) );
	g_pd3dDevice->SetFVF( D3DFVF_Faces_Diffuse_Texture1 );

//	g_pd3dDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);	
	g_pd3dDevice->DrawPrimitive  ( D3DPT_TRIANGLESTRIP , 0 , m_nNumFaces);

//	SRCLINE LineK = m_vecSrcLine[0];

	RestoreMatrix();

	return S_OK;
}
Ejemplo n.º 16
0
void Rectangle::SetHeight(float height_) {
    height = height_;
    UpdateVertices();
}
Ejemplo n.º 17
0
// Startup D3D resources
void EditExt::D3DInit()
{
	// Get the D3D device used by the runtime
	pDevice = (IDirect3DDevice9*)pEditTime->GetDisplayDevice();

	if (pDevice == NULL) {
		MessageBox(NULL, "No DirectX device available", "3D Cube Error", MB_OK | MB_ICONHAND);
		return;
	}

	// Set up the cube vertices
	hr = pDevice->CreateVertexBuffer(sizeof(TLVERTEX) * 36, D3DUSAGE_WRITEONLY, D3DFVF_TLVERTEX, D3DPOOL_MANAGED,
								&pVertices, NULL);

	if (FAILED(hr)) {
		MessageBox(NULL, "Failed to create vertex buffer", "3D Cube Error", MB_OK | MB_ICONHAND);
		return;
	}

	UpdateVertices();

	//Here we build our View Matrix, think of it as our camera.
	//First we specify that our viewpoint is 8 units back on the Z-axis
	eye_vector = D3DXVECTOR3( 0.0f, 0.0f, 8.0f );

	//We are looking towards the origin
	lookat_vector = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );

	//The "up" direction is the positive direction on the y-axis
	up_vector = D3DXVECTOR3(0.0f,1.0f,0.0f);

	D3DXMatrixLookAtLH(&view_matrix,&eye_vector,
								   &lookat_vector,
								   &up_vector);

	SIZE s;
	s.cx = GetSystemMetrics(SM_CXSCREEN);
	s.cy = GetSystemMetrics(SM_CYSCREEN);
	aspect=((float)s.cx / (float)s.cy);

	D3DXMatrixPerspectiveFovLH(&projection_matrix, //Result Matrix
							  D3DX_PI/4,          //Field of View, in radians.
							  aspect,             //Aspect ratio
							  1.0f,               //Near view plane
							  100.0f );           //Far view plane

	D3DXMatrixIdentity(&worldMatrix);
	D3DXMatrixIdentity(&rotMatrix);
	D3DXMatrixIdentity(&transMatrix);
	D3DXMatrixIdentity(&scaleMatrix);

	// The vectors used in screen projection
	orig.x = 0;
	orig.y = 0;
	orig.z = 0;
	normal.x = 0;
	normal.y = 0;
	normal.z = 1;		// Normal facing the view

	CreateZBuffer();
}
Ejemplo n.º 18
0
void EditExt::EditFace(int face)
{
	pEditTime->EditImage(imageHandles[face]);
	textures[face] = pEditTime->AddImageAsTexture(imageHandles[face]);
	UpdateVertices();
}
Ejemplo n.º 19
0
HRESULT KModelSFXLineGrass::LoadMesh(LPSTR pFileName)
{
	
	//////////////////////////////////////////////////////////////////////////
	LPMOTION pMotion = new MOTION;
	m_lpMotion.push_back(pMotion);
	pMotion = new _MotionCircle;
	m_lpMotion.push_back(pMotion);

	DWORD m_dwNumObject = 400;
	
	DWORD Row =0,K =0;
	DWORD RowLength = (DWORD) sqrt((float)(m_dwNumObject));

	for(DWORD i=0;i<m_dwNumObject;i++)
	{
		K++;
		float X = (rand()%1000)*0.001f*500 - 250;
		float Y = (rand()%1000)*0.001f*500 - 250;
		
		if (K>RowLength)
		{
			Row++;
			K=0;
		}
		X = Row * 100.0f - RowLength*50 + (rand()%1000)*0.001f*50;
		Y = K   * 100.0f - RowLength*50 + (rand()%1000)*0.001f*50;
		float Size = (rand()%1000)*0.001f*5+15;

		D3DXVECTOR3 Position = D3DXVECTOR3(X,0,Y);

		LPSPRITE pSpr = new SPRITE;

		pSpr->Width    = Size ;
		pSpr->Height = Size;
		pSpr->MotionType = 0;
		pSpr->Position   = Position;
		pSpr->Arg[0] = Position.x;
		pSpr->Arg[1] = Position.y;
		pSpr->Arg[2] = Position.z;

		m_lpSprite.push_back(pSpr);
		m_nNumFaces = m_nNumLinePerGrass*m_lpSprite.size();

	}

	CreateVerticesBuffer();
	
	wsprintf(m_szMeshFileName,"Line Grass");
	UpdateVertices();

	m_dNumMaterial = 1;
	m_lpMaterial = new MATERIAL[m_dNumMaterial];
	ZeroMemory(m_lpMaterial,sizeof(MATERIAL)*m_dNumMaterial);
	
	DWORD Def_Option = MATERIAL_OPTION_ZBUFFER_TRUE|
		MATERIAL_OPTION_FILL_SOLID|
		MATERIAL_OPTION_SHADE_GOURAUD|
		MATERIAL_OPTION_CULL_CW|
		MATERIAL_OPTION_SPECULARENABLE;
	
	for( i=0;i<m_dNumMaterial;i++)
	{
		m_lpMaterial[i].m_sMaterial9.Diffuse.r = 0.7f ;
		m_lpMaterial[i].m_sMaterial9.Diffuse.g = 0.7f ;
		m_lpMaterial[i].m_sMaterial9.Diffuse.b = 0.7f ;
		m_lpMaterial[i].m_sMaterial9.Diffuse.a = 1.0f ;
		m_lpMaterial[i].m_sMaterial9.Ambient = m_lpMaterial[i].m_sMaterial9.Diffuse;
		m_lpMaterial[i].m_sMaterial9.Specular = m_lpMaterial[i].m_sMaterial9.Diffuse;
		m_lpMaterial[i].m_sMaterial9.Power = 15;
		m_lpMaterial[i].m_dOption = Def_Option;
	}
	TCHAR Name[256];
	wsprintf(Name,"%s\\BillBoard.Mtl",g_Def_ModelDirectory);
	LoadMaterial(Name);

	return S_OK;
}
Ejemplo n.º 20
0
void Rectangle::SetWidth(float width_) {
    width = width_;
    UpdateVertices();
}