コード例 #1
0
ファイル: geometry_script.cpp プロジェクト: ejabx/katana
void setGeometryIndices( Geometry * pGeom, const luabind::object & indexTable )
{
	if ( indexTable.is_valid() && indexTable.type() == LUA_TTABLE )
	{
		if ( !pGeom->m_indexBuffer ) pGeom->m_indexBuffer.reset( new vector<unsigned short> );
		unsigned int uiNewIndices = 0;
		pGeom->m_indexBuffer->clear();
		for( luabind::object::array_iterator iter = indexTable.abegin();
			iter != indexTable.aend();
			iter++, uiNewIndices++ )
		{
			boost::optional<unsigned short> oindex = luabind::object_cast_nothrow<unsigned short>( *iter );
			if ( oindex )
				pGeom->m_indexBuffer->push_back( *oindex.get() );
		}
		pGeom->m_indexCount = uiNewIndices;
	}
}
コード例 #2
0
ファイル: geometry_script.cpp プロジェクト: ejabx/katana
void setGeometryTexture1( Geometry * pGeom, const luabind::object & texture1Table )
{
	if ( texture1Table.is_valid() && texture1Table.type() == LUA_TTABLE )
	{
		if ( !pGeom->m_texture1Buffer ) pGeom->m_texture1Buffer.reset( new vector<float> );
		pGeom->m_texture1Buffer->clear();
		for( luabind::object::array_iterator iter = texture1Table.abegin();
			iter != texture1Table.aend();
			iter++ )
		{
			boost::optional<Point2> opt = luabind::object_cast_nothrow<Point2>( *iter );
			if ( opt )
			{
				Point2 * pt = opt.get();
				pGeom->m_texture1Buffer->push_back( pt->x );
				pGeom->m_texture1Buffer->push_back( pt->y );
			}
		}
	}
}
コード例 #3
0
ファイル: geometry_script.cpp プロジェクト: ejabx/katana
void setGeometryColor( Geometry * pGeom, const luabind::object & colorTable )
{
	if ( colorTable.is_valid() && colorTable.type() == LUA_TTABLE )
	{
		if ( !pGeom->m_colorBuffer ) pGeom->m_colorBuffer.reset( new vector<float> );
		pGeom->m_colorBuffer->clear();
		for( luabind::object::array_iterator iter = colorTable.abegin();
			iter != colorTable.aend();
			iter++ )
		{
			boost::optional<ColorA> opt = luabind::object_cast_nothrow<ColorA>( *iter );
			if ( opt )
			{
				ColorA * pt = opt.get();
				pGeom->m_colorBuffer->push_back( pt->r );
				pGeom->m_colorBuffer->push_back( pt->g );
				pGeom->m_colorBuffer->push_back( pt->b );
				pGeom->m_colorBuffer->push_back( pt->a );
			}
		}
	}
}
コード例 #4
0
ファイル: geometry_script.cpp プロジェクト: ejabx/katana
//
// Local Functions
//
void setGeometryVertices( Geometry * pGeom, const luabind::object & vertexTable )
{
	if ( vertexTable.is_valid() && vertexTable.type() == LUA_TTABLE )
	{
		if ( !pGeom->m_vertexBuffer ) pGeom->m_vertexBuffer.reset( new vector<float> );
		pGeom->m_vertexBuffer->clear();
		unsigned uiNewVertices = 0;
		for( luabind::object::array_iterator iter = vertexTable.abegin();
			iter != vertexTable.aend();
			iter++, uiNewVertices++ )
		{
			boost::optional<Point3> opt = luabind::object_cast_nothrow<Point3>( *iter );
			if ( opt )
			{
				Point3 * pt = opt.get();
				pGeom->m_vertexBuffer->push_back( pt->x );
				pGeom->m_vertexBuffer->push_back( pt->y );
				pGeom->m_vertexBuffer->push_back( pt->z );
			}
		}
		pGeom->m_vertexCount = uiNewVertices;
	}
}