• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ OGRE_ALLOC_T函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中OGRE_ALLOC_T函数的典型用法代码示例。如果您正苦于以下问题:C++ OGRE_ALLOC_T函数的具体用法?C++ OGRE_ALLOC_T怎么用?C++ OGRE_ALLOC_T使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了OGRE_ALLOC_T函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: OGRE_ALLOC_T

    //-----------------------------------------------------------------------
    Math::Math( unsigned int trigTableSize )
    {
        msAngleUnit = AU_DEGREE;
        mTrigTableSize = trigTableSize;
        mTrigTableFactor = mTrigTableSize / Math::TWO_PI;

        mSinTable = OGRE_ALLOC_T(Real, mTrigTableSize, MEMCATEGORY_GENERAL);
        mTanTable = OGRE_ALLOC_T(Real, mTrigTableSize, MEMCATEGORY_GENERAL);

        buildTrigTables();
    }
开发者ID:Gerviba,项目名称:MuOnline,代码行数:12,代码来源:OgreMath.cpp


示例2: OGRE_EXCEPT

  void SplattingManager::createColourMap(Image& image, const ColourList& colours)
  {
    if (colours.size() > mImpl->numTextures)
      OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Given more colours than texture channels available.", __FUNCTION__);

#if OGRE_VERSION_MINOR > 4
    uchar* data = OGRE_ALLOC_T(uchar, mImpl->width*mImpl->height*3, MEMCATEGORY_GENERAL);
#else
    uchar* data = new uchar[mImpl->width*mImpl->height*3];
#endif

    for (size_t y = 0; y < mImpl->height; ++y)
    {
      for (size_t x = 0; x < mImpl->width; ++x)
      {
        ColourValue val (0, 0, 0);
        for (size_t i = 0; i < colours.size(); ++i)
        {
          size_t m = i / mImpl->channels;
          uint t = (uint) (i % mImpl->channels);
          val += colours[i] * (float(mImpl->maps[m]->getValue((uint)x, (uint)y, t)) / 255);
        }

        size_t pos = (x + y * mImpl->width) * 3;
        data[pos+0] = uchar(255*val.r);
        data[pos+1] = uchar(255*val.g);
        data[pos+2] = uchar(255*val.b);
      }
    }

    image.loadDynamicImage(data, mImpl->width, mImpl->height, 1, PF_BYTE_RGB, true);
  }
开发者ID:hjqqq,项目名称:Forever,代码行数:32,代码来源:ETSplattingManager.cpp


示例3: OGRE_FREE

	//-----------------------------------------------------------------------------
	Image & Image::operator = ( const Image &img )
	{
		if( m_pBuffer && m_bAutoDelete )
		{
			OGRE_FREE(m_pBuffer, MEMCATEGORY_GENERAL);
			m_pBuffer = NULL;
		}
		m_uWidth = img.m_uWidth;
		m_uHeight = img.m_uHeight;
		m_uDepth = img.m_uDepth;
		m_eFormat = img.m_eFormat;
		m_uSize = img.m_uSize;
		m_uFlags = img.m_uFlags;
		m_ucPixelSize = img.m_ucPixelSize;
		m_uNumMipmaps = img.m_uNumMipmaps;
		m_bAutoDelete = img.m_bAutoDelete;
		//Only create/copy when previous data was not dynamic data
		if( m_bAutoDelete )
		{
			m_pBuffer = OGRE_ALLOC_T(uchar, m_uSize, MEMCATEGORY_GENERAL);
			memcpy( m_pBuffer, img.m_pBuffer, m_uSize );
		}
		else
		{
			m_pBuffer = img.m_pBuffer;
		}

		return *this;
	}
开发者ID:jjiezheng,项目名称:pap_full,代码行数:30,代码来源:OgreImage.cpp


示例4: OGRE_EXCEPT

    //-----------------------------------------------------------------------------
    Image & Image::flipAroundX()
    {
        if( !mBuffer )
        {
            OGRE_EXCEPT( 
                Exception::ERR_INTERNAL_ERROR,
                "Can not flip an uninitialised texture",
                "Image::flipAroundX" );
        }
        
        mNumMipmaps = 0; // Image operations lose precomputed mipmaps

        size_t rowSpan = mWidth * mPixelSize;

        uchar *pTempBuffer = OGRE_ALLOC_T(uchar, rowSpan * mHeight, MEMCATEGORY_GENERAL);
        uchar *ptr1 = mBuffer, *ptr2 = pTempBuffer + ( ( mHeight - 1 ) * rowSpan );

        for( ushort i = 0; i < mHeight; i++ )
        {
            memcpy( ptr2, ptr1, rowSpan );
            ptr1 += rowSpan; ptr2 -= rowSpan;
        }

        memcpy( mBuffer, pTempBuffer, rowSpan * mHeight);

        OGRE_FREE(pTempBuffer, MEMCATEGORY_GENERAL);

        return *this;
    }
开发者ID:ballisticwhisper,项目名称:ogre,代码行数:30,代码来源:OgreImage.cpp


示例5: freeMemory

    //-----------------------------------------------------------------------------
    Image & Image::operator = ( const Image &img )
    {
        freeMemory();
        mWidth = img.mWidth;
        mHeight = img.mHeight;
        mDepth = img.mDepth;
        mFormat = img.mFormat;
        mBufSize = img.mBufSize;
        mFlags = img.mFlags;
        mPixelSize = img.mPixelSize;
        mNumMipmaps = img.mNumMipmaps;
        mAutoDelete = img.mAutoDelete;
        //Only create/copy when previous data was not dynamic data
        if( mAutoDelete )
        {
            mBuffer = OGRE_ALLOC_T(uchar, mBufSize, MEMCATEGORY_GENERAL);
            memcpy( mBuffer, img.mBuffer, mBufSize );
        }
        else
        {
            mBuffer = img.mBuffer;
        }

        return *this;
    }
开发者ID:ballisticwhisper,项目名称:ogre,代码行数:26,代码来源:OgreImage.cpp


示例6: createMinimap

  Image createMinimap(const Image& colourMap, const Image& lightMap)
  {
    if (colourMap.getWidth() != lightMap.getWidth() || colourMap.getHeight() != lightMap.getHeight())
      OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Images must have the same dimensions.", __FUNCTION__);

#if OGRE_VERSION_MINOR > 4
    uchar* data = OGRE_ALLOC_T(uchar, colourMap.getWidth()*colourMap.getHeight()*3, MEMCATEGORY_GENERAL);
#else
    uchar* data = new uchar[colourMap.getWidth()*colourMap.getHeight()*3];
#endif

    for (size_t y = 0; y < colourMap.getWidth(); ++y)
    {
      for (size_t x = 0; x < colourMap.getHeight(); ++x)
      {
        ColourValue val = const_cast<Image&>(colourMap).getColourAt((uint)x, (uint)y, 0) * const_cast<Image&>(lightMap).getColourAt((uint)x, (uint)y, 0);
        size_t pos = (x + y*colourMap.getWidth()) * 3;
        data[pos+0] = uchar(255*val.r);
        data[pos+1] = uchar(255*val.g);
        data[pos+2] = uchar(255*val.b);
      }
    }

    Image image;
    image.loadDynamicImage(data, colourMap.getWidth(), colourMap.getHeight(), 1, PF_BYTE_RGB, true);
    return image;
  }
开发者ID:hjqqq,项目名称:Forever,代码行数:27,代码来源:ETSplattingManager.cpp


示例7: FreeImage_SetOutputMessage

    //---------------------------------------------------------------------
    DataStreamPtr FreeImageCodec::code(MemoryDataStreamPtr& input, Codec::CodecDataPtr& pData) const
    {        
		// Set error handler
		FreeImage_SetOutputMessage(FreeImageSaveErrorHandler);

		FIBITMAP* fiBitmap = encode(input, pData);

		// open memory chunk allocated by FreeImage
		FIMEMORY* mem = FreeImage_OpenMemory();
		// write data into memory
		FreeImage_SaveToMemory((FREE_IMAGE_FORMAT)mFreeImageType, fiBitmap, mem);
		// Grab data information
		BYTE* data;
		DWORD size;
		FreeImage_AcquireMemory(mem, &data, &size);
		// Copy data into our own buffer
		// Because we're asking MemoryDataStream to free this, must create in a compatible way
		BYTE* ourData = OGRE_ALLOC_T(BYTE, size, MEMCATEGORY_GENERAL);
		memcpy(ourData, data, size);
		// Wrap data in stream, tell it to free on close 
		DataStreamPtr outstream(OGRE_NEW MemoryDataStream(ourData, size, true));
		// Now free FreeImage memory buffers
		FreeImage_CloseMemory(mem);
		// Unload bitmap
		FreeImage_Unload(fiBitmap);

		return outstream;


    }
开发者ID:LiberatorUSA,项目名称:GUCE,代码行数:31,代码来源:OgreFreeImageCodec.cpp


示例8: OGRE_ALLOC_T

    //---------------------------------------------------------------------
	void DeflateStream::init()
	{
		mpZStream = OGRE_ALLOC_T(z_stream, 1, MEMCATEGORY_GENERAL);
		mpZStream->zalloc = OgreZalloc;
		mpZStream->zfree = OgreZfree;
		
		if (getAccessMode() == READ)
		{
			mpTmp = (unsigned char*)OGRE_MALLOC(OGRE_DEFLATE_TMP_SIZE, MEMCATEGORY_GENERAL);
			size_t restorePoint = mCompressedStream->tell();
			// read early chunk
			mpZStream->next_in = mpTmp;
			mpZStream->avail_in = mCompressedStream->read(mpTmp, OGRE_DEFLATE_TMP_SIZE);
			
			if (inflateInit(mpZStream) != Z_OK)
			{
				mIsCompressedValid = false;
			}
			else
				mIsCompressedValid = true;
			
			if (mIsCompressedValid)
			{
				// in fact, inflateInit on some implementations doesn't try to read
				// anything. We need to at least read something to test
				Bytef testOut[4];
				size_t savedIn = mpZStream->avail_in;
				mpZStream->avail_out = 4;
				mpZStream->next_out = testOut;
				if (inflate(mpZStream, Z_SYNC_FLUSH) != Z_OK)
					mIsCompressedValid = false;
				// restore for reading
				mpZStream->avail_in = savedIn;
				mpZStream->next_in = mpTmp;

				inflateReset(mpZStream);
			}

			if (!mIsCompressedValid)
			{
				// Not compressed data!
				// Fail gracefully, fall back on reading the underlying stream direct
				destroy();
				mCompressedStream->seek(restorePoint);
			}				
		}
		else 
		{
			// Write to temp file
			char tmpname[L_tmpnam];
			tmpnam(tmpname);
			mTempFileName = tmpname;
			std::fstream *f = OGRE_NEW_T(std::fstream, MEMCATEGORY_GENERAL)();
			f->open(tmpname, std::ios::binary | std::ios::out);
			mTmpWriteStream = DataStreamPtr(OGRE_NEW FileStreamDataStream(f));
			
		}

	}
开发者ID:dryadf68116,项目名称:vuforia-gamekit-integration,代码行数:60,代码来源:OgreDeflate.cpp


示例9: OGRE_ALLOC_T

//-----------------------------------------------------------------------------  
D3D9HardwarePixelBuffer::BufferResources* D3D9HardwarePixelBuffer::createBufferResources()
{
    BufferResources* newResources = OGRE_ALLOC_T(BufferResources, 1, MEMCATEGORY_RENDERSYS);

    memset(newResources, 0, sizeof(BufferResources));

    return newResources;
}
开发者ID:LiberatorUSA,项目名称:GUCEF,代码行数:9,代码来源:OgreD3D9HardwarePixelBuffer.cpp


示例10: OGRE_ALLOC_T

    void GlobalMap::clear()
    {
        Ogre::uchar* buffer =  OGRE_ALLOC_T(Ogre::uchar, mWidth * mHeight * 4, Ogre::MEMCATEGORY_GENERAL);
        memset(buffer, 0, mWidth * mHeight * 4);

        mOverlayImage.loadDynamicImage(&buffer[0], mWidth, mHeight, 1, Ogre::PF_A8B8G8R8, true); // pass ownership of buffer to image

        mOverlayTexture->load();
    }
开发者ID:AAlderman,项目名称:openmw,代码行数:9,代码来源:globalmap.cpp


示例11: suggestPixelFormat

    //-----------------------------------------------------------------------
    void RenderTarget::writeContentsToFile(const String& filename)
    {
        PixelFormat pf = suggestPixelFormat();

        uchar *data = OGRE_ALLOC_T(uchar, mWidth * mHeight * PixelUtil::getNumElemBytes(pf), MEMCATEGORY_RENDERSYS);
        PixelBox pb(mWidth, mHeight, 1, pf, data);

        copyContentsToMemory(pb);

        Image().loadDynamicImage(data, mWidth, mHeight, 1, pf, false, 1, 0).save(filename);

        OGRE_FREE(data, MEMCATEGORY_RENDERSYS);
    }
开发者ID:mACH1VO,项目名称:MuOnline,代码行数:14,代码来源:OgreRenderTarget.cpp


示例12: GridSource

HalfFloatGridSource::HalfFloatGridSource(const String &serializedVolumeFile, const bool trilinearValue, const bool trilinearGradient, const bool sobelGradient) :
    GridSource(trilinearValue, trilinearGradient, sobelGradient)
{

    Timer t;
    DataStreamPtr streamRead = Root::getSingleton().openFileStream(serializedVolumeFile);
#if OGRE_NO_ZIP_ARCHIVE == 0
    DataStreamPtr uncompressStream(OGRE_NEW DeflateStream(serializedVolumeFile, streamRead));
    StreamSerialiser ser(uncompressStream);
#else
    StreamSerialiser ser(streamRead);
#endif
    if (!ser.readChunkBegin(VOLUME_CHUNK_ID, VOLUME_CHUNK_VERSION))
    {
        OGRE_EXCEPT(Exception::ERR_INVALID_STATE,
                    "Invalid volume file given!",
                    __FUNCTION__);
    }

    // Read header
    Vector3 readFrom, readTo;
    ser.read(&readFrom);
    ser.read(&readTo);
    float voxelWidth;
    ser.read<float>(&voxelWidth);
    size_t width, height, depth;
    ser.read<size_t>(&width);
    ser.read<size_t>(&height);
    ser.read<size_t>(&depth);
    mWidth = static_cast<int>(width);
    mHeight = static_cast<int>(height);
    mDepth = static_cast<int>(depth);
    mDepthTimesHeight = static_cast<int>(mDepth * mHeight);

    Vector3 worldDimension = readTo - readFrom;
    mPosXScale = (Real)1.0 / (Real)worldDimension.x * (Real)mWidth;
    mPosYScale = (Real)1.0 / (Real)worldDimension.y * (Real)mHeight;
    mPosZScale = (Real)1.0 / (Real)worldDimension.z * (Real)mDepth;

    mVolumeSpaceToWorldSpaceFactor = (Real)worldDimension.x * (Real)mWidth;
    mMaxClampedAbsoluteDensity = 0;

    // Read data
    size_t elementCount = mWidth * mHeight * mDepth;
    mData = OGRE_ALLOC_T(uint16, elementCount, MEMCATEGORY_GENERAL);
    ser.read(mData, elementCount);

    ser.readChunkEnd(VOLUME_CHUNK_ID);

    LogManager::getSingleton().stream() << "Processed serialization in " << t.getMilliseconds() << "ms.";
}
开发者ID:quinsmpang,项目名称:xsilium-engine,代码行数:51,代码来源:OgreVolumeHalfFloatGridSource.cpp


示例13: saveBrushToImage

  void saveBrushToImage(const Brush& brush, Image& image)
  {
    // save brush as a 16bit grayscale image
#if OGRE_VERSION_MINOR > 4
    ushort* data = (ushort*)OGRE_ALLOC_T(uchar, brush.getWidth()*brush.getHeight()*sizeof(ushort), MEMCATEGORY_GENERAL);
#else
    ushort* data = (ushort*)new uchar[brush.getWidth()*brush.getHeight()*sizeof(ushort)];
#endif
    for (size_t x = 0; x < brush.getWidth(); ++x)
      for (size_t y = 0; y < brush.getHeight(); ++y)
        data[y*brush.getWidth() + x] = ushort(brush.at(x, y) * 0xffff);

    // pass the data to the image, image takes over ownership
    image.loadDynamicImage((uchar*)data, brush.getWidth(), brush.getHeight(), 1, PF_L16, true);
  }
开发者ID:oksangman,项目名称:Ant,代码行数:15,代码来源:ETBrush.cpp


示例14: publishFrame

  // bool publishFrame(Ogre::RenderWindow * render_object, const std::string frame_id)
  bool publishFrame(Ogre::RenderTexture * render_object, const std::string frame_id)
  {
    if (pub_.getTopic() == "")
    {
      return false;
    }
    if (frame_id == "")
    {
      return false;
    }
    // RenderTarget::writeContentsToFile() used as example
    int height = render_object->getHeight();
    int width = render_object->getWidth();
    // the results of pixel format have to be used to determine
    // image.encoding
    Ogre::PixelFormat pf = render_object->suggestPixelFormat();
    uint pixelsize = Ogre::PixelUtil::getNumElemBytes(pf);
    uint datasize = width * height * pixelsize;

    // 1.05 multiplier is to avoid crash when the window is resized.
    // There should be a better solution.
    uchar *data = OGRE_ALLOC_T(uchar, datasize * 1.05, Ogre::MEMCATEGORY_RENDERSYS);
    Ogre::PixelBox pb(width, height, 1, pf, data);
    render_object->copyContentsToMemory(pb, Ogre::RenderTarget::FB_AUTO);

    sensor_msgs::Image image;
    image.header.stamp = ros::Time::now();
    image.header.seq = image_id_++;
    image.header.frame_id = frame_id;
    image.height = height;
    image.width = width;
    image.step = pixelsize * width;
    if (pixelsize == 3)
      image.encoding = sensor_msgs::image_encodings::RGB8;  // would break if pf changes
    else if (pixelsize == 4)
      image.encoding = sensor_msgs::image_encodings::RGBA8;  // would break if pf changes
    else
    {
      ROS_ERROR_STREAM("unknown pixe format " << pixelsize << " " << pf);
    }
    image.is_bigendian = (OGRE_ENDIAN == OGRE_ENDIAN_BIG);
    image.data.resize(datasize);
    memcpy(&image.data[0], data, datasize);
    pub_.publish(image);

    OGRE_FREE(data, Ogre::MEMCATEGORY_RENDERSYS);
  }
开发者ID:lucasw,项目名称:rviz_camera_stream,代码行数:48,代码来源:camera_display.cpp


示例15: assert

    //-----------------------------------------------------------------------------
    void Image::resize(ushort width, ushort height, Filter filter)
    {
        // resizing dynamic images is not supported
        assert(mAutoDelete);
        assert(mDepth == 1);

        // reassign buffer to temp image, make sure auto-delete is true
        Image temp;
        temp.loadDynamicImage(mBuffer, mWidth, mHeight, 1, mFormat, true);
        // do not delete[] mBuffer!  temp will destroy it

        // set new dimensions, allocate new buffer
        mWidth = width;
        mHeight = height;
        mBufSize = PixelUtil::getMemorySize(mWidth, mHeight, 1, mFormat);
        mBuffer = OGRE_ALLOC_T(uchar, mBufSize, MEMCATEGORY_GENERAL);
        mNumMipmaps = 0; // Loses precomputed mipmaps

        // scale the image from temp into our resized buffer
        Image::scale(temp.getPixelBox(), getPixelBox(), filter);
    }
开发者ID:ballisticwhisper,项目名称:ogre,代码行数:22,代码来源:OgreImage.cpp


示例16: assert

	Vector4* SnowTerrain::convertNormalsToFloats(PixelBox* terrainNormals, bool compressed)
	{
		const size_t srcPixelSize = PixelUtil::getNumElemBytes(terrainNormals->format);
		const size_t dstPixelSize = PixelUtil::getNumElemBytes(PF_FLOAT32_RGBA);
		size_t w,h,d;
		w = terrainNormals->getWidth();
		h = terrainNormals->getHeight();
		d = terrainNormals->getDepth();

		assert(terrainNormals->getWidth() == mTerrainSize);
		size_t terrainNormalSize = terrainNormals->getWidth()*terrainNormals->getHeight();
		Vector4* terrainNormalDataCorrected = OGRE_ALLOC_T(Vector4, terrainNormalSize, MEMCATEGORY_GENERAL);

		size_t i = 0; size_t j = 0;
		uint8* pixelsBuffer = static_cast<uint8*>(terrainNormals->data);
		for(; i < terrainNormalSize * srcPixelSize && j < terrainNormalSize * sizeof(Vector4); i+=srcPixelSize)
		{
			uint8 r,g,b,a;
			PixelUtil::unpackColour(&r,&g,&b,&a, terrainNormals->format, static_cast<void*>(&pixelsBuffer[i]));
			float fr,fg,fb;
			if(compressed)
			{			
				//(signed) float packed/compressed into uint8, unpack
				fr = ((float)(r))/(0.5f * 255.0f) - 1.0f;
				fg = ((float)(g))/(0.5f * 255.0f) - 1.0f;
				fb = ((float)(b))/(0.5f * 255.0f) - 1.0f;
			}
			else
			{
				fr = ((float)(r))/255.0f;
				fg = ((float)(g))/255.0f;
				fb = ((float)(b))/255.0f;
			}
			Vector3 v = Vector3(fr, fg, fb);
			v.normalise();
			terrainNormalDataCorrected[j++] = Vector4(v);
		}

		return terrainNormalDataCorrected;
	}
开发者ID:pranavsureshpn,项目名称:gpusphsim,代码行数:40,代码来源:SnowTerrain.cpp


示例17: calculateSize

    //-----------------------------------------------------------------------------
    Image & Image::loadRawData(
        DataStreamPtr& stream, 
        uint32 uWidth, uint32 uHeight, uint32 uDepth,
        PixelFormat eFormat,
        size_t numFaces, size_t numMipMaps)
    {

        size_t size = calculateSize(numMipMaps, numFaces, uWidth, uHeight, uDepth, eFormat);
        if (size != stream->size())
        {
            OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
                "Stream size does not match calculated image size", 
                "Image::loadRawData");
        }

        uchar *buffer = OGRE_ALLOC_T(uchar, size, MEMCATEGORY_GENERAL);
        stream->read(buffer, size);

        return loadDynamicImage(buffer,
            uWidth, uHeight, uDepth,
            eFormat, true, numFaces, numMipMaps);

    }
开发者ID:ballisticwhisper,项目名称:ogre,代码行数:24,代码来源:OgreImage.cpp


示例18: OgreAssert

	//-----------------------------------------------------------------------
	void ConvexBody::clip( const Plane& pl, bool keepNegative )
	{
		if ( getPolygonCount() == 0 )
			return;

		// current will be used as the reference body
		ConvexBody current;
		current.moveDataFromBody(*this);
		
		OgreAssert( this->getPolygonCount() == 0, "Body not empty!" );
		OgreAssert( current.getPolygonCount() != 0, "Body empty!" );

		// holds all intersection edges for the different polygons
		Polygon::EdgeMap intersectionEdges;

		// clip all polygons by the intersection plane
		// add only valid or intersected polygons to *this
		for ( size_t iPoly = 0; iPoly < current.getPolygonCount(); ++iPoly )
		{

			// fetch vertex count and ignore polygons with less than three vertices
			// the polygon is not valid and won't be added
			const size_t vertexCount = current.getVertexCount( iPoly );
			if ( vertexCount < 3 )
				continue;

			// current polygon
			const Polygon& p = current.getPolygon( iPoly );

			// the polygon to assemble
			Polygon *pNew = allocatePolygon();

			// the intersection polygon (indeed it's an edge or it's empty)
			Polygon *pIntersect = allocatePolygon();
			
			// check if polygons lie inside or outside (or on the plane)
			// for each vertex check where it is situated in regard to the plane
			// three possibilities appear:
			Plane::Side clipSide = keepNegative ? Plane::POSITIVE_SIDE : Plane::NEGATIVE_SIDE;
			// - side is clipSide: vertex will be clipped
			// - side is !clipSide: vertex will be untouched
			// - side is NOSIDE:   vertex will be untouched
			Plane::Side *side = OGRE_ALLOC_T(Plane::Side, vertexCount, MEMCATEGORY_SCENE_CONTROL);
			for ( size_t iVertex = 0; iVertex < vertexCount; ++iVertex )
			{
				side[ iVertex ] = pl.getSide( p.getVertex( iVertex ) );
			}

			// now we check the side combinations for the current and the next vertex
			// four different combinations exist:
			// - both points inside (or on the plane): keep the second (add it to the body)
			// - both points outside: discard both (don't add them to the body)
			// - first vertex is inside, second is outside: add the intersection point
			// - first vertex is outside, second is inside: add the intersection point, then the second
			for ( size_t iVertex = 0; iVertex < vertexCount; ++iVertex )
			{
				// determine the next vertex
				size_t iNextVertex = ( iVertex + 1 ) % vertexCount;

				const Vector3& vCurrent = p.getVertex( iVertex );
				const Vector3& vNext    = p.getVertex( iNextVertex );

				// case 1: both points inside (store next)
				if ( side[ iVertex ]     != clipSide &&		// NEGATIVE or NONE
					 side[ iNextVertex ] != clipSide )		// NEGATIVE or NONE
				{
					// keep the second
					pNew->insertVertex( vNext );
				}

				// case 3: inside -> outside (store intersection)
				else if ( side[ iVertex ]		!= clipSide &&
						  side[ iNextVertex ]	== clipSide )
				{
					// Do an intersection with the plane. We use a ray with a start point and a direction.
					// The ray is forced to hit the plane with any option available (eigher current or next
					// is the starting point)

					// intersect from the outside vertex towards the inside one
					Vector3 vDirection = vCurrent - vNext;
					vDirection.normalise();
					Ray ray( vNext, vDirection );
					std::pair< bool, Real > intersect = ray.intersects( pl );

					// store intersection
					if ( intersect.first )
					{
						// convert distance to vector
						Vector3 vIntersect = ray.getPoint( intersect.second );	

						// store intersection
						pNew->insertVertex( vIntersect );
						pIntersect->insertVertex( vIntersect );
					}
				}

				// case 4: outside -> inside (store intersection, store next)
				else if ( side[ iVertex ]		== clipSide &&
					side[ iNextVertex ]			!= clipSide )
//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:gamekit,代码行数:101,代码来源:OgreConvexBody.cpp


示例19: root

//-----------------------------------------------------------------------
void AtlasImageTool::process (void)
{
	Ogre::Root root("", "", "atlas.log");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(mImagePath, "FileSystem");
	Ogre::StringVector::iterator itInputFileName;
	Ogre::StringVector::iterator itFrame;
	Ogre::StringVector::iterator itAlpha;

	itAlpha = mAlpha.begin();
	if (mInputFrames.empty() || mInputFrames[0] == Ogre::StringUtil::BLANK)
	{
		// No Frames are assigned so just add them
		for (itInputFileName = mInputFileNames.begin(); itInputFileName != mInputFileNames.end(); ++itInputFileName)
		{
			Ogre::String imageFileName = *itInputFileName;
			Ogre::Image image;
			image.load(imageFileName, "General");

			if (itAlpha != mAlpha.end() && *itAlpha != Ogre::StringUtil::BLANK)
			{
				Ogre::Real alpha = Ogre::StringConverter::parseReal(*itAlpha);
				correctAlpha(image, alpha);
				itAlpha++;
			}

			mAtlasImage.addImage(&image);
		}
	}
	else
	{
		// Frames are assigned, so generate intermediate images
		itInputFileName = mInputFileNames.begin();
		Ogre::Real alpha = 1.0f;
		Ogre::String nextImageFileName = *itInputFileName;
		Ogre::Image nextImage;
		itFrame = mInputFrames.begin();
		size_t nextFrame = Ogre::StringConverter::parseUnsignedInt(*itFrame);
		nextImage.load(nextImageFileName, "General");
		size_t frameCounter = 0;

		if (!mAlpha.empty() && mAlpha[0] != Ogre::StringUtil::BLANK)
		{
			itAlpha = mAlpha.begin();
			Ogre::Real alpha = Ogre::StringConverter::parseReal(*itAlpha);
			correctAlpha(nextImage, alpha);
			itAlpha++;
		}

		mAtlasImage.addImage(&nextImage);
		frameCounter++;
		itInputFileName++;
		itFrame++;

		while (itInputFileName != mInputFileNames.end())
		{
			// Get the next filename
			Ogre::Image firstImage(nextImage);
			nextImageFileName = *itInputFileName;
			nextImage.load(nextImageFileName, "General");

			if (itAlpha != mAlpha.end() && *itAlpha != Ogre::StringUtil::BLANK)
			{
				Ogre::Real alpha = Ogre::StringConverter::parseReal(*itAlpha);
				correctAlpha(nextImage, alpha);
				itAlpha++;
			}

			if (itFrame != mInputFrames.end())
			{
				size_t firstFrame = nextFrame;
				nextFrame = Ogre::StringConverter::parseUnsignedInt(*itFrame);
				itFrame++;
				frameCounter++;

				// Generate and add interpolated images to the atlas image
				size_t numberOfFrames = nextFrame - firstFrame;
				for (size_t i = 1; i < numberOfFrames; ++i)
				{
					Ogre::Real fraction = (Ogre::Real)i / (Ogre::Real)numberOfFrames;
					Ogre::Image interpolatedImage;
					size_t pixelSize = Ogre::PixelUtil::getNumElemBytes(firstImage.getFormat());
					size_t bufferSize = firstImage.getWidth() * firstImage.getHeight() * pixelSize;
					Ogre::uchar* data = OGRE_ALLOC_T(Ogre::uchar, bufferSize, Ogre::MEMCATEGORY_GENERAL);
					interpolatedImage.loadDynamicImage(data, firstImage.getWidth(), firstImage.getHeight(), 1, firstImage.getFormat(), true);
					interpolate (interpolatedImage, firstImage, nextImage, fraction);
					mAtlasImage.addImage(&interpolatedImage);
					frameCounter++;
				}
			}
			mAtlasImage.addImage(&nextImage);
			frameCounter++;
			itInputFileName++;
		}
	}

	mAtlasImage._compile();
	mAtlasImage.save(mImagePath + "//" + mOutputImage);
}
开发者ID:hsl9999,项目名称:particleuniverse,代码行数:99,代码来源:AtlasImageTool.cpp


示例20: getPreviewImage

void 
MaterialPreviewDialog::buildPreviewBitmap( const Ogre::String &texName )
{
	const Ogre::uchar BytePerPixel = 8;

	// 读取原始image
	Ogre::Image *oriImage = getPreviewImage(texName);
	// 源大纹理的大小
	size_t oriImageHeight = oriImage->getHeight();
	size_t oriImageWidth = oriImage->getWidth();

	Ogre::uchar *oriImageData = oriImage->getData();

	// 分配一个足够大的空间来保存新建的image的数据
	size_t newImagegetRowSpan = oriImageWidth*oriImage->getBPP()/BytePerPixel;  // 新建的image的行宽(单位为字节)
	Ogre::uchar *newImageData = OGRE_ALLOC_T(Ogre::uchar, oriImageHeight*newImagegetRowSpan, Ogre::MEMCATEGORY_GENERAL);//new Ogre::uchar[oriImageHeight*newImagegetRowSpan];

	Ogre::uchar *newImageDataPointer = newImageData;

	Ogre::uchar *oriImagedataPointer = oriImageData;

	// 把所选的纹理的数据提取出来,并创建一个新的image
	for ( Ogre::uint i=0; i<oriImageHeight; ++i )
	{
		memcpy(newImageDataPointer, oriImagedataPointer, newImagegetRowSpan);
		newImageDataPointer += newImagegetRowSpan;
		oriImagedataPointer += oriImage->getRowSpan();
	}

	Ogre::Image newImage;
	newImage.loadDynamicImage(newImageData,oriImageWidth,oriImageHeight,1,oriImage->getFormat(),true);

	// 如果所选纹理大于64*64,就先resize
	if ( oriImageWidth > mPreviewImageWidth || oriImageHeight > mPreviewImageHeight )
		newImage.resize(mPreviewImageWidth, mPreviewImageHeight);

	// 如果有alpha,要与黑白图进行混合
	if ( newImage.getHasAlpha() )
	{
		Ogre::ColourValue col;

		for ( int i=0; i<mPreviewImageWidth; ++i )
		{
			for ( int j=0; j<mPreviewImageWidth; ++j )
			{
				col = newImage.getColourAt(j,i,0);

				float alphaValue = col.a;

				unsigned char r = col.r*255 * alphaValue; 
				unsigned char g = col.g*255 * alphaValue; 
				unsigned char b = col.b*255 * alphaValue;

				// 设置到image中
				mCurrentPreviewImage.SetRGB(j,i,r,g,b);
			}
		}
	}
	// 没有alpha,就直接拷贝数据
	else
	{
		Ogre::ColourValue col;

		for ( int i=0; i<mPreviewImageWidth; ++i )
		{
			for ( int j=0; j<mPreviewImageWidth; ++j )
			{
				col = newImage.getColourAt(j,i,0);

				unsigned char r = col.r*255;
				unsigned char g = col.g*255;
				unsigned char b = col.b*255;

				// 设置到image中
				mCurrentPreviewImage.SetRGB(j,i,r,g,b);
			}
		}
	}
}
开发者ID:jjiezheng,项目名称:pap_full,代码行数:79,代码来源:WXMaterialPreviewDialog.cpp



注:本文中的OGRE_ALLOC_T函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ OGRE_DELETE_T函数代码示例发布时间:2022-05-30
下一篇:
C++ OGLPLUS_ERROR_INFO函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap