游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2014|回复: 4

做个调查问卷

[复制链接]

41

主题

184

帖子

184

积分

注册会员

Rank: 2

积分
184
发表于 2007-1-10 09:33:00 | 显示全部楼层 |阅读模式
全部研读过OpenGL白皮书,红皮书和黄皮书的有多少人。

理解了50%以上就可以了 [em20],

读过的留个名

180

主题

3511

帖子

3520

积分

论坛元老

Rank: 8Rank: 8

积分
3520
发表于 2007-1-10 17:56:00 | 显示全部楼层

Re:做个调查问卷

OpenGL白皮书......里面用的编译器都不是 VC++,
好象用的是 Boland C,所有原代码在 VC++里面编译出错.

我的学习材料是
nehe.gamedev.net

OpenGL白皮书,只适合拿来看理论,不适合实际编程练习.
回答完毕!
谢谢!

21

主题

230

帖子

230

积分

中级会员

Rank: 3Rank: 3

积分
230
发表于 2007-1-11 02:45:00 | 显示全部楼层

Re:做个调查问卷

我只知道有个红皮书。
白皮和黄皮的给个超连接?
我正想从0做个软件的渲染的东西。所以想看看。白皮的。
恩。其实很简单啊,有些东西只要做起来就简单了。我实验了下,用生成一个环,然后自己矩阵转换,SETUP Z.然后自己RASTER.几百行就搞定了。不过raster还是黑的。考虑加上材质。矩阵变化只有project的矩阵。自己实现这些,这个是我的一个心愿。
void calc(float *vt1,float *vt2,int *l,int *r,int left,int buttom,int top,int right,int &maxy1,int &maxy2)
{
        float *l1,*l2;

        if( vt2[1] > vt1[1] )
        {
                l1=vt1;l2=vt2;
        } else {
                l1=vt2;l2=vt1;
        }

        int y1= l1[1];
        int y2 = l2[1];
        if(y1< buttom ) y1=buttom;
        if(y2> top ) y2=top;
       
        if( y1< maxy1) maxy1=y1;
        if( y2 > maxy2) maxy2=y2;

        float dx = l2[0]-l1[0];
        float dy= l2[1]-l1[1];
        float slope = dx/dy;
        float cx=l1[0]+slope*(l1[1]-y1);
        //if( cx < left ) cx = left;
        for(int i=y1;i<y2;++i)
        {
                if(cx<l )
                {
                        if(cx< left) l= left;
                        else
                        l= cx;
                }
               
                if( cx>r )
                {
                        if( cx > right )
                                r=right;
                        else
                        r=cx;
                }
                cx+=slope;
        }
}

void calp(float *vts,unsigned short *id,int num,int left,int buttom,int top,int right,CPaintDC *dc)
{
        int hi= top-buttom;
        int *lv= new int[hi];
        int *lr= new int[hi];
        int maxy1,maxy2;
        maxy1=top;
        maxy2=buttom;
        for(unsigned i=0;i<hi;++i)
        {
                lv=right;
                lr=left;
        }
        for(unsigned i=0;i<num-1;++i)
        {
                calc(&vts[ id*4],&vts[id[i+1]*4],&lv[hi/2],&lr[hi/2],left,buttom,top,right,maxy1,maxy2);
        }
        calc(&vts[id[num-1]*4],&vts[id[0]*4],&lv[hi/2],&lr[hi/2],left,buttom,top,right,maxy1,maxy2);

        for(int i=maxy1;i<maxy2;++i)
        {
                for(int j= lv[i+hi/2];j<=lr[i+hi/2];++j)
                {
                        dc->SetPixel(j+300,i+300,0);
                }
        }
        delete [] lv;
        delete [] lr;
}

void calquad(float *vts,unsigned short *id,int num,int left,int buttom,int top,int right,CPaintDC *dc)
{
        for(unsigned i=0;i<num;++i)
        {
                calp(vts,&id[i*4],4,left,buttom,top,right,dc);
        }
}

float dot( float *f1,float *f2)
{
        float sum =0.0;
        for(unsigned i=0;i<4;++i)
        {
                sum+=f1*f2;
        }
        return sum;
}

float * mul(float *f1,float *f2,float *mat)
{
        for(unsigned i=0;i<4;++i)
        {
                f2=dot(f1,&mat[i*4]);
        }

        return f2;
}

#include<math.h>
void lookat(float near_plane,float far_plane,float fov_horiz,float fov_vert,float *mat)
{
        float    h, w, Q;

    w = (float)1/tan(fov_horiz*0.5);  
    h = (float)1/tan(fov_vert*0.5);   
    Q = far_plane/(far_plane - near_plane);

        memset(mat,0,16*sizeof(float));   

    mat[0] = w;
    mat[4+1] = h;
    mat[8+2] = Q;
    mat[8+3] = -Q*near_plane;
    mat[12+2] = 1;
}

void gen(float *ck,float r,float c,int s1,int s2,unsigned short *ids)
{
        float a=0;
        for(unsigned i=0;i<s1;++i)
        {
                float af1=2*3.14/s1*i;
                for(unsigned j=0;j<s2;++j)
                {
                        float af2=2*3.14/s2*j;
                        float nu= r+c*cos(af1);

                        ck[(i*s2+j)*4]=nu*sin(af2);
                        ck[(i*s2+j)*4+1]=nu*cos(af2);
                        ck[(i*s2+j)*4+2]=c*sin(af1)+50;
                        ck[(i*s2+j)*4+3]=0;
                }
        }
        for(unsigned i=0;i<s1;++i)
        {
                for(unsigned j=0;j<s2;++j)
                {
                        ids[(i*s2+j)*4]=i*s2+j;
                        ids[(i*s2+j)*4+1]=((i+1)%s1)*s2+j;
                        ids[(i*s2+j)*4+3]=i*s2+((j+1)%s2);
                        ids[(i*s2+j)*4+2]=((i+1)%s1)*s2+((j+1)%s2);
                }
        }
}

void appproj(float *verts,float *out,float *mat,int num)
{
        for(unsigned i=0;i<num;++i)
        {
                mul(&verts[i*4],&out[i*4],mat);
                char buf[1024];
                sprintf(buf,"%f %f %f %f",out[i*4],out[i*4+1],verts[i*4+2],verts[i*4+3]);
                int a=0;
        }
       
}

void setupz(float *verts,float *out,int num)
{
        for(unsigned i=0;i<num;++i)
        {
                for(unsigned j=0;j<3;++j)
                {
                        out[i*4+j] = verts[i*4+j]/verts[i*4+3];
                }
                        char buf[1024];
                sprintf(buf,"%f %f %f %f",verts[i*4],verts[i*4+1],verts[i*4+2],verts[i*4+3]);
                int a=0;
        }
}

void viewp(float *verts,float *out,int num,int w,int h)
{
        for(unsigned i=0;i<num;++i)
        {
                out[i*4]*=w;
                out[i*4+1]*=h;

        }
}


void CChildView::OnPaint()
{
        CPaintDC dc(this); // 用于绘制的设备上下文

        float vts[10*10*4] ;
        float vout[400];
        unsigned short id[400];
        gen(vts,30,5,5,20,id);
        //unsigned short id[]={0,1,2};
        float mat[16];
        lookat(10,10000,3.14/2,3.14/2,mat);

        appproj(vts,vout,mat,100);
        setupz(vout,vout,100);
        viewp(vout,vout,100,300,300);
        //calquad(vout,
        calquad(vout,id,100,-300,-300,300,300,&dc);
       
        // TODO: 在此处添加消息处理程序代码
       
        // 不要为绘制消息而调用 CWnd::OnPaint()
}

21

主题

230

帖子

230

积分

中级会员

Rank: 3Rank: 3

积分
230
发表于 2007-1-11 02:57:00 | 显示全部楼层

Re: 做个调查问卷

测试

21

主题

230

帖子

230

积分

中级会员

Rank: 3Rank: 3

积分
230
发表于 2007-1-11 03:14:00 | 显示全部楼层

Re:做个调查问卷

贴不了图。最后的结果是个黑环。很简单嘛。再扩充一下就能实现个固定管道了。 准备加上 percipect tive correct texture.只要材质坐标 1/z  u/z*z v/z*z 插值一下就可以了。alpha 混合不就是 ++ **.其他光照计算也容易。写过shader的都会做。
3d图形真他妈简单。我想大多数人都懂80%以上。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-26 05:41

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表