游戏开发论坛

 找回密码
 立即注册
搜索
查看: 10492|回复: 13

OGRE能支持复杂的换装效果吗?(高手进,新手来捧个人场

[复制链接]

35

主题

370

帖子

376

积分

中级会员

Rank: 3Rank: 3

积分
376
发表于 2007-12-24 10:18:00 | 显示全部楼层 |阅读模式
要求:人物中部分mesh换成其他的(好象OGRE中有个subMesh)。每个mesh可以更换纹理。如果修改下源代码就能完成的话(不用修改就更好了!)对机器性能的要求呢?

10

主题

219

帖子

236

积分

中级会员

Rank: 3Rank: 3

积分
236
QQ
发表于 2007-12-25 11:37:00 | 显示全部楼层

Re:OGRE能支持复杂的换装效果吗?(高手进,新手来捧个

每个submesh(subentity)对应了一个材质

0

主题

48

帖子

58

积分

注册会员

Rank: 2

积分
58
发表于 2008-1-4 16:05:00 | 显示全部楼层

Re:OGRE能支持复杂的换装效果吗?(高手进,新手来捧个

千万别修改原代码

25

主题

104

帖子

104

积分

注册会员

Rank: 2

积分
104
发表于 2008-1-8 21:31:00 | 显示全部楼层

Re:OGRE能支持复杂的换装效果吗?(高手进,新手来捧个

我在Ogre官方论坛看到的同样问题,对你可能有帮助:
Q:
I am currently working on the equipping technique for the characters in our game. Regarding the paint-on-armor(cloth leather chain) it is rather easy by assigning different materials to the desired SubEntities. For the modelled armor pieces like plate armor I am a little bit stuck now, I have searched around on the boards and in the wiki but cannot find the real clue. Attaching to bone doesnt seem to be a good option.

Is it possible to load a different mesh into a submesh and how does it work? Should I load all the gear in one go from the start and set the SubEntities to invisible untill i need them or what would be the best method to change the equipment on a game-character?

Thanks in advance

A:You're on the right track.

Attaching to bones is not the way to go for clothing. It works well for equipment (guns, swords, etc) and maybe some accesories (hat, holster, etc) but woul dnot work well for armour.

Building your model with all conceivable geometries (leather vs plate vs robe) in seperate subentities and then enabling/disabling as needed is a good way to go. A lot of games go this way.

You could also building your character out of components (leather torso vs plate torso vs robe torso) and attach/assembled limbs and heads as needed. A lot of game go this way (probably more than above).

Each has pros and cons. The first has some more overhead in terms of animation and vert/poly counts -- not sure how "smart" OGRE is in ignoring/optimising invisible subentities (but I would guess pretty smart).

The second way can be harder in terms of managing animation (crashing polys, seams, etc), but has some added benefits in terms of being able to easily detach components (i.e. decapitation and dismemberment), plus customizability options may be easier to do.

If you want something fast/eas(ish), go with 1. If you want something a little more robust/extensible, go with two.

A:
You can't "swap" them but you can set them visible/invisible using

entity->getSubEntity(0)->setVisible(false);

You could do it this way if you have a low number of combinations, but it's a bad idea if you have hundreds of pieces of clothing. With a few pieces, it's a decent idea though.

If you have lots of combinations, I think your best bet is to have a base character mesh, with bones and skeleton, animations, etc. Then have additional pieces that you share the skeleton with.

So for example, if a naked character is ok for your base mesh, use it. Let's say you want your character wearing armor. You'd model your armor in your 3d program and bind it to the same skeleton structure as your base mesh. All bones have to exist with the same names, positions and orientations.

Then in Ogre you can use:

entity->shareSkeletonInstanceWith(otherEntity);

That means as one animates, it animates both at the same time. I got this working through a bit of trial and error. I can't remember the problems I had but they were minor.

In the end, for a full system, you probably need a combination of the following:

1. Attaching certain pieces to bones
2. Sharing the skeleton between some pieces
3. Attaching equipment to the same scene node as the base mesh and playing the same animation name. For example, let's say you have a robe that has special animation for the robe cloth, you can't use #2 because it'll have different bones and special skeletal animation.

Anyhow, good luck. Also you should look into the Ogre files yourself - you could have found the answer to the SubEntity->setVisible problem in like 2 seconds.

35

主题

370

帖子

376

积分

中级会员

Rank: 3Rank: 3

积分
376
 楼主| 发表于 2008-1-8 23:26:00 | 显示全部楼层

Re:OGRE能支持复杂的换装效果吗?(高手进,新手来捧个

谢谢楼上的,仔细研读中

35

主题

370

帖子

376

积分

中级会员

Rank: 3Rank: 3

积分
376
 楼主| 发表于 2008-1-8 23:48:00 | 显示全部楼层

Re:OGRE能支持复杂的换装效果吗?(高手进,新手来捧个

和我想的差不多呵呵,可能还有些细节问题,大家能告诉我吗~

34

主题

236

帖子

236

积分

中级会员

Rank: 3Rank: 3

积分
236
发表于 2008-1-15 17:13:00 | 显示全部楼层

Re:OGRE能支持复杂的换装效果吗?(高手进,新手来捧个

使用多维材质

0

主题

3

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2008-1-21 13:28:00 | 显示全部楼层

Re:OGRE能支持复杂的换装效果吗?(高手进,新手来捧个

Ogre::Mesh里面有一个mSubMeshNameMap,只要你找到对应的Iterator把它删掉,然后再加入你想换上的SubMesh就行了啊!不过你要重建一下SubEntityList,不然会出错的!

10

主题

219

帖子

236

积分

中级会员

Rank: 3Rank: 3

积分
236
QQ
发表于 2008-1-22 11:04:00 | 显示全部楼层

Re: Re:OGRE能支持复杂的换装效果吗?(高手进,新手来捧

andyjiang: Re:OGRE能支持复杂的换装效果吗?(高手进,新手来捧个人场!)

Ogre::Mesh里面有一个mSubMeshNameMap,只要你找到对应的Iterator把它删掉,然后再加入你想换上的SubMesh就行...


你试过这样做了吗?这样效率超低,换装是个很频繁调用的过程

0

主题

3

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2008-1-25 13:20:00 | 显示全部楼层

Re:OGRE能支持复杂的换装效果吗?(高手进,新手来捧个

这样效率会低多少呢?我们的项目中就是这么做的并没有低多少啊!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-21 05:44

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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