//
// cocos2d (incomplete) GLU implementation
//
// gluLookAt and gluPerspective from:
// http://jet.ro/creations (San Angeles Observation)
//
//
#import <OpenGLES/ES1/gl.h>
#import <math.h>
#import "OpenGL_Internal.h"
#include "glu.h"
void gluPerspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar)
{
GLfloat xmin, xmax, ymin, ymax;
ymax = zNear * (GLfloat)tanf(fovy * (float)M_PI / 360);
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;
glFrustumf(xmin, xmax,
ymin, ymax,
zNear, zFar);
}
void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez,
GLfloat centerx, GLfloat centery, GLfloat centerz,
GLfloat upx, GLfloat upy, GLfloat upz)
{
GLfloat m[16];
GLfloat x[3], y[3], z[3];
GLfloat mag;
/* Make rotation matrix */
/* Z vector */
z[0] = eyex - centerx;
z[1] = eyey - centery;
z[2] = eyez - centerz;
mag = (float)sqrtf(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);
if (mag) {
z[0] /= mag;
z[1] /= mag;
z[2] /= mag;
}
/* Y vector */
y[0] = upx;
y[1] = upy;
y[2] = upz;
/* X vector = Y cross Z */
x[0] = y[1] * z[2] - y[2] * z[1];
x[1] = -y[0] * z[2] + y[2] * z[0];
x[2] = y[0] * z[1] - y[1] * z[0];
/* Recompute Y = Z cross X */
y[0] = z[1] * x[2] - z[2] * x[1];
y[1] = -z[0] * x[2] + z[2] * x[0];
y[2] = z[0] * x[1] - z[1] * x[0];
/* cross product gives area of parallelogram, which is < 1.0 for
* non-perpendicular unit-length vectors; so normalize x, y here
*/
mag = (float)sqrtf(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
if (mag) {
x[0] /= mag;
x[1] /= mag;
x[2] /= mag;
}
mag = (float)sqrtf(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);
if (mag) {
y[0] /= mag;
y[1] /= mag;
y[2] /= mag;
}
#define M(row,col) m[col*4+row]
M(0, 0) = x[0];
M(0, 1) = x[1];
M(0, 2) = x[2];
M(0, 3) = 0.0f;
M(1, 0) = y[0];
M(1, 1) = y[1];
M(1, 2) = y[2];
M(1, 3) = 0.0f;
M(2, 0) = z[0];
M(2, 1) = z[1];
M(2, 2) = z[2];
M(2, 3) = 0.0f;
M(3, 0) = 0.0f;
M(3, 1) = 0.0f;
M(3, 2) = 0.0f;
M(3, 3) = 1.0f;
#undef M
glMultMatrixf(m);
/* Translate Eye to Origin */
glTranslatef(-eyex, -eyey, -eyez);
}
没有合适的资源?快使用搜索试试~ 我知道了~
cocos2d 游戏例子
共283个文件
h:132个
m:83个
cpp:35个
需积分: 9 5 下载量 135 浏览量
2011-07-16
10:13:55
上传
评论
收藏 1.82MB ZIP 举报
温馨提示
这是一个很好的入门游戏,动画播放,碰撞处理,怪物清除
资源推荐
资源详情
资源评论
收起资源包目录
cocos2d 游戏例子 (283个子文件)
glu.c 2KB
base64.c 2KB
LICENSE.cocos2d 890B
LICENSE.cocosdenshion 1KB
control 256KB
b2World.cpp 23KB
b2ContactSolver.cpp 17KB
b2PrismaticJoint.cpp 15KB
b2LineJoint.cpp 14KB
b2Island.cpp 12KB
b2Distance.cpp 12KB
b2RevoluteJoint.cpp 12KB
b2TimeOfImpact.cpp 11KB
b2PolygonShape.cpp 10KB
b2PulleyJoint.cpp 10KB
b2Body.cpp 10KB
b2CollidePolygon.cpp 8KB
b2DynamicTree.cpp 8KB
b2GearJoint.cpp 7KB
b2Contact.cpp 6KB
b2WeldJoint.cpp 6KB
b2TOISolver.cpp 6KB
b2Collision.cpp 6KB
b2ContactManager.cpp 6KB
b2FrictionJoint.cpp 6KB
b2DistanceJoint.cpp 6KB
b2MouseJoint.cpp 5KB
b2BlockAllocator.cpp 5KB
b2Joint.cpp 4KB
b2CollideCircle.cpp 4KB
b2Fixture.cpp 4KB
b2BroadPhase.cpp 3KB
b2CircleShape.cpp 3KB
b2PolygonAndCircleContact.cpp 2KB
b2PolygonContact.cpp 2KB
b2StackAllocator.cpp 2KB
b2CircleContact.cpp 2KB
b2Math.cpp 2KB
b2WorldCallbacks.cpp 2KB
b2Settings.cpp 1KB
.DS_Store 6KB
b2Body.h 21KB
CCCompatibility.h 15KB
b2Math.h 14KB
CCNode.h 13KB
CCDirector.h 12KB
CCIntervalAction.h 12KB
ccArray.h 12KB
CDOpenALSupport.h 11KB
CCSprite.h 10KB
CCTexture2D.h 9KB
b2World.h 9KB
b2Fixture.h 8KB
CDAudioManager.h 8KB
CCMenuItem.h 8KB
CocosDenshion.h 8KB
b2Collision.h 8KB
CCParticleSystem.h 8KB
b2WorldCallbacks.h 8KB
CCTransition.h 7KB
b2DynamicTree.h 7KB
b2Contact.h 7KB
b2BroadPhase.h 6KB
EAGLView.h 6KB
CCTiledGridAction.h 6KB
CCGrid3DAction.h 6KB
b2Joint.h 5KB
b2RevoluteJoint.h 5KB
b2Settings.h 5KB
b2PrismaticJoint.h 5KB
CGPointExtension.h 5KB
b2LineJoint.h 5KB
CCEaseAction.h 5KB
ccHashSet.h 4KB
CCTMXXMLParser.h 4KB
CCGridAction.h 4KB
CCTextureAtlas.h 4KB
OpenGL_Internal.h 4KB
CCTMXTiledMap.h 4KB
b2PulleyJoint.h 4KB
ccTypes.h 4KB
CCLayer.h 4KB
CCBitmapFontAtlas.h 4KB
CCTMXLayer.h 4KB
CCSpriteSheet.h 4KB
CCProtocols.h 4KB
FontLabelStringDrawing.h 4KB
b2PolygonShape.h 4KB
b2DistanceJoint.h 4KB
CCTextureCache.h 4KB
ccConfig.h 4KB
b2Distance.h 4KB
CCAction.h 4KB
CCSpriteFrame.h 4KB
CLScoreServerRequest.h 3KB
CLScoreServerPost.h 3KB
b2MouseJoint.h 3KB
FontManager.h 3KB
CCSpriteFrameCache.h 3KB
b2Shape.h 3KB
共 283 条
- 1
- 2
- 3
资源评论
sen8878059
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Python 程序语言设计模式思路-行为型模式:职责链模式:将请求从一个处理者传递到下一个处理者
- 9241703124789646.16健身系统2.apk
- postgresql-16.3-1-windows-x64.exe
- Python 程序语言设计模式思路-结构型模式:装饰器讲解及利用Python装饰器模式实现高效日志记录和性能测试
- 基于YOLOv5和DeepSORT的多目标跟踪仿真与记录
- Python 程序语言设计模式思路-创建型模式:原型模式:通过复制现有对象来创建新对象,面向对象编程
- 卸载软件geek卸载软件geek
- Python 程序语言设计模式思路-创建型模式:单例模式,确保一个类的唯一实例(装饰器)面向对象编程、继承
- skywalking-plugins.jar skywalking-alarm.jar
- 独栋别墅图纸D020-两层-10.00&11.00米- 施工图.dwg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功