Exemple #1
0
bool CoreRP::addBlockDevProps()
{
    if (!m_impl->info->device()) {
        return true;
    }

    std::vector<unsigned char> contents;
    m_impl->cpio->contents("default.prop", &contents);

    std::vector<std::string> lines = StringUtils::splitData(contents, '\n');
    for (auto it = lines.begin(); it != lines.end();) {
        if (StringUtils::starts_with(*it, "ro.patcher.blockdevs.")) {
            it = lines.erase(it);
        } else {
            ++it;
        }
    }

    Device *device = m_impl->info->device();
    std::string encoded;

    encoded = "ro.patcher.blockdevs.base=";
    encoded += encode_list(device->blockDevBaseDirs());
    lines.push_back(encoded);

    encoded = "ro.patcher.blockdevs.system=";
    encoded += encode_list(device->systemBlockDevs());
    lines.push_back(encoded);

    encoded = "ro.patcher.blockdevs.cache=";
    encoded += encode_list(device->cacheBlockDevs());
    lines.push_back(encoded);

    encoded = "ro.patcher.blockdevs.data=";
    encoded += encode_list(device->dataBlockDevs());
    lines.push_back(encoded);

    encoded = "ro.patcher.blockdevs.recovery=";
    encoded += encode_list(device->recoveryBlockDevs());
    lines.push_back(encoded);

    encoded = "ro.patcher.blockdevs.extra=";
    encoded += encode_list(device->extraBlockDevs());
    lines.push_back(encoded);

    contents = StringUtils::joinData(lines, '\n');
    m_impl->cpio->setContents("default.prop", std::move(contents));

    return true;
}
int closeOpenNIDevice(Device &device , VideoStream &color , VideoStream &depth , VideoStream &ir)
{
    fprintf(stderr,"Stopping depth and color streams\n");
    depth.stop();
    color.stop();

    #if MOD_IR
       ir.stop();
       ir.destroy();
    #endif // MOD_IR

    depth.destroy();
    color.destroy();
    device.close();
    return 1;
}
/// \fn ParticleSystem::create()
/// \brief Creates and initializes the particle system components neccessary for rendering.
bool ParticleSystem::create(Device& device)
{
   mpTexture = device.getContentManager().loadContent<Graphics::Texture>(UTEXT("images/particle"));
   if ( mpTexture == NULL )
   {
      return false;
   }

   emittime = 0.0f;
   updatetime = 0.0f;
   active = 0;
   maxActive = 2000;
   mParticles.initialize(maxActive);

	return true;
}
Exemple #4
0
void Correlator::gatherCorrelationUnits(size_t tileTypeIndex,
  const Design& design, const Device& device, CfgExtractor& cfgExtractor)
{
    // gather correlation units from XDL
    m_tileUnits.clear();
    m_tileIndices.clear();
    XDLExtractor xdlExtractor(design, device);
    xdlExtractor.getTileTypeUnits(m_tileUnits, m_tileIndices, tileTypeIndex);

    // loop over gathered units
    size_t unitIndex = 0;
    size_t tileIndicesIndex = 0;
    const Tiles& tiles = device.tiles();
    while (unitIndex < (m_tileUnits.size()))
    {
        // get current unit
        CorrelationUnit& unit = m_tileUnits[unitIndex];
        // get corresponding tile and its position
        size_t tileIndex = m_tileIndices[tileIndicesIndex++];
        const Tile& tile = tiles.at(tileIndex);
        unsigned tileRow = tile.row();
        unsigned tileColumn = tile.column();

        // get configuration data size of this tile
        size_t dataWordCount = cfgExtractor.getDataWordCount(tileRow, tileColumn);
        // if there is no data for it, delete current unit (this happens when
        // the configuration extractor does not know where to find the data and
        // returns zero)
        if (0 != dataWordCount) ++unitIndex;
        else
        {
            m_tileUnits.erase(m_tileUnits.begin() + unitIndex);
            continue;
        }

        // enlarge buffer to hold this data
        if (m_buffer.size() < dataWordCount) m_buffer.resize(dataWordCount);
        // copy configuration data into buffer
        cfgExtractor.getDataWords(tileRow, tileColumn, &(m_buffer[0]), dataWordCount);
        // set unit's configuration bits accordingly
        unit.appendCfgBits(&(m_buffer[0]), dataWordCount);
    }

    // clear temporary data
    m_buffer.clear();
    m_tileIndices.clear();
}
	PseudoAddressSpace::PseudoAddressSpace( Device& userclient, UserObjectHandle inKernAddrSpaceRef,
												void* inBuffer, UInt32 inBufferSize, void* inBackingStore, void* inRefCon) 
	: IOFireWireIUnknown( reinterpret_cast<const IUnknownVTbl &>( sInterface ) ),
		mNotifyIsOn(false),
		mWriter( nil ),
		mReader( nil ),
		mSkippedPacketHandler( nil ),
		mUserClient(userclient), 
		mKernAddrSpaceRef(inKernAddrSpaceRef),
		mBuffer((char*)inBuffer),
		mBufferSize(inBufferSize),
		mBackingStore(inBackingStore),
		mRefCon(inRefCon)
	{
		userclient.AddRef() ;

		mPendingLocks = ::CFDictionaryCreateMutable( kCFAllocatorDefault, 0, NULL, NULL ) ;
		if (!mPendingLocks)
			throw kIOReturnNoMemory ;
	
		AddressSpaceInfo info ;

		IOReturn error ;
		
		uint32_t outputCnt = 0;
		size_t outputStructSize =  sizeof( info ) ;
		const uint64_t inputs[1]={(const uint64_t)mKernAddrSpaceRef};

		error = IOConnectCallMethod(mUserClient.GetUserClientConnection(), 
									kPseudoAddrSpace_GetFWAddrInfo,
									inputs,1,
									NULL,0,
									NULL,&outputCnt,
									&info,&outputStructSize);
		if (error)
		{
			throw error ;
		}

#ifndef __LP64__		
		ROSETTA_ONLY(
			{
				info.address.nodeID = OSSwapInt16( info.address.nodeID );
				info.address.addressHi = OSSwapInt16( info.address.addressHi );
				info.address.addressLo = OSSwapInt32( info.address.addressLo );
			}
		);
	//--------------------------------------------------------------------------------------
	void ParticleShader::_SetParameters ()
	{
		Engine& engine = Engine::Instance();
		Device* device = engine.GetDevice();
		device->SetShaderParameter(m_hMatViewPorject, engine.GetCamera()->GetViewProj());
		device->SetShaderParameter(m_hCameraPos, engine.GetCamera()->GetPosition());
		Texture* tex = (Texture*)m_pMaterial->Attribute( Material::ATT_TEX_DIFFUSE );
		if( NULL != tex )
		{
			device->SetShaderParameter(m_Texture, *tex );
		}
		device->SetShaderParameter(m_hWind, *((vector3f*)m_pMaterial->Attribute( IAttributeNode::ATT_USER_0 )));
		device->SetShaderParameter(m_hAcceleration, *((float*)m_pMaterial->Attribute( IAttributeNode::ATT_USER_1 )));
		device->SetShaderParameter(m_hTime, (float)(*((int*)m_pMaterial->Attribute( IAttributeNode::ATT_USER_2 ))));
	}
Exemple #7
0
int main()
{
    std::map<time_t,int>::iterator it;

    Device device = Device();
    //device.print();
    time_t rawtime;

    time(&rawtime);
    for(int i = 0; i < 15; i++) {
        device.add_reading(rawtime-i, i);
    }

    //device.print(10);

    for(int i = 1; i < 6; i++)
        device.rm_reading(rawtime-i);

    //device.print(10);

    device.rm_reading(0);
    device.rm_reading(0);
    //device.print();
    device.save_readings();

    pugi::xml_document doc;
    device.xml(doc);

    //doc.print(std::cout);
    doc.save_file("xml_output.xml");

    device.clear_readings();

    //device.print();

    pugi::xml_document new_doc;
    pugi::xml_parse_result result = new_doc.load_file("xml_output.xml");
    if(result)
        device.process_msg(new_doc);

    //new_doc.print(std::cout);

}
	//--------------------------------------------------------------------------------------
	void PrePixelLight::_SetParameters ()
	{
		Engine& engine = Engine::Instance();
		Device* device = engine.GetDevice();
		Environment* env = engine.GetEnvironment();
		ICamera* camera = engine.GetCamera();
		device->SetShaderParameter(m_hWorldViewProjMatrixLoc, camera->GetViewProj());
		device->SetShaderParameter(m_hLightDirectionLoc, -env->GetCurrentLight().GetWorldDirection());//phong光是像素到光源的方向,所以这里反向
		device->SetShaderParameter(m_hCameraPositionLoc, camera->GetPosition() );
		device->SetShaderParameter(m_hAmbientLoc, env->GetAmbient());
		device->SetShaderParameter(m_hLightLoc, env->GetCurrentLight().GetColor());
	}
Exemple #9
0
void *handler_device(void *device_pointer) {
  Device *device = (Device *)device_pointer;

  if (device->connect() < 0) {
    fprintf(stderr, "Could not connect to %s\n", device->name);
    return 0;
  }

  device->setFileModeTCP();
  device->startRecording();
  device->ping(60);
  device->stopRecording();
  device->updateTimeDiff();

  return 0;
}
Exemple #10
0
void DeviceCfgDbFiller::initDeviceDb(DeviceCfgDb& deviceDb,
  const Device& device)
{
    // clear device database
    deviceDb.clear();

    // get tile types from device
    const TileTypes& tileTypes = device.tileTypes();
    size_t tileTypeCount = tileTypes.size();

    // create one tile type database for every tile type
    TileTypeCfgDbs& tileTypeDbs = deviceDb.tileTypeDbs();
    tileTypeDbs.resize(tileTypeCount);

    // loop over all tile type databases and fill them
    for (size_t i = 0; i < tileTypeCount; ++i)
        initTileTypeDb(tileTypeDbs[i], tileTypes[i], i);
}
Exemple #11
0
/**
 *  @details The list of available packet devices is loaded from the system and
 *           matched against the command-line supplied device name.  Packets are
 *           captured and hosts extracted.
 */
int IPForensics::load_from_device() {
  // load packet capture device list from system
  try {
    load_devices();
  } catch (std::exception const &e) {
    std::cout << ipf::kProgramName << ": ";
    std::cout << "Could not query system for packet capture devices: ";
    std::cout << e.what() << std::endl;
  }
  // select device to use
  Device device = Device(this);
  for (Device d : devices_) {
    if (device_ == d.name()) {
      device = d;
    }
  }
  // exit if invalid device specified
  if (!device_.empty() && device_ != device.name()) {
    std::cout << ipf::kProgramName << ": ";
    std::cout << "Invalid packet capture device \'" << device_ << "\'. ";
    std::cout << "Valid device(s):\n";
    for (size_t i = 0; i < devices_.size(); ++i) {
      std::cout << i+1 << ". " << devices_[i] << '\n';
    }
    std::cout << std::endl;
    return -1;
  }
  // display run-time parameters
  if (verbose_) {
    std::cout << "Using \'" << device.name() << "\' with network address ";
    std::cout << device.net() << " and network mask " << device.mask();
    std::cout << " to capture " << packet_count_ << " packet(s).";
    std::cout << std::endl;
  }
  // capture packets
  int packet_count = device.capture(packet_count_);
  // display packets captured
  if (verbose_) {
    for (Packet p : device.packets()) {
      std::cout << p << std::endl;
    }
  }
  // extract hosts
  load_hosts(device);
  return packet_count;
}
Exemple #12
0
int HardReset(int /*argc*/, const char* /*argv*/[])
{
	printf("Resetting device...");
	Status nRetVal = g_device.invoke(PS_COMMAND_POWER_RESET, NULL, 0);
	printf("\n");
	if (nRetVal == STATUS_OK)
	{
		printf("Successfully executed Hard Reset.\n\n");
		printf("**********************************************\n");
		printf("Warning: console must be restarted!\n");
		printf("**********************************************\n\n");
	}
	else
	{
		printf("Failed to execute hard reset: %s\n\n", OpenNI::getExtendedError());
	}

	return nRetVal;
}
	void DeviceSettings::RestoreFromDictionary(Device& device, const CFDictionaryRef dictionary, const ControlInfo* controlsToRestore, UInt32 numberControlsToRestore)
	{

		if (dictionary != NULL)
		{
			// Take and hold the device's state guard while we do this to prevent notifications from Interupting the full completion of this routine.
			CAMutex::Locker deviceStateMutex(device.GetStateMutex());
		
			CACFDictionary settings(dictionary, false);
			
			// Restore the device settings
			DeviceSettings_RestoreDeviceSettings(device, settings, kCMIODevicePropertyScopeInput, controlsToRestore, numberControlsToRestore);
			DeviceSettings_RestoreDeviceSettings(device, settings, kCMIODevicePropertyScopeOutput, controlsToRestore, numberControlsToRestore);
		
			// Restore the stream settings
			DeviceSettings_RestoreStreamSettings(device, settings, kCMIODevicePropertyScopeInput, controlsToRestore, numberControlsToRestore);
			DeviceSettings_RestoreStreamSettings(device, settings, kCMIODevicePropertyScopeOutput, controlsToRestore, numberControlsToRestore);
		}
	}
Exemple #14
0
void
PartitionPage::onNewPartitionTableClicked()
{
    QModelIndex index = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
    Q_ASSERT( index.isValid() );
    Device* device = m_core->deviceModel()->deviceForIndex( index );

    QPointer<QDialog> dlg = new QDialog( this );
    Ui_CreatePartitionTableDialog ui;
    ui.setupUi( dlg.data() );
    QString areYouSure = tr( "Are you sure you want to create a new partition table on %1?" ).arg( device->name() );
    ui.areYouSureLabel->setText( areYouSure );
    if ( dlg->exec() == QDialog::Accepted )
    {
        PartitionTable::TableType type = ui.mbrRadioButton->isChecked() ? PartitionTable::msdos : PartitionTable::gpt;
        m_core->createPartitionTable( device, type );
    }
    delete dlg;
}
Exemple #15
0
/** Inserts unallocated children for a Device's PartitionTable with the given parent.

    This method inserts unallocated Partitions for a parent, usually the Device this
    PartitionTable is on. It will also insert unallocated Partitions in any extended
    Partitions it finds.

    @warning This method assumes that no unallocated Partitions exist when it is called.

    @param d the Device this PartitionTable and @p p are on
    @param p the parent PartitionNode (may be this or an extended Partition)
    @param start the first sector to begin looking for free space
*/
void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64 start)
{
    Q_ASSERT(p);

    qint64 lastEnd = start;

    if (d.type() == Device::LVM_Device && !p->children().isEmpty()) {
        // rearranging the sectors of all partitions to keep unallocated space at the end
        lastEnd = 0;
        qSort(children().begin(), children().end(), [](const Partition* p1, const Partition* p2) { return p1->deviceNode() < p2->deviceNode(); });
        for (const auto &child : children()) {
            qint64 totalSectors = child->length();
            child->setFirstSector(lastEnd);
            child->setLastSector(lastEnd + totalSectors - 1);

            lastEnd += totalSectors;
        }
    } else {
        const auto pChildren = p->children();
        for (const auto &child : pChildren) {
            p->insert(createUnallocated(d, *p, lastEnd, child->firstSector() - 1));

            if (child->roles().has(PartitionRole::Extended))
                insertUnallocated(d, child, child->firstSector());

            lastEnd = child->lastSector() + 1;
        }
    }

    // Take care of the free space between the end of the last child and the end
    // of the device or the extended partition.
    qint64 parentEnd = lastUsable();

    if (!p->isRoot()) {
        Partition* extended = dynamic_cast<Partition*>(p);
        parentEnd = extended ? extended->lastSector() : -1;
        Q_ASSERT(extended);
    }

    if (parentEnd >= firstUsable() && parentEnd >= lastEnd)
        p->insert(createUnallocated(d, *p, lastEnd, parentEnd));
}
	bool CreateSprite()
	{
		auto_interface<ID3D10Device> pNativeDevice(_device.GetNativeDevice());
		HRESULT hRet = D3DX10CreateSprite(pNativeDevice, 128, &_pSprite);
		if (FAILED(hRet))
		{
			return false;
		}

		D3DXMATRIX m;
		//D3DXVECTOR3 vEye(0.0f, 0.0f,  3.0f);	// 視点(カメラの位置)
		D3DXVECTOR3 vEye(0.0f, 0.0f,  -3.0f);	// 視点(カメラの位置)
		D3DXVECTOR3 vAt(0.0f, 0.0f,  0.0f);	// 注視点
		D3DXVECTOR3 vUp(0.0f, 1.0f,  0.0f);		// カメラの上方向

		D3DXMatrixLookAtLH(&m, &vEye, &vAt, &vUp);
		_pSprite->SetViewTransform(&m);

		return true;
	}
Exemple #17
0
int Dir(int /*argc*/, const char* /*argv*/[])
{
	XnFwFileEntry files[50];
	XnCommandGetFileList args;
	args.count = sizeof(files) / sizeof(files[0]);
	args.files = files;

	Status nRetVal = g_device.invoke(PS_COMMAND_GET_FILE_LIST, args);
	if (nRetVal != STATUS_OK)
	{
		printf("Failed to get file list: %s\n\n", OpenNI::getExtendedError());
		return nRetVal;
	}
	else
	{
		// print list
		printf("\n");
		printf("%-4s  %-32s  %-8s  %-10s  %-6s  %-6s  %-15s\n", "ZONE", "NAME", "VERSION", "ADDRESS", "SIZE", "CRC", "FLAGS");
		printf("%-4s  %-32s  %-8s  %-10s  %-6s  %-6s  %-15s\n", "====", "====", "=======", "=======", "====", "===", "=====");

		for (XnUInt32 i = 0; i < args.count; ++i)
		{
			XnFwFileEntry& file = files[i];
			printf("%-4u  %-32s  %01u.%01u.%01u.%02u  0x%08x  %6u  0x%04x  ", 
				file.zone, file.name, 
				file.version.major, file.version.minor, file.version.maintenance, file.version.build,
				file.address, file.size, file.crc);

			// flags
			if ((file.flags & XN_FILE_FLAG_BAD_CRC) != 0)
			{
				printf("CORRUPT");
			}

			printf("\n");
		}
		printf("\n");
	}

	return 0;
}
Exemple #18
0
int PrintBootStatus(int /*argc*/, const char* /*argv*/[])
{
	XnBootStatus bootStatus;
	Status nRetVal = g_device.getProperty(LINK_PROP_BOOT_STATUS, &bootStatus);
	if (nRetVal != STATUS_OK)
	{
		printf("Failed to get boot status: %s\n\n", OpenNI::getExtendedError());
		return nRetVal;
	}
	else
	{
		enum{MAX_STR_LEN = 256};
		char bootZoneStr[MAX_STR_LEN], bootZoneErr[MAX_STR_LEN];

		//Helper macro to write enum names
		#define CASE_ENUM_TOSTRING(enumValue, enumStr, targetStr) \
				case enumValue: sprintf(targetStr, "%s", enumStr); break;

		//Get XnLinkBootZone string
		switch(bootStatus.zone){
			CASE_ENUM_TOSTRING(XN_ZONE_FACTORY, "FACTORY_ZONE", bootZoneStr)
			CASE_ENUM_TOSTRING(XN_ZONE_UPDATE, "UPDATE_ZONE", bootZoneStr)
			default:
				sprintf(bootZoneStr, "Unexpected - %d",bootStatus.zone);
		}

		//Get XnLinkBootErrorCode string
		switch(bootStatus.errorCode){
			CASE_ENUM_TOSTRING(XN_BOOT_OK, "BOOT_OK", bootZoneErr)
			CASE_ENUM_TOSTRING(XN_BOOT_BAD_CRC, "BAD_CRC", bootZoneErr)
			CASE_ENUM_TOSTRING(XN_BOOT_UPLOAD_IN_PROGRESS, "UPLOAD_IN_PROGRESS", bootZoneErr)
			CASE_ENUM_TOSTRING(XN_BOOT_FW_LOAD_FAILED, "FW_LOAD_FAILED", bootZoneErr)
			default:
				sprintf(bootZoneErr, "Unexpected - %d",bootStatus.errorCode);
		}

		printf("Zone: %s\nError code: %s\n\n", bootZoneStr, bootZoneErr);

		return nRetVal;
	}
}
Exemple #19
0
bool
DebugReplayNMEA::Next()
{
  last_basic = basic;
  last_calculated = calculated;

  const char *line;
  while ((line = reader->read()) != NULL) {
    if (basic.time_available)
      basic.clock = basic.time;
    if (device == NULL || !device->ParseNMEA(line, basic))
      parser.ParseLine(line, basic);

    if (basic.location_available != last_basic.location_available) {
      Compute();
      return true;
    }
  }

  return false;
}
Exemple #20
0
int Emitter(int argc, const char* argv[])
{
	if ((argc < 2) || 
		((xnOSStrCaseCmp(argv[1], "on") != 0) && (xnOSStrCaseCmp(argv[1], "off") != 0)))
	{
		printf("Usage: %s <on|off>\n\n", argv[0]);
		return -1;
	}
	const XnChar* strEmitterActive = argv[1];
	XnBool bEmitterActive = (xnOSStrCaseCmp(strEmitterActive, "on") == 0);
	Status nRetVal = g_device.setProperty(LINK_PROP_EMITTER_ACTIVE, bEmitterActive);
	if (nRetVal == STATUS_OK)
	{
		printf("Emitter is now %s.\n\n", strEmitterActive);
	}
	else
	{
		printf("Failed to set emitter %s: %s\n\n", strEmitterActive, OpenNI::getExtendedError());
	}

	return nRetVal;
}
Exemple #21
0
// write multiple characters
// virtual
std::streamsize DeviceOutBuffer::xsputn(const char* s, std::streamsize num){
	//we can safely put BUFF_FLUSH into the buffer
	int towrite = BUFF_CP - BUFF_FLUSH;
	if(towrite > static_cast<int>(num)) towrite = static_cast<int>(num);
	memcpy(bpos, s, towrite);
	bpos += towrite;
	if((bpos - bbeg) > BUFF_FLUSH && !flush()){
		cassert(0);
		return -1;
	}
	if(num == towrite) return num;
	num -= towrite;
	s += towrite;
	if(num >= BUFF_FLUSH){
		std::streamsize retv = pd->write(s, static_cast<uint32>(num));
		cassert(retv != num);
		return retv;
	}
	memcpy(bpos, s, static_cast<size_t>(num));
	bpos += num;
	return num;
}
Exemple #22
0
int StopStream(int argc, const char* argv[])
{
	if (argc < 2)
	{
		printf("Usage: %s <StreamID>\n\n", argv[0]);
		return -1;
	}

	XnCommandStopStream args;
	args.id = MyAtoi(argv[1]);
	Status nRetVal = g_device.invoke(LINK_COMMAND_STOP_FW_STREAM, args);
	if (nRetVal == STATUS_OK)
	{
		printf("Successfully stopped stream %u\n\n", args.id);
	}
	else
	{
		printf("Failed to stop stream %u: %s\n\n", args.id, OpenNI::getExtendedError());
	}

	return nRetVal;
}
Exemple #23
0
int Download(int argc, const char* argv[])
{
	if (argc < 4)
	{
		printf("Usage: %s <zone> <firmware file name> <host target file>\n", argv[0]);
		printf("Note: filename can not contain any spaces.\n\n");
		return -1;
	}

	XnCommandDownloadFile args;
	args.zone = (uint16_t)MyAtoi(argv[1]);
	args.firmwareFileName = argv[2];
	args.targetPath = argv[3];

	Status nRetVal = g_device.invoke(PS_COMMAND_DOWNLOAD_FILE, args);
	if (nRetVal != STATUS_OK)
	{
		printf("Failed to download file '%s' from zone %u: %s\n\n", args.firmwareFileName, args.zone, OpenNI::getExtendedError());
	}

	return nRetVal;
}
Exemple #24
0
int FormatZone(int argc, const char* argv[])
{
	if (argc < 2)
	{
		printf("Usage: %s <Zone>\n", argv[0]);
		printf("Note - each parameter may be in hex, indicated by an '0x' prefix.\n\n");
		return -1;
	}

	XnUInt32 nZone = MyAtoi(argv[1]);
	Status nRetVal = g_device.invoke(PS_COMMAND_FORMAT_ZONE, nZone);
	if (nRetVal == STATUS_OK)
	{
		printf("Successfully formatZone.\n\n");
	}
	else
	{
		printf("Failed to format Zone value: %s\n\n", OpenNI::getExtendedError());
	}

	return nRetVal;
}
	//--------------------------------------------------------------------------------------
	void ModelDepth::_SetParameters ()
	{
		Engine& engine = Engine::Instance();
		Device* device = engine.GetDevice();
		ICamera* camera = engine.GetCamera();

		Matrix44f& mat = *(Matrix44f*)(m_pMaterial->Attribute( IAttributeNode::ATT_WORLDTRANSFORM ));
		
		device->SetShaderParameter(m_hWorldTransform, mat );
		if ( m_pMaterial->Attribute( IAttributeNode::ATT_USER_0 ) )
		{
			device->SetShaderParameter(m_hCameraLineDepthParam, camera->LineDepthParamBais() );
			device->SetShaderParameter(m_hWorldViewProjMatrixLoc, mat * camera->GetViewProjBias() );
		}
		else
		{
			device->SetShaderParameter(m_hCameraLineDepthParam, camera->LineDepthParam() );
			device->SetShaderParameter(m_hWorldViewProjMatrixLoc, mat * camera->GetViewProj() );
		}
		device->SetShaderParameter(m_hLightPositionLoc, engine.GetEnvironment()->GetCurrentLight().GetWorldPosition() );
	}
Exemple #26
0
static void
TestFlyNet()
{
  NullPort null;
  Device *device = flynet_driver.CreateOnPort(dummy_config, null);
  ok1(device != NULL);

  NMEAInfo nmea_info;
  nmea_info.Reset();
  nmea_info.clock = fixed(1);

  ok1(device->ParseNMEA("_PRS 00017CBA", nmea_info));
  ok1(nmea_info.static_pressure_available);
  ok1(equals(nmea_info.static_pressure.GetPascal(), 97466));

  nmea_info.Reset();
  nmea_info.clock = fixed(1);

  ok1(device->ParseNMEA("_PRS 00018BCD", nmea_info));
  ok1(nmea_info.static_pressure_available);
  ok1(equals(nmea_info.static_pressure.GetPascal(), 101325));

  nmea_info.Reset();
  nmea_info.clock = fixed(1);

  ok1(device->ParseNMEA("_BAT 0", nmea_info));
  ok1(nmea_info.battery_level_available);
  ok1(equals(nmea_info.battery_level, 0));

  nmea_info.Reset();
  nmea_info.clock = fixed(1);

  ok1(device->ParseNMEA("_BAT 7", nmea_info));
  ok1(nmea_info.battery_level_available);
  ok1(equals(nmea_info.battery_level, 70));

  nmea_info.Reset();
  nmea_info.clock = fixed(1);

  ok1(device->ParseNMEA("_BAT A", nmea_info));
  ok1(nmea_info.battery_level_available);
  ok1(equals(nmea_info.battery_level, 100));

  delete device;
}
Exemple #27
0
bool Stream::setup(Device &device, SensorType sensorType)
{
    if (!device.isOpen()) {
        return false;
    }

    m_Kinect2Timestamp = 0;
    m_OpenGLTimestamp = 0;
    m_Frame.sensorType = sensorType;
    m_Frame.mode.fps = 0;
    m_Frame.frameIndex = 0;
    m_Frame.stride = 0;
    m_Frame.data = nullptr;
    m_Frame.dataSize = 0;
    m_IsFrameNew = false;
    m_IsTextureNeedUpdate = false;

    device.m_Streams.push_back(this);
    this->m_Device = &device;

    setMirror(false);
    return true;
}
Exemple #28
0
int DestroyStream(int argc, const char* argv[])
{
	if (argc < 2)
	{
		printf("Usage: %s <streamID>\n", argv[0]);
		printf("Destroys a stream, where stream ID is an ID returned from the Create command.\n");
		return -1;
	}

	XnCommandDestroyStream args;
	args.id = MyAtoi(argv[1]);
	Status nRetVal = g_device.invoke(LINK_COMMAND_DESTROY_FW_STREAM, args);
	if (nRetVal == STATUS_OK)
	{
		printf("Successfully destroyed stream %u\n\n", args.id);
	}
	else
	{
		printf("Failed to destroy stream: %s\n\n", OpenNI::getExtendedError());
	}

	return nRetVal;
}
	// ウィンドウリサイズ。
	LRESULT OnWindowSizeMessage(HWND /*hWnd*/, UINT /*msg*/, WPARAM wParam, LPARAM lParam)
	{
		WindowSizeMessageParameters params(wParam, lParam);
		SIZE sz;
		sz.cx = params.GetClientWidth();
		sz.cy = params.GetClientHeight();

		if (params.GetType() == SIZE_MINIMIZED)
		{
			return 0;
		}
		
		// なんか↓の処理しなくても上手くできてるように見えるんですけど…。
		if (failed(_device.ResizeBackBuffer(sz)))
		{
			Exit(0);
			return 0;
		}
		
		// 射影トランスフォームをリセット。
		ResetProjectionTransform(sz);
		return 0;
	}
Exemple #30
0
xnl::Array<XnFwLogMask>& GetLogMaskList()
{
	static xnl::Array<XnFwLogMask> s_masks;

	if (s_masks.GetSize() == 0)
	{
		XnFwLogMask masks[20];
		XnCommandGetLogMaskList args;
		args.masks = masks;
		args.count = sizeof(masks)/sizeof(masks[0]);

		if (STATUS_OK != g_device.invoke(PS_COMMAND_GET_LOG_MASK_LIST, args))
		{
			printf("Failed getting masks list: %s\n\n", OpenNI::getExtendedError());
		}
		else
		{
			s_masks.SetData(args.masks, args.count);
		}
	}

	return s_masks;
}