render engine outline

This is a discussion on render engine outline within the C Programming forums, part of the General Programming Boards category; I've been trying to build a structure that can define 3D models made of 3 point polygons and figure out ...

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    26

    render engine outline

    I've been trying to build a structure that can define 3D models made of 3 point polygons and figure out the position of all of the vertices during rotations and movements. It can only rotate on the Y and Z axis, I'm not sure how I would go about making it rotate on an axis defined by any two points yet. Am I heading down the right path here, I'm not really sure how too render in directX or openGL yet so I'm not sure if this would be compatible.

    Code:
    #include "math.h"
    #include "stdlib.h"
    
    const double PI = 3.14159265358979;
    
    typedef struct Tvertice{
        float x;
        float y;
        float z;
    } Tvertice;
    typedef struct Tpos{
        float x;
        float y;
        float z;
    } Tpos;
    typedef struct Tvector{
        unsigned int x;
        unsigned int y;
        unsigned int z;
    } Tvector;
    
    typedef struct Tpolygon{
        Tvertice vertice[3];
    } Tpolygon;
    
    typedef struct Trender{
        Tvertice vertice[3];
    } Trender;
    
    typedef struct Tobject{
        Tpolygon polygon[100];
        Tpos pos;
        Tvector vector;
        float spinZ;
        float spinY;
        float spinvZ;
        float spinvY;
        Trender render[100];
    } Tobject;
    
    Tobject object;
    float timeinterval;
    
    int moveobject(void){
    
    int ctr;
    int ctr1;
    
    object.vector.x = (object.vector.x)*(timeinterval);
    object.vector.y = (object.vector.y)*(timeinterval);
    object.vector.z = (object.vector.z)*(timeinterval);
    
    object.spinvY = (object.spinvY)*(timeinterval);
    object.spinvZ = (object.spinvZ)*(timeinterval);
    
    object.pos.x = object.pos.x + object.vector.x;
    object.pos.y = object.pos.y + object.vector.y;
    object.pos.z = object.pos.z + object.vector.z;
    object.spinZ = fmod(float (object.spinZ + object.spinvZ), float (2*PI));
    object.spinY = fmod(float (object.spinY + object.spinvY), float (2*PI));
    
    for(ctr= 0; ctr<100; ctr++)
    {
        for(ctr1 = 0; ctr1 <3; ctr1 ++)
        {
            object.render[ctr].vertice[ctr1].x = (((object.polygon[ctr].vertice[ctr1].x)(cos(object.spinZ)))-(object.polygon[ctr].vertice[ctr1].y(sin(object.spinZ)))+(object.pos.x));
    
            object.render[ctr].vertice[ctr1].y = (((object.polygon[ctr].vertice[ctr1].x)(sin(object.spinZ)))+(object.polygon[ctr].vertice[ctr1].y(cos(object.spinZ)))+(object.pos.y));
    
            object.render[ctr].vertice[ctr1].z = (((object.polygon[ctr].vertice[ctr1].x)(sin(object.spinY)))+(object.polygon[ctr].vertice[ctr1].z(cos(object.spinY)))+(object.pos.z));
        }
    }
    }

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    You need to dive in and start learning OpenGL (or DirectX) since many of these concepts are directly implemented there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 3d render contest
    By kryptkat in forum Contests Board
    Replies: 3
    Last Post: 03-02-2010, 04:22 AM
  2. Render text
    By Livijn in forum C++ Programming
    Replies: 6
    Last Post: 07-06-2007, 04:32 PM
  3. Outline on my text
    By Sentral in forum Game Programming
    Replies: 6
    Last Post: 06-05-2006, 08:43 PM
  4. Best way to render a graph?
    By jverkoey in forum Windows Programming
    Replies: 4
    Last Post: 02-05-2005, 01:08 AM
  5. need help on writting a general outline
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 03-14-2002, 08:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21