Beispiel #1
0
void Vector4Test::access() {
    Vector4 vec(1.0f, -2.0f, 5.0f, 0.5f);
    CORRADE_COMPARE(vec.x(), 1.0f);
    CORRADE_COMPARE(vec.r(), 1.0f);
    CORRADE_COMPARE(vec.y(), -2.0f);
    CORRADE_COMPARE(vec.g(), -2.0f);
    CORRADE_COMPARE(vec.z(), 5.0f);
    CORRADE_COMPARE(vec.b(), 5.0f);
    CORRADE_COMPARE(vec.w(), 0.5f);
    CORRADE_COMPARE(vec.a(), 0.5f);

    constexpr Vector4 cvec(1.0f, -2.0f, 5.0f, 0.5f);
    constexpr Float x = cvec.x();
    constexpr Float r = cvec.r();
    constexpr Float y = cvec.y();
    constexpr Float g = cvec.g();
    constexpr Float z = cvec.z();
    constexpr Float b = cvec.b();
    constexpr Float w = cvec.w();
    constexpr Float a = cvec.a();
    CORRADE_COMPARE(x, 1.0f);
    CORRADE_COMPARE(r, 1.0f);
    CORRADE_COMPARE(y, -2.0f);
    CORRADE_COMPARE(g, -2.0f);
    CORRADE_COMPARE(z, 5.0f);
    CORRADE_COMPARE(b, 5.0f);
    CORRADE_COMPARE(w, 0.5f);
    CORRADE_COMPARE(a, 0.5f);
}
Beispiel #2
0
void draw3DBackToFront() {

	glEnable(GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glBegin(GL_POINTS);

	for(int c = 0; c < WIDTH; c++) {
		for(int r = 0; r < HEIGHT; r++) {
			//
			Vector3 voxelLocation = rotationMatrix * Vector3(c, r, 0) + startingPosition + (directionVector * 256);
			for (int i = 0; i < 256; i++) {
				if (withinBounds(head->GetWidth(), head->GetHeight(), 256, voxelLocation) ) {
					unsigned char val = head->Get((int)voxelLocation.r(), (int)voxelLocation.g(), (int)voxelLocation.b()*(100.0/256.0));

					double normalisedVal = val/255.0;
					if (normalisedVal > 0.3) {
						Vector4 color = manualColoursAndOpacities(normalisedVal);
						glColor4f(color.r(), color.g(), color.b(), color.a());

						glVertex3f(c, r,0);
					}
				}
				voxelLocation -= directionVector;
			}

		}
	}
	glEnd();
	glFlush();
	glutSwapBuffers();
}
Beispiel #3
0
void manualDraw() {
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glBegin(GL_POINTS);

	for (int x = 0; x < head->GetWidth() ; x++) {
		for(int y = 0; y < head->GetHeight(); y++) {
			//for(int z = 0; z < head->GetDepth(); z++) {
			for(int z = head->GetDepth(); z > 0; z--) {
				//for(int y = head->GetHeight(); y > 0; y--) {
				//for(int x = head->GetWidth(); x > 0; x--) {


				unsigned char val = head->Get(x, y, z);

				double normalisedVal = val/255.0;
				if (normalisedVal > 0.3) {
					Vector4 color = manualColoursAndOpacities(normalisedVal);
					glColor4f(color.r(), color.g(), color.b(), color.a());

					glVertex3f(x, y,0);
				}
			}
		}
	}
	glEnd();
	glFlush();
	glutSwapBuffers();
}
Beispiel #4
0
void draw3DFrontToBack() {

	glEnable(GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glBegin(GL_POINTS);

	for(int c = 0; c < WIDTH; c++) {
		for(int r = 0; r < HEIGHT; r++) {
			double currentA = 0;
			Vector3 currentI = Vector3(0,0,0);
			Vector3 voxelLocation = rotationMatrix * Vector3(c, r, 0) + startingPosition;
			for (int i = 0; i < 256; i++) {
				if (withinBounds(head->GetWidth(), head->GetHeight(), 256, voxelLocation) ) {
					double val = trilinearInterpolate(voxelLocation.r(), voxelLocation.g(), voxelLocation.b()*(100.0/256.0));

					double normalisedVal = val/255.0;
					if (normalisedVal > 0.2) {
						Vector4 color = manualColoursAndOpacities(normalisedVal);
						Vector3 justColor = Vector3(color.r(), color.g(), color.b());

						currentI = currentI + justColor*color.a()*(1-currentA);
						currentA = color.a() + currentA*(1-color.a());
						if (currentA > 0.95) {
							break;
						}
					}
				}
				voxelLocation += directionVector;
			}
			glColor4f(currentI.r(), currentI.g(), currentI.b(), currentA);
			glVertex3f(c, r,0);
		}
	}
	glEnd();
	glFlush();
	glutSwapBuffers();
}