need help to complete my TShape class

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

need help to complete my TShape class

Post by Emil_halim »

hi all

i was thinking, why Irrlicht lacks to create primative mesh like cube , cone ,Cylinder,Sphere
just like Blitz3D, so i decided to create this class, but i only know who to create
a plane mesh.

so if any one could help me ,it will be my pleasuer.

here is the class

Code: Select all

class TShape
 {
    public: 
      TShape() {}
     ~TShape() {}
     
     virtual IMesh* CreatePlane()
       {
           SMesh* msh = new SMesh();      
           SMeshBuffer* mb = new SMeshBuffer();
           msh->addMeshBuffer(mb);  
           S3DVertex vtx[4];
           vtx[0] = S3DVertex(-1,-1,0, 0,0,1,SColor(255,255,255,255),0,1);
           vtx[1] = S3DVertex( 1,-1,0, 0,0,1,SColor(255,255,255,255),1,1); 
           vtx[2] = S3DVertex( 1, 1,0, 0,0,1,SColor(255,255,255,255),1,0);
           vtx[3] = S3DVertex(-1, 1,0, 0,0,1,SColor(255,255,255,255),0,0); 
           for(int i=0;i<4;i++)mb->Vertices.push_back(vtx[i]);
           u16 indices[] = { 0,1,3, 3,1,2, 1,0,2, 2,0,3 };
           for(int i=0;i<12;i++)mb->Indices.push_back(indices[i]);  
           return msh;
       }     
     
     virtual IMesh* CreateCube()
       {
           SMesh* msh = new SMesh();      
           SMeshBuffer* mb = new SMeshBuffer();
           msh->addMeshBuffer(mb);  
           
           // creating cube stuff here

           return msh;
       }
                 
    virtual IMesh* CreateCone()
       {
           SMesh* msh = new SMesh();      
           SMeshBuffer* mb = new SMeshBuffer();
           msh->addMeshBuffer(mb);   
           
           // creating cone stuff here
             
           return msh;
       } 
      
     virtual IMesh* CreateCylinder()
       {
           SMesh* msh = new SMesh();      
           SMeshBuffer* mb = new SMeshBuffer();
           msh->addMeshBuffer(mb);
           
           // creating Cylinder stuff here
     
           return msh;
       } 

    virtual IMesh* CreateSphere()
       {
           SMesh* msh = new SMesh();      
           SMeshBuffer* mb = new SMeshBuffer();
           msh->addMeshBuffer(mb);
           
           // creating Sphere stuff here
     
           return msh;
       } 
 };     
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

it seems that, i am lonly here.

is there any one here interested this subject?
pax_tempo

Post by pax_tempo »

I am interested, but don't know formulas (or for that matter, a lot on programming) of how those shapes work, would if be of help if i post you the code (as converted from deep exploration) from an opengl sphere, cube and cone??
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

thanks and go ahead and post it may it help me somehow.
pax_tempo

Post by pax_tempo »

Hi, here's opengl shape code, hope it helps:

cone:

Code: Select all

/*
This file was produced by Deep Exploration Plugin: CPP Export filter. 

Deep Exploration 

Copyright (c) 1999-2003 Right Hemisphere, Inc 

WWW http://www.righthemisphere.com/dexp.htm 
eMail support@righthemisphere.com
*/
#include <windows.h>
#include <GL\gl.h>
#include <GL\glu.h>


struct sample_MATERIAL{
 GLfloat ambient[3];
 GLfloat diffuse[3];
 GLfloat specular[3];
 GLfloat emission[3];
 GLfloat alpha;
 GLfloat phExp;
 int   texture;
};

static sample_MATERIAL materials [1] = {
 {{0.3f,0.3f,0.3f},	{0.7f,0.7f,0.7f},	{0.752941f,0.752941f,0.752941f},	{0.0f,0.0f,0.0f},	1.0f,8.0f,-1} //DefaultLib.Scene_Material
};

// 26 Verticies
// 20 Texture Coordinates
// 10 Normals
// 48 Triangles

static BYTE face_indicies[48][9] = {
// Object #-1
	{5,2,0 ,0,0,0 ,0,1,2 }, {2,6,3 ,0,0,0 ,1,0,1 }, {2,5,6 ,0,0,0 ,1,0,0 },
	{3,7,4 ,1,2,1 ,1,3,4 }, {3,6,7 ,1,2,2 ,1,0,3 }, {4,7,1 ,1,2,3 ,4,3,5 },
	{8,5,0 ,0,0,0 ,6,0,2 }, {5,9,6 ,0,0,0 ,0,6,0 }, {5,8,9 ,0,0,0 ,0,6,6 },
	{6,10,7 ,2,4,2 ,0,7,3 }, {6,9,10 ,2,4,4 ,0,6,7 }, {7,10,1 ,2,4,3 ,3,7,5 },
	{11,8,0 ,0,0,0 ,8,6,9 }, {8,12,9 ,0,0,0 ,6,8,6 }, {8,11,12 ,0,0,0 ,6,8,8 },
	{9,13,10 ,4,5,4 ,6,10,7 }, {9,12,13 ,4,5,5 ,6,8,10 }, {10,13,1 ,4,5,3 ,7,10,11 },
	{14,11,0 ,0,0,0 ,12,8,9 }, {11,15,12 ,0,0,0 ,8,12,8 }, {11,14,15 ,0,0,0 ,8,12,12 },
	{12,16,13 ,5,6,5 ,8,13,10 }, {12,15,16 ,5,6,6 ,8,12,13 }, {13,16,1 ,5,6,3 ,10,13,11 },
	{17,14,0 ,0,0,0 ,14,12,9 }, {14,18,15 ,0,0,0 ,12,14,12 }, {14,17,18 ,0,0,0 ,12,14,14 },
	{15,19,16 ,6,7,6 ,12,15,13 }, {15,18,19 ,6,7,7 ,12,14,15 }, {16,19,1 ,6,7,3 ,13,15,11 },
	{20,17,0 ,0,0,0 ,9,14,9 }, {17,21,18 ,0,0,0 ,14,9,14 }, {17,20,21 ,0,0,0 ,14,9,9 },
	{18,22,19 ,7,8,7 ,14,16,15 }, {18,21,22 ,7,8,8 ,14,9,16 }, {19,22,1 ,7,8,3 ,15,16,11 },
	{23,20,0 ,0,0,0 ,17,2,2 }, {20,24,21 ,0,0,0 ,2,17,2 }, {20,23,24 ,0,0,0 ,2,17,17 },
	{21,25,22 ,8,9,8 ,2,18,19 }, {21,24,25 ,8,9,9 ,2,17,18 }, {22,25,1 ,8,9,3 ,19,18,5 },
	{2,23,0 ,0,0,0 ,1,17,2 }, {23,3,24 ,0,0,0 ,17,1,17 }, {23,2,3 ,0,0,0 ,17,1,1 },
	{24,4,25 ,9,1,9 ,17,4,18 }, {24,3,4 ,9,1,1 ,17,1,4 }, {25,4,1 ,9,1,3 ,18,4,5 }
};
static GLfloat vertices [26][3] = {
{0.0f,-0.5f,0.0f},{0.0f,0.5f,0.0f},{-0.125f,-0.5f,0.0f},
{-0.25f,-0.5f,0.0f},{-0.125f,0.0f,0.0f},{-0.0883882f,-0.5f,0.0883882f},
{-0.176777f,-0.5f,0.176777f},{-0.0883882f,0.0f,0.0883882f},{0.0f,-0.5f,0.125f},
{0.0f,-0.5f,0.25f},{0.0f,0.0f,0.125f},{0.0883882f,-0.5f,0.0883882f},
{0.176777f,-0.5f,0.176777f},{0.0883882f,0.0f,0.0883882f},{0.125f,-0.5f,0.0f},
{0.25f,-0.5f,0.0f},{0.125f,0.0f,0.0f},{0.0883882f,-0.5f,-0.0883882f},
{0.176777f,-0.5f,-0.176777f},{0.0883882f,0.0f,-0.0883882f},{0.0f,-0.5f,-0.125f},
{0.0f,-0.5f,-0.25f},{0.0f,0.0f,-0.125f},{-0.0883882f,-0.5f,-0.0883882f},
{-0.176777f,-0.5f,-0.176777f},{-0.0883882f,0.0f,-0.0883882f}
};
static GLfloat normals [10][3] = {
{0.0f,-1.0f,0.0f},{-0.970142f,0.242536f,0.0f},{-0.685994f,0.242536f,0.685994f},
{0.0f,1.0f,0.0f},{0.0f,0.242536f,0.970142f},{0.685994f,0.242536f,0.685994f},
{0.970142f,0.242536f,0.0f},{0.685994f,0.242536f,-0.685994f},{0.0f,0.242536f,-0.970142f},
{-0.685994f,0.242536f,-0.685994f}
};
static GLfloat textures [20][2] = {
{0.375f,0.0f},{0.25f,0.0f},{0.0f,0.0f},
{0.375f,0.5f},{0.25f,0.5f},{0.0f,1.0f},
{0.5f,0.0f},{0.5f,0.5f},{0.625f,0.0f},
{1.0f,0.0f},{0.625f,0.5f},{1.0f,1.0f},
{0.75f,0.0f},{0.75f,0.5f},{0.875f,0.0f},
{0.875f,0.5f},{1.0f,0.5f},{0.125f,0.0f},
{0.125f,0.5f},{0.0f,0.5f}
};
/*Material indicies*/
/*{material index,face count}*/
static int material_ref [1][2] = {
{0,48}
};
void MyMaterial(GLenum mode,GLfloat *f,GLfloat alpha)
{
 GLfloat d[4];
 d[0]=f[0];
 d[1]=f[1];
 d[2]=f[2];
 d[3]=alpha;
 glMaterialfv (GL_FRONT_AND_BACK,mode,d);
}
/*
 *  SelectMaterial uses OpenGL commands to define facet colors.
 *
 *  Returns:
 *    Nothing
 */

void SelectMaterial(int i)
{
  //
  // Define the reflective properties of the 3D Object faces.
  //
  glEnd();
  GLfloat alpha=materials[i].alpha;
  MyMaterial (GL_AMBIENT, materials[i].ambient,alpha);
  MyMaterial (GL_DIFFUSE, materials[i].diffuse,alpha);
  MyMaterial (GL_SPECULAR, materials[i].specular,alpha);
  MyMaterial (GL_EMISSION, materials[i].emission,alpha);
  glMaterialf (GL_FRONT_AND_BACK,GL_SHININESS,materials[i].phExp);
  glBegin(GL_TRIANGLES);

};

GLint Gen3DObjectList()
{
 int i;
 int j;

 GLint lid=glGenLists(1);
	int mcount=0;
	int mindex=0;
   glNewList(lid, GL_COMPILE);

    glBegin (GL_TRIANGLES);
      for(i=0;i<sizeof(face_indicies)/sizeof(face_indicies[0]);i++)
       {
      if(!mcount)
       {
        SelectMaterial(material_ref[mindex][0]);
        mcount=material_ref[mindex][1];
        mindex++;
       }
       mcount--;
       for(j=0;j<3;j++)
        {
          int vi=face_indicies[i][j];
          int ni=face_indicies[i][j+3];//Normal index
          int ti=face_indicies[i][j+6];//Texture index
           glNormal3f (normals[ni][0],normals[ni][1],normals[ni][2]);
           glTexCoord2f(textures[ti][0],textures[ti][1]);
           glVertex3f (vertices[vi][0],vertices[vi][1],vertices[vi][2]);
        }
       }
    glEnd ();

   glEndList();
   return lid;
};

cube

Code: Select all

/*
This file was produced by Deep Exploration Plugin: CPP Export filter. 

Deep Exploration 

Copyright (c) 1999-2003 Right Hemisphere, Inc 

WWW http://www.righthemisphere.com/dexp.htm 
eMail support@righthemisphere.com
*/
#include <windows.h>
#include <GL\gl.h>
#include <GL\glu.h>


struct sample_MATERIAL{
 GLfloat ambient[3];
 GLfloat diffuse[3];
 GLfloat specular[3];
 GLfloat emission[3];
 GLfloat alpha;
 GLfloat phExp;
 int   texture;
};

static sample_MATERIAL materials [1] = {
 {{0.3f,0.3f,0.3f},	{0.7f,0.7f,0.7f},	{0.752941f,0.752941f,0.752941f},	{0.0f,0.0f,0.0f},	1.0f,8.0f,-1} //DefaultLib.Scene_Material
};

// 8 Verticies
// 4 Texture Coordinates
// 6 Normals
// 12 Triangles

static BYTE face_indicies[12][9] = {
// Object #-1
	{0,3,1 ,0,0,0 ,0,1,2 }, {0,2,3 ,0,0,0 ,0,3,1 }, {0,5,4 ,1,1,1 ,2,3,1 },
	{0,1,5 ,1,1,1 ,2,0,3 }, {0,6,2 ,2,2,2 ,2,3,1 }, {0,4,6 ,2,2,2 ,2,0,3 },
	{1,7,5 ,3,3,3 ,0,1,2 }, {1,3,7 ,3,3,3 ,0,3,1 }, {2,7,3 ,4,4,4 ,1,0,3 },
	{2,6,7 ,4,4,4 ,1,2,0 }, {4,7,6 ,5,5,5 ,2,3,1 }, {4,5,7 ,5,5,5 ,2,0,3 }
};
static GLfloat vertices [8][3] = {
{-0.5f,-0.5f,-0.5f},{0.5f,-0.5f,-0.5f},{-0.5f,0.5f,-0.5f},
{0.5f,0.5f,-0.5f},{-0.5f,-0.5f,0.5f},{0.5f,-0.5f,0.5f},
{-0.5f,0.5f,0.5f},{0.5f,0.5f,0.5f}
};
static GLfloat normals [6][3] = {
{0.0f,0.0f,-1.0f},{0.0f,-1.0f,0.0f},{-1.0f,0.0f,0.0f},
{1.0f,0.0f,0.0f},{0.0f,1.0f,0.0f},{0.0f,0.0f,1.0f}
};
static GLfloat textures [4][2] = {
{1.0f,0.0f},{0.0f,1.0f},{0.0f,0.0f},
{1.0f,1.0f}
};
/*Material indicies*/
/*{material index,face count}*/
static int material_ref [1][2] = {
{0,12}
};
void MyMaterial(GLenum mode,GLfloat *f,GLfloat alpha)
{
 GLfloat d[4];
 d[0]=f[0];
 d[1]=f[1];
 d[2]=f[2];
 d[3]=alpha;
 glMaterialfv (GL_FRONT_AND_BACK,mode,d);
}
/*
 *  SelectMaterial uses OpenGL commands to define facet colors.
 *
 *  Returns:
 *    Nothing
 */

void SelectMaterial(int i)
{
  //
  // Define the reflective properties of the 3D Object faces.
  //
  glEnd();
  GLfloat alpha=materials[i].alpha;
  MyMaterial (GL_AMBIENT, materials[i].ambient,alpha);
  MyMaterial (GL_DIFFUSE, materials[i].diffuse,alpha);
  MyMaterial (GL_SPECULAR, materials[i].specular,alpha);
  MyMaterial (GL_EMISSION, materials[i].emission,alpha);
  glMaterialf (GL_FRONT_AND_BACK,GL_SHININESS,materials[i].phExp);
  glBegin(GL_TRIANGLES);

};

GLint Gen3DObjectList()
{
 int i;
 int j;

 GLint lid=glGenLists(1);
	int mcount=0;
	int mindex=0;
   glNewList(lid, GL_COMPILE);

    glBegin (GL_TRIANGLES);
      for(i=0;i<sizeof(face_indicies)/sizeof(face_indicies[0]);i++)
       {
      if(!mcount)
       {
        SelectMaterial(material_ref[mindex][0]);
        mcount=material_ref[mindex][1];
        mindex++;
       }
       mcount--;
       for(j=0;j<3;j++)
        {
          int vi=face_indicies[i][j];
          int ni=face_indicies[i][j+3];//Normal index
          int ti=face_indicies[i][j+6];//Texture index
           glNormal3f (normals[ni][0],normals[ni][1],normals[ni][2]);
           glTexCoord2f(textures[ti][0],textures[ti][1]);
           glVertex3f (vertices[vi][0],vertices[vi][1],vertices[vi][2]);
        }
       }
    glEnd ();

   glEndList();
   return lid;
};

cylinder

Code: Select all

/*
This file was produced by Deep Exploration Plugin: CPP Export filter. 

Deep Exploration 

Copyright (c) 1999-2003 Right Hemisphere, Inc 

WWW http://www.righthemisphere.com/dexp.htm 
eMail support@righthemisphere.com
*/
#include <windows.h>
#include <GL\gl.h>
#include <GL\glu.h>


struct sample_MATERIAL{
 GLfloat ambient[3];
 GLfloat diffuse[3];
 GLfloat specular[3];
 GLfloat emission[3];
 GLfloat alpha;
 GLfloat phExp;
 int   texture;
};

static sample_MATERIAL materials [1] = {
 {{0.3f,0.3f,0.3f},	{0.7f,0.7f,0.7f},	{0.752941f,0.752941f,0.752941f},	{0.0f,0.0f,0.0f},	1.0f,8.0f,-1} //DefaultLib.Scene_Material
};

// 42 Verticies
// 27 Texture Coordinates
// 10 Normals
// 80 Triangles

static BYTE face_indicies[80][9] = {
// Object #-1
	{7,2,0 ,0,0,0 ,0,1,2 }, {2,8,3 ,0,0,0 ,1,0,1 }, {2,7,8 ,0,0,0 ,1,0,0 },
	{3,9,4 ,1,2,1 ,1,3,4 }, {3,8,9 ,1,2,2 ,1,0,3 }, {4,10,5 ,1,2,1 ,4,5,6 },
	{4,9,10 ,1,2,2 ,4,3,5 }, {5,11,6 ,3,3,3 ,6,5,6 }, {5,10,11 ,3,3,3 ,6,5,5 },
	{6,11,1 ,3,3,3 ,6,5,7 }, {12,7,0 ,0,0,0 ,8,0,2 }, {7,13,8 ,0,0,0 ,0,8,0 },
	{7,12,13 ,0,0,0 ,0,8,8 }, {8,14,9 ,2,4,2 ,0,9,3 }, {8,13,14 ,2,4,4 ,0,8,9 },
	{9,15,10 ,2,4,2 ,3,10,5 }, {9,14,15 ,2,4,4 ,3,9,10 }, {10,16,11 ,3,3,3 ,5,10,5 },
	{10,15,16 ,3,3,3 ,5,10,10 }, {11,16,1 ,3,3,3 ,5,10,7 }, {17,12,0 ,0,0,0 ,11,8,12 },
	{12,18,13 ,0,0,0 ,8,11,8 }, {12,17,18 ,0,0,0 ,8,11,11 }, {13,19,14 ,4,5,4 ,8,13,9 },
	{13,18,19 ,4,5,5 ,8,11,13 }, {14,20,15 ,4,5,4 ,9,14,10 }, {14,19,20 ,4,5,5 ,9,13,14 },
	{15,21,16 ,3,3,3 ,10,14,10 }, {15,20,21 ,3,3,3 ,10,14,14 }, {16,21,1 ,3,3,3 ,10,14,15 },
	{22,17,0 ,0,0,0 ,16,11,12 }, {17,23,18 ,0,0,0 ,11,16,11 }, {17,22,23 ,0,0,0 ,11,16,16 },
	{18,24,19 ,5,6,5 ,11,17,13 }, {18,23,24 ,5,6,6 ,11,16,17 }, {19,25,20 ,5,6,5 ,13,18,14 },
	{19,24,25 ,5,6,6 ,13,17,18 }, {20,26,21 ,3,3,3 ,14,18,14 }, {20,25,26 ,3,3,3 ,14,18,18 },
	{21,26,1 ,3,3,3 ,14,18,15 }, {27,22,0 ,0,0,0 ,19,16,12 }, {22,28,23 ,0,0,0 ,16,19,16 },
	{22,27,28 ,0,0,0 ,16,19,19 }, {23,29,24 ,6,7,6 ,16,20,17 }, {23,28,29 ,6,7,7 ,16,19,20 },
	{24,30,25 ,6,7,6 ,17,21,18 }, {24,29,30 ,6,7,7 ,17,20,21 }, {25,31,26 ,3,3,3 ,18,21,18 },
	{25,30,31 ,3,3,3 ,18,21,21 }, {26,31,1 ,3,3,3 ,18,21,15 }, {32,27,0 ,0,0,0 ,12,19,12 },
	{27,33,28 ,0,0,0 ,19,12,19 }, {27,32,33 ,0,0,0 ,19,12,12 }, {28,34,29 ,7,8,7 ,19,22,20 },
	{28,33,34 ,7,8,8 ,19,12,22 }, {29,35,30 ,7,8,7 ,20,15,21 }, {29,34,35 ,7,8,8 ,20,22,15 },
	{30,36,31 ,3,3,3 ,21,15,21 }, {30,35,36 ,3,3,3 ,21,15,15 }, {31,36,1 ,3,3,3 ,21,15,15 },
	{37,32,0 ,0,0,0 ,23,2,2 }, {32,38,33 ,0,0,0 ,2,23,2 }, {32,37,38 ,0,0,0 ,2,23,23 },
	{33,39,34 ,8,9,8 ,2,24,25 }, {33,38,39 ,8,9,9 ,2,23,24 }, {34,40,35 ,8,9,8 ,25,26,7 },
	{34,39,40 ,8,9,9 ,25,24,26 }, {35,41,36 ,3,3,3 ,7,26,7 }, {35,40,41 ,3,3,3 ,7,26,26 },
	{36,41,1 ,3,3,3 ,7,26,7 }, {2,37,0 ,0,0,0 ,1,23,2 }, {37,3,38 ,0,0,0 ,23,1,23 },
	{37,2,3 ,0,0,0 ,23,1,1 }, {38,4,39 ,9,1,9 ,23,4,24 }, {38,3,4 ,9,1,1 ,23,1,4 },
	{39,5,40 ,9,1,9 ,24,6,26 }, {39,4,5 ,9,1,1 ,24,4,6 }, {40,6,41 ,3,3,3 ,26,6,26 },
	{40,5,6 ,3,3,3 ,26,6,6 }, {41,6,1 ,3,3,3 ,26,6,7 }
};
static GLfloat vertices [42][3] = {
{0.0f,-0.5f,0.0f},{0.0f,0.5f,0.0f},{-0.125f,-0.5f,0.0f},
{-0.25f,-0.5f,0.0f},{-0.25f,0.0f,0.0f},{-0.25f,0.5f,0.0f},
{-0.125f,0.5f,0.0f},{-0.0883882f,-0.5f,0.0883882f},{-0.176777f,-0.5f,0.176777f},
{-0.176777f,0.0f,0.176777f},{-0.176777f,0.5f,0.176777f},{-0.0883882f,0.5f,0.0883882f},
{0.0f,-0.5f,0.125f},{0.0f,-0.5f,0.25f},{0.0f,0.0f,0.25f},
{0.0f,0.5f,0.25f},{0.0f,0.5f,0.125f},{0.0883882f,-0.5f,0.0883882f},
{0.176777f,-0.5f,0.176777f},{0.176777f,0.0f,0.176777f},{0.176777f,0.5f,0.176777f},
{0.0883882f,0.5f,0.0883882f},{0.125f,-0.5f,0.0f},{0.25f,-0.5f,0.0f},
{0.25f,0.0f,0.0f},{0.25f,0.5f,0.0f},{0.125f,0.5f,0.0f},
{0.0883882f,-0.5f,-0.0883882f},{0.176777f,-0.5f,-0.176777f},{0.176777f,0.0f,-0.176777f},
{0.176777f,0.5f,-0.176777f},{0.0883882f,0.5f,-0.0883882f},{0.0f,-0.5f,-0.125f},
{0.0f,-0.5f,-0.25f},{0.0f,0.0f,-0.25f},{0.0f,0.5f,-0.25f},
{0.0f,0.5f,-0.125f},{-0.0883882f,-0.5f,-0.0883882f},{-0.176777f,-0.5f,-0.176777f},
{-0.176777f,0.0f,-0.176777f},{-0.176777f,0.5f,-0.176777f},{-0.0883882f,0.5f,-0.0883882f}
};
static GLfloat normals [10][3] = {
{0.0f,-1.0f,0.0f},{-1.0f,0.0f,0.0f},{-0.707107f,0.0f,0.707107f},
{0.0f,1.0f,0.0f},{0.0f,0.0f,1.0f},{0.707107f,0.0f,0.707107f},
{1.0f,0.0f,0.0f},{0.707107f,0.0f,-0.707107f},{0.0f,0.0f,-1.0f},
{-0.707107f,0.0f,-0.707107f}
};
static GLfloat textures [27][2] = {
{0.375f,0.0f},{0.25f,0.0f},{0.0f,0.0f},
{0.375f,0.5f},{0.25f,0.5f},{0.375f,1.0f},
{0.25f,1.0f},{0.0f,1.0f},{0.5f,0.0f},
{0.5f,0.5f},{0.5f,1.0f},{0.625f,0.0f},
{1.0f,0.0f},{0.625f,0.5f},{0.625f,1.0f},
{1.0f,1.0f},{0.75f,0.0f},{0.75f,0.5f},
{0.75f,1.0f},{0.875f,0.0f},{0.875f,0.5f},
{0.875f,1.0f},{1.0f,0.5f},{0.125f,0.0f},
{0.125f,0.5f},{0.0f,0.5f},{0.125f,1.0f}
};
/*Material indicies*/
/*{material index,face count}*/
static int material_ref [1][2] = {
{0,80}
};
void MyMaterial(GLenum mode,GLfloat *f,GLfloat alpha)
{
 GLfloat d[4];
 d[0]=f[0];
 d[1]=f[1];
 d[2]=f[2];
 d[3]=alpha;
 glMaterialfv (GL_FRONT_AND_BACK,mode,d);
}
/*
 *  SelectMaterial uses OpenGL commands to define facet colors.
 *
 *  Returns:
 *    Nothing
 */

void SelectMaterial(int i)
{
  //
  // Define the reflective properties of the 3D Object faces.
  //
  glEnd();
  GLfloat alpha=materials[i].alpha;
  MyMaterial (GL_AMBIENT, materials[i].ambient,alpha);
  MyMaterial (GL_DIFFUSE, materials[i].diffuse,alpha);
  MyMaterial (GL_SPECULAR, materials[i].specular,alpha);
  MyMaterial (GL_EMISSION, materials[i].emission,alpha);
  glMaterialf (GL_FRONT_AND_BACK,GL_SHININESS,materials[i].phExp);
  glBegin(GL_TRIANGLES);

};

GLint Gen3DObjectList()
{
 int i;
 int j;

 GLint lid=glGenLists(1);
	int mcount=0;
	int mindex=0;
   glNewList(lid, GL_COMPILE);

    glBegin (GL_TRIANGLES);
      for(i=0;i<sizeof(face_indicies)/sizeof(face_indicies[0]);i++)
       {
      if(!mcount)
       {
        SelectMaterial(material_ref[mindex][0]);
        mcount=material_ref[mindex][1];
        mindex++;
       }
       mcount--;
       for(j=0;j<3;j++)
        {
          int vi=face_indicies[i][j];
          int ni=face_indicies[i][j+3];//Normal index
          int ti=face_indicies[i][j+6];//Texture index
           glNormal3f (normals[ni][0],normals[ni][1],normals[ni][2]);
           glTexCoord2f(textures[ti][0],textures[ti][1]);
           glVertex3f (vertices[vi][0],vertices[vi][1],vertices[vi][2]);
        }
       }
    glEnd ();

   glEndList();
   return lid;
};

sphere

Code: Select all

/*
This file was produced by Deep Exploration Plugin: CPP Export filter. 

Deep Exploration 

Copyright (c) 1999-2003 Right Hemisphere, Inc 

WWW http://www.righthemisphere.com/dexp.htm 
eMail support@righthemisphere.com
*/
#include <windows.h>
#include <GL\gl.h>
#include <GL\glu.h>


struct sample_MATERIAL{
 GLfloat ambient[3];
 GLfloat diffuse[3];
 GLfloat specular[3];
 GLfloat emission[3];
 GLfloat alpha;
 GLfloat phExp;
 int   texture;
};

static sample_MATERIAL materials [1] = {
 {{0.3f,0.3f,0.3f},	{0.7f,0.7f,0.7f},	{0.752941f,0.752941f,0.752941f},	{0.0f,0.0f,0.0f},	1.0f,8.0f,-1} //DefaultLib.Scene_Material
};

// 58 Verticies
// 67 Texture Coordinates
// 58 Normals
// 112 Triangles

static BYTE face_indicies[112][9] = {
// Object #-1
	{9,2,0 ,0,1,2 ,0,1,2 }, {2,10,3 ,1,3,4 ,1,3,4 }, {2,9,10 ,1,0,3 ,1,0,3 },
	{3,11,4 ,4,5,6 ,4,5,6 }, {3,10,11 ,4,3,5 ,4,3,5 }, {4,12,5 ,6,7,8 ,6,7,8 },
	{4,11,12 ,6,5,7 ,6,5,7 }, {5,13,6 ,8,9,10 ,8,9,10 }, {5,12,13 ,8,7,9 ,8,7,9 },
	{6,14,7 ,10,11,12 ,10,11,12 }, {6,13,14 ,10,9,11 ,10,9,11 },
	{7,15,8 ,12,13,14 ,12,13,14 }, {7,14,15 ,12,11,13 ,12,11,13 },
	{8,15,1 ,14,13,15 ,14,13,15 }, {16,9,0 ,16,0,2 ,16,0,2 }, {9,17,10 ,0,17,3 ,0,17,3 },
	{9,16,17 ,0,16,17 ,0,16,17 }, {10,18,11 ,3,18,5 ,3,18,5 }, {10,17,18 ,3,17,18 ,3,17,18 },
	{11,19,12 ,5,19,7 ,5,19,7 }, {11,18,19 ,5,18,19 ,5,18,19 }, {12,20,13 ,7,20,9 ,7,20,9 },
	{12,19,20 ,7,19,20 ,7,19,20 }, {13,21,14 ,9,21,11 ,9,21,11 },
	{13,20,21 ,9,20,21 ,9,20,21 }, {14,22,15 ,11,22,13 ,11,22,13 },
	{14,21,22 ,11,21,22 ,11,21,22 }, {15,22,1 ,13,22,15 ,13,22,15 },
	{23,16,0 ,23,16,2 ,23,16,24 }, {16,24,17 ,16,24,17 ,16,25,17 },
	{16,23,24 ,16,23,24 ,16,23,25 }, {17,25,18 ,17,25,18 ,17,26,18 },
	{17,24,25 ,17,24,25 ,17,25,26 }, {18,26,19 ,18,26,19 ,18,27,19 },
	{18,25,26 ,18,25,26 ,18,26,27 }, {19,27,20 ,19,27,20 ,19,28,20 },
	{19,26,27 ,19,26,27 ,19,27,28 }, {20,28,21 ,20,28,21 ,20,29,21 },
	{20,27,28 ,20,27,28 ,20,28,29 }, {21,29,22 ,21,29,22 ,21,30,22 },
	{21,28,29 ,21,28,29 ,21,29,30 }, {22,29,1 ,22,29,15 ,22,30,31 },
	{30,23,0 ,30,23,2 ,32,23,24 }, {23,31,24 ,23,31,24 ,23,33,25 },
	{23,30,31 ,23,30,31 ,23,32,33 }, {24,32,25 ,24,32,25 ,25,34,26 },
	{24,31,32 ,24,31,32 ,25,33,34 }, {25,33,26 ,25,33,26 ,26,35,27 },
	{25,32,33 ,25,32,33 ,26,34,35 }, {26,34,27 ,26,34,27 ,27,36,28 },
	{26,33,34 ,26,33,34 ,27,35,36 }, {27,35,28 ,27,35,28 ,28,37,29 },
	{27,34,35 ,27,34,35 ,28,36,37 }, {28,36,29 ,28,36,29 ,29,38,30 },
	{28,35,36 ,28,35,36 ,29,37,38 }, {29,36,1 ,29,36,15 ,30,38,31 },
	{37,30,0 ,37,30,2 ,39,32,24 }, {30,38,31 ,30,38,31 ,32,40,33 },
	{30,37,38 ,30,37,38 ,32,39,40 }, {31,39,32 ,31,39,32 ,33,41,34 },
	{31,38,39 ,31,38,39 ,33,40,41 }, {32,40,33 ,32,40,33 ,34,42,35 },
	{32,39,40 ,32,39,40 ,34,41,42 }, {33,41,34 ,33,41,34 ,35,43,36 },
	{33,40,41 ,33,40,41 ,35,42,43 }, {34,42,35 ,34,42,35 ,36,44,37 },
	{34,41,42 ,34,41,42 ,36,43,44 }, {35,43,36 ,35,43,36 ,37,45,38 },
	{35,42,43 ,35,42,43 ,37,44,45 }, {36,43,1 ,36,43,15 ,38,45,31 },
	{44,37,0 ,44,37,2 ,46,39,24 }, {37,45,38 ,37,45,38 ,39,47,40 },
	{37,44,45 ,37,44,45 ,39,46,47 }, {38,46,39 ,38,46,39 ,40,48,41 },
	{38,45,46 ,38,45,46 ,40,47,48 }, {39,47,40 ,39,47,40 ,41,49,42 },
	{39,46,47 ,39,46,47 ,41,48,49 }, {40,48,41 ,40,48,41 ,42,50,43 },
	{40,47,48 ,40,47,48 ,42,49,50 }, {41,49,42 ,41,49,42 ,43,51,44 },
	{41,48,49 ,41,48,49 ,43,50,51 }, {42,50,43 ,42,50,43 ,44,52,45 },
	{42,49,50 ,42,49,50 ,44,51,52 }, {43,50,1 ,43,50,15 ,45,52,31 },
	{51,44,0 ,51,44,2 ,53,54,2 }, {44,52,45 ,44,52,45 ,54,55,56 },
	{44,51,52 ,44,51,52 ,54,53,55 }, {45,53,46 ,45,53,46 ,56,57,58 },
	{45,52,53 ,45,52,53 ,56,55,57 }, {46,54,47 ,46,54,47 ,58,59,60 },
	{46,53,54 ,46,53,54 ,58,57,59 }, {47,55,48 ,47,55,48 ,60,61,62 },
	{47,54,55 ,47,54,55 ,60,59,61 }, {48,56,49 ,48,56,49 ,62,63,64 },
	{48,55,56 ,48,55,56 ,62,61,63 }, {49,57,50 ,49,57,50 ,64,65,66 },
	{49,56,57 ,49,56,57 ,64,63,65 }, {50,57,1 ,50,57,15 ,66,65,15 },
	{2,51,0 ,1,51,2 ,1,53,2 }, {51,3,52 ,51,4,52 ,53,4,55 }, {51,2,3 ,51,1,4 ,53,1,4 },
	{52,4,53 ,52,6,53 ,55,6,57 }, {52,3,4 ,52,4,6 ,55,4,6 }, {53,5,54 ,53,8,54 ,57,8,59 },
	{53,4,5 ,53,6,8 ,57,6,8 }, {54,6,55 ,54,10,55 ,59,10,61 }, {54,5,6 ,54,8,10 ,59,8,10 },
	{55,7,56 ,55,12,56 ,61,12,63 }, {55,6,7 ,55,10,12 ,61,10,12 },
	{56,8,57 ,56,14,57 ,63,14,65 }, {56,7,8 ,56,12,14 ,63,12,14 },
	{57,8,1 ,57,14,15 ,65,14,15 }
};
static GLfloat vertices [58][3] = {
{0.0f,-0.5f,0.0f},{0.0f,0.5f,0.0f},{-0.191342f,-0.46194f,0.0f},
{-0.353553f,-0.353553f,0.0f},{-0.46194f,-0.191342f,0.0f},{-0.5f,0.0f,0.0f},
{-0.46194f,0.191342f,0.0f},{-0.353553f,0.353553f,0.0f},{-0.191342f,0.46194f,0.0f},
{-0.135299f,-0.46194f,0.135299f},{-0.25f,-0.353553f,0.25f},{-0.326641f,-0.191342f,0.326641f},
{-0.353553f,0.0f,0.353553f},{-0.326641f,0.191342f,0.326641f},{-0.25f,0.353553f,0.25f},
{-0.135299f,0.46194f,0.135299f},{0.0f,-0.46194f,0.191342f},{0.0f,-0.353553f,0.353553f},
{0.0f,-0.191342f,0.46194f},{0.0f,0.0f,0.5f},{0.0f,0.191342f,0.46194f},
{0.0f,0.353553f,0.353553f},{0.0f,0.46194f,0.191342f},{0.135299f,-0.46194f,0.135299f},
{0.25f,-0.353553f,0.25f},{0.326641f,-0.191342f,0.326641f},{0.353553f,0.0f,0.353553f},
{0.326641f,0.191342f,0.326641f},{0.25f,0.353553f,0.25f},{0.135299f,0.46194f,0.135299f},
{0.191342f,-0.46194f,0.0f},{0.353553f,-0.353553f,0.0f},{0.46194f,-0.191342f,0.0f},
{0.5f,0.0f,0.0f},{0.46194f,0.191342f,0.0f},{0.353553f,0.353553f,0.0f},
{0.191342f,0.46194f,0.0f},{0.135299f,-0.46194f,-0.135299f},{0.25f,-0.353553f,-0.25f},
{0.326641f,-0.191342f,-0.326641f},{0.353553f,0.0f,-0.353553f},{0.326641f,0.191342f,-0.326641f},
{0.25f,0.353553f,-0.25f},{0.135299f,0.46194f,-0.135299f},{0.0f,-0.46194f,-0.191342f},
{0.0f,-0.353553f,-0.353553f},{0.0f,-0.191342f,-0.46194f},{0.0f,0.0f,-0.5f},
{0.0f,0.191342f,-0.46194f},{0.0f,0.353553f,-0.353553f},{0.0f,0.46194f,-0.191342f},
{-0.135299f,-0.46194f,-0.135299f},{-0.25f,-0.353553f,-0.25f},{-0.326641f,-0.191342f,-0.326641f},
{-0.353553f,0.0f,-0.353553f},{-0.326641f,0.191342f,-0.326641f},{-0.25f,0.353553f,-0.25f},
{-0.135299f,0.46194f,-0.135299f}
};
static GLfloat normals [58][3] = {
{-0.269132f,-0.924736f,0.269132f},{-0.380611f,-0.924735f,0.0f},{0.0f,-1.0f,0.0f},
{-0.498494f,-0.70923f,0.498494f},{-0.704977f,-0.70923f,0.0f},{-0.652733f,-0.384551f,0.652733f},
{-0.923104f,-0.384551f,0.0f},{-0.707107f,0.0f,0.707107f},{-1.0f,0.0f,0.0f},
{-0.652733f,0.384551f,0.652733f},{-0.923104f,0.384551f,0.0f},{-0.498494f,0.70923f,0.498494f},
{-0.704977f,0.70923f,0.0f},{-0.269132f,0.924736f,0.269132f},{-0.380611f,0.924735f,0.0f},
{0.0f,1.0f,0.0f},{0.0f,-0.924735f,0.380611f},{0.0f,-0.70923f,0.704977f},
{0.0f,-0.384551f,0.923104f},{0.0f,0.0f,1.0f},{0.0f,0.384551f,0.923104f},
{0.0f,0.70923f,0.704977f},{0.0f,0.924735f,0.380611f},{0.269132f,-0.924736f,0.269132f},
{0.498494f,-0.70923f,0.498494f},{0.652733f,-0.384551f,0.652733f},{0.707107f,0.0f,0.707107f},
{0.652733f,0.384551f,0.652733f},{0.498494f,0.70923f,0.498494f},{0.269132f,0.924736f,0.269132f},
{0.380611f,-0.924735f,0.0f},{0.704977f,-0.70923f,0.0f},{0.923104f,-0.384551f,0.0f},
{1.0f,0.0f,0.0f},{0.923104f,0.384551f,0.0f},{0.704977f,0.70923f,0.0f},
{0.380611f,0.924735f,0.0f},{0.269132f,-0.924736f,-0.269132f},{0.498494f,-0.70923f,-0.498494f},
{0.652733f,-0.384551f,-0.652733f},{0.707107f,0.0f,-0.707107f},{0.652733f,0.384551f,-0.652733f},
{0.498494f,0.70923f,-0.498494f},{0.269132f,0.924736f,-0.269132f},{0.0f,-0.924735f,-0.380611f},
{0.0f,-0.70923f,-0.704977f},{0.0f,-0.384551f,-0.923104f},{0.0f,0.0f,-1.0f},
{0.0f,0.384551f,-0.923104f},{0.0f,0.70923f,-0.704977f},{0.0f,0.924735f,-0.380611f},
{-0.269132f,-0.924736f,-0.269132f},{-0.498494f,-0.70923f,-0.498494f},{-0.652733f,-0.384551f,-0.652733f},
{-0.707107f,0.0f,-0.707107f},{-0.652733f,0.384551f,-0.652733f},{-0.498494f,0.70923f,-0.498494f},
{-0.269132f,0.924736f,-0.269132f}
};
static GLfloat textures [67][2] = {
{0.375f,0.125f},{0.25f,0.125f},{0.0f,0.0f},
{0.375f,0.25f},{0.25f,0.25f},{0.375f,0.375f},
{0.25f,0.375f},{0.375f,0.5f},{0.25f,0.5f},
{0.375f,0.625f},{0.25f,0.625f},{0.375f,0.75f},
{0.25f,0.75f},{0.375f,0.875f},{0.25f,0.875f},
{0.0f,1.0f},{0.5f,0.125f},{0.5f,0.25f},
{0.5f,0.375f},{0.5f,0.5f},{0.5f,0.625f},
{0.5f,0.75f},{0.5f,0.875f},{0.625f,0.125f},
{1.0f,0.0f},{0.625f,0.25f},{0.625f,0.375f},
{0.625f,0.5f},{0.625f,0.625f},{0.625f,0.75f},
{0.625f,0.875f},{1.0f,1.0f},{0.75f,0.125f},
{0.75f,0.25f},{0.75f,0.375f},{0.75f,0.5f},
{0.75f,0.625f},{0.75f,0.75f},{0.75f,0.875f},
{0.875f,0.125f},{0.875f,0.25f},{0.875f,0.375f},
{0.875f,0.5f},{0.875f,0.625f},{0.875f,0.75f},
{0.875f,0.875f},{1.0f,0.125f},{1.0f,0.25f},
{1.0f,0.375f},{1.0f,0.5f},{1.0f,0.625f},
{1.0f,0.75f},{1.0f,0.875f},{0.125f,0.125f},
{0.0f,0.125f},{0.125f,0.25f},{0.0f,0.25f},
{0.125f,0.375f},{0.0f,0.375f},{0.125f,0.5f},
{0.0f,0.5f},{0.125f,0.625f},{0.0f,0.625f},
{0.125f,0.75f},{0.0f,0.75f},{0.125f,0.875f},
{0.0f,0.875f}
};
/*Material indicies*/
/*{material index,face count}*/
static int material_ref [1][2] = {
{0,112}
};
void MyMaterial(GLenum mode,GLfloat *f,GLfloat alpha)
{
 GLfloat d[4];
 d[0]=f[0];
 d[1]=f[1];
 d[2]=f[2];
 d[3]=alpha;
 glMaterialfv (GL_FRONT_AND_BACK,mode,d);
}
/*
 *  SelectMaterial uses OpenGL commands to define facet colors.
 *
 *  Returns:
 *    Nothing
 */

void SelectMaterial(int i)
{
  //
  // Define the reflective properties of the 3D Object faces.
  //
  glEnd();
  GLfloat alpha=materials[i].alpha;
  MyMaterial (GL_AMBIENT, materials[i].ambient,alpha);
  MyMaterial (GL_DIFFUSE, materials[i].diffuse,alpha);
  MyMaterial (GL_SPECULAR, materials[i].specular,alpha);
  MyMaterial (GL_EMISSION, materials[i].emission,alpha);
  glMaterialf (GL_FRONT_AND_BACK,GL_SHININESS,materials[i].phExp);
  glBegin(GL_TRIANGLES);

};

GLint Gen3DObjectList()
{
 int i;
 int j;

 GLint lid=glGenLists(1);
	int mcount=0;
	int mindex=0;
   glNewList(lid, GL_COMPILE);

    glBegin (GL_TRIANGLES);
      for(i=0;i<sizeof(face_indicies)/sizeof(face_indicies[0]);i++)
       {
      if(!mcount)
       {
        SelectMaterial(material_ref[mindex][0]);
        mcount=material_ref[mindex][1];
        mindex++;
       }
       mcount--;
       for(j=0;j<3;j++)
        {
          int vi=face_indicies[i][j];
          int ni=face_indicies[i][j+3];//Normal index
          int ti=face_indicies[i][j+6];//Texture index
           glNormal3f (normals[ni][0],normals[ni][1],normals[ni][2]);
           glTexCoord2f(textures[ti][0],textures[ti][1]);
           glVertex3f (vertices[vi][0],vertices[vi][1],vertices[vi][2]);
        }
       }
    glEnd ();

   glEndList();
   return lid;
};

Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

thanks pax_tempo,i will study it.
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

here is a createcube function, add it to the class.
but still need help for the other function.

Code: Select all

virtual IMesh* CreateCube()
       {
           SMesh* msh = new SMesh();      
           SMeshBuffer* mb = new SMeshBuffer();
           msh->addMeshBuffer(mb);  
           S3DVertex vtx[12];
           vtx[0]  = S3DVertex(-1,-1,-1, -1,-1,-1, SColor(255,255,255,255), 0, 1); 
           vtx[1]  = S3DVertex( 1,-1,-1,  1,-1,-1, SColor(255,255,255,255), 1, 1); 
           vtx[2]  = S3DVertex( 1, 1,-1,  1, 1,-1, SColor(255,255,255,255), 1, 0); 
           vtx[3]  = S3DVertex(-1, 1,-1, -1, 1,-1, SColor(255,255,255,255), 0, 0); 
           vtx[4]  = S3DVertex( 1,-1, 1,  1,-1, 1, SColor(255,255,255,255), 0, 1); 
           vtx[5]  = S3DVertex( 1, 1, 1,  1, 1, 1, SColor(255,255,255,255), 0, 0); 
           vtx[6]  = S3DVertex(-1, 1, 1, -1, 1, 1, SColor(255,255,255,255), 1, 0); 
           vtx[7]  = S3DVertex(-1,-1, 1, -1,-1, 1, SColor(255,255,255,255), 1, 1); 
           vtx[8]  = S3DVertex(-1, 1, 1, -1, 1, 1, SColor(255,255,255,255), 0, 1); 
           vtx[9]  = S3DVertex(-1, 1,-1, -1, 1,-1, SColor(255,255,255,255), 1, 1); 
           vtx[10] = S3DVertex( 1,-1, 1,  1,-1, 1, SColor(255,255,255,255), 1, 0); 
           vtx[11] = S3DVertex( 1,-1,-1,  1,-1,-1, SColor(255,255,255,255), 0, 0);            
           for(int i=0;i<12;i++)mb->Vertices.push_back(vtx[i]);
           u16 indices[36] = {   0,2,1,   0,3,2,   1,5,4,   1,2,5,   
                                 4,6,7,   4,5,6,   7,3,0,   7,6,3,   
                                 9,5,2,   9,8,5,   0,11,10, 0,10,7
                             };
           for(int i=0;i<36;i++)mb->Indices.push_back(indices[i]); 
           return msh;
       }
domstyledesign
Posts: 9
Joined: Sat Apr 30, 2005 3:41 am
Contact:

Post by domstyledesign »

i did some coding similar to this in opengl using parametric equations.

http://www.domstyle.net/board/viewtopic.php?t=465

here's some code. (you probably just need what's in SURFACES.H, so scroll down).

main.cpp

Code: Select all

#include <iostream>
#include <string>
using namespace std;
#include <gl/glut.h>
#include <dom/camera.h>
#include <dom/terrain.h>
#include <dom/bitmap.h>
#include <dom/vect.h>
#include <dom/surface.h>

//#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )

#define BUFFERSIZE 512

int windowWidth=0,windowHeight=0;

camera cam;
surface mySurface;
int myWindow=0;
int centerViewX=0,centerViewY=0;
int centerViewRightX=0,centerViewRightY=0,centerViewLeftX=0,centerViewLeftY=0;
bool rightMouseDown=false,leftMouseDown=false;;


void renderScene(void){
	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
	glMatrixMode(GL_PROJECTION);
	cam.glLoad();

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glBegin(GL_LINES);
		glColor3f(1,0,0);
		glVertex3f(0,0,0);glVertex3f(10,0,0);
		glColor3f(0,1,0);
		glVertex3f(0,0,0);glVertex3f(0,10,0);
		glColor3f(0,0,1);
		glVertex3f(0,0,0);glVertex3f(0,0,10);
	glEnd();

	glColor3f(1,1,1);
	
	mySurface.render();


	glFlush();
	glutSwapBuffers();
}
void keyInput(unsigned char key,int,int){
	switch(key){
		case 'f':
//			glEnable(GL_TEXTURE_2D);
			glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
			renderScene();
		break;	
		case 'l':
//			glDisable(GL_TEXTURE_2D);
			glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
			renderScene();
		break;
		case 'p':
//			glDisable(GL_TEXTURE_2D);
			glPolygonMode(GL_FRONT_AND_BACK,GL_POINT);
			renderScene();
		break;
	}
}
void specKeyInput(int key, int x, int y){
	int mod = glutGetModifiers();
	switch(key){
		case GLUT_KEY_UP:
			if(mod==GLUT_ACTIVE_CTRL){cam.moveUp();}
			else{cam.goForward();}
		break;
		case GLUT_KEY_LEFT:
			if(mod==GLUT_ACTIVE_CTRL){cam.strafeLeft();}
			else if(mod==GLUT_ACTIVE_ALT){cam.leanLeft();}
			else{cam.turnLeft();}
		break;
		case GLUT_KEY_DOWN:
			if(mod==GLUT_ACTIVE_CTRL){cam.moveDown();}
			else{cam.goBackward();}
		break;
		case GLUT_KEY_RIGHT:
			if(mod==GLUT_ACTIVE_CTRL){cam.strafeRight();}
			else if(mod==GLUT_ACTIVE_ALT){cam.leanRight();}
			else{cam.turnRight();}
		break;
	}
	renderScene();
}
void reshape(int w, int h){
    windowWidth=w;
	windowHeight=h;
	cam.ratio=(float)w/(float)h;
	glViewport(0,0,w,h);
	renderScene();
}
void mouseCall(int button, int state, int x, int y){
	switch(button){
		case GLUT_RIGHT_BUTTON:
			if(state==GLUT_DOWN){				
				rightMouseDown=true;
				centerViewRightX=x;
				centerViewRightY=y;
			}else{				
				rightMouseDown=false;
				cam.yaw+=cam.yawOffset;
				cam.pitch+=cam.pitchOffset;
				cam.yawOffset=0;
				cam.pitchOffset=0;
			}
		break;
		case GLUT_LEFT_BUTTON:
			if(state==GLUT_DOWN){
				leftMouseDown=true;
				centerViewLeftX=x;
				centerViewLeftY=y;
			}else{
				leftMouseDown=false;
			}
		break;
	}
}

void moveMouse(int x, int y){
	if(rightMouseDown){
		cam.yawOffset=(((GLfloat)centerViewRightX)-x)/10;
		cam.pitchOffset=(((GLfloat)centerViewRightY)-y)/10;
		renderScene();
	}else if(leftMouseDown){
	}
}
void mouseInOut(int state){}
void initLighting(){
	GLfloat light_ambient[] = {.4,.4,.4,1};
	GLfloat light_diffuse[] = {1,1,1,1};
	GLfloat light_spec[] = {1,1,1,1};
	GLfloat light_posi[] = {0,5,0,1};
	GLfloat light_spot_direction[] = {0,0,0};
	GLfloat light_spot_exponent = 0;
	GLfloat light_spot_cuttoff = 180;
	GLfloat light_cAtten = 1;
	GLfloat light_lAtten = .01;
	GLfloat light_qAtten = .0001;

	glEnable(GL_LIGHTING);
	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE);
	glLightfv(GL_LIGHT0,GL_AMBIENT,light_ambient);
	glLightfv(GL_LIGHT0,GL_DIFFUSE,light_diffuse);
	glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION,light_lAtten);
	glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION,light_qAtten);
	glLightfv(GL_LIGHT0,GL_SPECULAR,light_spec);
	glLightfv(GL_LIGHT0, GL_POSITION, light_posi);
	glEnable(GL_LIGHT0);

	glEnable(GL_COLOR_MATERIAL);
	GLfloat mat_shin[] = {0};
	GLfloat mat_spec[] = {0,0,0,1};
	glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE);
	glMaterialfv(GL_FRONT, GL_SPECULAR, mat_spec);
	glMaterialfv(GL_FRONT, GL_SHININESS, mat_shin);
}

void initGlut(int argc,char* argv[]){
	glutInit(&argc,argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
	glutInitWindowPosition(0,0);
	glutInitWindowSize(640,480);
	myWindow = glutCreateWindow("im learnding.");

	glutKeyboardFunc(keyInput);
	glutSpecialFunc(specKeyInput);
	glutMouseFunc(mouseCall);
	glutMotionFunc(moveMouse);
	glutEntryFunc(mouseInOut);
	glutReshapeFunc(reshape);	

	glutDisplayFunc(renderScene);

	glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
	glShadeModel(GL_SMOOTH);
	glClearColor(0,0,0,1);
	glEnable(GL_DEPTH_TEST);
//	glCullFace(GL_BACK);
//	glEnable(GL_CULL_FACE);

	cam.moveTo(-5,10,-5);
	cam.turnTo(0,30,135);
	initLighting();
	glutMainLoop();
}
void main(int argc, char* argv[]){
	int mode=0;
	cout << "SPHERE=0,CONE=1,CYLINDER=2,TORUS=3,BOHEM=4,APPLE=5" << endl;
	cout << "MODE : ";
	cin >> mode;
	mySurface.setMode(mode);
	initGlut(argc,argv);
}
surface.h

Code: Select all

#ifndef SURFACE_H
#define SURFACE_H

#include <dom/bitmap.h>
#include <gl/glut.h>
const int SPHERE=0,CONE=1,CYLINDER=2,TORUS=3,BOHEM=4,APPLE=5;

class surface{
public:
	float uMin;
	float uMax;
	int uCount;
	float uStep;
	float vMin;
	float vMax;
	int vCount;
	float vStep;
	float a;
	vect *vects;
	bitmap t;
//	int mode;
	void setupSphere(){
		uMin=2*PI;			uMax=0;
		uCount=50;		uStep=(uMax-uMin)/(uCount-1);
		vMin=-PI/2;		vMax=PI/2;
		vCount=45;		vStep=(vMax-vMin)/(vCount-1);
		vects = new vect[uCount*vCount];
		a=5;
	}
	void setupCone(){
		uMin=0;		uMax=10;
		uCount=16;	uStep=(uMax-uMin)/(uCount-1);
		vMin=0;		vMax=2*PI;
		vCount=64;	vStep=(vMax-vMin)/(vCount-1);
		vects = new vect[uCount*vCount];
		a=1;
	}
	void setupCylinder(){
		uMin=0;		uMax=2*PI;
		uCount=32;	uStep=(uMax-uMin)/(uCount-1);
		vMin=0;		vMax=5;
		vCount=10;	vStep=(vMax-vMin)/(vCount-1);
		vects = new vect[uCount*vCount];
		a=1;
	}
	void setupTorus(){
		uMin=0;		uMax=2*PI;
		uCount=32;	uStep=(uMax-uMin)/(uCount-1);
		vMin=0;		vMax=2*PI;
		vCount=32;	vStep=(vMax-vMin)/(vCount-1);
		vects = new vect[uCount*vCount];
		a=5;
	}
	void setupBohem(){
		uMin=0;		uMax=2*PI;
		uCount=32;	uStep=(uMax-uMin)/(uCount-1);
		vMin=0;		vMax=2*PI;
		vCount=32;	vStep=(vMax-vMin)/(vCount-1);
		vects = new vect[uCount*vCount];
		a=5;
	}
	void setupApple(){
		uMin=0;		uMax=2*PI;
		uCount=32;	uStep=(uMax-uMin)/(uCount-1);
		vMin=-PI;		vMax=PI;
		vCount=32;	vStep=(vMax-vMin)/(vCount-1);
		vects = new vect[uCount*vCount];
		a=3;
	}
	surface(){
	}
	void setMode(int mode){
		t.load("tex.bmp");
		int u=0,v=0;
		if(mode==SPHERE){
			setupSphere();
			for(u=0;u<uCount;u++){
				for(v=0;v<vCount;v++){
					setVect(u,v,
						sphereX((float)u*uStep+uMin,(float)v*vStep+vMin),
						sphereY((float)u*uStep+uMin,(float)v*vStep+vMin),
						sphereZ((float)u*uStep+uMin,(float)v*vStep+vMin));
				}
			}
		}else if(mode==CONE){
			setupCone();
			for(u=0;u<uCount;u++){
				for(v=0;v<vCount;v++){
					setVect(u,v,
						coneX((float)u*uStep+uMin,(float)v*vStep-vMin),
						coneY((float)u*uStep+uMin,(float)v*vStep-vMin),
						coneZ((float)u*uStep+uMin,(float)v*vStep-vMin));
				}
			}
		}else if(mode==CYLINDER){
			setupCylinder();
			for(u=0;u<uCount;u++){
				for(v=0;v<vCount;v++){
					setVect(u,v,
						cylinderX((float)u*uStep+uMin,(float)v*vStep+vMin),
						cylinderY((float)u*uStep+uMin,(float)v*vStep+vMin),
						cylinderZ((float)u*uStep+uMin,(float)v*vStep+vMin));
				}
			}
		}else if(mode==TORUS){
			setupTorus();
			for(u=0;u<uCount;u++){
				for(v=0;v<vCount;v++){
					setVect(u,v,
						torusX((float)u*uStep+uMin,(float)v*vStep+vMin),
						torusY((float)u*uStep+uMin,(float)v*vStep+vMin),
						torusZ((float)u*uStep+uMin,(float)v*vStep+vMin));
				}
			}
		}else if(mode==BOHEM){
			setupBohem();
			for(u=0;u<uCount;u++){
				for(v=0;v<vCount;v++){
					setVect(u,v,
						bohemX((float)u*uStep+uMin,(float)v*vStep+vMin),
						bohemY((float)u*uStep+uMin,(float)v*vStep+vMin),
						bohemZ((float)u*uStep+uMin,(float)v*vStep+vMin));
				}
			}
		}else if(mode==APPLE){
			setupApple();
			for(u=0;u<uCount;u++){
				for(v=0;v<vCount;v++){
					setVect(u,v,
						appleX((float)u*uStep+uMin,(float)v*vStep+vMin),
						appleY((float)u*uStep+uMin,(float)v*vStep+vMin),
						appleZ((float)u*uStep+uMin,(float)v*vStep+vMin));
				}
			}
		}
	}
	float sphereX(float u,float v){return a*cos(v)*cos(u);}
	float sphereY(float u,float v){return a*sin(v);}
	float sphereZ(float u,float v){return a*cos(v)*sin(u);}

	float coneX(float u,float v){return a*u*cos(v);}
	float coneY(float u,float v){return a*(uMax-u);}
	float coneZ(float u,float v){return a*u*sin(v);}

	float cylinderX(float u,float v){return a*sin(u);}
	float cylinderY(float u,float v){return a*v;}
	float cylinderZ(float u,float v){return a*cos(u);}

	float torusX(float u,float v){return (a+a/2*cos(u))*cos(v);}
	float torusY(float u,float v){return (a/2*sin(u));}
	float torusZ(float u,float v){return (a+a/2*cos(u))*sin(v);}

	float bohemX(float u,float v){return a/2*cos(u);}
	float bohemY(float u,float v){return a*sin(v);}			//# y = L*Sin(Alpha/2)
	float bohemZ(float u,float v){return a*2*cos(v)+a/2*sin(u);} //# z = (R + L*Cos(Alpha/2)) * Sin(Alpha)
	float appleX(float u,float v){return cos(u)*(a + a*cos(v))+ pow((v/PI),100);}
	float appleY(float u,float v){return -2.3*log(1 - v*0.3157) + 6*sin(v) +2*cos(v);}
	float appleZ(float u,float v){return sin(u)*(a + a*cos(v)) + 0.25*cos(5*u);}


//	float mobiusX(float u,float v){return cos(u)+v*cos(u/2)*cos(u);}
//	float mobiusY(float u,float v){return v*sin(u/2);}
//	float mobiusZ(float u,float v){return sin(u)+v*cos(u/2)*sin(u);}


	vect getVect(int u,int v){
		return vects[u*vCount+v];
	}
	void setVect(int u,int v,float x,float y,float z){
		vect tmp(x,y,z);
		vects[u*vCount+v]=tmp;

	}
	void setVect(int u,int v,vect a){
		vects[u*vCount+v]=a;
	}
	void render(){
		t.toTexture(0);
		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, 0);
		int u=0,v=0;
		vect tmp1,tmp2;
		for(u=0;u<uCount-1;u++){
			//glBegin(GL_POINTS);
			//glBegin(GL_LINES);
			glBegin(GL_TRIANGLE_STRIP);
			for(v=0;v<vCount;v++){
				tmp1=getVect(u,v%vCount);
				tmp2=getVect((u+1)%uCount,v%vCount);
				glTexCoord2f((float)v/vCount,(float)u/uCount);
				glVertex3f(tmp1.x,tmp1.y,tmp1.z);
				glTexCoord2f((float)v/vCount,(float)(u+1)/uCount);
				glVertex3f(tmp2.x,tmp2.y,tmp2.z);
			}
			glEnd();
		}
	}
};

#endif

it's not the greatest coding in the world... i know. i wrote it a while ago, and i don't remember what state i left the code in, but it should work. i think i was debugging my bitmap loader and texture generation... not sure. i didn't bother with any normal calculations, and i think the text coords are spherical.

i wanted to have a mobius strip too, but i was having a hell of a time w/ the formula.

arrow keys move around
right click and drag to look
L key = line mode
P key = point mode
F key = fill mode

don't be surprised if it hogs yer CPU. the framerate is not limited, so it goes as fast as possible. it doesn't bog down my pc at all, but you're probably just interested in the code anyways.

hope this helps!
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

thanks for you help.
domstyledesign
Posts: 9
Joined: Sat Apr 30, 2005 3:41 am
Contact:

Post by domstyledesign »

no sweat. that code was just lying around collecting digital dust.

good luck
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

here is the latest update of TShape class, but still need help for
CreateSphere member function.

Code: Select all

class TShape
 {
    public: 
      TShape() {}
     ~TShape() {}
     
     virtual IMesh* CreateCube()
       {
           SMesh* msh = new SMesh();      
           SMeshBuffer* mb = new SMeshBuffer();
           msh->addMeshBuffer(mb);  
           S3DVertex vtx[12];
           vtx[0]  = S3DVertex(-1,-1,-1, -1,-1,-1, SColor(255,255,255,255), 0, 1); 
           vtx[1]  = S3DVertex( 1,-1,-1,  1,-1,-1, SColor(255,255,255,255), 1, 1); 
           vtx[2]  = S3DVertex( 1, 1,-1,  1, 1,-1, SColor(255,255,255,255), 1, 0); 
           vtx[3]  = S3DVertex(-1, 1,-1, -1, 1,-1, SColor(255,255,255,255), 0, 0); 
           vtx[4]  = S3DVertex( 1,-1, 1,  1,-1, 1, SColor(255,255,255,255), 0, 1); 
           vtx[5]  = S3DVertex( 1, 1, 1,  1, 1, 1, SColor(255,255,255,255), 0, 0); 
           vtx[6]  = S3DVertex(-1, 1, 1, -1, 1, 1, SColor(255,255,255,255), 1, 0); 
           vtx[7]  = S3DVertex(-1,-1, 1, -1,-1, 1, SColor(255,255,255,255), 1, 1); 
           vtx[8]  = S3DVertex(-1, 1, 1, -1, 1, 1, SColor(255,255,255,255), 0, 1); 
           vtx[9]  = S3DVertex(-1, 1,-1, -1, 1,-1, SColor(255,255,255,255), 1, 1); 
           vtx[10] = S3DVertex( 1,-1, 1,  1,-1, 1, SColor(255,255,255,255), 1, 0); 
           vtx[11] = S3DVertex( 1,-1,-1,  1,-1,-1, SColor(255,255,255,255), 0, 0);            
           for(int i=0;i<12;i++)mb->Vertices.push_back(vtx[i]);
           u16 indices[36] = {   0,2,1,   0,3,2,   1,5,4,   1,2,5,   
                                 4,6,7,   4,5,6,   7,3,0,   7,6,3,   
                                 9,5,2,   9,8,5,   0,11,10, 0,10,7
                             };
           for(int i=0;i<36;i++)mb->Indices.push_back(indices[i]); 
           return msh;
       }
       
    virtual IMesh* CreatePlane(int gridX=25, int gridY=25)
       {
           SMesh* msh = new SMesh();      
           SMeshBuffer* mb = new SMeshBuffer();
           msh->addMeshBuffer(mb);
           int vertCnt = 0;
           for (int x = 0; x < gridX; x++)
               for (int y = 0; y < gridY; y++)
                {
                    f32 xx   = (0.5-(float)x/(gridX-1))*2;
                    f32 yy   = (0.5-(float)y/(gridY-1))*2;
                    f32 xcord = 1-(float)x/(gridX-1);
                    f32 ycord = (float)y/(gridY-1)-1;
                    mb->Vertices.push_back(S3DVertex(xx,yy,0, 0,0,0,SColor(255,255,255,255),xcord,ycord));
                    if (x < gridX - 1 && y < gridY - 1)
                     {
                        mb->Indices.push_back(vertCnt + 0);
                        mb->Indices.push_back(vertCnt + 1);
                        mb->Indices.push_back(vertCnt + 1 + gridY);
                        mb->Indices.push_back(vertCnt + 1 + gridY);
                        mb->Indices.push_back(vertCnt + gridY);
                        mb->Indices.push_back(vertCnt + 0);
                     }
                   vertCnt++; 
                }     
           return msh;
       } 
       
     virtual IMesh* CreateCylinder(int gridX=25, int gridY=25,f32 ridus=1)
       {
           SMesh* msh = new SMesh();      
           SMeshBuffer* mb = new SMeshBuffer();
           msh->addMeshBuffer(mb);
           f32 Tstp = 2*3.14/(float)(gridX-1);
           int vertCnt = 0;
           for (int x = 0; x < gridX; x++)
               for (int y = 0; y < gridY; y++)
                {
                    f32 yy   = (0.5-(float)y/(gridY-1))*2;
                    f32 xx   = sin((f32)x*Tstp)*ridus;  
                    f32 zz   = cos((f32)x*Tstp)*ridus;
                    f32 xcord = 1-(float)x/(gridX-1);
                    f32 ycord = (float)y/(gridY-1)-1;
                    if (x < gridX-1)
                     {
                        mb->Vertices.push_back(S3DVertex(xx,yy,zz, 0,0,0,SColor(255,255,255,255),xcord,ycord)); 
                     }    
                    else
                     {  
                        f32 yy   = (0.5-(float)y/(gridY-1))*2;
                        f32 xx   = sin(0.0)*ridus;  
                        f32 zz   = cos(0.0)*ridus;
                        mb->Vertices.push_back(S3DVertex(xx,yy,zz, 0,0,0,SColor(255,255,255,255),xcord,ycord));
                     }
                    if (x < gridX - 1 && y < gridY - 1)
                     {
                        mb->Indices.push_back(vertCnt + 0);
                        mb->Indices.push_back(vertCnt + 1);
                        mb->Indices.push_back(vertCnt + 1 + gridY);
                        mb->Indices.push_back(vertCnt + 1 + gridY);
                        mb->Indices.push_back(vertCnt + gridY);
                        mb->Indices.push_back(vertCnt + 0);
                     }
                   vertCnt++; 
                }       
           return msh;
       }      
       
     virtual IMesh* CreateCone(int gridX=25, int gridY=25,f32 ridus=1)
       {
           SMesh* msh = new SMesh();      
           SMeshBuffer* mb = new SMeshBuffer();
           msh->addMeshBuffer(mb); 
           f32 vstp = ridus/(float)(gridY-1);
           f32 Tstp = 2*3.14/(float)(gridX-1);
           int vertCnt = 0;
           for (int x = 0; x < gridX; x++)
               for (int y = 0; y < gridY; y++)
                {
                    f32 yy   = (0.5-(float)y/(gridY-1))*2;
                    f32 xx   = sin((f32)x*Tstp)*((f32)y*vstp);  
                    f32 zz   = cos((f32)x*Tstp)*((f32)y*vstp);
                    f32 xcord = 1-(float)x/(gridX-1);
                    f32 ycord = (float)y/(gridY-1)-1;
                    if (x < gridX-1)
                     {
                        mb->Vertices.push_back(S3DVertex(xx,yy,zz, 0,0,0,SColor(255,255,255,255),xcord,ycord)); 
                     }    
                    else
                     {  
                        f32 yy   = (0.5-(float)y/(gridY-1))*2;
                        f32 xx   = sin((f32)x*Tstp)*((f32)y*vstp);  
                        f32 zz   = cos((f32)x*Tstp)*((f32)y*vstp);
                        mb->Vertices.push_back(S3DVertex(xx,yy,zz, 0,0,0,SColor(255,255,255,255),xcord,ycord));
                     }
                    if (x < gridX - 1 && y < gridY - 1)
                     {
                        mb->Indices.push_back(vertCnt + 0);
                        mb->Indices.push_back(vertCnt + 1);
                        mb->Indices.push_back(vertCnt + 1 + gridY);
                        mb->Indices.push_back(vertCnt + 1 + gridY);
                        mb->Indices.push_back(vertCnt + gridY);
                        mb->Indices.push_back(vertCnt + 0);
                     }
                   vertCnt++; 
                }       
           return msh;
       }   
                        
    virtual IMesh* CreateSphere()
       {
           SMesh* msh = new SMesh();      
           SMeshBuffer* mb = new SMeshBuffer();
           msh->addMeshBuffer(mb);
           
           // creating Sphere stuff here
     
           return msh;
       }   
 };    
campino
Posts: 24
Joined: Wed Sep 21, 2005 12:57 pm
Location: Germany

Post by campino »

mhhh...

so...in the Sphere:

Code: Select all

x, y, z; //coordinates of the center
r; //radius

x1, y1, z1; //coordinates of the pointes

angle=0; //x/y Plane
zangle=0; // z

while(zangle<=360){
  x1=sin(angle)*r;
  y1=cos(angle)*r;
  z1=cos(zangle)*r;

  //make a Vertex out of x+x1, y+y1 and z+z1
  angle=angle+1; //maybe more than one for less Vertex
  if(angle>=361){
    zangle=zangle+1; //again: maybe more than one
    angle=0;
  }
}
Not sure if it will work, but maybe...
I don't implement it complete, just a quick idea...

Something else:
I want to make up a Java-Version of this class, but this

Code: Select all

for(int i=0;i<12;i++)mb->Vertices.push_back(vtx[i]); 
isn't posible in Java, have you got some idea how to do it instead (Can be a C++ idea also, maybe I find a Java-way if I got a different solution in C++). The problem is that the Array has got size 0 in Java so I can't fill it.
Youth-Irrlicht-Coder

There are 10 sorts of people, those who understand binaries and those who don't.
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

Since I remember Spinz wrote SkyDome class for Irrlicht. SkyDome uses sphere right? So, check Irrlicht-Spintz code.
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Ooops, I forgot to put the skydome in Irrlicht-Spintz-0.12, but here's where I got code from -

http://www.andypike.com/tutorials/directx8/009.asp
Image
Post Reply