IManualObject cube;
cube = sceneMgr.createManualObject("cube");
cube.begin("Examples/Anchor", OperationType.OT_TRIANGLE_LIST);
// 顶点
cube.position( -100, -100, -100); //0
cube.position( 100, -100, -100); //1
cube.position( 100, -100, 100); //2
cube.position( -100, -100, 100); //3
cube.position( -100, 100, -100); //4
cube.position( 100, 100, -100); //5
cube.position( 100, 100, 100); //6
cube.position( -100, 100, 100); //7
索引
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();
ISceneNode sn = sceneMgr.getRootSceneNode().createChildSceneNode(Vector3.getZERO(), Quaternion.getIDENTITY());
sn.attachObject(cube);
贴6个不同纹理的立方体
IManualObject cube;
cube = sceneMgr.createManualObject("cube");
/// 下面, begin的第一个参数为要设置的材质名称
cube.begin("Examples/Anchor1", OperationType.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("Examples/Anchor2", OperationType.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("Examples/Anchor3", OperationType.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("Examples/Anchor4", OperationType.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("Examples/Anchor5", OperationType.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("Examples/Anchor6", OperationType.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();
ISceneNode sn = sceneMgr.getRootSceneNode().createChildSceneNode(
Vector3.getZERO(), Quaternion.getIDENTITY());
sn.attachObject(cube);
创建立方体
最新推荐文章于 2024-09-07 15:37:11 发布