网易
新闻
微博
邮箱
相册
阅读
有道
摄影
爱拍
云笔记
闪电邮
手机邮
印像派
游戏江湖
更多
博客
手机博客
博客搬家
博客VIP服务
LiveWriter写博
word写博
邮件写博
短信写博
群博客
博客油菜地
博客话题
博客热点
博客圈子
找朋友
发现
小组
风格
网易轻博客LOFTER
创建博客
登录
关注
显示下一条
|
关闭
飞天小猪
小猪飞丫飞丫飞~~~~
导航
首页
日志
相册
音乐
收藏
博友
关于我
日志
OIS鼠标非独占解决方法
Online Judge(OJ)之缓存系统
Ogre手动绘制模型以及添加材质
2010-02-20 09:04:33
| 分类:
Ogre
| 标签:
|
字号
大
中
小
订阅
用Ogre来绘制一个立方体
ManualObject* cube;
cube = mSceneMgr->createManualObject(
"cube"
);
cube->begin(
"cubeMaterial"
);
// 顶点
cube->position( -100, -100, -100);
//0
cube->colour(0.0, 0.0, 0.0);
cube->position( 100, -100, -100);
//1
cube->colour(1.0, 0.0, 0.0);
cube->position( 100, -100, 100);
//2
cube->colour(1.0, 0.0, 1.0);
cube->position( -100, -100, 100);
//3
cube->colour(0.0, 0.0, 1.0);
cube->position( -100, 100, -100);
//4
cube->colour(0.0, 1.0, 0.0);
cube->position( 100, 100, -100);
//5
cube->colour(1.0, 1.0, 0.0);
cube->position( 100, 100, 100);
//6
cube->colour(1.0, 1.0, 1.0);
cube->position( -100, 100, 100);
//7
cube->colour(0.0, 1.0, 1.0);
//
// 索引
cube->triangle(0, 2, 1);
cube->triangle(0, 2, 3);
cube->triangle(3, 4, 0);
cube->triangle(3, 7, 4);
cube->triangle(4, 7, 6);
cube->triangle(4, 6, 5);
cube->triangle(5, 2, 1);
cube->triangle(5, 6, 2);
cube->triangle(0, 4, 1);
cube->triangle(5, 1, 4);
cube->triangle(3, 6, 7);
cube->triangle(3, 2, 6);
cube->end();
SceneNode* sn = mSceneMgr->getRootSceneNode()->createChildSceneNode();
sn->attachObject(cube);
在上个立方体的基础上加上6个贴图
// 创建六个纹理
MaterialPtr material = MaterialManager::getSingletonPtr()->create(
"q"
,
"General"
);
material->getTechnique(0)->getPass(0)->createTextureUnitState(
"q.jpg"
);
material = MaterialManager::getSingletonPtr()->create(
"a"
,
"General"
);
material->getTechnique(0)->getPass(0)->createTextureUnitState(
"a.jpg"
);
material = MaterialManager::getSingletonPtr()->create(
"z"
,
"General"
);
material->getTechnique(0)->getPass(0)->createTextureUnitState(
"z.jpg"
);
material = MaterialManager::getSingletonPtr()->create(
"x"
,
"General"
);
material->getTechnique(0)->getPass(0)->createTextureUnitState(
"x.jpg"
);
material = MaterialManager::getSingletonPtr()->create(
"s"
,
"General"
);
material->getTechnique(0)->getPass(0)->createTextureUnitState(
"s.jpg"
);
material = MaterialManager::getSingletonPtr()->create(
"w"
,
"General"
);
material->getTechnique(0)->getPass(0)->createTextureUnitState(
"w.jpg"
);
ManualObject* cube;
cube = mSceneMgr->createManualObject(
"cube"
);
/
// 下面, begin的第一个参数为要设置的材质名称
cube->begin(
"q"
, RenderOperation::OT_TRIANGLE_FAN);
cube->position( -100, -100, -100);
//0
cube->textureCoord(1, 0);
cube->position( 100, -100, -100);
//1
cube->textureCoord(0, 0);
cube->position( 100, -100, 100);
//2
cube->textureCoord(0, 1);
cube->position( -100, -100, 100);
//3
cube->textureCoord(1, 1);
cube->end();
/
// 左面
cube->begin(
"a"
, RenderOperation::OT_TRIANGLE_FAN);
cube->position( -100, -100, 100);
//3
cube->textureCoord(1, 0);
cube->position( -100, 100, 100);
//7
cube->textureCoord(0, 0);
cube->position( -100, 100, -100);
//4
cube->textureCoord(0, 1);
cube->position( -100, -100, -100);
//0
cube->textureCoord(1, 1);
cube->end();
/
// 上面
cube->begin(
"z"
, RenderOperation::OT_TRIANGLE_FAN);
cube->position( -100, 100, -100);
//4
cube->textureCoord(1, 0);
cube->position( -100, 100, 100);
//7
cube->textureCoord(0, 0);
cube->position( 100, 100, 100);
//6
cube->textureCoord(0, 1);
cube->position( 100, 100, -100);
//5
cube->textureCoord(1, 1);
cube->end();
/
// 右面
cube->begin(
"x"
, RenderOperation::OT_TRIANGLE_FAN);
cube->position( 100, -100, -100);
//1
cube->textureCoord(1, 0);
cube->position( 100, 100, -100);
//5
cube->textureCoord(0, 0);
cube->position( 100, 100, 100);
//6
cube->textureCoord(0, 1);
cube->position( 100, -100, 100);
//2
cube->textureCoord(1, 1);
cube->end();
/
// 前面
cube->begin(
"s"
, RenderOperation::OT_TRIANGLE_FAN);
cube->position( 100, -100, -100);
//1
cube->textureCoord(1, 0);
cube->position( -100, -100, -100);
//0
cube->textureCoord(0, 0);
cube->position( -100, 100, -100);
//4
cube->textureCoord(0, 1);
cube->position( 100, 100, -100);
//5
cube->textureCoord(1, 1);
cube->end();
/
// 后面
cube->begin(
"w"
, RenderOperation::OT_TRIANGLE_FAN);
cube->position( 100, -100, 100);
//2
cube->textureCoord(1, 0);
cube->position( 100, 100, 100);
//6
cube->textureCoord(0, 0);
cube->position( -100, 100, 100);
//7
cube->textureCoord(0, 1);
cube->position( -100, -100, 100);
//3
cube->textureCoord(1, 1);
cube->end();
评论这张
转发至微博
转发至微博
0
人
|
分享到:
阅读(
815
)
|
评论(
0
)
|
引用
(0)
|
举报
OIS鼠标非独占解决方法
Online Judge(OJ)之缓存系统
历史上的今天
相关文章
最近读者
评论
this.p={ m:2, b:2, id:'fks_080067085086084069084094087095093095082068084083083069', blogTitle:'Ogre手动绘制模型以及添加材质', blogAbstract:'用Ogre来绘制一个立方体\r\n\r\n\r\n\r\n
ManualObject* cube;
cube = mSceneMgr->createManualObject(
\"cube\"
);
cube->begin(
\"cubeMaterial\"
);
// 顶点
cube->position( -100, -100, -100);
//0
cube->colour(0.0, 0.0, 0.0);
', blogTag:'', blogUrl:'blog/static/9937055620101209433665', isPublished:1, istop:false, type:1, modifyTime:1266627980272, publishTime:1266627873665, permalink:'blog/static/9937055620101209433665', commentCount:0, mainCommentCount:0, recommendCount:0, bsrk:-100, publisherId:0, recomBlogHome:false, attachmentsFileIds:[], vote:{}, groupInfo:{}, friendstatus:'none', followstatus:'unFollow', pubSucc:'', visitorProvince:'未设置', visitorCity:'未设置', postAddInfo:{}, mset:'000', mcon:'', srk:-100, remindgoodnightblog:false, isBlackVisitor:false, isShowYodaoAd:false, hostIntro:'', hmcon:'', lofter_single:'
' }
{list a as x} {if !!x}
{if x.visitorName==visitor.userName}
{else}
{/if}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
{/if}
${fn(x.visitorNickname,8)|escape}
{/if} {/list}
{if !!a}
${fn(a.nickname,8)|escape}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{/if}
<#--最新日志,群博日志-->
{list a as x} {if !!x}
${fn(x.title,26)|escape}
{/if} {/list}
<#--推荐日志-->
推荐过这篇日志的人:
{list a as x} {if !!x}
${fn(x.recommenderNickname,6)|escape}
{/if} {/list}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y} {if !!y}
·
${y.recommendBlogTitle|escape}
{/if} {/list}
{/if}
<#--引用记录-->
引用记录:
{list d as x}
·
${x.referBlogTitle|escape}
${x.referUserName|escape}
{/list}
<#--博主推荐-->
{list a as x} {if !!x}
${x.title|default:""|escape}
{/if} {/list}
<#--随机阅读-->
{list a as x} {if !!x}
${x.title|default:""|escape}
{/if} {/list}
<#--首页推荐-->
{list a as x} {if !!x}
${x.blogTile|default:""|escape}
{/if} {/list}
<#--相关文章-->
{list a as x} {if x_index>9}{break}{/if} {if !!x}
${x.title|default:""|escape}
${fn2(parseInt(x.date),'yyyy-MM-dd HH:mm:ss')}
{/if} {/list}
<#--历史上的今天-->
{list a as x} {if x_index>4}{break}{/if} {if !!x}
${fn1(x.title,60)|escape}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{/if} {/list}
<#--右边模块结构-->
最新日志
该作者的其他文章
博主推荐
相关日志
随机阅读
首页推荐
更多>>
<#--评论模块结构-->
<#--引用模块结构-->
<#--博主发起的投票-->
{list a as x} {if !!x}
${x.nickName|escape}
投票给 {var first_option = true;} {list x.voteDetailList as voteToOption} {if voteToOption==1} {if first_option==false},{/if} “${b[voteToOption_index]}” {/if} {/list} {if (x.role!="-1") },“我是${c[x.role]}” {/if}
${fn1(x.voteTime)}
{if x.userName==''}{/if} {/if} {/list}
页脚
公司简介
-
联系方法
-
招聘信息
-
客户服务
-
隐私政策
-
博客风格
-
手机博客
-
VIP博客
-
订阅此博客
网易公司版权所有 ©1997-2012
帮助
${u}
{list wl as x}
${x.g}
{list x.l as y}
${y.n}
{/list} {/list}
{if defined('wl')} {list wl as x}
${x.n}
{/list} {/if}
评论