Пример #1
0
SMatrix SClock::InitMatrix(double angle, CPoint &center)
{
    //先平移到center,再旋转angle,再平移-center
    return SMatrix().translate((FLOAT)center.x,(FLOAT)center.y)
                    .rotate((FLOAT)angle-90)
                    .translate((FLOAT)-center.x,(FLOAT)-center.y);
}
Пример #2
0
void SClock::OnPaint(SOUI::IRenderTarget * pRT)
{
	SWindow::OnPaint(pRT);

	CRect rcClient;
	GetClientRect(&rcClient);

	CPoint center = rcClient.CenterPoint();

	// 计算矩形
	// 35 * 16
	CRect rcDraw(center, SOUI::CPoint(center.x + 200, center.y + 32));
	rcDraw.OffsetRect(-35, -16);
	CRect rcSrc(0, 0, 200, 32);


    SYSTEMTIME last_refresh_time;
    ::GetLocalTime(&last_refresh_time);

    {
        double angle = GetHourAngle(last_refresh_time.wHour,last_refresh_time.wMinute);
        SMatrix form = InitMatrix(angle,  center);
        pRT->SetTransform(&form, NULL);
        pRT->DrawBitmapEx(rcDraw, pointer_hour, &rcSrc, EM_STRETCH, 255);
    }

    {
        double angle = GetMinuteSecondAngle(last_refresh_time.wMinute);
        SMatrix form = InitMatrix(angle, center);
        pRT->SetTransform(&form, NULL);
        pRT->DrawBitmapEx(rcDraw, pointer_minute, &rcSrc, EM_STRETCH, 255);
    }

    {
        double angle = GetMinuteSecondAngle(last_refresh_time.wSecond);
        SMatrix form = InitMatrix(angle, center);
        pRT->SetTransform(&form, NULL);
        pRT->DrawBitmapEx(rcDraw, pointer_second, &rcSrc, EM_STRETCH, 255);
    }
	pRT->SetTransform(&SMatrix());
}
Пример #3
0
int main_test(){
  Context context;
  StopWatch swatch;
  World world;
  CameraControl ev;
  glPointSize(2.0);
  ev.cam.position = vec(0.0f,0.0f,5.0f);
  mouse_move_spawner.register_listener(&ev);
  key_event_handler.register_listener(&ev);
  
  FlatShader3D flat;
  flat.SetProjection(ProjectionMatrix(0.01,0.01,0.01,200000.0));
  
  GameObject * go = new GameObjectTest(context);
  
  go->GravityBound = false;
  go->aabb.pos[0] += 0.1;
  go->aabb.pos[2] += 0.1;
  go->aabb.pos[1] -= 4.0;
  go->aabb.size = vec(20.0,2.0,20.0);
  go->aabb.mass = 100000.0;
  go->Tetra.TRS = TMatrix(vec(10.0f,0.0f,10.0f)) * SMatrix(vec(10.0f,1.0f,10.0f));
  world.InsertObject(go);

  go = new GameObjectTest(context);
  go->GravityBound = false;
  go->aabb.size = vec(2.0,2.0,2.0);
  go->Tetra = Tetragon();
  world.InsertObject(go);
  VBO stars = context.Stars;
  while(true){
    Matrix<float,4> cameraMatrix;
    go->aabb.pos = -ev.cam.position.As<double>() - vec(0.0,0.0,0.0);
    print(go->aabb.pos);
    auto goList = world.GetNearbyObjects(vec(0.0,0.0,0.0),5000000.0);
    world.PhysicsUpdate(vec(0.0,0.0,0.0),500000,0.1);

    for(auto go : goList){
      go.Get()->DoUpdate(world);
    }

    //ev.cam.position = go->aabb.pos.As<float>() + vec(0.0f,-2.0f,0.0f);
    print(go->aabb.pos);
    swatch.Reset();
    swatch.Start();
    ClearBuffer(vec(0.0f,0.0f,0.0f,1.0f));
    cameraMatrix = ev.GetCamera().getTransformMatrix();
    /*cameraMatrix[3][0] = 0;
    cameraMatrix[3][1] = 0;
    cameraMatrix[3][2] = 0;
    */
    flat.SetCamera(cameraMatrix);   
    
    flat.SetModelView(Matrix<float,4>::Eye());
    context.StarColors.Bind(0);
    stars.BindBuffer(0);
    VertexBufferObject::DrawBuffers(DrawMethod::Points,100);
    flat.SetCamera(ev.GetCamera().getTransformMatrix());   
    goList = world.GetNearbyObjects(vec(0.0,0.0,0.0),5000000.0);
    for(auto go: goList){
      go.Get()->Draw(flat);
    }
    SwapBuffers();
    Sleep(1/30.0 - swatch.ElapsedSeconds());
  }
}
Пример #4
0
/**
 * Create a matrix based on the multiplication of the matrix and a value
 *
 * @param v The value to multiply the matrix by
 * @param im The matrix to multiply
 */
SMatrix operator * ( const T &v, const SMatrix &im )
{
    return (SMatrix( im ) * v );
}
Пример #5
0
/**
 * Multiply the matrix with the given value
 *
 * @param v The value to multiply the matrix with
 */
SMatrix SMatrix::operator *( const T &v ) const
{
    SMatrix m ( *this );
    return  SMatrix(((Matrix)m).operator *(v));
}