//
// 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);
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
iOS虚拟手柄 SneakyInput 例程 (229个子文件)
glu.c 2KB
base64.c 2KB
LICENSE.cocos2d 1KB
LICENSE.cocosdenshion 1KB
.DS_Store 6KB
.DS_Store 6KB
.gitignore 7B
uthash.h 63KB
utlist.h 36KB
CCDirector.h 16KB
CCNode.h 16KB
CCCompatibility.h 14KB
CCParticleSystem.h 14KB
CocosDenshion.h 13KB
CCIntervalAction.h 13KB
CCMenuItem.h 12KB
ccCArray.h 12KB
CCSprite.h 12KB
CCTexture2D.h 10KB
CDAudioManager.h 9KB
CCTransition.h 8KB
CGPointExtension.h 8KB
ccConfig.h 7KB
CCTiledGridAction.h 7KB
CCGrid3DAction.h 6KB
CCScheduler.h 6KB
EAGLView.h 6KB
CCTMXLayer.h 6KB
CCSpriteSheet.h 6KB
ccMacros.h 6KB
CCEaseAction.h 6KB
CCAction.h 6KB
ccTypes.h 6KB
CCTMXXMLParser.h 5KB
CCBitmapFontAtlas.h 5KB
CCTMXTiledMap.h 5KB
CCGridAction.h 5KB
CCTextureAtlas.h 5KB
CCSpriteFrame.h 5KB
CCLayer.h 5KB
CCTextureCache.h 5KB
OpenGL_Internal.h 4KB
CCInstantAction.h 4KB
CLScoreServerRequest.h 4KB
CLScoreServerPost.h 4KB
CCActionManager.h 4KB
CCSpriteFrameCache.h 4KB
CCRibbon.h 4KB
CCTouchDispatcher.h 4KB
FontLabelStringDrawing.h 4KB
SimpleAudioEngine.h 4KB
cocos2d.h 4KB
CCGrid.h 4KB
CCProtocols.h 4KB
CDOpenALSupport.h 3KB
FontManager.h 3KB
CCPVRTexture.h 3KB
CCTouchHandler.h 3KB
CCArray.h 3KB
CCAtlasNode.h 3KB
ZAttributedString.h 3KB
CCTileMapAtlas.h 3KB
CCCamera.h 3KB
CCProgressTimer.h 3KB
CCMotionStreak.h 3KB
CCDrawingPrimitives.h 3KB
CCMenu.h 3KB
CCTouchDelegateProtocol.h 3KB
CDConfig.h 3KB
CCConfiguration.h 3KB
CCRenderTexture.h 3KB
CCLabel.h 3KB
CCCameraAction.h 2KB
CCQuadParticleSystem.h 2KB
CCLabelAtlas.h 2KB
CDataScanner.h 2KB
CCPropertyAction.h 2KB
CCPageTurnTransition.h 2KB
CCTMXObjectGroup.h 2KB
CCParticleExamples.h 2KB
CCProgressTimerActions.h 2KB
CCBlockSupport.h 2KB
CJSONDeserializer.h 2KB
CCPointParticleSystem.h 2KB
CCParallaxNode.h 2KB
ES1Renderer.h 2KB
CJSONScanner.h 2KB
FontLabel.h 2KB
CCProfiling.h 2KB
SneakyJoystick.h 2KB
CCScene.h 2KB
CJSONSerializer.h 2KB
ZFont.h 2KB
CCPageTurn3DAction.h 2KB
NSScanner_Extensions.h 2KB
ESRenderer.h 1KB
CCGrabber.h 1KB
CCRadialTransition.h 1KB
cocoslive.h 1KB
CDataScanner_Extensions.h 1KB
共 229 条
- 1
- 2
- 3
资源评论
- yy55yyo32013-08-27不错,简单易懂,需要做游戏的朋友值得推荐
- wcx8609222013-04-18最近需要这方面知识,看了一下,很详细,适合新手。
- 三三三牛2013-09-255分啦 免费的还那么好 不错
- sujiaxiaoyu2014-07-31可以当作原型研究,有编译不过的地方直接注释掉了
freshman13
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功