如何翻转 CC3PlaneNode 上的纹理?

发布于 2024-12-02 17:37:15 字数 1056 浏览 0 评论 0原文

我正在创建一个 CC3PlaneNode (cocos3d),其代码如下所示:

CC3PlaneNode *bnode = [CC3PlaneNode nodeWithName: name];
CC3Texture *texture = [CC3Texture textureFromFile: texName];
[bnode populateAsCenteredRectangleWithSize: sz
                           andTessellation: ccg(1, 1)
                               withTexture: texture
                             invertTexture: YES];
bnode.material.specularColor = kCCC4FLightGray;
bnode.material.emissionColor = kCCC4FWhite;
bnode.material.isOpaque = NO;
bnode.shouldCullBackFaces = NO;
bnode.isTouchEnabled = YES;
bnode.location = loc;
[bnode retainVertexLocations];

在某些情况下,我希望平面显示其纹理的镜像(a la 上的水平翻转功能)许多图像程序。)我不只是想翻转飞机本身,因为这会导致它的所有子节点错位,这是不良行为。

也就是说,如果 X & Y 是我的纹理的一部分,“c”和“c'”是该图中的子节点:

+--------+
|        |
|  x   y |
|        |
+--------+
 c      c'

翻转后,我希望事情看起来像这样:

+--------+
|        |
|  y   x |
|        |
+--------+
 c      c'

除了不想旋转/自旋/翻转平面本身之外,否则我对解决方案非常灵活。

有什么提示吗?

谢谢!

I'm creating a CC3PlaneNode (cocos3d) with code that looks something like this:

CC3PlaneNode *bnode = [CC3PlaneNode nodeWithName: name];
CC3Texture *texture = [CC3Texture textureFromFile: texName];
[bnode populateAsCenteredRectangleWithSize: sz
                           andTessellation: ccg(1, 1)
                               withTexture: texture
                             invertTexture: YES];
bnode.material.specularColor = kCCC4FLightGray;
bnode.material.emissionColor = kCCC4FWhite;
bnode.material.isOpaque = NO;
bnode.shouldCullBackFaces = NO;
bnode.isTouchEnabled = YES;
bnode.location = loc;
[bnode retainVertexLocations];

Under certain circumstances, I'd like the plane to display the mirror image of its texture (a la the Flip Horizontal feature on many image programs.) I don't just want to flip the plane, itself, because that would throw out-of-position all of it's child-nodes, which is undesirable behaviour.

That is, if X & Y are parts of my texture, and "c" and "c'" are child-nodes in this diagram:

+--------+
|        |
|  x   y |
|        |
+--------+
 c      c'

after the flip, I want things to look like this:

+--------+
|        |
|  y   x |
|        |
+--------+
 c      c'

Other than not wanting to rotate/spin/flip the plane, itself, I'm otherwise pretty flexible on a solution.

Any hints?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文