/************ * * This file is part of a tool for producing 3D content in the PRC format. * Copyright (C) 2008 Orest Shardt and * Michail Vidiassov * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * *************/ #include "include/prc/oPRCFile.h" #include #include #include #include #include using namespace std; extern const double pi; int main() { #if 0 // List of pictures used; keep track of memory allocated to free it in the end // shared pointers or garbage collector may be an alternative uint8_t *picture1 = NULL; uint8_t *picture2 = NULL; uint8_t *picture3 = NULL; uint8_t *picture4 = NULL; oPRCFile file("test.prc"); const size_t N_COLOURS = 32; RGBAColour colours[N_COLOURS]; for(size_t i = 0; i < N_COLOURS; ++i) { colours[i%N_COLOURS].R = 0.0; colours[i%N_COLOURS].G = (i%N_COLOURS)/static_cast(N_COLOURS); colours[i%N_COLOURS].B = 0.95; colours[i%N_COLOURS].A = 0.75; } PRCmaterial materials[N_COLOURS]; for(size_t i = 0; i < N_COLOURS; ++i) { materials[i%N_COLOURS].diffuse.R = 0.0; materials[i%N_COLOURS].diffuse.G = (i%N_COLOURS)/static_cast(N_COLOURS); materials[i%N_COLOURS].diffuse.B = 0.95; materials[i%N_COLOURS].diffuse.A = 0.75; materials[i%N_COLOURS].specular.R = 0.01*0.0; materials[i%N_COLOURS].specular.G = 0.01*(i%N_COLOURS)/static_cast(N_COLOURS); materials[i%N_COLOURS].specular.B = 0.01*0.95; materials[i%N_COLOURS].specular.A = 0.01*0.75; materials[i%N_COLOURS].emissive.R = 0.20*0.0; materials[i%N_COLOURS].emissive.G = 0.20*(i%N_COLOURS)/static_cast(N_COLOURS); materials[i%N_COLOURS].emissive.B = 0.20*0.95; materials[i%N_COLOURS].emissive.A = 0.20*0.75; materials[i%N_COLOURS].ambient.R = 0.05*0.0; materials[i%N_COLOURS].ambient.G = 0.05*(i%N_COLOURS)/static_cast(N_COLOURS); materials[i%N_COLOURS].ambient.B = 0.05*0.95; materials[i%N_COLOURS].ambient.A = 0.05*0.75; materials[i%N_COLOURS].alpha = 0.75; materials[i%N_COLOURS].shininess = 0.1; } if(1) { double knotsU[] = {1,1,1,1,2,2,2,2}; double knotsV[] = {1,1,1,1,2,2,2,2}; const size_t NUMBER_OF_PATCHES = 32; double controlPoints[NUMBER_OF_PATCHES][16][3] = { { // Patch 0 {1.4,0,2.4},{1.4,-0.784,2.4},{0.784,-1.4,2.4},{0,-1.4,2.4}, {1.3375,0,2.53125},{1.3375,-0.749,2.53125},{0.749,-1.3375,2.53125},{0,-1.3375,2.53125}, {1.4375,0,2.53125},{1.4375,-0.805,2.53125},{0.805,-1.4375,2.53125},{0,-1.4375,2.53125}, {1.5,0,2.4},{1.5,-0.84,2.4},{0.84,-1.5,2.4},{0,-1.5,2.4}, }, { // Patch 1 {0,-1.4,2.4},{-0.784,-1.4,2.4},{-1.4,-0.784,2.4},{-1.4,0,2.4}, {0,-1.3375,2.53125},{-0.749,-1.3375,2.53125},{-1.3375,-0.749,2.53125},{-1.3375,0,2.53125}, {0,-1.4375,2.53125},{-0.805,-1.4375,2.53125},{-1.4375,-0.805,2.53125},{-1.4375,0,2.53125}, {0,-1.5,2.4},{-0.84,-1.5,2.4},{-1.5,-0.84,2.4},{-1.5,0,2.4}, }, { // Patch 2 {-1.4,0,2.4},{-1.4,0.784,2.4},{-0.784,1.4,2.4},{0,1.4,2.4}, {-1.3375,0,2.53125},{-1.3375,0.749,2.53125},{-0.749,1.3375,2.53125},{0,1.3375,2.53125}, {-1.4375,0,2.53125},{-1.4375,0.805,2.53125},{-0.805,1.4375,2.53125},{0,1.4375,2.53125}, {-1.5,0,2.4},{-1.5,0.84,2.4},{-0.84,1.5,2.4},{0,1.5,2.4}, }, { // Patch 3 {0,1.4,2.4},{0.784,1.4,2.4},{1.4,0.784,2.4},{1.4,0,2.4}, {0,1.3375,2.53125},{0.749,1.3375,2.53125},{1.3375,0.749,2.53125},{1.3375,0,2.53125}, {0,1.4375,2.53125},{0.805,1.4375,2.53125},{1.4375,0.805,2.53125},{1.4375,0,2.53125}, {0,1.5,2.4},{0.84,1.5,2.4},{1.5,0.84,2.4},{1.5,0,2.4}, }, { // Patch 4 {1.5,0,2.4},{1.5,-0.84,2.4},{0.84,-1.5,2.4},{0,-1.5,2.4}, {1.75,0,1.875},{1.75,-0.98,1.875},{0.98,-1.75,1.875},{0,-1.75,1.875}, {2,0,1.35},{2,-1.12,1.35},{1.12,-2,1.35},{0,-2,1.35}, {2,0,0.9},{2,-1.12,0.9},{1.12,-2,0.9},{0,-2,0.9}, }, { // Patch 5 {0,-1.5,2.4},{-0.84,-1.5,2.4},{-1.5,-0.84,2.4},{-1.5,0,2.4}, {0,-1.75,1.875},{-0.98,-1.75,1.875},{-1.75,-0.98,1.875},{-1.75,0,1.875}, {0,-2,1.35},{-1.12,-2,1.35},{-2,-1.12,1.35},{-2,0,1.35}, {0,-2,0.9},{-1.12,-2,0.9},{-2,-1.12,0.9},{-2,0,0.9}, }, { // Patch 6 {-1.5,0,2.4},{-1.5,0.84,2.4},{-0.84,1.5,2.4},{0,1.5,2.4}, {-1.75,0,1.875},{-1.75,0.98,1.875},{-0.98,1.75,1.875},{0,1.75,1.875}, {-2,0,1.35},{-2,1.12,1.35},{-1.12,2,1.35},{0,2,1.35}, {-2,0,0.9},{-2,1.12,0.9},{-1.12,2,0.9},{0,2,0.9}, }, { // Patch 7 {0,1.5,2.4},{0.84,1.5,2.4},{1.5,0.84,2.4},{1.5,0,2.4}, {0,1.75,1.875},{0.98,1.75,1.875},{1.75,0.98,1.875},{1.75,0,1.875}, {0,2,1.35},{1.12,2,1.35},{2,1.12,1.35},{2,0,1.35}, {0,2,0.9},{1.12,2,0.9},{2,1.12,0.9},{2,0,0.9}, }, { // Patch 8 {2,0,0.9},{2,-1.12,0.9},{1.12,-2,0.9},{0,-2,0.9}, {2,0,0.45},{2,-1.12,0.45},{1.12,-2,0.45},{0,-2,0.45}, {1.5,0,0.225},{1.5,-0.84,0.225},{0.84,-1.5,0.225},{0,-1.5,0.225}, {1.5,0,0.15},{1.5,-0.84,0.15},{0.84,-1.5,0.15},{0,-1.5,0.15}, }, { // Patch 9 {0,-2,0.9},{-1.12,-2,0.9},{-2,-1.12,0.9},{-2,0,0.9}, {0,-2,0.45},{-1.12,-2,0.45},{-2,-1.12,0.45},{-2,0,0.45}, {0,-1.5,0.225},{-0.84,-1.5,0.225},{-1.5,-0.84,0.225},{-1.5,0,0.225}, {0,-1.5,0.15},{-0.84,-1.5,0.15},{-1.5,-0.84,0.15},{-1.5,0,0.15}, }, { // Patch 10 {-2,0,0.9},{-2,1.12,0.9},{-1.12,2,0.9},{0,2,0.9}, {-2,0,0.45},{-2,1.12,0.45},{-1.12,2,0.45},{0,2,0.45}, {-1.5,0,0.225},{-1.5,0.84,0.225},{-0.84,1.5,0.225},{0,1.5,0.225}, {-1.5,0,0.15},{-1.5,0.84,0.15},{-0.84,1.5,0.15},{0,1.5,0.15}, }, { // Patch 11 {0,2,0.9},{1.12,2,0.9},{2,1.12,0.9},{2,0,0.9}, {0,2,0.45},{1.12,2,0.45},{2,1.12,0.45},{2,0,0.45}, {0,1.5,0.225},{0.84,1.5,0.225},{1.5,0.84,0.225},{1.5,0,0.225}, {0,1.5,0.15},{0.84,1.5,0.15},{1.5,0.84,0.15},{1.5,0,0.15}, }, { // Patch 12 {-1.6,0,2.025},{-1.6,-0.3,2.025},{-1.5,-0.3,2.25},{-1.5,0,2.25}, {-2.3,0,2.025},{-2.3,-0.3,2.025},{-2.5,-0.3,2.25},{-2.5,0,2.25}, {-2.7,0,2.025},{-2.7,-0.3,2.025},{-3,-0.3,2.25},{-3,0,2.25}, {-2.7,0,1.8},{-2.7,-0.3,1.8},{-3,-0.3,1.8},{-3,0,1.8}, }, { // Patch 13 {-1.5,0,2.25},{-1.5,0.3,2.25},{-1.6,0.3,2.025},{-1.6,0,2.025}, {-2.5,0,2.25},{-2.5,0.3,2.25},{-2.3,0.3,2.025},{-2.3,0,2.025}, {-3,0,2.25},{-3,0.3,2.25},{-2.7,0.3,2.025},{-2.7,0,2.025}, {-3,0,1.8},{-3,0.3,1.8},{-2.7,0.3,1.8},{-2.7,0,1.8}, }, { // Patch 14 {-2.7,0,1.8},{-2.7,-0.3,1.8},{-3,-0.3,1.8},{-3,0,1.8}, {-2.7,0,1.575},{-2.7,-0.3,1.575},{-3,-0.3,1.35},{-3,0,1.35}, {-2.5,0,1.125},{-2.5,-0.3,1.125},{-2.65,-0.3,0.9375},{-2.65,0,0.9375}, {-2,0,0.9},{-2,-0.3,0.9},{-1.9,-0.3,0.6},{-1.9,0,0.6}, }, { // Patch 15 {-3,0,1.8},{-3,0.3,1.8},{-2.7,0.3,1.8},{-2.7,0,1.8}, {-3,0,1.35},{-3,0.3,1.35},{-2.7,0.3,1.575},{-2.7,0,1.575}, {-2.65,0,0.9375},{-2.65,0.3,0.9375},{-2.5,0.3,1.125},{-2.5,0,1.125}, {-1.9,0,0.6},{-1.9,0.3,0.6},{-2,0.3,0.9},{-2,0,0.9}, }, { // Patch 16 {1.7,0,1.425},{1.7,-0.66,1.425},{1.7,-0.66,0.6},{1.7,0,0.6}, {2.6,0,1.425},{2.6,-0.66,1.425},{3.1,-0.66,0.825},{3.1,0,0.825}, {2.3,0,2.1},{2.3,-0.25,2.1},{2.4,-0.25,2.025},{2.4,0,2.025}, {2.7,0,2.4},{2.7,-0.25,2.4},{3.3,-0.25,2.4},{3.3,0,2.4}, }, { // Patch 17 {1.7,0,0.6},{1.7,0.66,0.6},{1.7,0.66,1.425},{1.7,0,1.425}, {3.1,0,0.825},{3.1,0.66,0.825},{2.6,0.66,1.425},{2.6,0,1.425}, {2.4,0,2.025},{2.4,0.25,2.025},{2.3,0.25,2.1},{2.3,0,2.1}, {3.3,0,2.4},{3.3,0.25,2.4},{2.7,0.25,2.4},{2.7,0,2.4}, }, { // Patch 18 {2.7,0,2.4},{2.7,-0.25,2.4},{3.3,-0.25,2.4},{3.3,0,2.4}, {2.8,0,2.475},{2.8,-0.25,2.475},{3.525,-0.25,2.49375},{3.525,0,2.49375}, {2.9,0,2.475},{2.9,-0.15,2.475},{3.45,-0.15,2.5125},{3.45,0,2.5125}, {2.8,0,2.4},{2.8,-0.15,2.4},{3.2,-0.15,2.4},{3.2,0,2.4}, }, { // Patch 19 {3.3,0,2.4},{3.3,0.25,2.4},{2.7,0.25,2.4},{2.7,0,2.4}, {3.525,0,2.49375},{3.525,0.25,2.49375},{2.8,0.25,2.475},{2.8,0,2.475}, {3.45,0,2.5125},{3.45,0.15,2.5125},{2.9,0.15,2.475},{2.9,0,2.475}, {3.2,0,2.4},{3.2,0.15,2.4},{2.8,0.15,2.4},{2.8,0,2.4}, }, { // Patch 20 {0,0,3.15},{0,0,3.15},{0,0,3.15},{0,0,3.15}, {0.8,0,3.15},{0.8,-0.45,3.15},{0.45,-0.8,3.15},{0,-0.8,3.15}, {0,0,2.85},{0,0,2.85},{0,0,2.85},{0,0,2.85}, {0.2,0,2.7},{0.2,-0.112,2.7},{0.112,-0.2,2.7},{0,-0.2,2.7}, }, { // Patch 21 {0,0,3.15},{0,0,3.15},{0,0,3.15},{0,0,3.15}, {0,-0.8,3.15},{-0.45,-0.8,3.15},{-0.8,-0.45,3.15},{-0.8,0,3.15}, {0,0,2.85},{0,0,2.85},{0,0,2.85},{0,0,2.85}, {0,-0.2,2.7},{-0.112,-0.2,2.7},{-0.2,-0.112,2.7},{-0.2,0,2.7}, }, { // Patch 22 {0,0,3.15},{0,0,3.15},{0,0,3.15},{0,0,3.15}, {-0.8,0,3.15},{-0.8,0.45,3.15},{-0.45,0.8,3.15},{0,0.8,3.15}, {0,0,2.85},{0,0,2.85},{0,0,2.85},{0,0,2.85}, {-0.2,0,2.7},{-0.2,0.112,2.7},{-0.112,0.2,2.7},{0,0.2,2.7}, }, { // Patch 23 {0,0,3.15},{0,0,3.15},{0,0,3.15},{0,0,3.15}, {0,0.8,3.15},{0.45,0.8,3.15},{0.8,0.45,3.15},{0.8,0,3.15}, {0,0,2.85},{0,0,2.85},{0,0,2.85},{0,0,2.85}, {0,0.2,2.7},{0.112,0.2,2.7},{0.2,0.112,2.7},{0.2,0,2.7}, }, { // Patch 24 {0.2,0,2.7},{0.2,-0.112,2.7},{0.112,-0.2,2.7},{0,-0.2,2.7}, {0.4,0,2.55},{0.4,-0.224,2.55},{0.224,-0.4,2.55},{0,-0.4,2.55}, {1.3,0,2.55},{1.3,-0.728,2.55},{0.728,-1.3,2.55},{0,-1.3,2.55}, {1.3,0,2.4},{1.3,-0.728,2.4},{0.728,-1.3,2.4},{0,-1.3,2.4}, }, { // Patch 25 {0,-0.2,2.7},{-0.112,-0.2,2.7},{-0.2,-0.112,2.7},{-0.2,0,2.7}, {0,-0.4,2.55},{-0.224,-0.4,2.55},{-0.4,-0.224,2.55},{-0.4,0,2.55}, {0,-1.3,2.55},{-0.728,-1.3,2.55},{-1.3,-0.728,2.55},{-1.3,0,2.55}, {0,-1.3,2.4},{-0.728,-1.3,2.4},{-1.3,-0.728,2.4},{-1.3,0,2.4}, }, { // Patch 26 {-0.2,0,2.7},{-0.2,0.112,2.7},{-0.112,0.2,2.7},{0,0.2,2.7}, {-0.4,0,2.55},{-0.4,0.224,2.55},{-0.224,0.4,2.55},{0,0.4,2.55}, {-1.3,0,2.55},{-1.3,0.728,2.55},{-0.728,1.3,2.55},{0,1.3,2.55}, {-1.3,0,2.4},{-1.3,0.728,2.4},{-0.728,1.3,2.4},{0,1.3,2.4}, }, { // Patch 27 {0,0.2,2.7},{0.112,0.2,2.7},{0.2,0.112,2.7},{0.2,0,2.7}, {0,0.4,2.55},{0.224,0.4,2.55},{0.4,0.224,2.55},{0.4,0,2.55}, {0,1.3,2.55},{0.728,1.3,2.55},{1.3,0.728,2.55},{1.3,0,2.55}, {0,1.3,2.4},{0.728,1.3,2.4},{1.3,0.728,2.4},{1.3,0,2.4}, }, { // Patch 28 {0,0,0},{0,0,0},{0,0,0},{0,0,0}, {1.425,0,0},{1.425,0.798,0},{0.798,1.425,0},{0,1.425,0}, {1.5,0,0.075},{1.5,0.84,0.075},{0.84,1.5,0.075},{0,1.5,0.075}, {1.5,0,0.15},{1.5,0.84,0.15},{0.84,1.5,0.15},{0,1.5,0.15}, }, { // Patch 29 {0,0,0},{0,0,0},{0,0,0},{0,0,0}, {0,1.425,0},{-0.798,1.425,0},{-1.425,0.798,0},{-1.425,0,0}, {0,1.5,0.075},{-0.84,1.5,0.075},{-1.5,0.84,0.075},{-1.5,0,0.075}, {0,1.5,0.15},{-0.84,1.5,0.15},{-1.5,0.84,0.15},{-1.5,0,0.15}, }, { // Patch 30 {0,0,0},{0,0,0},{0,0,0},{0,0,0}, {-1.425,0,0},{-1.425,-0.798,0},{-0.798,-1.425,0},{0,-1.425,0}, {-1.5,0,0.075},{-1.5,-0.84,0.075},{-0.84,-1.5,0.075},{0,-1.5,0.075}, {-1.5,0,0.15},{-1.5,-0.84,0.15},{-0.84,-1.5,0.15},{0,-1.5,0.15}, }, { // Patch 31 {0,0,0},{0,0,0},{0,0,0},{0,0,0}, {0,-1.425,0},{0.798,-1.425,0},{1.425,-0.798,0},{1.425,0,0}, {0,-1.5,0.075},{0.84,-1.5,0.075},{1.5,-0.84,0.075},{1.5,0,0.075}, {0,-1.5,0.15},{0.84,-1.5,0.15},{1.5,-0.84,0.15},{1.5,0,0.15}, }, }; file.begingroup("Teapot"); for(size_t i = 0; i < NUMBER_OF_PATCHES; ++i) { if(1) file.addPatch(controlPoints[i],materials[i%N_COLOURS]); if(0) file.addSurface(3,3,4,4,controlPoints[i],knotsU,knotsV,materials[i%N_COLOURS],NULL); // use (too) general API for the same result as above } file.endgroup(); double t[4][4]; t[0][0]=1; t[0][1]=0; t[0][2]=0; t[0][3]=6; t[1][0]=0; t[1][1]=1; t[1][2]=0; t[1][3]=0; t[2][0]=0; t[2][1]=0; t[2][2]=1; t[2][3]=0; t[3][0]=0; t[3][1]=0; t[3][2]=0; t[3][3]=1; PRCoptions teapotopt; teapotopt.no_break = true; teapotopt.do_break = false; teapotopt.compression = 0.0001; // force joining together of patches, damaging transparency file.begingroup("Teapot rendered in the way of opaque surfaces and transferred",&teapotopt,t); for(size_t i = 0; i < NUMBER_OF_PATCHES; ++i) { file.addPatch(controlPoints[i],materials[i%N_COLOURS]); } file.endgroup(); } const size_t NUMBER_OF_POINTS = 31; double points[NUMBER_OF_POINTS][3]; for(size_t i = 0; i < NUMBER_OF_POINTS; ++i) { points[i][0] = 3.5*cos(3.0*i/NUMBER_OF_POINTS*2.0*pi); points[i][1] = 3.5*sin(3.0*i/NUMBER_OF_POINTS*2.0*pi); points[i][2] = 5.0*i/NUMBER_OF_POINTS-1.0; } const size_t NUMBER_OF_WIRES = 2; double shifted_points[NUMBER_OF_WIRES][NUMBER_OF_POINTS][3]; for(size_t wire = 0; wire < NUMBER_OF_WIRES; ++wire) for(size_t point = 0; point < NUMBER_OF_POINTS; ++point) { shifted_points[wire][point][0] = points[point][0]; shifted_points[wire][point][1] = points[point][1]; shifted_points[wire][point][2] = points[point][2]+0.1*wire+0.1; } double knots[3+NUMBER_OF_POINTS+1]; knots[0] = 1; for(size_t i = 1; i < 3+NUMBER_OF_POINTS; ++i) { knots[i] = (i+2)/3; // integer division is intentional } knots[3+NUMBER_OF_POINTS] = (3+NUMBER_OF_POINTS+1)/3; PRCoptions grpopt; grpopt.no_break = true; grpopt.do_break = false; grpopt.tess = true; if(1){ double point1[3] = {11,0,0}; double point2[3] = {12,0,0}; double points[2][3] = {{9,0,0},{10,0,0}}; file.begingroup("points",&grpopt); file.addPoint(point1, RGBAColour(1.0,0.0,0.0)); file.addPoint(point2, RGBAColour(1.0,0.0,0.0)); file.addPoints(2, points, RGBAColour(1.0,0.0,0.0,0.5),10); file.endgroup(); } if(1){ PRCoptions grpopt; grpopt.no_break = true; grpopt.do_break = false; grpopt.tess = true; grpopt.closed = true; double t[4][4]; const size_t nP = 5; double P[nP][3] = {{0,0,0},{1,0,0},{1,1,0},{0,1,0},{0,2,0}}; const size_t nI = 3; uint32_t PI[nI][3] = {{0,1,3},{1,2,3},{3,2,4}}; const size_t nM = 2; PRCmaterial M[nM]; M[0] = PRCmaterial( RGBAColour(0.0,0.0,0.18), RGBAColour(0.0,0.0,0.878431), RGBAColour(0.0,0.0,0.32), RGBAColour(0.0,0.0,0.072), 1.0,0.1); M[1] = PRCmaterial( RGBAColour(0.18,0.0,0.0), RGBAColour(0.878431,0.0,0.0), RGBAColour(0.32,0.0,0.0), RGBAColour(0.072,0.0,0.0), 0.5,0.1); uint32_t MI[nI] = {0,1,0}; const size_t nN = 2; double N[nN][3] = {{0,0,1},{0,0,-1}}; uint32_t NI[nI][3] = {{0,0,0},{0,0,0},{1,1,1}}; const uint32_t nC = 3; RGBAColour C[nC]; uint32_t CI[nI][3] = {{0,0,0},{1,1,1},{1,1,2}}; PRCmaterial materialGreen( RGBAColour(0.0,0.18,0.0), RGBAColour(0.0,0.878431,0.0), RGBAColour(0.0,0.32,0.0), RGBAColour(0.0,0.072,0.0), 1.0,0.1); if(1){ t[0][0]=1; t[0][1]=0; t[0][2]=0; t[0][3]=0; t[1][0]=0; t[1][1]=1; t[1][2]=0; t[1][3]=0; t[2][0]=0; t[2][1]=0; t[2][2]=1; t[2][3]=-1; t[3][0]=0; t[3][1]=0; t[3][2]=0; t[3][3]=1; file.begingroup("triangles_onecolor_with_normals",&grpopt,t); file.addTriangles(nP, P, nI, PI, materialGreen, nN, N, NI, 0, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL); file.endgroup(); } if(1){ file.begingroup("triangles_onecolor",&grpopt); file.addTriangles(nP, P, nI, PI, materialGreen, 0, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL); file.endgroup(); } if(1){ t[0][0]=1; t[0][1]=0; t[0][2]=0; t[0][3]=0; t[1][0]=0; t[1][1]=1; t[1][2]=0; t[1][3]=0; t[2][0]=0; t[2][1]=0; t[2][2]=1; t[2][3]=1; t[3][0]=0; t[3][1]=0; t[3][2]=0; t[3][3]=1; file.begingroup("triangles_manymaterials",&grpopt,t); file.addTriangles(nP, P, nI, PI, materialGreen, 0, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, nM, M, MI); file.endgroup(); } if(1){ t[0][0]=1; t[0][1]=0; t[0][2]=0; t[0][3]=0; t[1][0]=0; t[1][1]=1; t[1][2]=0; t[1][3]=0; t[2][0]=0; t[2][1]=0; t[2][2]=1; t[2][3]=2; t[3][0]=0; t[3][1]=0; t[3][2]=0; t[3][3]=1; PRCmaterial materialBase( RGBAColour(0.1,0.1,0.1,1), RGBAColour(1,1,1,1), RGBAColour(0.1,0.1,0.1,1), RGBAColour(0.1,0.1,0.1,1), 1.0,0.1); C[0] = RGBAColour(1,0,0,0.1); C[1] = RGBAColour(0,1,0,0.5); C[2] = RGBAColour(0,0,1,0.9); file.begingroup("triangles_rgba_vertexcolors_on_opaque_a_component_of_vertexcolor_ignored",&grpopt,t); file.addTriangles(nP, P, nI, PI, materialBase, 0, NULL, NULL, 0, NULL, NULL, nC, C, CI, 0, NULL, NULL); file.endgroup(); t[0][0]=1; t[0][1]=0; t[0][2]=0; t[0][3]=0; t[1][0]=0; t[1][1]=1; t[1][2]=0; t[1][3]=0; t[2][0]=0; t[2][1]=0; t[2][2]=1; t[2][3]=3; t[3][0]=0; t[3][1]=0; t[3][2]=0; t[3][3]=1; PRCmaterial materialTransparent( RGBAColour(0.1,0.1,0.1,0.3), RGBAColour(1,1,1,0.3), RGBAColour(0.1,0.1,0.1,0.3), RGBAColour(0.1,0.1,0.1,0.3), 0.3,0.1); C[0] = RGBAColour(1,0,0,0.1); C[1] = RGBAColour(0,1,0,0.5); C[2] = RGBAColour(0,0,1,0.9); file.begingroup("triangles_rgba_vertexcolors_on_transparent_a_component_of_vertexcolor_ignored",&grpopt,t); file.addTriangles(nP, P, nI, PI, materialTransparent, 0, NULL, NULL, 0, NULL, NULL, nC, C, CI, 0, NULL, NULL); file.endgroup(); t[0][0]=1; t[0][1]=0; t[0][2]=0; t[0][3]=0; t[1][0]=0; t[1][1]=1; t[1][2]=0; t[1][3]=0; t[2][0]=0; t[2][1]=0; t[2][2]=1; t[2][3]=4; t[3][0]=0; t[3][1]=0; t[3][2]=0; t[3][3]=1; C[0] = RGBAColour(1,0,0,0.5); C[1] = RGBAColour(0,1,0,0.5); C[2] = RGBAColour(0,0,1,0.5); file.begingroup("triangles_rgb_vertexcolors_on_transparent_may_not_work_in_OpenGL",&grpopt,t); file.addTriangles(nP, P, nI, PI, materialTransparent, 0, NULL, NULL, 0, NULL, NULL, nC, C, CI, 0, NULL, NULL); file.endgroup(); } if(1){ t[0][0]=1; t[0][1]=0; t[0][2]=0; t[0][3]=0; t[1][0]=0; t[1][1]=1; t[1][2]=0; t[1][3]=0; t[2][0]=0; t[2][1]=0; t[2][2]=1; t[2][3]=5; t[3][0]=0; t[3][1]=0; t[3][2]=0; t[3][3]=1; const uint32_t picture_width=2; const uint32_t picture_height=2; const uint8_t picRGB[picture_width*picture_height*3] = {255,0,0, 0,255,0, 0,0,255, 0,0,0 }; // {255,255,0, 255,0,0, 255,0,0, 255,0,0 }; // { 255,0,0, 255,255,0, 255,255,0, 255,255,255 }; // {255,0,0, 0,255,0, 0,0,255, 0,0,0 }; const uint8_t picRGBA[picture_width*picture_height*4] = {255,0,0,255, 0,255,0,150, 0,0,255,150, 0,0,0,100 }; // (1,0) 2 3 (1,1) // (0,0) 0 1 (1,0) uint8_t *pictureRGB = new uint8_t[picture_width*picture_height*3]; for(size_t i=0; i