本资源包括项目演示视频、源代码、说明文档、项目资源。
本场景是一个篮球场,篮球可以做自由落体运动和反弹。
场景涉及灯光,纹理,摄像机的移动。
具体细节可看博客:https://blog.csdn.net/A_ACM/article/details/100569142
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1227654 2019-06-19 08:56 篮球场data3.bmp
文件 2141238 2019-06-20 09:54 篮球场data5.bmp
文件 11338 2019-06-21 11:37 篮球场datac.png
文件 1227654 2019-06-19 08:56 篮球场HomeWorkindata3.bmp
文件 2141238 2019-06-20 09:54 篮球场HomeWorkindata5.bmp
文件 11338 2019-06-21 11:37 篮球场HomeWorkindatac.png
文件 55892 2019-06-27 15:27 篮球场HomeWorkinDebugHomeWork.exe
文件 1447 2019-06-16 12:52 篮球场HomeWorkHomeWork.cbp
文件 5634 2019-06-27 15:22 篮球场HomeWorkHomeWork.depend
文件 362 2019-06-27 15:27 篮球场HomeWorkHomeWork.layout
文件 13019 2019-06-27 15:27 篮球场HomeWorkmain.cpp
文件 23767 2019-06-27 15:27 篮球场HomeWorkobjDebugmain.o
文件 55892 2019-06-27 15:26 篮球场HomeWork.exe
文件 37093523 2019-06-27 14:57 篮球场作品演示.mp4
文件 13019 2019-06-27 15:29 篮球场源码.txt
文件 407384 2019-09-06 11:04 篮球场说明文档.pdf
目录 0 2019-06-27 15:19 篮球场HomeWorkindata
目录 0 2019-06-27 15:27 篮球场HomeWorkinDebug
目录 0 2019-06-27 15:27 篮球场HomeWorkobjDebug
目录 0 2019-06-27 15:19 篮球场HomeWorkin
目录 0 2019-06-27 15:05 篮球场HomeWorkobj
目录 0 2019-06-27 15:26 篮球场data
目录 0 2019-06-27 15:28 篮球场HomeWork
目录 0 2019-09-06 11:04 篮球场
----------- --------- ---------- ----- ----
44430399 24
#include
#include
#include
#include
#include
struct vec3
{
float x;
float y;
float z;
};
#define a -0.00003
#define PI acos(-1.0)
#define BMP_Header_Length 54
double v=0;
double x=0;
double ypos=5;
double v0=0;
int t=0;
int flag=1;
float xPosition=0; ///相机位置
float yPosition=6;
float zPosition=6;
float radius = 40.0f;///相机旋转的长度
float theta = 0;///相机旋转角度
float thetb = 40;
float step=0;///球移动
float step2=0;
float step3=0;///太阳旋转
float radius2=40;
GLuint tex1tex2tex3tex4;
int power_of_two(int n)
{
if( n <= 0 )
return 0;
return (n & (n-1)) == 0;
}
GLuint load_texture(const char* file_name)
{
GLint width height total_bytes;
GLubyte* pixels = 0;
GLuint last_texture_ID=0 texture_ID = 0;
FILE* pFile = fopen(file_name “rb“);
if( pFile == 0 )
return 0;
fseek(pFile 0x0012 SEEK_SET);
fread(&width 4 1 pFile);
fread(&height 4 1 pFile);
fseek(pFile BMP_Header_Length SEEK_SET);
{
GLint line_bytes = width * 3;
while( line_bytes % 4 != 0 )
++line_bytes;
total_bytes = line_bytes * height;
}
pixels = (GLubyte*)malloc(total_bytes);
if( pixels == 0 )
{
fclose(pFile);
return 0;
}
if( fread(pixels total_bytes 1 pFile) <= 0 )
{
free(pixels);
fclose(pFile);
return 0;
}
{
GLint max;
glGetIntegerv(GL_MAX_TEXTURE_SIZE &max);
if( !power_of_two(width) || !power_of_two(height) || width > max || height > max )
{
const GLint new_width = 256;
const GLint new_height = 256;
GLint new_line_bytes new_total_bytes;
GLubyte* new_pixels = 0;
new_line_bytes = new_width * 3;
while( new_line_bytes % 4 != 0 )
++new_line_bytes;
new_total_bytes = new_line_bytes * new_height;
new_pixels = (GLubyte*)malloc(new_total_bytes);
if( new_pixels == 0 )
{
free(pixels);
fclose(pFile);
return 0;
}
gluScaleImage(GL_RGB width height GL_UNSIGNED_BYTE pixelsnew_width new_height GL_UNSIGNED_BYTE new_pixels);
free(pixels);
pixels = new_pixels;
width = new_width;
height = new_height;
}
}
glGenTextures(1 &texture_ID);
if( texture_ID == 0 )
{
free(pixels);
fclose(pFile);
return 0;
}
GLint lastTextureID=last_texture_ID;
glGetIntegerv(GL_TEXTURE_BINDING_2D &lastTextureID);
glBindTexture(GL_TEXTURE_2D texture_ID);
glTexParameteri(GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER GL_LINEAR);
glTexParameteri
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1227654 2019-06-19 08:56 篮球场data3.bmp
文件 2141238 2019-06-20 09:54 篮球场data5.bmp
文件 11338 2019-06-21 11:37 篮球场datac.png
文件 1227654 2019-06-19 08:56 篮球场HomeWorkindata3.bmp
文件 2141238 2019-06-20 09:54 篮球场HomeWorkindata5.bmp
文件 11338 2019-06-21 11:37 篮球场HomeWorkindatac.png
文件 55892 2019-06-27 15:27 篮球场HomeWorkinDebugHomeWork.exe
文件 1447 2019-06-16 12:52 篮球场HomeWorkHomeWork.cbp
文件 5634 2019-06-27 15:22 篮球场HomeWorkHomeWork.depend
文件 362 2019-06-27 15:27 篮球场HomeWorkHomeWork.layout
文件 13019 2019-06-27 15:27 篮球场HomeWorkmain.cpp
文件 23767 2019-06-27 15:27 篮球场HomeWorkobjDebugmain.o
文件 55892 2019-06-27 15:26 篮球场HomeWork.exe
文件 37093523 2019-06-27 14:57 篮球场作品演示.mp4
文件 13019 2019-06-27 15:29 篮球场源码.txt
文件 407384 2019-09-06 11:04 篮球场说明文档.pdf
目录 0 2019-06-27 15:19 篮球场HomeWorkindata
目录 0 2019-06-27 15:27 篮球场HomeWorkinDebug
目录 0 2019-06-27 15:27 篮球场HomeWorkobjDebug
目录 0 2019-06-27 15:19 篮球场HomeWorkin
目录 0 2019-06-27 15:05 篮球场HomeWorkobj
目录 0 2019-06-27 15:26 篮球场data
目录 0 2019-06-27 15:28 篮球场HomeWork
目录 0 2019-09-06 11:04 篮球场
----------- --------- ---------- ----- ----
44430399 24
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)