About Store Forum Documentation Contact



Post Reply 
Custom Rendering
Author Message
Brainache Offline
Member

Post: #1
Custom Rendering
Hey there,

If I wanted to create an object and define how it was rendered - for example - lets just say I want to create an object that renders a cube...

Is it possable to actualy define the draw method?
Send verts and texture coords to render?

If I've overlooked an example showing this - please let me know...

Thanks
12-05-2008 03:57 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
Re: Custom Rendering
Hi,

Yes you can access vertex positions, textures, etc.

If you want it only for cube rendering you can use already defined following functions:
Code:
struct Mshb
{
   Mshb& createPlane   (Int      x=2,Int y=2,UInt flag=0                                       ); // create plane                                , 'flag'=VTX_FLAG
   Mshb& createFast    (Box     &box                                                           ); // create box (fast)
   Mshb& create        (Box     &box     ,UInt flag=0     ,Int resolution=-1                   ); // create box                                  , 'flag'=VTX_FLAG
   Mshb& create        (Ball    &ball    ,UInt flag=0     ,Int resolution=-1                   ); // create ball in cube      mode and uv mapping, 'flag'=VTX_FLAG
   Mshb& create2       (Ball    &ball    ,UInt flag=0     ,Int resolution=-1,Int resolution2=-1); // create ball in spherical mode and uv mapping, 'flag'=VTX_FLAG
   Mshb& createHalf    (Ball    &ball    ,UInt flag=0     ,Int resolution=-1                   ); // create ball's upper half                    , 'flag'=VTX_FLAG
   Mshb& create        (Capsule &capsule ,UInt flag=0     ,Int resolution=-1,Int resolution2=-1); // create capsule                              , 'flag'=VTX_FLAG
   Mshb& createFast    (Tube    &tube    ,                 Int resolution=-1                   ); // create tube (fast)
   Mshb& create        (Tube    &tube    ,UInt flag=0     ,Int resolution=-1                   ); // create tube                                 , 'flag'=VTX_FLAG
   Mshb& create        (Cone    &cone    ,UInt flag=0     ,Int resolution=-1                   ); // create cone                                 , 'flag'=VTX_FLAG
   Mshb& create        (Torus   &torus   ,UInt flag=0     ,Int resolution=-1,Int resolution2=-1); // create torus                                , 'flag'=VTX_FLAG
...
};

these functions generate meshes out of geometrical shapes,

if you wish however to manually setup each vertex and triangle, please use something like this:

Code:
Mshb mshb; // mesh base

// use this function to create a mesh  -  Mshb& create(Int  vtxs ,Int edges,Int tris,Int quads,UInt flag=0                 ); // create, 'vtxs'=number of vertexes, 'edges'=number of edges, 'tris'=number of triangles, 'quads'=number of quads, 'flag'=MSHB_FLAG

mshb.create(100, 0, 100, 0, VTX_TX0); // create a mesh with 100 vertexes, 100 triangles and include VertexTextures (VTX_TX0) creation (VTX_POS-vertex positions and TRI_IND-triangle indexes are created automatically)
// now you can access freely - mshb.vtx.pos, mshb.vtx.tx0, mshb.tri.ind

// for example:
mshb.vtx.pos[0].set(0,0,0); // set position of 0th vertex
mshb.vtx.tx0[0].set(0,0); // set UV mapping of 0th vertex
mshb.tri.ind[0].set(0,1,2); // set indexes of 0th triangle
12-05-2008 04:24 PM
Find all posts by this user Quote this message in a reply
Brainache Offline
Member

Post: #3
Re: Custom Rendering
Exactly what I was looking for... thanks!
12-05-2008 06:50 PM
Find all posts by this user Quote this message in a reply
Post Reply