Start e.g.:
../../../bin/vish Simple3DObject.vis
Further tutorials: - DisplayListObject.cpp - VertexBufferObject.cpp
00001 00002 #include <stdio.h> 00003 00004 #include <ocean/GLvish/VRenderObject.hpp> 00005 #include <ocean/plankton/VCreator.hpp> 00006 #include <ocean/plankton/VTime.hpp> 00007 #include <ocean/GLvish/BoundingBox.hpp> 00008 00009 #include <stdio.h> 00010 00011 using namespace Wizt; 00012 00013 00031 /* 00032 Render object for a helix-like object. 00033 */ 00034 class Simple3DObject : public VRenderObject 00035 { 00036 virtual void render(VRenderContext&Context) const; 00037 00038 public: 00039 TypedSlot<double> Complexity; 00040 00041 Simple3DObject(const string&name, int p, const RefPtr<VCreationPreferences>&VP) 00042 : VRenderObject(name, p, VP) 00043 , Complexity(this, "complexity", 0.5) 00044 {} 00045 00046 ~Simple3DObject() 00047 {} 00048 }; 00049 00050 void Simple3DObject::render(VRenderContext&Context) const 00051 { 00052 00053 resetBBox(Context); 00054 00055 static GLfloat Red[4] = {0.9, 0.1, 0.1, 1.0 }; 00056 00057 glEnable( GL_COLOR_MATERIAL ); 00058 glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); 00059 00060 // mark the beginning of an object that can be picked by the mouse 00061 SubObjectBegin(Context); 00062 00063 // define the highlight color of an picked object 00064 vglColor4fv(Context, Red, 0.4); 00065 00066 glEnable(GL_DEPTH_TEST); 00067 00068 int N = 300; 00069 double r = 1.0; 00070 00071 double complexity = 0.5; 00072 Complexity << Context >> complexity; 00073 00074 double dphi = 3.1415/ 10, 00075 zs = 0.1 * complexity; 00076 00077 glBegin( GL_QUAD_STRIP ); 00078 for (int i=0;i<N;i++) 00079 { 00080 double phi0 = i*dphi, 00081 phi1 = (i+1/complexity)*dphi; 00082 00083 point A, B; 00084 A = r*cos(phi0), r*sin(phi0), phi0*zs; 00085 B = r*cos(phi0), r*sin(phi0), phi1*zs; 00086 00087 bivector N; 00088 N = cos(phi0), sin(phi0), 0; 00089 00090 // Enlarge Bounding Box if necessary 00091 embrace( Context, A ); 00092 embrace( Context, B ); 00093 00094 glNormal( N ); 00095 glVertex( A ); 00096 glVertex( B ); 00097 } 00098 glEnd(); 00099 00100 // BoundingBox has to be closed, corresponding BoundingSphere is calculated 00101 closeBBox(Context); 00102 } 00103 00104 static Ref<VCreator<Simple3DObject> > MyCreator("Tutorial/Simple3DObject", 0); 00105 00106 /* 00107 This line needs to be contained in ONE source file of each 00108 VISH plugin module. It's not important which one. 00109 */ 00110 VISH_DEFAULT_INIT 00111 00112