zoukankan      html  css  js  c++  java
  • [Ogre]纹理设置

    MaterialPtr material= MaterialManager::getSingleton().create("name",“ResourcesGroupName”);
    material->getTechnique(0)->getPass(0)->createTextureUnitState(”TextureFilename“);

    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();

  • 相关阅读:
    mybais 的映射文件,需要从poviderDao.java 的一个 方法 public getProvidersFactors(参数 ) 中传入多个参数到providerDao.xml中的两种方法
    mybatis映射文件,当从XXXDao.java中传入的参数是一个对象Provider的时候,那在XXXDao.xml中的Provider的属性id的时候需要怎么写
    AJAX概念及作用。 JQuery中关于AJAX的几个常用的函数
    js代码中的parent,top和self有什么区别
    JS window对象的top、parent、opener含义介绍
    登录为什么登陆什么都要验证码?验证码有什么用?没有验证码之后会有什么危害
    关于重定向RedirectAttributes的用法
    HTML meta标签总结与属性使用介绍 ,超详细,代例子
    jsp页面中的:<%@ page contentType="text/html; charset=utf-8" language="java"%>的作用及含义,超详细!
    mybatis和Dao映射的配置文件xml,中什么时候需要用resultType .什么时候用resultMap,及resultType和resultMap的区别
  • 原文地址:https://www.cnblogs.com/lyggqm/p/5548901.html
Copyright © 2011-2022 走看看