void SingleRayDevice::rtSetTransform(Device::RTHandle handle, const char* property, const float* transform)
 {
   RT_COMMAND_HEADER;
   if (!property) throw std::runtime_error("invalid property");
   if (!handle  ) return;
   ((_RTHandle*)handle)->set(property,Variant(copyFromArray(transform)));
 }
 Device::RTPrimitive SingleRayDevice::rtTransformPrimitive(Device::RTPrimitive primitive, const float* transform) 
 {
   RT_COMMAND_HEADER;
   Ref<PrimitiveHandle> prim = dynamic_cast<PrimitiveHandle*>((_RTHandle*)primitive);
   AffineSpace3f space = transform ? copyFromArray(transform) : AffineSpace3f(one);
   return (Device::RTPrimitive) new PrimitiveHandle(space, prim);
 }
Example #3
0
 extern "C" void rtTransformPrimitive(uint32_t numBuffers, void** buffers, uint64_t* bufferBytes, 
                                      parmsTransformPrimitive* parms, uint16_t parmBytes, void* ret, uint16_t retBytes)
 {
   if (g_verbose) {
     printf("handle %06d = rtTransformPrimitive(%06d,%s)\n", 
            parms->id, parms->primitive, std::stringOf(copyFromArray(parms->transform)).c_str());
     fflush(stdout);
   }
   set(parms->id, g_device->rtTransformPrimitive(get<Device::RTPrimitive>(parms->primitive),parms->transform));
 }
Example #4
0
 extern "C" void rtNewLightPrimitive(uint32_t numBuffers, void** buffers, uint64_t* bufferBytes, 
                                     parmsNewLightPrimitive* parms, uint16_t parmBytes, void* ret, uint16_t retBytes)
 {
   if (g_verbose) {
     printf("handle %06d = rtNewLightPrimitive(%06d, %06d, %s)\n", 
            parms->id, parms->light, parms->material, std::stringOf(copyFromArray(parms->transform)).c_str());
     fflush(stdout);
   }
   set(parms->id, g_device->rtNewLightPrimitive(get<Device::RTLight>(parms->light),get<Device::RTMaterial>(parms->material),parms->transform));
 }
 Device::RTPrimitive SingleRayDevice::rtNewShapePrimitive(Device::RTShape shape_i, 
                                                          Device::RTMaterial material_i, 
                                                          const float* transform)
 {
   RT_COMMAND_HEADER;
   Ref<InstanceHandle<Shape> > shape = castHandle<InstanceHandle<Shape>    >(shape_i   ,"shape"   );
   Ref<InstanceHandle<Material> > material = castHandle<InstanceHandle<Material> >(material_i,"material");
   AffineSpace3f space = transform ? copyFromArray(transform) : AffineSpace3f(one);
   return (Device::RTPrimitive) new PrimitiveHandle(shape,material,space);
 }
 Device::RTPrimitive SingleRayDevice::rtNewLightPrimitive(Device::RTLight light_i, 
                                                       Device::RTMaterial material_i, 
                                                       const float* transform)
 {
   RT_COMMAND_HEADER;
   Ref<InstanceHandle<Light> > light = castHandle<InstanceHandle<Light> >(light_i,"light");
   Ref<InstanceHandle<Material> > material = NULL;
   if (material_i) material = castHandle<InstanceHandle<Material> >(material_i,"material");
   AffineSpace3f space = transform ? copyFromArray(transform) : AffineSpace3f(one);
   return (Device::RTPrimitive) new PrimitiveHandle(light,material,space);
 }
Example #7
0
std::string ToUTF8::getUtf8(ToUTF8::FromType from)
{
  // Pick translation array
  const char *arr;
  if(from == ToUTF8::WINDOWS_1252)
    arr = ToUTF8::windows_1252;
  else
    assert(0);

  // Double check that the input string stops at some point (it might
  // contain zero terminators before this, inside its own data, which
  // is also ok.)
  const char* input = &buf[0];
  assert(input[size] == 0);

  // TODO: The rest of this function is designed for single-character
  // input encodings only. It also assumes that the input the input
  // encoding shares its first 128 values (0-127) with ASCII. These
  // conditions must be checked again if you add more input encodings
  // later.

  // Compute output length, and check for pure ascii input at the same
  // time.
  bool ascii;
  size_t outlen = getLength(arr, input, ascii);

  // If we're pure ascii, then don't bother converting anything.
  if(ascii)
    return std::string(input, outlen);

  // Make sure the output is large enough
  resize(output, outlen);
  char *out = &output[0];

  // Translate
  while(*input)
    copyFromArray(arr, *(input++), out);

  // Make sure that we wrote the correct number of bytes
  assert((out-&output[0]) == (int)outlen);

  // And make extra sure the output is null terminated
  assert(output.size() > outlen);
  assert(output[outlen] == 0);

  // Return a string
  return std::string(&output[0], outlen);
}
Example #8
0
 extern "C" void rtSetTransform(uint32_t numBuffers, void** buffers, uint64_t* bufferBytes, parmsSetTransform* parms, uint16_t parmBytes, void* ret, uint16_t retBytes)
 {
   if (g_verbose) {
     printf("rtSetTransform(%06d, %s, %s)\n", parms->handle, parms->property, std::stringOf(copyFromArray(parms->transform)).c_str());
     fflush(stdout);
   }
   g_device->rtSetTransform(get<Device::RTHandle>(parms->handle),parms->property,parms->transform);
 }