Пример #1
0
Dvoid Camera::Yaw()
{
    if (m_MouseMoveInterval.x == 0)
        return;

    m_bMove = true;

    Matrix44	matRot;
    Vector3	vUp(0, 1, 0);
    float	fAngle = m_MouseMoveInterval.x * m_fMouseSens * m_fTimeDelta;

    matRot.Rotation(vUp, fAngle);

    for (Duint i = 0; i < CD_MAX; ++i)
    {
        m_vDir[i] = Vec4ToVec3(matRot * Vector4(m_vDir[i], 0), Vector4::W_IGNORE);
        m_vDir[i].Normalize();
    }
}
Пример #2
0
Dvoid Camera::Pitch()
{
    if ( m_MouseMoveInterval.y == 0)
        return;

    m_bMove = true;

    Matrix44	matRot;
    float fAngle = m_MouseMoveInterval.y * m_fMouseSens * m_fTimeDelta;

    matRot.Rotation( m_vDir[CD_RIGHT], fAngle );

    // Right축을 제외한 축을 변환한다.
    for ( Duint i = 0; i < CD_MAX; ++i )
    {
        if (i == CD_RIGHT)	continue;

        m_vDir[i] = Vec4ToVec3(matRot * Vector4(m_vDir[i], 0), Vector4::W_IGNORE);
        m_vDir[i].Normalize();
    }
}
Пример #3
0
	Vector3 TransformHelper::TransformViewport(const array<Matrix44, TRANSFORM_END>& arrayTransform, Vector3& vertex)
	{		
		Vector4 v = arrayTransform[ VIEWPORT ] * Vector4(vertex, 1);
		return Vec4ToVec3(v, Vector4::W_IGNORE);
	}
Пример #4
0
	Vector3 TransformHelper::TransformWVP(const array<Matrix44, TRANSFORM_END>& arrayTransform, Vector3 vertex)
	{			
		Vector4 v = arrayTransform[ PERSPECTIVE ] * arrayTransform[ VIEW ] * arrayTransform[ WORLD ] * Vector4(vertex, 1);		
		return Vec4ToVec3(v, Vector4::W_DIVIDE);
	}
Пример #5
0
//
//	EWaving::Update
//
void EWaving::Update( float dtime, const EVec4 &_view_pos, const EQuat &orient )
{
	time	+=	dtime;

	r_sky->SetPose( _view_pos, QuatIdentity() );
	r_sky->SetFlag( RSE_HIDDEN );
	
	EFrustum fr	=	ESciVis::self->view.frustum;
	
	EVec4	view_pos	=	_view_pos;

	float	elevation		=	sqrt(1+abs(view_pos.z));
	float	view_area_scale	=	elevation * 100;
	float	step			=	1.0f / 64.0f * view_area_scale;

	view_pos.x	=	floor( view_pos.x / step ) * step;
	view_pos.y	=	floor( view_pos.y / step ) * step;

	//
	//	Make grid :
	//
	IPxTriMesh	mesh	=	sea_mesh->Clone();
	uint n = mesh->GetVertexNum();
	
	for (uint i=0; i<n; i++) {
		EVertex	v;
		
		float	wave_factor		=	1;
		
		v			=	mesh->GetVertex( i );
		float gx	=	v.position.x;
		float gy	=	v.position.y;
		
		float x		=	gx * view_area_scale + view_pos.x;
		float y		=	gy * view_area_scale + view_pos.y;
		
		wave_factor	=	clamp<float>(1 - (gx*gx + gy*gy), 0, 1);
		wave_factor	=	pow( wave_factor, 2 );
		
		//
		//	write vertex :
		//		
		v.position.x	=	x;
		v.position.y	=	y;
		v.position.z	=	0;
		
		float	dist	=	Vec3Length( v.position - Vec4ToVec3(view_pos) );

		v.position.z	=	GetPosition( Vec3ToVec4(v.position) ).z * wave_factor;
		/*if (dist < view_area_scale*0.1 || fr.IsPointInside( EVec4(x,y,0,1), 0.1 * dist )) {
		}  */

		mesh->SetVertex( i, v );
	}
	
	//
	//	post process mesh :
	//
	for (uint i=0; i<n; i++) {
		EVertex	v	=	mesh->GetVertex( i );
		v.uv0.x		=	v.position.x/4;
		v.uv0.y		=	v.position.y/4;
		mesh->SetVertex( i, v );
	}
	
	r_ent->SetMesh( mesh );
	//r_ent->SetFlag( RSE_HIDDEN );  
}