Results 1 to 7 of 7

Thread: World to screen с++

  1. #1

    Default World to screen с++

    Can you lay out the example source code "World is Screen" on any game? or where it is possible to learn (except googl)?

  2. #2
    Join Date
    Jun 2009
    Location
    https://www.downloadedskills.com/
    Age
    29
    Posts
    421

    Default

    Quote Originally Posted by VDV View Post
    Can you lay out the example source code "World is Screen" on any game? or where it is possible to learn(except googl)?
    The answer is mathematics

  3. #3

    Default

    Quote Originally Posted by PocketMonster View Post
    The answer is mathematics
    bool WorldToScreen(Vector3D World, float *ScreenX, float *ScreenY)
    {
    //Get the enemy position
    Vector3D Position = VectorSubtract(World, RefDef->Origin);
    Vector3D Transform;

    //Get the Dot Products from the View Angles of the player
    Transform.x = DotProduct(Position, RefDef->viewAxis[1]);
    Transform.y = DotProduct(Position, RefDef->viewAxis[2]);
    Transform.z = DotProduct(Position, RefDef->viewAxis[0]);

    //Make sure the enemy is in front of the player. If not, return.
    if (Transform.z < 0.1f)
    return false;

    //Calculate the center of the screen
    Vector2D Center = Vector2D((float)RefDef->Width * 0.5f, (float)RefDef->Height * 0.5f);

    //Calculates the screen coordinates
    *ScreenX = Center.x * (1 - (Transform.x / RefDef->fov.x / Transform.z));
    *ScreenY = Center.y * (1 - (Transform.y / RefDef->fov.y / Transform.z));

    return true;


    it is one of the sources




    RefDef - whatever address you have that stores your origin, view angles and view axis - how to do this ????
    Vector 3d - not understand it, hike x, y, z enemy - x, y, z my
    VectorSubtract - do not understand the difference between a campaign 2x vectors: the enemy of my
    DotProduct - x * y * z or something like that, too, it is not clear
    viewAxis - view along the axis - how to properly calculate not understand, can anyone help
    Vector2D - I do not know how to calculate


    That count if you do not know what it looks like?

  4. #4

    Default

    I wish you the best of luck to project 3d coordinates in a 2d screen space without even knowing what vectors are, or what vector operations are.
    Logical conclusion, look it up and study it.

  5. #5

    Default

    Quote Originally Posted by mOwl View Post
    I wish you the best of luck to project 3d coordinates in a 2d screen space without even knowing what vectors are, or what vector operations are.
    Logical conclusion, look it up and study it.
    So the easiest way to tell. But to explain .....

  6. #6
    Join Date
    Jan 2010
    Location
    America
    Posts
    244

    Default

    bool; getC0de -- 2dto3d));
    if
    2d=true;
    return;
    false;
    [SIGPIC][/SIGPIC]

  7. #7
    Join Date
    Jun 2009
    Location
    https://www.downloadedskills.com/
    Age
    29
    Posts
    421

    Default

    Quote Originally Posted by VDV View Post
    So the easiest way to tell. But to explain .....
    I think mOwl pointed you into the right direction

    Quote Originally Posted by mOwl View Post
    I wish you the best of luck to project 3d coordinates in a 2d screen space without even knowing what vectors are, or what vector operations are.
    Logical conclusion, look it up and study it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •