Crystal Space
Welcome, Guest. Please login or register.
July 30, 2014, 02:07:50 am

Login with username, password and session length
Search:     Advanced search
9005 Posts in 2043 Topics by 8255 Members
Latest Member: Mslenacarleen0303
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Game Content Creation
| | |-+  How do I construct a csRenderBuffer that will hold triangles?
« previous next »
Pages: [1] Print
Author Topic: How do I construct a csRenderBuffer that will hold triangles?  (Read 7420 times)
Newbie
*
Posts: 8


View Profile Email
« on: April 27, 2008, 04:13:50 am »

Dear Crystal Space users and developers:
     I am subdividing a single genmesh room into a floor submesh, a submesh of walls and a ceiling
submesh. I have found out what triangles of my mesh belong to those different groups and I stored each group into it's own csArray<csTriangle>. I was hoping to fill corresponding csRenderBuffers for each group with the contents of each group's csArray<csTriangle>. Then, I could use these buffers in GeneralFactoryState's function for adding a submesh. However, I don't understand how a csRenderBuffer works. It holds an unsigned char array, but I want it to hold triangles. The CopyInto(const void *data,size_t elementCount,size_t elemOffset=0) function takes a void*; I don't know how I can make my csArray of triangles into void*. Could I give it the pointer of a normal array of triangles? How is a csRenderBuffer supposed to be used to designate the part of a genmesh that will become a submesh?
     Also, could anyone tell me if I have this all wrong. My company and I are going to use genmeshes for our rooms, rocks, weapons and items; furthermore, any meshes that must have two, or more materials we are going to split up into submeshes. This process is very time consuming as you may decipher from the former paragraph. We have to examine the factory file for a given mesh and determine what triangles are where, so that we can designate them to certain submeshes. I don't believe that Blender can export genmeshes to a factory file with preprogrammed sub-meshes, so this is how we're going to do it. Does anyone know a better way?
                                                                                                                                                                       Sincerely,
                                                                                                                                      Stewy P. of Glass Tower Studios
Logged
Administrator
Jr. Member
*****
Posts: 51


View Profile Email
« Reply #1 on: April 27, 2008, 02:41:23 pm »

Well, I think there are two parts to the answer, but first a question, what is it you are actually trying to do?

As for the building a csRenderBuffer manually, below is some example code that builds a index render buffer out of an array of csTriangles. To be able to access the raw array, you should use csDirtyAccessArray instead of csArray

Code:
csDirtyAccessArray<csTriangle> triArray;

// fill the array

csRef<iRenderBuffer> mybuffer = csRenderBuffer::CreateIndexRenderBuffer(triArray.GetSize() * 3, CS_BUF_STATIC, CS_BUFCOMP_UNSIGNED_INT, 0, (size_t)~0);
mybuffer->CopyInto(triArray.GetArray(), triArray.GetSize()*3);

As for blender2cs, it does support submeshes. I believe it will automatically split up an object if you have multiple materials/textures, however I do not know if you can manually create submeshes too. I think someone more versed in blender & b2cs would have to answer that.

-M
Logged
Vincent
Full Member
***
Posts: 191


View Profile WWW
« Reply #2 on: April 27, 2008, 03:03:47 pm »

Quote from:  link=topic=1634.msg7332#msg7332 date=1209303683
As for blender2cs, it does support submeshes. I believe it will automatically split up an object if you have multiple materials/textures, however I do not know if you can manually create submeshes too. I think someone more versed in blender & b2cs would have to answer that.
Just to clarify that statement: get in touch with caedes on IRC at #crystalspace @chat.freenode.net, he should be able to answer, and perhaps implement what you need...
Logged
Newbie
*
Posts: 8


View Profile Email
« Reply #3 on: April 28, 2008, 09:05:07 pm »

Dear first helper:
     The thing that I am needing to do is create genmeshes in CS that have multiple materials. I want a single genmesh room that has a material for the walls and two other materials for the
ceiling and floor. I was under the impression that Blender didn't export the meshes that way, due to having one of my meshes, that had multiple materials, be partially in invisible in CS. I discerned that all faces belonging to the mesh that had the first material were visible while the ones with a second material were not. Therefore, I jumped the conclusion that submeshes were not supported.
     Do you know where I'm supposed to assign the materials on mesh, so that Blender2Crystal will understand? I was assigning materials to the a mesh object through Blender's "edit" buttons, but do you know if I should assign them with the UV editor? If not, then I need to talk to Caedes like Vincent, my other helper, said.
     No matter what, thankyou for your help; I was especially happy to learn how to use a csRenderBuffer.
                                                                                                                                                                       Sincerely,
                                                                                                                                                  Stewy P. of Glass Tower Studios
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 8.988 seconds with 16 queries.