All pastes #396643 Raw Edit

Mine

public text v1 · immutable
·published 2007-03-15 22:11 UTC
rendered paste body
RTint generateUnitCubeObject() {
  RTint objId = rtGenObjects(1);
  rtNewObject(objId, RT_COMPILE);
  RTuint shaderClass = rtGenNewShaderClass("Shader6", "libShader6.so");
  RTuint shaderId = rtGenNewShader();
  rtBindShader(shaderId);
  rtMatrixMode(RT_MODELVIEW);
  rtLoadIdentity();
  rtPushMatrix();
  rtTranslatef(-0.5f, -0.5f, -0.5f);

  rtBegin(RT_POLYGON); {
    rtColor3f(0, 0, 0); rtVertex3f(0, 0, 0);
    rtColor3f(0, 1, 0); rtVertex3f(0, 1, 0);
    rtColor3f(1, 1, 0); rtVertex3f(1, 1, 0);
    rtColor3f(1, 0, 0); rtVertex3f(1, 0, 0);
  } rtEnd();

  rtBegin(RT_POLYGON); {
    rtColor3f(1, 0, 1); rtVertex3f(1, 0, 1);
    rtColor3f(1, 1, 1); rtVertex3f(1, 1, 1);
    rtColor3f(0, 1, 1); rtVertex3f(0, 1, 1);
    rtColor3f(0, 0, 1); rtVertex3f(0, 0, 1);
  } rtEnd();

  rtBegin(RT_POLYGON); {
    rtColor3f(0, 0, 0); rtVertex3f(0, 0, 0);
    rtColor3f(0, 0, 1); rtVertex3f(0, 0, 1);
    rtColor3f(1, 0, 1); rtVertex3f(1, 0, 1);
    rtColor3f(1, 0, 0); rtVertex3f(1, 0, 0);
  } rtEnd();

  rtBegin(RT_POLYGON); {
    rtColor3f(1, 1, 0); rtVertex3f(1, 1, 0);
    rtColor3f(1, 1, 1); rtVertex3f(1, 1, 1);
    rtColor3f(0, 1, 1); rtVertex3f(0, 1, 1);
    rtColor3f(0, 1, 0); rtVertex3f(0, 1, 0);
  } rtEnd();

  rtBegin(RT_POLYGON); {
    rtColor3f(0, 1, 0); rtVertex3f(0, 1, 0);
    rtColor3f(0, 1, 1); rtVertex3f(0, 1, 1);
    rtColor3f(0, 0, 1); rtVertex3f(0, 0, 1);
    rtColor3f(0, 0, 0); rtVertex3f(0, 0, 0);
  } rtEnd();

  rtBegin(RT_POLYGON); {
    rtColor3f(1, 0, 0); rtVertex3f(1, 0, 0);
    rtColor3f(1, 0, 1); rtVertex3f(1, 0, 1);
    rtColor3f(1, 1, 1); rtVertex3f(1, 1, 1);
    rtColor3f(1, 1, 0); rtVertex3f(1, 1, 0);
  } rtEnd();

  rtPopMatrix();
  rtEndObject();
  return objId;
}

void instantiateCubeObjects(RTint objId) {
  rtMatrixMode(RT_MODELVIEW);
  for (RTint i=-2; i<2; i++)
    for (RTint j=-2; j<2; j++)
      for (RTint k=-2; k<2; k++)
      {
        rtLoadIdentity();
        rtScalef(0.4f, 0.4f, 0.4f);
        rtTranslatef(i, j, k);
        rtScalef(0.4f, 0.4f, 0.4f);
        RTuint instID = rtInstantiateObject(objId);
        rtSetInstanceVisibility(instID, RT_SHADOW);
	if (i == 0)
          rtAddInstanceVisibility(instID, RT_PRIMARY);
	if (j == 0)
          rtAddInstanceVisibility(instID, RT_REFLECTION);
    }
}