コード例 #1
0
void Mouse::fireMultiTouchEvent(uint8_t cContacts,
                                const LONG64 *paContacts,
                                uint32_t u32ScanTime)
{
    com::SafeArray<SHORT> xPositions(cContacts);
    com::SafeArray<SHORT> yPositions(cContacts);
    com::SafeArray<USHORT> contactIds(cContacts);
    com::SafeArray<USHORT> contactFlags(cContacts);

    uint8_t i;
    for (i = 0; i < cContacts; i++)
    {
        uint32_t u32Lo = RT_LO_U32(paContacts[i]);
        uint32_t u32Hi = RT_HI_U32(paContacts[i]);
        xPositions[i] = (int16_t)u32Lo;
        yPositions[i] = (int16_t)(u32Lo >> 16);
        contactIds[i] = RT_BYTE1(u32Hi);
        contactFlags[i] = RT_BYTE2(u32Hi);
    }

    VBoxEventDesc evDesc;
    evDesc.init(mEventSource, VBoxEventType_OnGuestMultiTouch,
                cContacts, ComSafeArrayAsInParam(xPositions), ComSafeArrayAsInParam(yPositions),
                ComSafeArrayAsInParam(contactIds), ComSafeArrayAsInParam(contactFlags), u32ScanTime);
    evDesc.fire(0);
}
コード例 #2
0
ファイル: instancer_op.cpp プロジェクト: ppearson/rendererDev
void InstancerOp::create3DGrid(unsigned int numItems, const Vec3& areaSpread, std::vector<Vec3>& aItemPositions)
{
	// round up to the next cube number, so we get a good even distribution for both X, Y and Z
	unsigned int edgeCount = (unsigned int)(cbrtf((float)numItems));
	if (edgeCount * edgeCount * edgeCount < numItems)
		edgeCount += 1;

	unsigned int fullItemCount = edgeCount * edgeCount * edgeCount;

	unsigned int extra = fullItemCount - numItems;
	
	fprintf(stderr, "Creating 3D grid of: %u items, 'full' size: %u.\n", numItems, fullItemCount);
	
	aItemPositions.clear();

	// TODO: could do resize() here and then just set the members of each item
	//       directly, which might be more efficient...
	aItemPositions.reserve(numItems);	
	
	float edgeDelta = 1.0f / (float)edgeCount;
	
	std::vector<float> xPositions(edgeCount);
	std::vector<float> yPositions(edgeCount);
	std::vector<float> zPositions(edgeCount);
	
	for (unsigned int i = 0; i < edgeCount; i++)
	{
		float samplePos = (float(i) * edgeDelta) - 0.5f;
		
		xPositions[i] = samplePos * areaSpread.x;
		yPositions[i] = samplePos * areaSpread.y;
		zPositions[i] = samplePos * areaSpread.z;
	}
	
	if (extra > 0)
	{
		// we need to skip certain items
		
		unsigned int skipStride = fullItemCount / extra;
		
		unsigned int count = 0;
		for (unsigned int xInd = 0; xInd < edgeCount; xInd++)
		{
			const float xPos = xPositions[xInd];
			for (unsigned int yInd = 0; yInd < edgeCount; yInd++)
			{
				float yPos = yPositions[yInd];
				for (unsigned int zInd = 0; zInd < edgeCount; zInd++)
				{
					if (extra > 0 && ++count >= skipStride)
					{
						count = 0;
						continue;
					}
					
					float zPos = zPositions[zInd];
		
					aItemPositions.push_back(Vec3(xPos, yPos, zPos));
				}
			}
		}
	}
	else
	{
		for (unsigned int xInd = 0; xInd < edgeCount; xInd++)
		{
			const float xPos = xPositions[xInd];
			for (unsigned int yInd = 0; yInd < edgeCount; yInd++)
			{
				float yPos = yPositions[yInd];
				
				for (unsigned int zInd = 0; zInd < edgeCount; zInd++)
				{
					float zPos = zPositions[zInd];
					aItemPositions.push_back(Vec3(xPos, yPos, zPos));
				}
			}
		}
	}
}