void CqDisplayServerImage::acceptData(TqUlong xmin, TqUlong xmaxplus1, TqUlong ymin, TqUlong ymaxplus1, TqInt elementSize, const unsigned char* bucketData )
{
	assert(elementSize == m_realData->channelList().bytesPerPixel());

	// yuck.  To fix the casts, refactor Image to use signed ints.
	TqInt cropXmin = static_cast<TqInt>(xmin) - static_cast<TqInt>(m_originX);
	TqInt cropYmin = static_cast<TqInt>(ymin) - static_cast<TqInt>(m_originY);

	boost::mutex::scoped_lock lock(mutex());

	if(m_realData && m_displayData)
	{
		// The const_cast below is ugly, but I don't see how to avoid it
		// without some notion of "const constructor" which isn't present in
		// C++
		const CqMixedImageBuffer bucketBuf(m_realData->channelList(),
				boost::shared_array<TqUchar>(const_cast<TqUchar*>(bucketData),
					nullDeleter), xmaxplus1 - xmin, ymaxplus1 - ymin);

		m_realData->copyFrom(bucketBuf, cropXmin, cropYmin);
		m_displayData->compositeOver(bucketBuf, m_displayMap, cropXmin, cropYmin);

		if(m_updateCallback)
			m_updateCallback(xmin, ymin, xmaxplus1-xmin, ymaxplus1-ymin);
	}
}
void dBonesToPoseBinding::UpdatePose() const
{
	if (m_updateCallback) {
		for (dListNode* node = GetFirst(); node; node = node->GetNext()) {
			dBindFrameToNode& bindFrame = node->GetInfo();
			m_updateCallback (bindFrame.m_userData, &bindFrame.m_sourceTranform->m_posit[0], &bindFrame.m_sourceTranform->m_rotation.m_q0); 
//break;
		}
	}
}
示例#3
0
/** \brief Update the [near,far] clipping interval for z-buffer data
 *
 * If the data represents a z-buffer, iterate across and update the clipping
 * range reported by the image to reflect the minimum and maximum data present
 * in the image.  Occurances of FLT_MAX in the data are ignored since that
 * represents regions without visible objects.
 */
void CqImage::updateClippingRange()
{
	if(!isZBuffer())
		return;

	assert(m_realData);

	TqFloat maxD = 0;
	TqFloat minD = FLT_MAX;
	// Iterate through the map, updating the min and max depths.
	const TqFloat* buf = reinterpret_cast<const TqFloat*>(m_realData->rawData());
	for(int i = 0, size = m_realData->width()*m_realData->height(); i < size; ++i)
	{
		TqFloat z = buf[i];
		// Ignore any depths greater than 0.5*FLT_MAX, since they more than
		// likely come from regions where the max depth was averaged with a
		// surface near the camera, and will result in a non-useful
		// normalisation.
		if(z >= 0.5f*FLT_MAX)
			continue;
		if(z > maxD)
			maxD = z;
		else if(z < minD)
			minD = z;
	}
	if(minD == FLT_MAX)
		minD = 0;
	// Make sure a finite range is reported when no data is present.
	if(maxD <= minD)
		maxD = minD+1e-5;
	m_clippingNear = minD;
	m_clippingFar = maxD;

	if(m_updateCallback)
		m_updateCallback(-1, -1, -1, -1);
}
void SDLStage::update(int deltaTime)
{	
	if (m_updateCallback)
		m_updateCallback(deltaTime);
}
示例#5
0
void CqImage::loadFromFile(const std::string& fileName, TqInt imageIndex)
{
	boost::mutex::scoped_lock lock(mutex());

	boost::shared_ptr<IqTexInputFile> texFile;
	try
	{
		texFile = IqTexInputFile::open(fileName);
		if(imageIndex > 0)
		{
			IqMultiTexInputFile* multiFile = dynamic_cast<IqMultiTexInputFile*>(texFile.get());
			if(multiFile && imageIndex < multiFile->numSubImages())
			{
				multiFile->setImageIndex(imageIndex);
				m_imageIndex = imageIndex;
			}
			else
				return;
		}
		else
			m_imageIndex = 0;
	}
	catch(XqInternal& e)
	{
		Aqsis::log() << error << "Could not load image \"" << fileName << "\": "
			<< e.what() << "\n";
		return;
	}
	setFilename(fileName);
	// \todo: Should read the origin and frame size out of the image.

	const CqTexFileHeader& header = texFile->header();
	TqUint width = header.width();
	TqUint height = header.height();
	setImageSize(width, height);
	// set size within larger cropped window
	const SqImageRegion displayWindow = header.find<Attr::DisplayWindow>(
			SqImageRegion(width, height, 0, 0) );
	setFrameSize(displayWindow.width, displayWindow.height);
	setOrigin(displayWindow.topLeftX, displayWindow.topLeftY);
	// descriptive strings
	setDescription(header.find<Attr::Description>(
				header.find<Attr::Software>("No description") ).c_str());

	m_realData = boost::shared_ptr<CqMixedImageBuffer>(new CqMixedImageBuffer());
	texFile->readPixels(*m_realData);

	Aqsis::log() << Aqsis::info << "Loaded image " << fileName
		<< " [" << width << "x" << height << " : "
		<< texFile->header().channelList() << "]" << std::endl;

	fixupDisplayMap(m_realData->channelList());
	// Quantize and display the data
	m_displayData = boost::shared_ptr<CqMixedImageBuffer>(
			new CqMixedImageBuffer(CqChannelList::displayChannels(), width, height));
	m_displayData->initToCheckerboard();
	m_displayData->compositeOver(*m_realData, m_displayMap);

	// Compute the effective clipping range for z-buffers
	updateClippingRange();

	if(m_updateCallback)
		m_updateCallback(-1, -1, -1, -1);
}