the error of integrate with ogre iOS

Help with integrating libRocket into your engine and game

the error of integrate with ogre iOS

Postby yaxinhoo on Mon Nov 07, 2011 1:49 pm

i write a demo integrate with ogre on iOS . every thing seems ok , but got a bad result .
demo source can download from
http://www.adrive.com/public/dAjSQP.html

librocket can download from
http://www.adrive.com/public/XZEVEt.html

the result is , any suggestion?
Attachments
屏幕快照 2011-11-07 下午9.38.26.png
屏幕快照 2011-11-07 下午9.38.26.png (126.81 KiB) Viewed 10647 times
Last edited by yaxinhoo on Tue Mar 27, 2012 6:25 pm, edited 3 times in total.
yaxinhoo
 
Posts: 47
Joined: Sat Sep 18, 2010 4:52 am

Re: the error of integrate with ogre iOS

Postby yaxinhoo on Sat Nov 12, 2011 4:47 am

the right result should be
Attachments
rightresultdialog.png
rightresultdialog.png (50.31 KiB) Viewed 10638 times
yaxinhoo
 
Posts: 47
Joined: Sat Sep 18, 2010 4:52 am

Re: the error of integrate with ogre iOS

Postby lloydw on Sat Mar 03, 2012 12:10 am

Unfortunately I'm not that familiar with Ogre and iOS. I'm pretty sure some other people in this forum have got Ogre running on iOS ok, try searching and contacting them.

One thing that may be an issue is libRocket passes indices as 32bit ints, so you have to convert these to 16bit indices for iOS, not sure if Ogre is doing this for you or not.
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm

Re: the error of integrate with ogre iOS

Postby yaxinhoo on Thu Mar 29, 2012 2:53 am

thanks for you reply. what can i do if i want to change the rocket passes indices as 16bit ints.
yaxinhoo
 
Posts: 47
Joined: Sat Sep 18, 2010 4:52 am

Re: the error of integrate with ogre iOS

Postby lloydw on Thu Mar 29, 2012 3:00 am

You'd have to go through the code and change all the geometry classes to store indices as 16bit ints. It would take a couple hours most likely and is currently on the TODO list, so feel free to do it and send me a GitHub pull request :)
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm


Re: the error of integrate with ogre iOS

Postby yaxinhoo on Sun Apr 08, 2012 11:03 am

i can convert the ogre indices to 16bit , but i don't know how to convert rocket's indices. can you tell me ?
yaxinhoo
 
Posts: 47
Joined: Sat Sep 18, 2010 4:52 am

Re: the error of integrate with ogre iOS

Postby lloydw on Wed May 23, 2012 10:05 am

Just a simple for loop will do.

Code: Select all
uint16_t new_indices[10240];
for (int i = 0; i < num_indices; i++)
   new_indices[i] = indices[i];
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm

Re: the error of integrate with ogre iOS

Postby yaxinhoo on Thu Jun 28, 2012 1:32 am

~~~~~~~not that mean , it can work any more . i want to know the rocekt intf "CompiledGeometryHandle" is 32 bit . but i want to change it to 16 bit , so i implation the RenderInteface to render it .
Code: Select all
Rocket::Core::CompiledGeometryHandle RenderInterfaceOgre3D::CompileGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture)
{
   RocketOgre3DCompiledGeometry* geometry = new RocketOgre3DCompiledGeometry();
   geometry->texture = texture == NULL ? NULL : (RocketOgre3DTexture*) texture;

   geometry->render_operation.vertexData = new Ogre::VertexData();
   geometry->render_operation.vertexData->vertexStart = 0;
   geometry->render_operation.vertexData->vertexCount = num_vertices;

   geometry->render_operation.indexData = new Ogre::IndexData();
   geometry->render_operation.indexData->indexStart = 0;
   geometry->render_operation.indexData->indexCount = num_indices;

   geometry->render_operation.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;


   // Set up the vertex declaration.
   Ogre::VertexDeclaration* vertex_declaration = geometry->render_operation.vertexData->vertexDeclaration;
   size_t element_offset = 0;
   vertex_declaration->addElement(0, element_offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
   element_offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
   vertex_declaration->addElement(0, element_offset, Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);
   element_offset += Ogre::VertexElement::getTypeSize(Ogre::VET_COLOUR);
   vertex_declaration->addElement(0, element_offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES);


   // Create the vertex buffer.
   Ogre::HardwareVertexBufferSharedPtr vertex_buffer = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(vertex_declaration->getVertexSize(0), num_vertices, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
   geometry->render_operation.vertexData->vertexBufferBinding->setBinding(0, vertex_buffer);

   // Fill the vertex buffer.
   RocketOgre3DVertex* ogre_vertices = (RocketOgre3DVertex*) vertex_buffer->lock(0, vertex_buffer->getSizeInBytes(), Ogre::HardwareBuffer::HBL_NORMAL);
   for (int i = 0; i < num_vertices; ++i)
   {
      ogre_vertices[i].x = vertices[i].position.x;
      ogre_vertices[i].y = vertices[i].position.y;
      ogre_vertices[i].z = 0;

      Ogre::ColourValue diffuse(vertices[i].colour.red / 255.0f, vertices[i].colour.green / 255.0f, vertices[i].colour.blue / 255.0f, vertices[i].colour.alpha / 255.0f);
      render_system->convertColourValue(diffuse, &ogre_vertices[i].diffuse);

      ogre_vertices[i].u = vertices[i].tex_coord[0];
      ogre_vertices[i].v = vertices[i].tex_coord[1];
   }
   vertex_buffer->unlock();


   // Create the index buffer.
   Ogre::HardwareIndexBufferSharedPtr index_buffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(Ogre::HardwareIndexBuffer::IT_32BIT, num_indices, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
   geometry->render_operation.indexData->indexBuffer = index_buffer;
   geometry->render_operation.useIndexes = true;

   // Fill the index buffer.
   void* ogre_indices = index_buffer->lock(0, index_buffer->getSizeInBytes(), Ogre::HardwareBuffer::HBL_NORMAL);
   memcpy(ogre_indices, indices, sizeof(unsigned int) * num_indices);
   index_buffer->unlock();


   return reinterpret_cast<Rocket::Core::CompiledGeometryHandle>(geometry);
}


i must change
Code: Select all
Ogre::HardwareIndexBufferSharedPtr index_buffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(Ogre::HardwareIndexBuffer::IT_32BIT, num_indices, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);


to

Code: Select all
Ogre::HardwareIndexBufferSharedPtr index_buffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(Ogre::HardwareIndexBuffer::IT_16BIT, num_indices, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);


but the result convert

Code: Select all
return reinterpret_cast<Rocket::Core::CompiledGeometryHandle>(geometry);


is 32 bit . so it 's wrong.
yaxinhoo
 
Posts: 47
Joined: Sat Sep 18, 2010 4:52 am

Re: the error of integrate with ogre iOS

Postby yaxinhoo on Thu Jun 28, 2012 1:43 am

thanks
Last edited by yaxinhoo on Mon Apr 29, 2013 6:28 pm, edited 1 time in total.
yaxinhoo
 
Posts: 47
Joined: Sat Sep 18, 2010 4:52 am

Next

Return to Engine Integration


cron