PLIB 1.8.5+ r2173 from http://plib.svn.sourceforge.net/svnroot/plib/trunk
This commit is contained in:
3
examples/src/ssg/Makefile.am
Normal file
3
examples/src/ssg/Makefile.am
Normal file
@@ -0,0 +1,3 @@
|
||||
SUBDIRS = tux majik load_save state_test viewer tween_test water sky shrubs dynamics shapes
|
||||
|
||||
EXTRA_DIST = README
|
||||
20
examples/src/ssg/README
Normal file
20
examples/src/ssg/README
Normal file
@@ -0,0 +1,20 @@
|
||||
SSG Example programs.
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Tux -- Loads a 3D Tux model and a simple scene and
|
||||
animates it until you hit key.
|
||||
Needs to be run from it's source directory
|
||||
so it can find it's data files.
|
||||
|
||||
Majik -- An example I wrote for the Majik team
|
||||
http://majik.netti.fi to show them how to
|
||||
make a viewer for large area terrain.
|
||||
It's pretty basic.
|
||||
|
||||
Water -- A demo of some ssgAux stuff - waves, particle-systems
|
||||
a teapot and a cube.
|
||||
|
||||
Sky -- A demo of a sky dome, with sun, moon, stars and clouds.
|
||||
|
||||
Dynamics -- Spring/Mass/Damper demo.
|
||||
|
||||
12
examples/src/ssg/dynamics/Makefile.am
Normal file
12
examples/src/ssg/dynamics/Makefile.am
Normal file
@@ -0,0 +1,12 @@
|
||||
if BUILD_SSG
|
||||
|
||||
noinst_PROGRAMS = dynamics
|
||||
|
||||
dynamics_SOURCES = dynamics.cxx
|
||||
|
||||
dynamics_LDADD = -lplibpu -lplibfnt -lplibssgaux -lplibssg -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS)
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = dynamics.dsp
|
||||
|
||||
BIN
examples/src/ssg/dynamics/data/bw.rgb
Normal file
BIN
examples/src/ssg/dynamics/data/bw.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/dynamics/data/mg.rgb
Normal file
BIN
examples/src/ssg/dynamics/data/mg.rgb
Normal file
Binary file not shown.
450
examples/src/ssg/dynamics/dynamics.cxx
Normal file
450
examples/src/ssg/dynamics/dynamics.cxx
Normal file
@@ -0,0 +1,450 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: dynamics.cxx 2099 2006-11-03 20:04:40Z fayjf $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <plib/ssg.h>
|
||||
#include <plib/ssgAux.h>
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define GUI_BASE 80
|
||||
#define VIEW_GUI_BASE 20
|
||||
#define FONT_COLOUR 1,1,1,1
|
||||
#define DEEPEST_HELL -10000.0
|
||||
#define HOT_TOLERANCE 1.0f
|
||||
|
||||
static ssgRoot *scene = NULL ;
|
||||
static ssgaWaveSystem *ocean = NULL ;
|
||||
static ssgSimpleState *sea_state = NULL ;
|
||||
static ssgSimpleState *cube_state = NULL ;
|
||||
|
||||
static ssgaWaveTrain trains [ 3 ] ;
|
||||
|
||||
static ssgTransform *cube [ 10 ] ;
|
||||
static sgParticle *particle [ 10 ] ;
|
||||
static sgSpringDamper *spring [ 20 ] ;
|
||||
static int num_particles ;
|
||||
static int num_springs ;
|
||||
|
||||
static void resetSMD ()
|
||||
{
|
||||
particle [ 0 ] -> setPos ( 2.0f, -4.0f, 0.0f ) ;
|
||||
particle [ 1 ] -> setPos ( 2.4f, 0.0f, 6.0f ) ;
|
||||
particle [ 2 ] -> setPos ( 2.1f, 4.0f, 0.0f ) ;
|
||||
particle [ 3 ] -> setPos ( 4.1f, -4.0f, 4.0f ) ;
|
||||
particle [ 4 ] -> setPos ( 0.0f, -4.0f, 4.0f ) ;
|
||||
particle [ 5 ] -> setPos ( 4.0f, 4.0f, 4.0f ) ;
|
||||
particle [ 6 ] -> setPos ( 0.0f, 4.0f, 4.0f ) ;
|
||||
|
||||
particle [ 0 ] -> setVel ( 0, 0, 0 ) ;
|
||||
particle [ 1 ] -> setVel ( 0, 0, 30 ) ;
|
||||
particle [ 2 ] -> setVel ( 0, 0, 0 ) ;
|
||||
particle [ 3 ] -> setVel ( 0, 0, 0 ) ;
|
||||
particle [ 4 ] -> setVel ( 0, 0, 0 ) ;
|
||||
particle [ 5 ] -> setVel ( 0, 0, 0 ) ;
|
||||
particle [ 6 ] -> setVel ( 0, 0, 0 ) ;
|
||||
}
|
||||
|
||||
static void initSMD ()
|
||||
{
|
||||
particle [ 0 ] = new sgParticle ( 1.0f, 2.0f, -4.0f, 4.0f ) ;
|
||||
particle [ 1 ] = new sgParticle ( 1.0f, 2.4f, 0.0f, 6.0f ) ;
|
||||
particle [ 2 ] = new sgParticle ( 1.0f, 2.0f, 4.0f, 4.0f ) ;
|
||||
particle [ 3 ] = new sgParticle ( 1.0f, 4.0f, -4.0f, 0.0f ) ;
|
||||
particle [ 4 ] = new sgParticle ( 1.0f, 0.0f, -4.0f, 0.0f ) ;
|
||||
particle [ 5 ] = new sgParticle ( 1.0f, 4.0f, 4.0f, 0.0f ) ;
|
||||
particle [ 6 ] = new sgParticle ( 1.0f, 0.0f, 4.0f, 0.0f ) ;
|
||||
|
||||
num_particles = 7 ;
|
||||
|
||||
int s=0;
|
||||
|
||||
spring [s++] = new sgSpringDamper ( particle[0], particle[1], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[0], particle[2], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[0], particle[3], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[0], particle[4], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[0], particle[5], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[1], particle[2], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[2], particle[3], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[2], particle[5], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[2], particle[6], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[3], particle[4], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[3], particle[5], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[4], particle[6], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[5], particle[6], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[3], particle[6], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[4], particle[5], 50.0f, 1.0f ) ;
|
||||
|
||||
spring [s++] = new sgSpringDamper ( particle[2], particle[4], 50.0f, 1.0f ) ;
|
||||
spring [s++] = new sgSpringDamper ( particle[0], particle[6], 50.0f, 1.0f ) ;
|
||||
|
||||
num_springs = s ;
|
||||
|
||||
for ( int i = 0 ; i < num_particles ; i++ )
|
||||
{
|
||||
ssgaCube *cb = new ssgaCube () ;
|
||||
cb -> setKidState ( cube_state ) ;
|
||||
cb -> regenerate () ;
|
||||
|
||||
cube [ i ] = new ssgTransform () ;
|
||||
cube [ i ] -> addKid ( cb ) ;
|
||||
cube [ i ] -> clrTraversalMaskBits ( SSGTRAV_ISECT | SSGTRAV_HOT ) ;
|
||||
|
||||
scene -> addKid ( cube[i] ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static float getHeightAndNormal ( sgVec3 my_position, sgVec3 normal )
|
||||
{
|
||||
/* Look for the nearest polygon *beneath* my_position */
|
||||
|
||||
ssgHit *results ;
|
||||
int num_hits ;
|
||||
|
||||
float hot ; /* H.O.T == Height Of Terrain */
|
||||
sgVec3 HOTvec ;
|
||||
|
||||
sgMat4 invmat ;
|
||||
sgMakeIdentMat4 ( invmat ) ;
|
||||
invmat[3][0] = - my_position [0] ;
|
||||
invmat[3][1] = - my_position [1] ;
|
||||
invmat[3][2] = 0.0 ;
|
||||
|
||||
sgSetVec3 ( HOTvec, 0.0f, 0.0f, my_position [ 2 ]+HOT_TOLERANCE ) ;
|
||||
|
||||
num_hits = ssgHOT ( scene, HOTvec, invmat, &results ) ;
|
||||
|
||||
hot = DEEPEST_HELL ;
|
||||
|
||||
for ( int i = 0 ; i < num_hits ; i++ )
|
||||
{
|
||||
ssgHit *h = &results [ i ] ;
|
||||
|
||||
float hgt = - h->plane[3] / h->plane[2] ;
|
||||
|
||||
if ( hgt >= hot )
|
||||
{
|
||||
hot = hgt ;
|
||||
|
||||
if ( normal != NULL )
|
||||
sgCopyVec3 ( normal, h->plane ) ;
|
||||
}
|
||||
}
|
||||
|
||||
return hot ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define RESTITUTION 0.9f
|
||||
|
||||
|
||||
static void updateSMD ( float dt )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0 ; i < num_particles ; i++ )
|
||||
{
|
||||
sgVec3 friction ;
|
||||
|
||||
sgScaleVec3 ( friction, particle[i]->getVel (), 0.1f ) ;
|
||||
|
||||
particle [ i ] -> gravityOnly () ;
|
||||
particle [ i ] -> subForce ( friction ) ;
|
||||
}
|
||||
|
||||
for ( i = 0 ; i < num_springs ; i++ )
|
||||
spring [ i ] -> update () ;
|
||||
|
||||
for ( i = 0 ; i < num_particles ; i++ )
|
||||
{
|
||||
particle [ i ] -> update ( dt ) ;
|
||||
|
||||
sgVec3 normal ;
|
||||
|
||||
float hot = getHeightAndNormal ( particle [ i ] -> getPos(), normal ) ;
|
||||
|
||||
if ( particle [ i ] -> getPos ()[2] <= hot )
|
||||
{
|
||||
particle [ i ] -> bounce ( normal, RESTITUTION ) ;
|
||||
particle [ i ] -> getPos ()[2] = hot ;
|
||||
}
|
||||
}
|
||||
|
||||
for ( i = 0 ; i < num_particles ; i++ )
|
||||
cube [ i ] -> setTransform ( particle[i] -> getPos () ) ;
|
||||
}
|
||||
|
||||
|
||||
static sgCoord campos = { { 0, -20, 8 }, { 0, -20, 0 } } ;
|
||||
|
||||
static void update_motion ( int frameno )
|
||||
{
|
||||
ssgSetCamera ( & campos ) ;
|
||||
|
||||
ocean -> setWindDirn ( 25.0f * (float)sin ( frameno / 10.0 ) ) ;
|
||||
|
||||
static ulClock ck ; ck . update () ;
|
||||
|
||||
float t = (float)ck . getAbsTime () ;
|
||||
float dt = (float)ck . getDeltaTime () ;
|
||||
|
||||
if ( dt > 0.05f ) dt = 0.05f ;
|
||||
|
||||
ocean -> updateAnimation ( t ) ;
|
||||
|
||||
updateSMD ( dt ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT window reshape event
|
||||
*/
|
||||
|
||||
static void reshape ( int w, int h )
|
||||
{
|
||||
glViewport ( 0, 0, w, h ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT keyboard/mouse events
|
||||
*/
|
||||
|
||||
|
||||
static void keyboard ( unsigned char key, int, int )
|
||||
{
|
||||
switch ( key )
|
||||
{
|
||||
case 0x03 : exit ( 0 ) ;
|
||||
default : resetSMD () ; break ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void specialfn ( int key, int x, int y )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void motionfn ( int x, int y )
|
||||
{
|
||||
}
|
||||
|
||||
static void mousefn ( int button, int updown, int x, int y )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT redraw event
|
||||
*/
|
||||
|
||||
static void redraw ()
|
||||
{
|
||||
static int frameno = 0 ;
|
||||
frameno++ ;
|
||||
|
||||
update_motion ( frameno % 2000 ) ;
|
||||
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
ssgCullAndDraw ( scene ) ;
|
||||
|
||||
glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL ) ;
|
||||
|
||||
glutPostRedisplay () ;
|
||||
glutSwapBuffers () ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void init_graphics ()
|
||||
{
|
||||
int fake_argc = 1 ;
|
||||
char *fake_argv[3] ;
|
||||
fake_argv[0] = "ssgExample" ;
|
||||
fake_argv[1] = "Simple Scene Graph : Example Program." ;
|
||||
fake_argv[2] = NULL ;
|
||||
|
||||
/*
|
||||
Initialise GLUT
|
||||
*/
|
||||
|
||||
glutInitWindowPosition ( 0, 0 ) ;
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInit ( &fake_argc, fake_argv ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
glutCreateWindow ( fake_argv[1] ) ;
|
||||
glutDisplayFunc ( redraw ) ;
|
||||
glutReshapeFunc ( reshape ) ;
|
||||
glutKeyboardFunc ( keyboard ) ;
|
||||
glutSpecialFunc ( specialfn ) ;
|
||||
glutMouseFunc ( mousefn ) ;
|
||||
glutMotionFunc ( motionfn ) ;
|
||||
glutPassiveMotionFunc ( motionfn ) ;
|
||||
|
||||
ssgInit () ;
|
||||
|
||||
/*
|
||||
Some basic OpenGL setup
|
||||
*/
|
||||
|
||||
glClearColor ( 0.2f, 0.7f, 1.0f, 1.0f ) ;
|
||||
glEnable ( GL_DEPTH_TEST ) ;
|
||||
|
||||
/*
|
||||
Set up the viewing parameters
|
||||
*/
|
||||
|
||||
ssgSetFOV ( 60.0f, 0.0f ) ;
|
||||
ssgSetNearFar ( 1.0f, 700.0f ) ;
|
||||
|
||||
/*
|
||||
Set up the Sun.
|
||||
*/
|
||||
|
||||
sgVec3 sunposn ;
|
||||
sgSetVec3 ( sunposn, 0.1f, -1.0f, 0.1f ) ;
|
||||
ssgGetLight ( 0 ) -> setPosition ( sunposn ) ;
|
||||
}
|
||||
|
||||
|
||||
static void init_states ()
|
||||
{
|
||||
cube_state = new ssgSimpleState () ;
|
||||
cube_state -> setTexture ( "data/mg.rgb" ) ;
|
||||
cube_state -> enable ( GL_TEXTURE_2D ) ;
|
||||
cube_state -> setShadeModel ( GL_SMOOTH ) ;
|
||||
cube_state -> enable ( GL_CULL_FACE ) ;
|
||||
cube_state -> enable ( GL_BLEND ) ;
|
||||
cube_state -> enable ( GL_LIGHTING ) ;
|
||||
cube_state -> setColourMaterial ( GL_AMBIENT_AND_DIFFUSE ) ;
|
||||
cube_state -> setMaterial ( GL_EMISSION, 0, 0, 0, 1 ) ;
|
||||
cube_state -> setMaterial ( GL_SPECULAR, 1, 1, 1, 1 ) ;
|
||||
cube_state -> setShininess ( 2 ) ;
|
||||
|
||||
sea_state = new ssgSimpleState () ;
|
||||
sea_state -> setTexture ( "data/bw.rgb" ) ;
|
||||
sea_state -> enable ( GL_TEXTURE_2D ) ;
|
||||
sea_state -> setShadeModel ( GL_SMOOTH ) ;
|
||||
sea_state -> enable ( GL_CULL_FACE ) ;
|
||||
sea_state -> disable ( GL_BLEND ) ;
|
||||
sea_state -> enable ( GL_LIGHTING ) ;
|
||||
sea_state -> setColourMaterial ( GL_AMBIENT_AND_DIFFUSE ) ;
|
||||
sea_state -> setMaterial ( GL_EMISSION, 0, 0, 0, 1 ) ;
|
||||
sea_state -> setMaterial ( GL_SPECULAR, 1, 1, 1, 1 ) ;
|
||||
sea_state -> setShininess ( 5 ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void load_database ()
|
||||
{
|
||||
/* Set up the path to the data files */
|
||||
|
||||
ssgModelPath ( "data" ) ;
|
||||
ssgTexturePath ( "data" ) ;
|
||||
|
||||
/* Load the states */
|
||||
|
||||
init_states () ;
|
||||
|
||||
sgVec4 WHITE = { 1.0, 1.0, 1.0, 1.0 } ;
|
||||
|
||||
/* Set up some interesting defaults. */
|
||||
|
||||
trains[0] . setSpeed ( 3.1f ) ;
|
||||
trains[0] . setLength ( 0.8f ) ;
|
||||
trains[0] . setLambda ( 0.6f ) ;
|
||||
trains[0] . setHeading ( 47.0f ) ;
|
||||
trains[0] . setWaveHeight ( 0.2f ) ;
|
||||
|
||||
trains[1] . setSpeed ( 4.6f ) ;
|
||||
trains[1] . setLength ( 0.8f ) ;
|
||||
trains[1] . setLambda ( 1.0f ) ;
|
||||
trains[1] . setHeading ( 36.0f ) ;
|
||||
trains[1] . setWaveHeight ( 0.1f ) ;
|
||||
|
||||
trains[2] . setSpeed ( 8.5f ) ;
|
||||
trains[2] . setLength ( 0.6f ) ;
|
||||
trains[2] . setLambda ( 1.0f ) ;
|
||||
trains[2] . setHeading ( 65.0f ) ;
|
||||
trains[2] . setWaveHeight ( 0.1f ) ;
|
||||
|
||||
ocean = new ssgaWaveSystem ( 10000 ) ;
|
||||
ocean -> setColour ( WHITE ) ;
|
||||
ocean -> setSize ( 100 ) ;
|
||||
ocean -> setTexScale ( 3, 3 ) ;
|
||||
ocean -> setKidState ( sea_state ) ;
|
||||
ocean -> setWindSpeed ( 10.0f ) ;
|
||||
ocean -> setWaveTrain ( 0, & trains[0] ) ;
|
||||
ocean -> setWaveTrain ( 1, & trains[1] ) ;
|
||||
ocean -> setWaveTrain ( 2, & trains[2] ) ;
|
||||
ocean -> regenerate () ;
|
||||
|
||||
/* Build the scene graph */
|
||||
|
||||
scene = new ssgRoot ;
|
||||
scene -> addKid ( ocean ) ;
|
||||
|
||||
initSMD () ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
The works.
|
||||
*/
|
||||
|
||||
int main ( int, char ** )
|
||||
{
|
||||
init_graphics () ;
|
||||
load_database () ;
|
||||
glutMainLoop () ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
88
examples/src/ssg/dynamics/dynamics.dsp
Normal file
88
examples/src/ssg/dynamics/dynamics.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="dynamics" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=dynamics - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "dynamics.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "dynamics.mak" CFG="dynamics - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "dynamics - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "dynamics - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "dynamics - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssgAux.lib ssg.lib sg.lib ul.lib winmm.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /out:"dynamics.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "dynamics - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssgAux_d.lib ssg_d.lib sg_d.lib ul_d.lib winmm.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /out:"dynamics.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "dynamics - Win32 Release"
|
||||
# Name "dynamics - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dynamics.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
14
examples/src/ssg/load_save/Makefile.am
Normal file
14
examples/src/ssg/load_save/Makefile.am
Normal file
@@ -0,0 +1,14 @@
|
||||
if BUILD_SSG
|
||||
|
||||
noinst_PROGRAMS = load save
|
||||
|
||||
load_SOURCES = load.cxx
|
||||
save_SOURCES = save.cxx
|
||||
|
||||
load_LDADD = -lplibssg -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS)
|
||||
save_LDADD = -lplibssg -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS)
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = load.dsp save.dsp
|
||||
|
||||
BIN
examples/src/ssg/load_save/data/Penguin_beak.rgb
Normal file
BIN
examples/src/ssg/load_save/data/Penguin_beak.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/load_save/data/Penguin_body.rgb
Normal file
BIN
examples/src/ssg/load_save/data/Penguin_body.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/load_save/data/embossed_herring.bmp
Normal file
BIN
examples/src/ssg/load_save/data/embossed_herring.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
81
examples/src/ssg/load_save/data/pedestal.ac
Normal file
81
examples/src/ssg/load_save/data/pedestal.ac
Normal file
@@ -0,0 +1,81 @@
|
||||
AC3Db
|
||||
MATERIAL "" rgb 1 1 1 amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10 trans 0
|
||||
MATERIAL "" rgb 1 1 1 amb 0.2 0.2 0.2 emis 1 1 1 spec 0.502 0.502 0.502 shi 0 trans 0
|
||||
OBJECT world
|
||||
kids 2
|
||||
OBJECT poly
|
||||
name "box"
|
||||
texture "wood.rgb"
|
||||
texrep 5 5
|
||||
numvert 8
|
||||
-1.29615 -0.6 -1.29615
|
||||
-1 0 -1
|
||||
1 0 -1
|
||||
1.3 -0.6 -1.29615
|
||||
-1.29615 -0.6 1.3
|
||||
-1 0 1
|
||||
1 0 1
|
||||
1.3 -0.6 1.3
|
||||
numsurf 6
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
0 0 0
|
||||
1 0.114074 0.114074
|
||||
2 0.884445 0.114074
|
||||
3 1 0
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
6 0.884445 0.884445
|
||||
7 1 1
|
||||
3 1 0
|
||||
2 0.884445 0.114074
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
7 1 1
|
||||
6 0.884445 0.884445
|
||||
5 0.114074 0.884445
|
||||
4 0 1
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
4 0 1
|
||||
5 0.114074 0.884445
|
||||
1 0.114074 0.114074
|
||||
0 0 0
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
1 0.114074 0.114074
|
||||
5 0.114074 0.884445
|
||||
6 0.884445 0.884445
|
||||
2 0.884445 0.114074
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
4 0 1
|
||||
0 0 0
|
||||
3 1 0
|
||||
7 1 1
|
||||
kids 0
|
||||
OBJECT poly
|
||||
name "rect"
|
||||
loc -0.0500002 0 -2.5
|
||||
texture "embossed_herring.bmp"
|
||||
texrep 20 30
|
||||
numvert 4
|
||||
-17.95 -0.7 -18.6
|
||||
17.95 -0.7 -18.6
|
||||
17.95 -0.7 18.6
|
||||
-17.95 -0.7 18.6
|
||||
numsurf 1
|
||||
SURF 0x0
|
||||
mat 1
|
||||
refs 4
|
||||
3 0 0
|
||||
2 1 0
|
||||
1 1 1
|
||||
0 0 1
|
||||
kids 0
|
||||
81
examples/src/ssg/load_save/data/pedestal.safe
Normal file
81
examples/src/ssg/load_save/data/pedestal.safe
Normal file
@@ -0,0 +1,81 @@
|
||||
AC3Db
|
||||
MATERIAL "" rgb 1 1 1 amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10 trans 0
|
||||
MATERIAL "" rgb 1 1 1 amb 0.2 0.2 0.2 emis 1 1 1 spec 0.502 0.502 0.502 shi 0 trans 0
|
||||
OBJECT world
|
||||
kids 2
|
||||
OBJECT poly
|
||||
name "box"
|
||||
texture "wood.rgb"
|
||||
texrep 5 5
|
||||
numvert 8
|
||||
-1.29615 -0.6 -1.29615
|
||||
-1 0 -1
|
||||
1 0 -1
|
||||
1.3 -0.6 -1.29615
|
||||
-1.29615 -0.6 1.3
|
||||
-1 0 1
|
||||
1 0 1
|
||||
1.3 -0.6 1.3
|
||||
numsurf 6
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
0 0 0
|
||||
1 0.114074 0.114074
|
||||
2 0.884445 0.114074
|
||||
3 1 0
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
6 0.884445 0.884445
|
||||
7 1 1
|
||||
3 1 0
|
||||
2 0.884445 0.114074
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
7 1 1
|
||||
6 0.884445 0.884445
|
||||
5 0.114074 0.884445
|
||||
4 0 1
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
4 0 1
|
||||
5 0.114074 0.884445
|
||||
1 0.114074 0.114074
|
||||
0 0 0
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
1 0.114074 0.114074
|
||||
5 0.114074 0.884445
|
||||
6 0.884445 0.884445
|
||||
2 0.884445 0.114074
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
4 0 1
|
||||
0 0 0
|
||||
3 1 0
|
||||
7 1 1
|
||||
kids 0
|
||||
OBJECT poly
|
||||
name "rect"
|
||||
loc -0.0500002 0 -2.5
|
||||
texture "embossed_herring.rgb"
|
||||
texrep 20 30
|
||||
numvert 4
|
||||
-17.95 -0.7 -18.6
|
||||
17.95 -0.7 -18.6
|
||||
17.95 -0.7 18.6
|
||||
-17.95 -0.7 18.6
|
||||
numsurf 1
|
||||
SURF 0x0
|
||||
mat 1
|
||||
refs 4
|
||||
3 0 0
|
||||
2 1 0
|
||||
1 1 1
|
||||
0 0 1
|
||||
kids 0
|
||||
1695
examples/src/ssg/load_save/data/tuxedo.ac
Normal file
1695
examples/src/ssg/load_save/data/tuxedo.ac
Normal file
File diff suppressed because it is too large
Load Diff
BIN
examples/src/ssg/load_save/data/wood.rgb
Normal file
BIN
examples/src/ssg/load_save/data/wood.rgb
Normal file
Binary file not shown.
234
examples/src/ssg/load_save/load.cxx
Normal file
234
examples/src/ssg/load_save/load.cxx
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: load.cxx 2099 2006-11-03 20:04:40Z fayjf $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <plib/ssg.h>
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static ssgRoot *scene = NULL ;
|
||||
static ssgTransform *penguin = NULL ;
|
||||
static ssgTransform *pedestal = NULL ;
|
||||
|
||||
/*
|
||||
Something to make some interesting motion
|
||||
for both Tux and the camera.
|
||||
*/
|
||||
|
||||
static void update_motion ()
|
||||
{
|
||||
static int frameno = 0 ;
|
||||
|
||||
frameno++ ;
|
||||
|
||||
sgCoord campos ;
|
||||
sgCoord tuxpos ;
|
||||
|
||||
/*
|
||||
Spin Tux, make the camera pan sinusoidally left and right
|
||||
*/
|
||||
|
||||
sgSetCoord ( & campos, 0.0f, -5.0f, 1.0f, 25.0f * (float)sin(frameno/100.0), 0.0f, 0.0f ) ;
|
||||
sgSetCoord ( & tuxpos, 0.0f, 0.0f, 0.0f, (float)frameno, 0.0f, 0.0f ) ;
|
||||
|
||||
ssgSetCamera ( & campos ) ;
|
||||
penguin -> setTransform ( & tuxpos ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT window reshape event
|
||||
*/
|
||||
|
||||
static void reshape ( int w, int h )
|
||||
{
|
||||
glViewport ( 0, 0, w, h ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT keyboard event
|
||||
*/
|
||||
|
||||
static void keyboard ( unsigned char, int, int )
|
||||
{
|
||||
exit ( 0 ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT redraw event
|
||||
*/
|
||||
|
||||
static void redraw ()
|
||||
{
|
||||
update_motion () ;
|
||||
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
ssgCullAndDraw ( scene ) ;
|
||||
|
||||
glutPostRedisplay () ;
|
||||
glutSwapBuffers () ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void init_graphics ()
|
||||
{
|
||||
int fake_argc = 1 ;
|
||||
char *fake_argv[3] ;
|
||||
fake_argv[0] = "ssgExample" ;
|
||||
fake_argv[1] = "Simple Scene Graph : Example Program." ;
|
||||
fake_argv[2] = NULL ;
|
||||
|
||||
/*
|
||||
Initialise GLUT
|
||||
*/
|
||||
|
||||
glutInitWindowPosition ( 0, 0 ) ;
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInit ( &fake_argc, fake_argv ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
glutCreateWindow ( fake_argv[1] ) ;
|
||||
glutDisplayFunc ( redraw ) ;
|
||||
glutReshapeFunc ( reshape ) ;
|
||||
glutKeyboardFunc ( keyboard ) ;
|
||||
|
||||
/*
|
||||
Initialise SSG
|
||||
*/
|
||||
|
||||
ssgInit () ;
|
||||
|
||||
/*
|
||||
Some basic OpenGL setup
|
||||
*/
|
||||
|
||||
glClearColor ( 0.2f, 0.7f, 1.0f, 1.0f ) ;
|
||||
glEnable ( GL_DEPTH_TEST ) ;
|
||||
|
||||
/*
|
||||
Set up the viewing parameters
|
||||
*/
|
||||
|
||||
ssgSetFOV ( 60.0f, 0.0f ) ;
|
||||
ssgSetNearFar ( 1.0f, 700.0f ) ;
|
||||
|
||||
/*
|
||||
Set up the Sun.
|
||||
*/
|
||||
|
||||
sgVec3 sunposn ;
|
||||
sgSetVec3 ( sunposn, 0.2f, -0.5f, 0.5f ) ;
|
||||
ssgGetLight ( 0 ) -> setPosition ( sunposn ) ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Load a simple database
|
||||
*/
|
||||
|
||||
static void load_database ()
|
||||
{
|
||||
/*
|
||||
Set up the path to the data files
|
||||
*/
|
||||
|
||||
ssgModelPath ( "data" ) ;
|
||||
ssgTexturePath ( "data" ) ;
|
||||
|
||||
/*
|
||||
Create a root node - and a transform to position
|
||||
the pedestal - and another to position the penguin
|
||||
beneath that (in the tree that is).
|
||||
*/
|
||||
|
||||
scene = new ssgRoot ;
|
||||
pedestal = new ssgTransform ;
|
||||
penguin = new ssgTransform ;
|
||||
|
||||
/*
|
||||
Load the models - optimise them a bit
|
||||
and then add them into the scene.
|
||||
*/
|
||||
|
||||
ssgEntity *ped_obj = ssgLoadAC ( "pedestal.ac" ) ;
|
||||
ssgEntity *tux_obj = ssgLoadSSG ( "tuxedo.ssg" ) ;
|
||||
|
||||
if ( ped_obj == NULL )
|
||||
ulSetError ( UL_FATAL, "Cannot load pedastal.ac" ) ;
|
||||
if ( tux_obj == NULL )
|
||||
ulSetError ( UL_FATAL, "Cannot load tuxedo.ssg -- Please run 'save' first" ) ;
|
||||
|
||||
tux_obj->print();
|
||||
|
||||
penguin -> addKid ( tux_obj ) ;
|
||||
pedestal -> addKid ( ped_obj ) ;
|
||||
|
||||
/*ssgFlatten ( tux_obj ) ;*/
|
||||
ssgFlatten ( ped_obj ) ;
|
||||
/*ssgStripify ( penguin ) ;*/
|
||||
ssgStripify ( pedestal ) ;
|
||||
|
||||
pedestal -> addKid ( penguin ) ;
|
||||
scene -> addKid ( pedestal ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The works.
|
||||
*/
|
||||
|
||||
int main ( int, char ** )
|
||||
{
|
||||
init_graphics () ;
|
||||
load_database () ;
|
||||
glutMainLoop () ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
88
examples/src/ssg/load_save/load.dsp
Normal file
88
examples/src/ssg/load_save/load.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="load" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=load - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "load.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "load.mak" CFG="load - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "load - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "load - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "load - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg.lib sg.lib ul.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /out:"load.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "load - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg_d.lib sg_d.lib ul_d.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /out:"load.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "load - Win32 Release"
|
||||
# Name "load - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\load.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
131
examples/src/ssg/load_save/save.cxx
Normal file
131
examples/src/ssg/load_save/save.cxx
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: save.cxx 1551 2002-09-01 12:04:53Z ude $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <plib/ssg.h>
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static ssgRoot *scene = NULL ;
|
||||
static ssgTransform *object = NULL ;
|
||||
static ssgEntity *obj_obj = NULL ;
|
||||
|
||||
|
||||
static void redraw ()
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
static void init_graphics ()
|
||||
{
|
||||
int fake_argc = 1 ;
|
||||
char *fake_argv[3] ;
|
||||
fake_argv[0] = "ssgExample" ;
|
||||
fake_argv[1] = "Simple Scene Graph : Example Program." ;
|
||||
fake_argv[2] = NULL ;
|
||||
|
||||
/*
|
||||
Initialise GLUT
|
||||
*/
|
||||
|
||||
glutInitWindowPosition ( 0, 0 ) ;
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInit ( &fake_argc, fake_argv ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
glutCreateWindow ( fake_argv[1] ) ;
|
||||
glutDisplayFunc ( redraw ) ;
|
||||
|
||||
/*
|
||||
Initialise SSG
|
||||
*/
|
||||
|
||||
ssgInit () ;
|
||||
}
|
||||
|
||||
|
||||
static void load_database ()
|
||||
{
|
||||
/*
|
||||
Set up the path to the data files
|
||||
*/
|
||||
|
||||
ssgModelPath ( "data" ) ;
|
||||
ssgTexturePath ( "data" ) ;
|
||||
|
||||
/*
|
||||
Create a root node - and a transform to position
|
||||
the object beneath that (in the tree that is).
|
||||
*/
|
||||
|
||||
scene = new ssgRoot ;
|
||||
object = new ssgTransform ;
|
||||
|
||||
/*
|
||||
Load the models - optimise them a bit
|
||||
and then add them into the scene.
|
||||
*/
|
||||
|
||||
obj_obj = ssgLoadAC ( "tuxedo.ac" ) ;
|
||||
|
||||
object -> addKid ( obj_obj ) ;
|
||||
|
||||
ssgFlatten ( obj_obj ) ;
|
||||
ssgStripify ( object ) ;
|
||||
scene -> addKid ( object ) ;
|
||||
}
|
||||
|
||||
|
||||
static void save_database ()
|
||||
{
|
||||
ssgSaveSSG ( "data/tuxedo.ssg", object ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main ( int, char ** )
|
||||
{
|
||||
init_graphics () ;
|
||||
load_database () ;
|
||||
save_database () ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
88
examples/src/ssg/load_save/save.dsp
Normal file
88
examples/src/ssg/load_save/save.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="save" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=save - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "save.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "save.mak" CFG="save - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "save - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "save - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "save - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg.lib sg.lib ul.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /out:"save.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "save - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg_d.lib sg_d.lib ul_d.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /out:"save.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "save - Win32 Release"
|
||||
# Name "save - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\save.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
14
examples/src/ssg/majik/Makefile.am
Normal file
14
examples/src/ssg/majik/Makefile.am
Normal file
@@ -0,0 +1,14 @@
|
||||
if BUILD_SSG
|
||||
|
||||
noinst_PROGRAMS = majik_demo
|
||||
|
||||
majik_demo_SOURCES = elevation_map.h \
|
||||
image_map.h \
|
||||
majik_demo.cxx
|
||||
|
||||
majik_demo_LDADD = -lplibjs -lplibssg -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS)
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = majik_demo.dsp
|
||||
|
||||
BIN
examples/src/ssg/majik/data/Penguin_beak.rgb
Normal file
BIN
examples/src/ssg/majik/data/Penguin_beak.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/majik/data/Penguin_body.rgb
Normal file
BIN
examples/src/ssg/majik/data/Penguin_body.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/majik/data/bumpnoise.rgb
Normal file
BIN
examples/src/ssg/majik/data/bumpnoise.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/majik/data/majik.rgb
Normal file
BIN
examples/src/ssg/majik/data/majik.rgb
Normal file
Binary file not shown.
1695
examples/src/ssg/majik/data/tuxedo.ac
Normal file
1695
examples/src/ssg/majik/data/tuxedo.ac
Normal file
File diff suppressed because it is too large
Load Diff
3859
examples/src/ssg/majik/elevation_map.h
Normal file
3859
examples/src/ssg/majik/elevation_map.h
Normal file
File diff suppressed because it is too large
Load Diff
13111
examples/src/ssg/majik/image_map.h
Normal file
13111
examples/src/ssg/majik/image_map.h
Normal file
File diff suppressed because it is too large
Load Diff
433
examples/src/ssg/majik/majik_demo.cxx
Normal file
433
examples/src/ssg/majik/majik_demo.cxx
Normal file
@@ -0,0 +1,433 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: majik_demo.cxx 2099 2006-11-03 20:04:40Z fayjf $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <plib/ssg.h>
|
||||
#include <plib/js.h>
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define TILE_SIZE 2000.0f /* cubits */
|
||||
#define LAMBDA (TILE_SIZE/48.0f)
|
||||
#define TILE_GRID_SIZE 20 /* Even number please! */
|
||||
#define TRIANGLE_GRID_SIZE 12 /* Num vertices */
|
||||
#define ELEVATION_SCALE 4.0f
|
||||
#define ONLINE_TERRAIN_RANGE ((float)(TILE_GRID_SIZE/2 )* TILE_SIZE ) /* cubits */
|
||||
#define VISUAL_RANGE ((float)(TILE_GRID_SIZE/2-1)* TILE_SIZE ) /* cubits */
|
||||
|
||||
/***** *****/
|
||||
|
||||
static ssgSimpleState *state = NULL ;
|
||||
static ssgRoot *scene = NULL ;
|
||||
static ssgTransform *penguin = NULL ;
|
||||
static ssgTransform *terrain = NULL ;
|
||||
static ssgTransform *tilegrid [ TILE_GRID_SIZE ][ TILE_GRID_SIZE ] ;
|
||||
|
||||
#include "elevation_map.h"
|
||||
#include "image_map.h"
|
||||
|
||||
static jsJoystick *js ;
|
||||
static float *ax ;
|
||||
static sgCoord tuxpos = { { 0.0f,0.0f,0.0f }, { 0.0f,0.0f,0.0f } } ;
|
||||
|
||||
#define ROT_SPEED 5.0f
|
||||
#define TRANS_SPEED 10.0f
|
||||
|
||||
static void update_motion ()
|
||||
{
|
||||
static int frameno = 0 ;
|
||||
|
||||
frameno++ ;
|
||||
|
||||
sgCoord campos ;
|
||||
|
||||
int buttons ;
|
||||
|
||||
js -> read ( &buttons, ax ) ;
|
||||
|
||||
tuxpos.hpr[0] -= ax [ 0 ] * ROT_SPEED ;
|
||||
tuxpos.xyz[0] -= (float)sin ( tuxpos.hpr[0] * SG_DEGREES_TO_RADIANS ) * ax[1] * TRANS_SPEED ;
|
||||
tuxpos.xyz[1] += (float)cos ( tuxpos.hpr[0] * SG_DEGREES_TO_RADIANS ) * ax[1] * TRANS_SPEED ;
|
||||
|
||||
sgVec3 test_vec ;
|
||||
sgMat4 invmat ;
|
||||
sgMakeIdentMat4 ( invmat ) ;
|
||||
|
||||
invmat[3][0] = -tuxpos.xyz[0] ;
|
||||
invmat[3][1] = -tuxpos.xyz[1] ;
|
||||
invmat[3][2] = 0.0f ;
|
||||
|
||||
test_vec [0] = 0.0f ;
|
||||
test_vec [1] = 0.0f ;
|
||||
test_vec [2] = 100000.0f ;
|
||||
|
||||
ssgHit *results ;
|
||||
int num_hits = ssgHOT ( scene, test_vec, invmat, &results ) ;
|
||||
|
||||
float hot = -1000000.0f ;
|
||||
|
||||
for ( int i = 0 ; i < num_hits ; i++ )
|
||||
{
|
||||
ssgHit *h = &results [ i ] ;
|
||||
|
||||
float hgt = - h->plane[3] / h->plane[2] ;
|
||||
|
||||
if ( hgt >= hot )
|
||||
hot = hgt ;
|
||||
}
|
||||
|
||||
tuxpos . xyz [ 2 ] = hot + 0.1f ;
|
||||
tuxpos . hpr [ 1 ] = 0.0f ;
|
||||
tuxpos . hpr [ 2 ] = 0.0f ;
|
||||
|
||||
sgCopyVec3 ( campos.xyz, tuxpos.xyz ) ;
|
||||
|
||||
campos . hpr [ 0 ] = 0.0f ;
|
||||
campos . hpr [ 1 ] = -20.0f ;
|
||||
campos . hpr [ 2 ] = 0.0f ;
|
||||
campos . xyz [ 0 ] += 1.0f ;
|
||||
campos . xyz [ 1 ] -= 20.0f ;
|
||||
campos . xyz [ 2 ] += 12.0f ;
|
||||
|
||||
ssgSetCamera ( & campos ) ;
|
||||
penguin -> setTransform ( & tuxpos ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT window reshape event
|
||||
*/
|
||||
|
||||
static void reshape ( int w, int h )
|
||||
{
|
||||
glViewport ( 0, 0, w, h ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT keyboard event
|
||||
*/
|
||||
|
||||
static void keyboard ( unsigned char k, int, int )
|
||||
{
|
||||
static int wireframe = FALSE ;
|
||||
|
||||
if ( k == 'w' )
|
||||
{
|
||||
wireframe = ! wireframe ;
|
||||
|
||||
glPolygonMode ( GL_FRONT_AND_BACK, wireframe ? GL_LINE : GL_FILL ) ;
|
||||
}
|
||||
|
||||
if ( k == 0x03 || k == 'x' )
|
||||
exit ( 0 ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT redraw event
|
||||
*/
|
||||
|
||||
static void redraw ()
|
||||
{
|
||||
update_motion () ;
|
||||
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
ssgCullAndDraw ( scene ) ;
|
||||
|
||||
glutPostRedisplay () ;
|
||||
glutSwapBuffers () ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void init_graphics ()
|
||||
{
|
||||
int fake_argc = 1 ;
|
||||
char *fake_argv[3] ;
|
||||
fake_argv[0] = "MajikTerrain" ;
|
||||
fake_argv[1] = "Majik Terrain Demo - by Steve Baker" ;
|
||||
fake_argv[2] = NULL ;
|
||||
|
||||
jsInit () ;
|
||||
|
||||
js = new jsJoystick ( 0 ) ;
|
||||
|
||||
if ( js -> notWorking () || js -> getNumAxes () < 2 )
|
||||
{
|
||||
fprintf ( stderr,
|
||||
"Majik_Demo: Joystick with at least two axes required.\n" ) ;
|
||||
exit ( 0 ) ;
|
||||
}
|
||||
|
||||
ax = new float [ js->getNumAxes () ] ;
|
||||
|
||||
/*
|
||||
Initialise GLUT
|
||||
*/
|
||||
|
||||
glutInitWindowPosition ( 0, 0 ) ;
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInit ( &fake_argc, fake_argv ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
glutCreateWindow ( fake_argv[1] ) ;
|
||||
glutDisplayFunc ( redraw ) ;
|
||||
glutReshapeFunc ( reshape ) ;
|
||||
glutKeyboardFunc ( keyboard ) ;
|
||||
|
||||
/*
|
||||
Initialise SSG
|
||||
*/
|
||||
|
||||
ssgInit () ;
|
||||
|
||||
/*
|
||||
Some basic OpenGL setup
|
||||
*/
|
||||
|
||||
sgVec4 skycol ; sgSetVec4 ( skycol, 0.4f, 0.7f, 1.0f, 1.0f ) ;
|
||||
sgVec4 fogcol ; sgSetVec4 ( fogcol, 0.4f, 0.7f, 1.0f, 1.0f ) ;
|
||||
|
||||
glClearColor ( skycol[0], skycol[1], skycol[2], skycol[3] ) ;
|
||||
|
||||
glEnable ( GL_DEPTH_TEST ) ;
|
||||
|
||||
/*
|
||||
Set up the viewing parameters
|
||||
*/
|
||||
|
||||
ssgSetFOV ( 60.0f, 0.0f ) ;
|
||||
ssgSetNearFar ( 1.0f, 30000.0f ) ;
|
||||
|
||||
/*
|
||||
Initial Position
|
||||
*/
|
||||
|
||||
sgCoord startpos ;
|
||||
sgSetCoord ( &startpos, 2350.0f, -920.0f, 0.0f, 0.0f, 0.0f, 0.0f ) ;
|
||||
|
||||
/*
|
||||
Set up some fog
|
||||
*/
|
||||
|
||||
glFogf ( GL_FOG_DENSITY, 0.015f / 100.0f ) ;
|
||||
glFogfv( GL_FOG_COLOR , fogcol ) ;
|
||||
glFogf ( GL_FOG_START , 0.0 ) ;
|
||||
glFogi ( GL_FOG_MODE , GL_EXP2 ) ;
|
||||
glHint ( GL_FOG_HINT , GL_NICEST ) ;
|
||||
glEnable ( GL_FOG ) ;
|
||||
|
||||
/*
|
||||
Set up the Sun.
|
||||
*/
|
||||
|
||||
sgVec3 sunposn ;
|
||||
sgVec4 sunamb ;
|
||||
sgSetVec3 ( sunposn, 0.2f, -0.5f, 0.5f ) ;
|
||||
sgSetVec4 ( sunamb , 0.4f, 0.4f, 0.4f, 1.0f ) ;
|
||||
ssgGetLight ( 0 ) -> setPosition ( sunposn ) ;
|
||||
ssgGetLight ( 0 ) -> setColour ( GL_AMBIENT, sunamb ) ;
|
||||
}
|
||||
|
||||
|
||||
static ssgBranch *createTileLOD ( int x, int y, ssgSimpleState *state, int ntris, float z_off )
|
||||
{
|
||||
sgVec4 *scolors = new sgVec4 [ (ntris+1) * (ntris+1) ] ;
|
||||
sgVec2 *tcoords = new sgVec2 [ (ntris+1) * (ntris+1) ] ;
|
||||
sgVec3 *snorms = new sgVec3 [ (ntris+1) * (ntris+1) ] ;
|
||||
sgVec3 *scoords = new sgVec3 [ (ntris+1) * (ntris+1) ] ;
|
||||
|
||||
for ( int j = 0 ; j < (ntris+1) ; j++ )
|
||||
for ( int i = 0 ; i < (ntris+1) ; i++ )
|
||||
{
|
||||
int address = (int)floor( 12.0f * ((float)x + (float)i / (float)ntris) ) % 256 +
|
||||
((int)floor( 12.0f * ((float)y + (float)j / (float)ntris) ) % 256 ) * 256 ;
|
||||
int addressN = (int)floor( 12.0f * ((float)x + (float)i / (float)ntris) ) % 256 +
|
||||
((int)floor( 12.0f * ((float)y + (float)j / (float)ntris)+1.0f ) % 256 ) * 256 ;
|
||||
int addressE = (int)floor( 12.0f * ((float)x + (float)i / (float)ntris)+1.0f ) % 256 +
|
||||
((int)floor( 12.0f * ((float)y + (float)j / (float)ntris) ) % 256 ) * 256 ;
|
||||
|
||||
float zz = (float) elevation_map [ address ] * ELEVATION_SCALE + z_off ;
|
||||
float zzN = (float) elevation_map [ addressN ] * ELEVATION_SCALE + z_off ;
|
||||
float zzE = (float) elevation_map [ addressE ] * ELEVATION_SCALE + z_off ;
|
||||
|
||||
float rr = (float) image_map [ address * 3 + 0 ] / 255.0f ;
|
||||
float gg = (float) image_map [ address * 3 + 1 ] / 255.0f ;
|
||||
float bb = (float) image_map [ address * 3 + 2 ] / 255.0f ;
|
||||
|
||||
float xx = (float) i * (TILE_SIZE/(float)ntris) ;
|
||||
float yy = (float) j * (TILE_SIZE/(float)ntris) ;
|
||||
|
||||
sgVec3 nrm ;
|
||||
|
||||
nrm [ 0 ] = (zz - zzE) / (TILE_SIZE/12.0f) ;
|
||||
nrm [ 1 ] = (zz - zzN) / (TILE_SIZE/12.0f) ;
|
||||
nrm [ 2 ] = (float)sqrt ( nrm[0] * nrm[0] + nrm[1] * nrm[1] ) ;
|
||||
|
||||
sgCopyVec3( snorms [i+j*(ntris+1)], nrm ) ;
|
||||
sgSetVec2 ( tcoords [i+j*(ntris+1)], xx/LAMBDA, yy/LAMBDA ) ;
|
||||
sgSetVec4 ( scolors [i+j*(ntris+1)], rr, gg, bb, 1.0f ) ;
|
||||
sgSetVec3 ( scoords [i+j*(ntris+1)], xx, yy, zz ) ;
|
||||
}
|
||||
|
||||
ssgBranch *branch = new ssgBranch () ;
|
||||
|
||||
for ( int i = 0 ; i < ntris ; i++ )
|
||||
{
|
||||
unsigned short *vlist = new unsigned short [ 2 * (ntris+1) ] ;
|
||||
|
||||
for ( int j = 0 ; j < (ntris+1) ; j++ )
|
||||
{
|
||||
vlist [ j + j ] = j + (i+1) * (ntris+1) ;
|
||||
vlist [ j + j + 1 ] = j + i * (ntris+1) ;
|
||||
}
|
||||
|
||||
ssgLeaf *gset = new ssgVTable ( GL_TRIANGLE_STRIP,
|
||||
2 * (ntris+1), vlist, scoords,
|
||||
2 * (ntris+1), vlist, snorms ,
|
||||
2 * (ntris+1), vlist, tcoords,
|
||||
2 * (ntris+1), vlist, scolors ) ;
|
||||
gset -> setState ( state ) ;
|
||||
branch -> addKid ( gset ) ;
|
||||
}
|
||||
|
||||
return branch ;
|
||||
}
|
||||
|
||||
|
||||
static void createTile ( ssgTransform *tile, int x, int y, ssgSimpleState *state )
|
||||
{
|
||||
float rr[] = { 0.0f, 6000.0f, 7000.0f, 12000.0f } ;
|
||||
ssgRangeSelector *lod = new ssgRangeSelector () ;
|
||||
|
||||
lod -> addKid ( createTileLOD ( x, y, state, TRIANGLE_GRID_SIZE - 1, 0.0f ) ) ;
|
||||
lod -> addKid ( createTileLOD ( x, y, state, TRIANGLE_GRID_SIZE/2 - 1, -30.0f ) ) ;
|
||||
lod -> addKid ( createTileLOD ( x, y, state, TRIANGLE_GRID_SIZE/4 - 1, -250.0f ) ) ;
|
||||
lod -> setRanges ( rr, 4 ) ;
|
||||
|
||||
tile -> addKid ( lod ) ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Load a simple database
|
||||
*/
|
||||
|
||||
static void load_database ()
|
||||
{
|
||||
/*
|
||||
Set up the path to the data files
|
||||
*/
|
||||
|
||||
ssgModelPath ( "data" ) ;
|
||||
ssgTexturePath ( "data" ) ;
|
||||
|
||||
/*
|
||||
Create a root node - and a transform to position
|
||||
the terrain - and another to position the player.
|
||||
*/
|
||||
|
||||
scene = new ssgRoot ;
|
||||
penguin = new ssgTransform ;
|
||||
terrain = new ssgTransform ;
|
||||
state = new ssgSimpleState ;
|
||||
state -> setTexture ( "data/bumpnoise.rgb" ) ;
|
||||
state -> enable ( GL_TEXTURE_2D ) ;
|
||||
state -> enable ( GL_LIGHTING ) ;
|
||||
state -> setShadeModel ( GL_SMOOTH ) ;
|
||||
state -> enable ( GL_COLOR_MATERIAL ) ;
|
||||
state -> enable ( GL_CULL_FACE ) ;
|
||||
state -> setColourMaterial ( GL_AMBIENT_AND_DIFFUSE ) ;
|
||||
state -> setMaterial ( GL_EMISSION, 0, 0, 0, 1 ) ;
|
||||
state -> setMaterial ( GL_SPECULAR, 0, 0, 0, 1 ) ;
|
||||
state -> setShininess ( 0 ) ;
|
||||
state -> setOpaque () ;
|
||||
state -> disable ( GL_BLEND ) ;
|
||||
|
||||
/*
|
||||
Load the models - optimise them a bit
|
||||
and then add them into the scene.
|
||||
*/
|
||||
|
||||
ssgEntity *tux_obj = ssgLoadAC ( "tuxedo.ac" ) ;
|
||||
|
||||
penguin -> addKid ( tux_obj ) ;
|
||||
ssgFlatten ( tux_obj ) ;
|
||||
ssgStripify ( penguin ) ;
|
||||
penguin -> clrTraversalMaskBits ( SSGTRAV_HOT ) ;
|
||||
|
||||
for ( int i = 0 ; i < TILE_GRID_SIZE ; i++ )
|
||||
for ( int j = 0 ; j < TILE_GRID_SIZE ; j++ )
|
||||
{
|
||||
tilegrid [ i ][ j ] = new ssgTransform ;
|
||||
|
||||
terrain -> addKid ( tilegrid [ i ][ j ] ) ;
|
||||
|
||||
sgVec3 tilepos ;
|
||||
sgSetVec3 ( tilepos, (float)i * TILE_SIZE - ONLINE_TERRAIN_RANGE,
|
||||
(float)j * TILE_SIZE - ONLINE_TERRAIN_RANGE, 0.0f ) ;
|
||||
|
||||
tilegrid [ i ][ j ] -> setTransform ( tilepos ) ;
|
||||
createTile ( tilegrid [ i ][ j ], i, j, state ) ;
|
||||
}
|
||||
|
||||
scene -> addKid ( terrain ) ;
|
||||
scene -> addKid ( penguin ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The works.
|
||||
*/
|
||||
|
||||
int main ( int, char ** )
|
||||
{
|
||||
init_graphics () ;
|
||||
load_database () ;
|
||||
glutMainLoop () ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
96
examples/src/ssg/majik/majik_demo.dsp
Normal file
96
examples/src/ssg/majik/majik_demo.dsp
Normal file
@@ -0,0 +1,96 @@
|
||||
# Microsoft Developer Studio Project File - Name="majik_demo" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=majik_demo - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "majik_demo.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "majik_demo.mak" CFG="majik_demo - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "majik_demo - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "majik_demo - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "majik_demo - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg.lib sg.lib ul.lib js.lib winmm.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /out:"majik_demo.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "majik_demo - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg_d.lib sg_d.lib ul_d.lib js_d.lib winmm.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /out:"majik_demo.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "majik_demo - Win32 Release"
|
||||
# Name "majik_demo - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\elevation_map.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\image_map.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\majik_demo.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
10
examples/src/ssg/shapes/Makefile.am
Normal file
10
examples/src/ssg/shapes/Makefile.am
Normal file
@@ -0,0 +1,10 @@
|
||||
if BUILD_SSG
|
||||
|
||||
noinst_PROGRAMS = shapes
|
||||
|
||||
shapes_SOURCES = shapes.cxx
|
||||
|
||||
shapes_LDADD = -lplibssgaux -lplibssg -lplibsg -lplibul -lplibpw $(OGL_LIBS)
|
||||
|
||||
endif
|
||||
|
||||
180
examples/src/ssg/shapes/shapes.cxx
Normal file
180
examples/src/ssg/shapes/shapes.cxx
Normal file
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: shapes.cxx 2015 2005-02-02 15:48:09Z sjbaker $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <plib/ssg.h>
|
||||
#include <plib/ssgAux.h>
|
||||
#include <plib/pw.h>
|
||||
|
||||
#define MAX_SHAPE 5
|
||||
static ssgRoot *scene = NULL ;
|
||||
static ssgTransform *shape [ MAX_SHAPE ] = { NULL } ;
|
||||
|
||||
static sgVec4 colour [ MAX_SHAPE ] =
|
||||
{
|
||||
{ 1, 0, 0, 1 },
|
||||
{ 0, 1, 0, 1 },
|
||||
{ 0, 0, 1, 1 },
|
||||
{ 1, 1, 0, 1 },
|
||||
{ 0, 1, 1, 1 }
|
||||
} ;
|
||||
|
||||
/*
|
||||
Something to make some interesting motion
|
||||
*/
|
||||
|
||||
static void update_motion ()
|
||||
{
|
||||
static int frameno = 0 ;
|
||||
|
||||
frameno++ ;
|
||||
|
||||
sgCoord campos ;
|
||||
|
||||
sgSetCoord ( & campos, 0.0f, -6.0f, 0.0f, 0.0f, 0.0f, 0.0f ) ;
|
||||
ssgSetCamera ( & campos ) ;
|
||||
|
||||
for ( int i = 0 ; i < MAX_SHAPE ; i++ )
|
||||
{
|
||||
sgCoord pos ;
|
||||
sgSetCoord ( & pos, 2.0f*(float)(i % 3)-2.0f, 0.0f,
|
||||
2.0f*(float)(i / 3)-1.5f,
|
||||
frameno/100.0f, frameno/20.0f, 0.0f ) ;
|
||||
shape [ i ] -> setTransform ( & pos ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void redraw ()
|
||||
{
|
||||
update_motion () ;
|
||||
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
ssgCullAndDraw ( scene ) ;
|
||||
|
||||
pwSwapBuffers () ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void init_graphics ()
|
||||
{
|
||||
pwInit ( 100, 100, 640, 480, false, "PLIB Shapes Demo", true, 0 ) ;
|
||||
pwSetCallbacks ( NULL, NULL, NULL, NULL, NULL ) ;
|
||||
|
||||
/*
|
||||
Initialise SSG
|
||||
*/
|
||||
|
||||
ssgInit () ;
|
||||
|
||||
/*
|
||||
Some basic OpenGL setup
|
||||
*/
|
||||
|
||||
glClearColor ( 0.2f, 0.7f, 1.0f, 1.0f ) ;
|
||||
glEnable ( GL_DEPTH_TEST ) ;
|
||||
|
||||
/*
|
||||
Set up the viewing parameters
|
||||
*/
|
||||
|
||||
ssgSetFOV ( 60.0f, 0.0f ) ;
|
||||
ssgSetNearFar ( 1.0f, 700.0f ) ;
|
||||
|
||||
/*
|
||||
Set up the Sun.
|
||||
*/
|
||||
|
||||
sgVec3 sunposn ;
|
||||
sgSetVec3 ( sunposn, 0.2f, -0.5f, 0.5f ) ;
|
||||
ssgGetLight ( 0 ) -> setPosition ( sunposn ) ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Create a simple database
|
||||
*/
|
||||
|
||||
static void load_database ()
|
||||
{
|
||||
scene = new ssgRoot ;
|
||||
|
||||
ssgSimpleState *state = new ssgSimpleState () ;
|
||||
state -> setShininess ( 8.0f ) ;
|
||||
|
||||
for ( int i = 0 ; i < MAX_SHAPE ; i++ )
|
||||
{
|
||||
ssgaShape *s ;
|
||||
|
||||
shape [ i ] = new ssgTransform ;
|
||||
scene -> addKid ( shape [ i ] ) ;
|
||||
|
||||
switch ( i )
|
||||
{
|
||||
case 0 : s = new ssgaCube ( 1000 ) ; break ;
|
||||
case 1 : s = new ssgaCylinder ( 1000 ) ; break ;
|
||||
case 2 : s = new ssgaSphere ( 1000 ) ;
|
||||
((ssgaSphere*)s) -> setLatLongStyle ( FALSE) ; break ;
|
||||
case 3 : s = new ssgaSphere ( 1000 ) ;
|
||||
((ssgaSphere*)s) -> setLatLongStyle ( TRUE ) ; break ;
|
||||
case 4 :
|
||||
default: s = new ssgaTeapot ( 1000 ) ; break ;
|
||||
}
|
||||
|
||||
s -> setColour ( colour[i] ) ;
|
||||
s -> setKidState ( state ) ;
|
||||
shape [ i ] -> addKid ( s ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The works.
|
||||
*/
|
||||
|
||||
int main ( int, char ** )
|
||||
{
|
||||
init_graphics () ;
|
||||
load_database () ;
|
||||
|
||||
while ( 1 )
|
||||
redraw () ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
12
examples/src/ssg/shrubs/Makefile.am
Normal file
12
examples/src/ssg/shrubs/Makefile.am
Normal file
@@ -0,0 +1,12 @@
|
||||
if BUILD_SSG
|
||||
|
||||
noinst_PROGRAMS = shrubs
|
||||
|
||||
shrubs_SOURCES = shrubs.cxx
|
||||
|
||||
shrubs_LDADD = -lplibssgaux -lplibssg -lplibpu -lplibfnt -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS)
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST =
|
||||
|
||||
BIN
examples/src/ssg/shrubs/data/Courier-Bold.txf
Normal file
BIN
examples/src/ssg/shrubs/data/Courier-Bold.txf
Normal file
Binary file not shown.
BIN
examples/src/ssg/shrubs/data/deciduous-tree.rgb
Normal file
BIN
examples/src/ssg/shrubs/data/deciduous-tree.rgb
Normal file
Binary file not shown.
718
examples/src/ssg/shrubs/shrubs.cxx
Normal file
718
examples/src/ssg/shrubs/shrubs.cxx
Normal file
@@ -0,0 +1,718 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: shrubs.cxx 2053 2005-11-14 12:12:25Z bram $
|
||||
*/
|
||||
|
||||
// $Id: shrubs.cxx 2053 2005-11-14 12:12:25Z bram $
|
||||
|
||||
#include <plib/fnt.h>
|
||||
#include <plib/pu.h>
|
||||
#include <plib/ssg.h>
|
||||
#include <plib/ssgaBillboards.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef UL_WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef UL_MAC_OSX
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#define TILE_RES 12
|
||||
#define NUM_TILES (TILE_RES * TILE_RES)
|
||||
|
||||
#define TILE_SIZE 300.0f
|
||||
#define WORLD_SIZE (TILE_RES * TILE_SIZE)
|
||||
|
||||
#define FRAC_LEVEL 7 // --> 128*128
|
||||
|
||||
|
||||
// framerate control
|
||||
static double min_delta = 1.0 / 200.0;
|
||||
static double cur_delta = 1.0 / 50.0;
|
||||
|
||||
// terrain grid (display list)
|
||||
static GLuint grid;
|
||||
static bool draw_grid = true;
|
||||
|
||||
// billboard config
|
||||
static float near_dist = 500.0f;
|
||||
static float fade_dist = 2000.0f;
|
||||
static float clip_dist = 2500.0f;
|
||||
static int draw_num = 1000;
|
||||
static int fade_num = 100;
|
||||
|
||||
// state variables (GLUT enforced)
|
||||
static int winsx = 800, winsy = 600;
|
||||
static int mousex, mousey, bstate;
|
||||
|
||||
// motion model
|
||||
static int model = 1; // 0 - trackball, 1 - fly
|
||||
|
||||
// trackball
|
||||
static sgQuat rot = { 0, 0, 0, 1 };
|
||||
static sgVec3 tra = { 0, 1500, 0 };
|
||||
|
||||
// fly
|
||||
static sgVec2 spin;
|
||||
static float thrust;
|
||||
static float speed;
|
||||
static sgVec3 hpr;
|
||||
static sgVec3 pos = { 0, -0.25f * WORLD_SIZE, 20.0f };
|
||||
static sgVec3 dir = { 0, 1, 0 };
|
||||
|
||||
// scene
|
||||
static ssgRoot *scene;
|
||||
static ssgaBillboards *bb[NUM_TILES];
|
||||
|
||||
// gui
|
||||
static fntRenderer *text;
|
||||
static puSlider *near_dist_sl, *fade_dist_sl, *clip_dist_sl;
|
||||
static puSlider *draw_num_sl, *fade_num_sl;
|
||||
|
||||
|
||||
inline float clampf(float x, float lo, float hi)
|
||||
{
|
||||
return x <= lo ? lo : x >= hi ? hi : x;
|
||||
}
|
||||
|
||||
|
||||
static double get_time()
|
||||
{
|
||||
#ifdef UL_WIN32
|
||||
static LONGLONG t0, f;
|
||||
LONGLONG t;
|
||||
QueryPerformanceCounter((LARGE_INTEGER *) &t);
|
||||
if (f == 0) {
|
||||
QueryPerformanceFrequency((LARGE_INTEGER *) &f);
|
||||
t0 = t;
|
||||
}
|
||||
return (double) (t - t0) / f;
|
||||
#else
|
||||
static struct timeval t0;
|
||||
struct timeval t;
|
||||
gettimeofday(&t, 0);
|
||||
if (t0.tv_sec == 0)
|
||||
t0 = t;
|
||||
return (t.tv_sec - t0.tv_sec) + 1e-6 * (t.tv_usec - t0.tv_usec);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef UL_WIN32
|
||||
inline void srand48(int seed) { srand(seed); }
|
||||
inline double drand48() { return (double) rand() / RAND_MAX; }
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER /* UL_MSVC sometimes defined for mingw (gcc) */
|
||||
inline float hypotf(float x, float y) { return sqrtf(x*x + y*y); }
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
|
||||
static void motion_fn(int x, int y)
|
||||
{
|
||||
if (bstate || !puMouse(x, y)) {
|
||||
|
||||
if (model == 1) {
|
||||
if (bstate & 4) {
|
||||
spin[0] = 0;
|
||||
spin[1] = 0;
|
||||
} else {
|
||||
spin[0] = 2.0f * x / winsx - 1.0f;
|
||||
spin[1] = 2.0f * y / winsy - 1.0f;
|
||||
}
|
||||
} else {
|
||||
float fx = 2.0f * x / winsx - 1.0f;
|
||||
float fy = 1.0f - 2.0f * y / winsy;
|
||||
float dx = 2.0f * (x - mousex) / winsx;
|
||||
float dy = 2.0f * (mousey - y) / winsy;
|
||||
|
||||
if (bstate & 1) {
|
||||
float a = 0.5f * hypotf(dx, dy);
|
||||
if (a > 1e-6f) {
|
||||
sgQuat q;
|
||||
q[0] = dy * (1.0f - fx * fx);
|
||||
q[1] = dy * fx - dx * fy;
|
||||
q[2] = dx * (fy * fy - 1.0f);
|
||||
sgScaleVec3(q, sinf(a) / sgLengthVec3(q));
|
||||
q[3] = cosf(a);
|
||||
sgMultQuat(rot, rot, q);
|
||||
}
|
||||
}
|
||||
|
||||
if (bstate & 4) {
|
||||
tra[1] = tra[1] / (1.0f - dy);
|
||||
}
|
||||
}
|
||||
}
|
||||
mousex = x;
|
||||
mousey = y;
|
||||
}
|
||||
|
||||
|
||||
static void mouse_fn(int button, int updown, int x, int y)
|
||||
{
|
||||
if (bstate || !puMouse(button, updown, x, y)) {
|
||||
int bit = 0;
|
||||
switch (button) {
|
||||
case GLUT_LEFT_BUTTON: bit = 1; break;
|
||||
case GLUT_MIDDLE_BUTTON: bit = 2; break;
|
||||
case GLUT_RIGHT_BUTTON: bit = 4; break;
|
||||
}
|
||||
switch (updown) {
|
||||
case GLUT_DOWN: bstate |= bit; break;
|
||||
case GLUT_UP: bstate &= ~bit; break;
|
||||
}
|
||||
thrust = (bstate & 1) - (bstate & 4) / 2;
|
||||
if (bstate & 4) {
|
||||
spin[0] = 0;
|
||||
spin[1] = 0;
|
||||
}
|
||||
}
|
||||
mousex = x;
|
||||
mousey = y;
|
||||
}
|
||||
|
||||
|
||||
static void special_fn(int key, int x, int y)
|
||||
{
|
||||
if (!puKeyboard(key + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN)) {
|
||||
switch (key) {
|
||||
case GLUT_KEY_UP: min_delta *= 1.1; break;
|
||||
case GLUT_KEY_DOWN: min_delta /= 1.1; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void keyboard_fn(unsigned char key, int, int)
|
||||
{
|
||||
if (!puKeyboard(key, PU_DOWN)) {
|
||||
switch (key) {
|
||||
case 0x1b:
|
||||
exit(0);
|
||||
case '1':
|
||||
model = 0;
|
||||
break;
|
||||
case '2':
|
||||
model = 1;
|
||||
break;
|
||||
case 'g':
|
||||
draw_grid = !draw_grid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void update_bboards()
|
||||
{
|
||||
for (int i = 0; i < NUM_TILES; i++) {
|
||||
bb[i]->setNearRange(near_dist);
|
||||
bb[i]->setFadeRange(fade_dist);
|
||||
bb[i]->setClipRange(clip_dist);
|
||||
bb[i]->setDrawNum(draw_num);
|
||||
bb[i]->setFadeNum(fade_num);
|
||||
}
|
||||
}
|
||||
|
||||
static void near_dist_cb(puObject *ob)
|
||||
{
|
||||
near_dist = ob->getFloatValue();
|
||||
update_bboards();
|
||||
}
|
||||
|
||||
static void fade_dist_cb(puObject *ob)
|
||||
{
|
||||
fade_dist = ob->getFloatValue();
|
||||
update_bboards();
|
||||
}
|
||||
|
||||
static void clip_dist_cb(puObject *ob)
|
||||
{
|
||||
clip_dist = ob->getFloatValue();
|
||||
update_bboards();
|
||||
}
|
||||
|
||||
static void draw_num_cb(puObject *ob)
|
||||
{
|
||||
draw_num = ob->getIntegerValue();
|
||||
update_bboards();
|
||||
}
|
||||
|
||||
static void fade_num_cb(puObject *ob)
|
||||
{
|
||||
fade_num = ob->getIntegerValue();
|
||||
update_bboards();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void init_scene()
|
||||
{
|
||||
int i, x, y;
|
||||
|
||||
scene = new ssgRoot;
|
||||
|
||||
// produce a simple diamond-square fractal
|
||||
const int size = 1 << FRAC_LEVEL;
|
||||
const int mask = size - 1;
|
||||
float *elev = new float[size * size]; // height map
|
||||
memset(elev, 0, sizeof(elev));
|
||||
for (i = FRAC_LEVEL; i > 0; i--) {
|
||||
int s = 1 << i, t = s >> 1;
|
||||
float r = 750.0f * powf(s / size, 0.9f);
|
||||
for (y = 0; y < size; y += s) {
|
||||
int y1 = (y + s) & mask;
|
||||
for (x = 0; x < size; x += s) {
|
||||
int x1 = (x + s) & mask;
|
||||
elev[(y + t) * size + (x + t)] = (0.25f * (elev[y * size + x ] +
|
||||
elev[y * size + x1] +
|
||||
elev[y1 * size + x ] +
|
||||
elev[y1 * size + x1])
|
||||
+ r * (0.5f - (float) drand48()));
|
||||
}
|
||||
}
|
||||
r = 750.0f * powf(0.7071f * s / size, 0.9f);
|
||||
for (y = 0; y < size; y += s) {
|
||||
int y0 = (y - t) & mask;
|
||||
int y1 = (y + s) & mask;
|
||||
for (x = 0; x < size; x += s) {
|
||||
int x0 = (x - t) & mask;
|
||||
int x1 = (x + s) & mask;
|
||||
elev[y * size + (x + t)] = (0.25f * (elev[y0 * size + (x + t)] +
|
||||
elev[y * size + x ] +
|
||||
elev[y * size + x1] +
|
||||
elev[(y + t) * size + (x + t)])
|
||||
+ r * (0.5f - (float) drand48()));
|
||||
elev[(y + t) * size + x] = (0.25f * (elev[(y + t) * size + x0] +
|
||||
elev[y * size + x] +
|
||||
elev[y1 * size + x] +
|
||||
elev[(y + t) * size + (x + t)])
|
||||
+ r * (0.5f - (float) drand48()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// generate display list
|
||||
grid = glGenLists(1);
|
||||
glNewList(grid, GL_COMPILE);
|
||||
for (y = 0; y <= size; y += 4) {
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (x = 0; x <= size; x++)
|
||||
glVertex3f(((float) x / size - 0.5f) * WORLD_SIZE,
|
||||
((float) y / size - 0.5f) * WORLD_SIZE,
|
||||
elev[(y & mask) * size + (x & mask)]);
|
||||
glEnd();
|
||||
}
|
||||
for (x = 0; x <= size; x += 4) {
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (y = 0; y <= size; y++)
|
||||
glVertex3f(((float) x / size - 0.5f) * WORLD_SIZE,
|
||||
((float) y / size - 0.5f) * WORLD_SIZE,
|
||||
elev[(y & mask) * size + (x & mask)]);
|
||||
glEnd();
|
||||
}
|
||||
glEndList();
|
||||
|
||||
|
||||
// now load the shrubs
|
||||
|
||||
ssgTexture *tex = new ssgTexture("data/deciduous-tree.rgb", FALSE, FALSE);
|
||||
|
||||
ssgaBillboards::initTexAlpha(tex);
|
||||
|
||||
for (y = 0; y < TILE_RES; y++) {
|
||||
for (x = 0; x < TILE_RES; x++) {
|
||||
ssgaBillboards *b = new ssgaBillboards;
|
||||
|
||||
b->setTexture(tex);
|
||||
b->setWidth(3.0f);
|
||||
b->setHeight(8.0f);
|
||||
|
||||
float tx = (x - 0.5f * TILE_RES) * TILE_SIZE;
|
||||
float ty = (y - 0.5f * TILE_RES) * TILE_SIZE;
|
||||
|
||||
for (int i = 0; i < 3000; i++) {
|
||||
|
||||
float x = tx + drand48() * TILE_SIZE;
|
||||
float y = ty + drand48() * TILE_SIZE;
|
||||
float z;
|
||||
|
||||
// bilinear lookup
|
||||
float xf = (0.5f + x / WORLD_SIZE) * size;
|
||||
float yf = (0.5f + y / WORLD_SIZE) * size;
|
||||
int x0 = (int) xf;
|
||||
int y0 = (int) yf;
|
||||
int x1 = x0 + 1;
|
||||
int y1 = y0 + 1;
|
||||
float xw1 = xf - (float) x0;
|
||||
float yw1 = yf - (float) y0;
|
||||
float xw0 = 1.0f - xw1;
|
||||
float yw0 = 1.0f - yw1;
|
||||
x0 &= mask;
|
||||
y0 &= mask;
|
||||
x1 &= mask;
|
||||
y1 &= mask;
|
||||
z = (elev[y0 * size + x0] * xw0 * yw0 +
|
||||
elev[y0 * size + x1] * xw1 * yw0 +
|
||||
elev[y1 * size + x0] * xw0 * yw1 +
|
||||
elev[y1 * size + x1] * xw1 * yw1);
|
||||
|
||||
b->add(x, y, z, 0.75f + 0.5f * drand48());
|
||||
}
|
||||
|
||||
bb[y * TILE_RES + x] = b;
|
||||
|
||||
scene->addKid(b);
|
||||
}
|
||||
}
|
||||
|
||||
x = (int)((0.5f + pos[0] / WORLD_SIZE) * size);
|
||||
y = (int)((0.5f + pos[1] / WORLD_SIZE) * size);
|
||||
pos[2] += elev[(y & mask) * size + (x & mask)];
|
||||
|
||||
delete [] elev;
|
||||
|
||||
update_bboards();
|
||||
}
|
||||
|
||||
|
||||
static void init_gui()
|
||||
{
|
||||
fntInit();
|
||||
|
||||
fntTexFont *font = new fntTexFont("data/Courier-Bold.txf");
|
||||
|
||||
text = new fntRenderer();
|
||||
text->setFont(font);
|
||||
text->setPointSize(18);
|
||||
|
||||
puInit();
|
||||
|
||||
puSetDefaultFonts(puFont(font, 14), puFont(font, 18));
|
||||
puSetDefaultStyle(PUSTYLE_SMALL_SHADED);
|
||||
puSetDefaultColourScheme(0.7f, 0.7f, 0.7f, 1.0f);
|
||||
|
||||
puGroup *group = new puGroup(0, 0);
|
||||
puSlider *sl;
|
||||
int h = winsy;
|
||||
|
||||
near_dist_sl = sl = new puSlider(250, h - 30, 150);
|
||||
sl->setValue(near_dist);
|
||||
sl->setMinValue(100.0f);
|
||||
sl->setMaxValue(5000.0f);
|
||||
sl->setCallback(near_dist_cb);
|
||||
|
||||
fade_dist_sl = sl = new puSlider(250, h - 55, 150);
|
||||
sl->setValue(fade_dist);
|
||||
sl->setMinValue(100.0f);
|
||||
sl->setMaxValue(5000.0f);
|
||||
sl->setCallback(fade_dist_cb);
|
||||
|
||||
clip_dist_sl = sl = new puSlider(250, h - 80, 150);
|
||||
sl->setValue(clip_dist);
|
||||
sl->setMinValue(100.0f);
|
||||
sl->setMaxValue(5000.0f);
|
||||
sl->setCallback(clip_dist_cb);
|
||||
|
||||
draw_num_sl = sl = new puSlider(250, h - 110, 150);
|
||||
sl->setValue(draw_num);
|
||||
sl->setMinValue(0);
|
||||
sl->setMaxValue(3000);
|
||||
sl->setCallback(draw_num_cb);
|
||||
|
||||
fade_num_sl = sl = new puSlider(250, h - 135, 150);
|
||||
sl->setValue(fade_num);
|
||||
sl->setMinValue(0);
|
||||
sl->setMaxValue(3000);
|
||||
sl->setCallback(fade_num_cb);
|
||||
|
||||
group->close();
|
||||
}
|
||||
|
||||
|
||||
static void reshape_fn(int w, int h)
|
||||
{
|
||||
winsx = w;
|
||||
winsy = h;
|
||||
|
||||
glViewport(0, 0, w, h);
|
||||
|
||||
if (near_dist_sl) {
|
||||
near_dist_sl->setPosition(250, h - 30);
|
||||
fade_dist_sl->setPosition(250, h - 55);
|
||||
clip_dist_sl->setPosition(250, h - 80);
|
||||
draw_num_sl->setPosition(250, h - 110);
|
||||
fade_num_sl->setPosition(250, h - 135);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void display_fn()
|
||||
{
|
||||
static float backlog1[256];
|
||||
static float backlog2[256];
|
||||
|
||||
static double last_time;
|
||||
static double sync_time;
|
||||
static int frame_count;
|
||||
|
||||
double t0 = get_time();
|
||||
int i;
|
||||
|
||||
frame_count++;
|
||||
|
||||
glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
sgMat4 mat;
|
||||
|
||||
if (model == 0) {
|
||||
// trackball
|
||||
sgQuatToMatrix(mat, rot);
|
||||
sgCopyVec3(mat[3], tra);
|
||||
sgTransposeNegateMat4(mat);
|
||||
} else {
|
||||
// fly
|
||||
float dt = cur_delta;
|
||||
float s = powf(0.2f, dt);
|
||||
hpr[2] = s * hpr[2] + (1.0f - s) * 40.0f * spin[0];
|
||||
hpr[1] = s * hpr[1] + (1.0f - s) * 40.0f * spin[1];
|
||||
hpr[0] -= dt * hpr[2];
|
||||
float a = 10.0f * (thrust - dir[2]);
|
||||
speed = clampf(speed + a * dt, 1.0f, 25.0f);
|
||||
sgAddScaledVec3(pos, dir, dt * speed);
|
||||
sgMakeCoordMat4(mat, pos, hpr);
|
||||
sgCopyVec3(dir, mat[1]);
|
||||
}
|
||||
|
||||
ssgaBillboards::total_drawn = 0;
|
||||
|
||||
ssgSetCamera(mat);
|
||||
ssgCullAndDraw(scene);
|
||||
ssgLoadModelviewMatrix();
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
|
||||
if (draw_grid) {
|
||||
glColor3f(0, 0, 0);
|
||||
glCallList(grid);
|
||||
}
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glAlphaFunc(GL_GREATER, 0.3f);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
|
||||
// timings
|
||||
|
||||
const float y0 = 0.45f, y1 = 1.0f;
|
||||
const float d0 = 0, d1 = 0.05f;
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glColor3f(0.4f, 0.7f, 0.4f);
|
||||
for (i = 1; i <= 256; i++) {
|
||||
float d = backlog2[(frame_count - i) & 0xff];
|
||||
glVertex2f(2.0f * i / 257 - 1.0f, y0 + (y1 - y0) * (d - d0) / (d1 - d0));
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glColor3f(0.7f, 0.7f, 0.7f);
|
||||
for (i = 1; i <= 256; i++) {
|
||||
float d = backlog1[(frame_count - i) & 0xff];
|
||||
glVertex2f(2.0f * i / 257 - 1.0f, y0 + (y1 - y0) * (d - d0) / (d1 - d0));
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(0.3f, 0.4f, 0.4f);
|
||||
float y = y0 + (y1 - y0) * ((float) min_delta - d0) / (d1 - d0);
|
||||
glVertex2f(-1.0f, y);
|
||||
glVertex2f( 1.0f, y);
|
||||
glEnd();
|
||||
|
||||
|
||||
// gui
|
||||
|
||||
int w = winsx;
|
||||
int h = winsy;
|
||||
char buf[64];
|
||||
|
||||
glOrtho(0, w, 0, h, 0, 1);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
glColor3f(0, 0, 0);
|
||||
|
||||
text->begin();
|
||||
|
||||
text->start2f(w - 200, h - 30);
|
||||
text->puts("fps:");
|
||||
snprintf(buf, sizeof(buf), "%.0f Hz", 1.0 / cur_delta);
|
||||
text->start2f(w - 100, h - 30);
|
||||
text->puts(buf);
|
||||
|
||||
text->start2f(w - 200, h - 55);
|
||||
text->puts("shrubs:");
|
||||
snprintf(buf, sizeof(buf), "%d\n", ssgaBillboards::total_drawn);
|
||||
text->start2f(w - 100, h - 55);
|
||||
text->puts(buf);
|
||||
|
||||
text->start2f(20, h - 30);
|
||||
text->puts("NearRange:");
|
||||
snprintf(buf, sizeof(buf), "%5.0f", near_dist);
|
||||
text->start2f(150, h - 30);
|
||||
text->puts(buf);
|
||||
|
||||
text->start2f(20, h - 55);
|
||||
text->puts("FadeRange:");
|
||||
snprintf(buf, sizeof(buf), "%5.0f", fade_dist);
|
||||
text->start2f(150, h - 55);
|
||||
text->puts(buf);
|
||||
|
||||
text->start2f(20, h - 80);
|
||||
text->puts("ClipRange:");
|
||||
snprintf(buf, sizeof(buf), "%5.0f", clip_dist);
|
||||
text->start2f(150, h - 80);
|
||||
text->puts(buf);
|
||||
|
||||
text->start2f(20, h - 110);
|
||||
text->puts("DrawNum:");
|
||||
snprintf(buf, sizeof(buf), "%5d", draw_num);
|
||||
text->start2f(150, h - 110);
|
||||
text->puts(buf);
|
||||
|
||||
text->start2f(20, h - 135);
|
||||
text->puts("FadeNum:");
|
||||
snprintf(buf, sizeof(buf), "%5d", fade_num);
|
||||
text->start2f(150, h - 135);
|
||||
text->puts(buf);
|
||||
|
||||
text->end();
|
||||
|
||||
puDisplay();
|
||||
|
||||
glFinish();
|
||||
|
||||
|
||||
// sync
|
||||
|
||||
double t1 = get_time();
|
||||
|
||||
backlog1[frame_count & 0xff] = t1 - t0;
|
||||
backlog2[frame_count & 0xff] = t1 - last_time;
|
||||
|
||||
last_time = t1;
|
||||
|
||||
sync_time += min_delta;
|
||||
|
||||
if (t1 < sync_time) {
|
||||
double dt = sync_time - t1 - 0.005;
|
||||
if (dt > 0) {
|
||||
#ifdef UL_WIN32
|
||||
Sleep((int)(1e+3 * dt));
|
||||
#else
|
||||
usleep((int)(1e+6 * dt));
|
||||
#endif
|
||||
}
|
||||
} else if (t1 > sync_time + 0.05)
|
||||
sync_time = t1;
|
||||
|
||||
cur_delta = 0;
|
||||
for (i = 0; i < 256; i++)
|
||||
cur_delta += backlog2[i];
|
||||
cur_delta *= 1.0 / 256;
|
||||
|
||||
glutSwapBuffers();
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
srand48(time(0));
|
||||
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowSize(winsx, winsy);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
glutCreateWindow("shrubs");
|
||||
|
||||
glutDisplayFunc(display_fn);
|
||||
glutReshapeFunc(reshape_fn);
|
||||
glutMouseFunc(mouse_fn);
|
||||
glutMotionFunc(motion_fn);
|
||||
glutKeyboardFunc(keyboard_fn);
|
||||
glutSpecialFunc(special_fn);
|
||||
|
||||
ssgInit();
|
||||
|
||||
ssgSetFOV(60.0f, 0.0f);
|
||||
ssgSetNearFar(10.0f, 10000.0f);
|
||||
|
||||
//ssgModelPath(".");
|
||||
//ssgTexturePath(".");
|
||||
|
||||
init_scene();
|
||||
|
||||
init_gui();
|
||||
|
||||
glutMainLoop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
mode: C++
|
||||
c-basic-offset: 4
|
||||
c-file-offsets: ((substatement-open 0) (case-label 0))
|
||||
End:
|
||||
*/
|
||||
12
examples/src/ssg/sky/Makefile.am
Normal file
12
examples/src/ssg/sky/Makefile.am
Normal file
@@ -0,0 +1,12 @@
|
||||
if BUILD_SSG
|
||||
|
||||
noinst_PROGRAMS = sky
|
||||
|
||||
sky_SOURCES = sky.cxx
|
||||
|
||||
sky_LDADD = -lplibpuaux -lplibpu -lplibfnt -lplibssgaux -lplibssg -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS)
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = sky.dsp README
|
||||
|
||||
39
examples/src/ssg/sky/README
Normal file
39
examples/src/ssg/sky/README
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
SkyDome.
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
The PLIB ssgAux library contains a class for creating a sky dome.
|
||||
|
||||
class ssgaSky ;
|
||||
|
||||
The program in this directory demonstrates creating a sky dome,
|
||||
including the sun, moon, stars and clouds.
|
||||
|
||||
This program does not attempt to place celestial bodies accurately
|
||||
if you wish to place sun, moon, planets & stars correctly then you
|
||||
could possibly plug-in the SimGear Ephemeris code.
|
||||
|
||||
|
||||
Keyboard controls:
|
||||
|
||||
left/right : turn left/right
|
||||
up/down arrow : look up/down
|
||||
up/down arrow + shift : increase/decrease altitude
|
||||
a/z : move forward/backward
|
||||
f : fullscreen
|
||||
w : wireframe
|
||||
s : solid
|
||||
space : toggle gui on and off
|
||||
q/esc : quit
|
||||
|
||||
|
||||
History:
|
||||
|
||||
Written by Durk Talsma. Originally started October 1997, for distribution
|
||||
with the FlightGear project. Version 2 was written in August and
|
||||
September 1998. This code is based upon algorithms and data kindly
|
||||
provided by Mr. Paul Schlyter. (pausch@saaf.se).
|
||||
|
||||
Separated out rendering pieces and converted to ssg by Curt Olson, March 2000.
|
||||
|
||||
Moved (from SimGear) into ssgAux by Nick McEvoy, July 2003.
|
||||
BIN
examples/src/ssg/sky/data/candy.rgb
Normal file
BIN
examples/src/ssg/sky/data/candy.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/sky/data/halo.rgba
Normal file
BIN
examples/src/ssg/sky/data/halo.rgba
Normal file
Binary file not shown.
BIN
examples/src/ssg/sky/data/moon.rgba
Normal file
BIN
examples/src/ssg/sky/data/moon.rgba
Normal file
Binary file not shown.
BIN
examples/src/ssg/sky/data/ocean.rgb
Normal file
BIN
examples/src/ssg/sky/data/ocean.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/sky/data/scattered.rgba
Normal file
BIN
examples/src/ssg/sky/data/scattered.rgba
Normal file
Binary file not shown.
BIN
examples/src/ssg/sky/data/sorority.txf
Normal file
BIN
examples/src/ssg/sky/data/sorority.txf
Normal file
Binary file not shown.
688
examples/src/ssg/sky/sky.cxx
Normal file
688
examples/src/ssg/sky/sky.cxx
Normal file
@@ -0,0 +1,688 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: sky.cxx 2077 2006-04-13 16:21:42Z bram $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <plib/ssg.h>
|
||||
#include <plib/pu.h>
|
||||
#include <plib/puAux.h>
|
||||
#include <plib/ssgAux.h>
|
||||
#include <plib/ssgaSky.h>
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define ROT_SPEED 2.0f
|
||||
#define TRANS_SPEED 5.0f
|
||||
|
||||
#define MAX_BODIES 2
|
||||
#define MAX_CLOUDS 3
|
||||
|
||||
#define GUI_BASE 20
|
||||
#define FONT_COLOUR 1,1,1,1
|
||||
|
||||
static int wireframe = FALSE ;
|
||||
static int displayGUI = TRUE ;
|
||||
|
||||
static puaSelectBox *bodySelectBox = (puaSelectBox *) NULL ;
|
||||
static puDial *bodyRADial = (puDial *) NULL ;
|
||||
static puDial *bodyDeclDial = (puDial *) NULL ;
|
||||
static puSlider *cloudElevationSlider = (puSlider *) NULL ;
|
||||
static puaSelectBox *cloudSelectBox = (puaSelectBox *) NULL ;
|
||||
static puButton *cloudEnableButton = (puButton *) NULL ;
|
||||
|
||||
static ssgRoot *scene = NULL ;
|
||||
static ssgaSky *sky = NULL ;
|
||||
static ssgTransform *teapot = NULL ;
|
||||
static ssgTransform *wave = NULL ;
|
||||
|
||||
static ssgaTeapot *tpt_obj = NULL ;
|
||||
static ssgaWaveSystem *wave_obj = NULL ;
|
||||
static ssgaWaveTrain wave_train;
|
||||
|
||||
static ssgaCelestialBody *bodies[MAX_BODIES] = {NULL} ;
|
||||
static ssgaCloudLayer *clouds[MAX_CLOUDS] = {NULL} ;
|
||||
|
||||
static ssgSimpleState *teapot_state = NULL ;
|
||||
static ssgSimpleState *wave_state = NULL ;
|
||||
|
||||
static int nstars = 1000 ;
|
||||
static sgdVec3 *star_data = NULL ;
|
||||
static int nplanets = 0 ;
|
||||
static sgdVec3 *planet_data = NULL ;
|
||||
|
||||
static char *bodyNameList[] = { "Sun", "Moon", NULL } ;
|
||||
static char *cloudNameList[] = { "Cloud 0", "Cloud 1", "Cloud 2", NULL } ;
|
||||
|
||||
static int curr_body = 0 ;
|
||||
static int curr_cloud = 0 ;
|
||||
|
||||
static sgVec4 black = { 0.0f, 0.0f, 0.0f, 1.0f } ;
|
||||
static sgVec4 white = { 1.0f, 1.0f, 1.0f, 1.0f } ;
|
||||
static sgVec4 translucent_white = { 1.0f, 1.0f, 1.0f, 0.8f } ;
|
||||
|
||||
static sgVec4 base_sky_color = { 0.39f, 0.50f, 0.74f, 1.0f } ;
|
||||
static sgVec4 base_fog_color = { 0.84f, 0.87f, 1.00f, 1.0f } ;
|
||||
|
||||
static sgVec4 base_ambient = { 0.2f, 0.2f, 0.2f, 1.0f } ;
|
||||
static sgVec4 base_diffuse = { 1.0f, 1.0f, 1.0f, 1.0f } ;
|
||||
static sgVec4 base_specular = { 1.0f, 1.0f, 1.0f, 1.0f } ;
|
||||
|
||||
static sgVec4 sky_color ;
|
||||
static sgVec4 fog_color ;
|
||||
static sgVec4 cloud_color ;
|
||||
|
||||
static sgVec4 scene_ambient ;
|
||||
static sgVec4 scene_diffuse ;
|
||||
static sgVec4 scene_specular ;
|
||||
|
||||
static const double m_log01 = -log( 0.01 );
|
||||
static const double sqrt_m_log01 = sqrt( m_log01 );
|
||||
|
||||
static int mods = 0 ;
|
||||
unsigned char keypress = 0 ;
|
||||
static int special_key = 0 ;
|
||||
|
||||
static sgCoord campos = { { -300, 0, 10 }, { -90, 0, 0 } } ;
|
||||
|
||||
static void bodySelectBox_cb ( puObject *ob )
|
||||
{
|
||||
curr_body = ((puaSelectBox *) ob) -> getCurrentItem () ;
|
||||
|
||||
if ( curr_body < 0 )
|
||||
curr_body = 0 ;
|
||||
|
||||
if ( curr_body >= MAX_BODIES )
|
||||
curr_body = MAX_BODIES - 1 ;
|
||||
|
||||
bodyRADial -> setValue ( float(bodies[curr_body]->getRightAscension () * SGD_RADIANS_TO_DEGREES) ) ;
|
||||
bodyDeclDial -> setValue ( float(bodies[curr_body]->getDeclination () * SGD_RADIANS_TO_DEGREES) ) ;
|
||||
}
|
||||
|
||||
static void bodyRADial_cb ( puObject *ob )
|
||||
{
|
||||
bodies[curr_body] -> setRightAscension ( ob -> getFloatValue () * SGD_DEGREES_TO_RADIANS ) ;
|
||||
ob -> setLegend ( ob -> getStringValue () ) ;
|
||||
}
|
||||
|
||||
static void bodyDeclDial_cb ( puObject *ob )
|
||||
{
|
||||
bodies[curr_body] -> setDeclination ( ob -> getFloatValue () * SGD_DEGREES_TO_RADIANS ) ;
|
||||
ob -> setLegend ( ob -> getStringValue () ) ;
|
||||
}
|
||||
|
||||
static void cloudSelectBox_cb ( puObject *ob )
|
||||
{
|
||||
curr_cloud = ((puaSelectBox *) ob) -> getCurrentItem () ;
|
||||
|
||||
if ( curr_cloud < 0 )
|
||||
curr_cloud = 0 ;
|
||||
|
||||
if ( curr_cloud >= MAX_CLOUDS )
|
||||
curr_cloud = MAX_CLOUDS - 1 ;
|
||||
|
||||
cloudElevationSlider -> setValue ( clouds[curr_cloud]->getElevation() ) ;
|
||||
cloudEnableButton -> setValue ( clouds[curr_cloud]->isEnabled() ) ;
|
||||
}
|
||||
|
||||
static void cloudElevationSlider_cb ( puObject *ob )
|
||||
{
|
||||
clouds[curr_cloud] -> setElevation ( ob -> getFloatValue () ) ;
|
||||
ob -> setLegend ( ob -> getStringValue () ) ;
|
||||
}
|
||||
|
||||
static void cloudEnableButton_cb ( puObject *ob )
|
||||
{
|
||||
if ( ob -> getIntegerValue () )
|
||||
clouds[curr_cloud] -> enable() ;
|
||||
else
|
||||
clouds[curr_cloud] -> disable() ;
|
||||
}
|
||||
|
||||
static void update_motion ()
|
||||
{
|
||||
static int frameno = 0 ;
|
||||
static ulClock ck ;
|
||||
|
||||
frameno++ ;
|
||||
|
||||
ck . update () ;
|
||||
|
||||
double t = ck . getAbsTime () ;
|
||||
double dt = ck . getDeltaTime () ;
|
||||
|
||||
/* update camera
|
||||
|
||||
keyboard controls:
|
||||
- left/right : turn left/right
|
||||
- up/down arrow : look up/down
|
||||
- up/down arrow + shift : increase/decrease altitude
|
||||
- a/z : move forward/backward
|
||||
|
||||
todo: add mouse or joystick support
|
||||
*/
|
||||
|
||||
if ( special_key == GLUT_KEY_UP )
|
||||
{
|
||||
if ( mods & GLUT_ACTIVE_SHIFT )
|
||||
campos.xyz[SG_Z] += TRANS_SPEED ;
|
||||
else
|
||||
campos.hpr[1] += ROT_SPEED ;
|
||||
}
|
||||
else if ( special_key == GLUT_KEY_DOWN )
|
||||
{
|
||||
if ( mods & GLUT_ACTIVE_SHIFT )
|
||||
campos.xyz[SG_Z] -= TRANS_SPEED ;
|
||||
else
|
||||
campos.hpr[1] -= ROT_SPEED ;
|
||||
}
|
||||
else if ( special_key == GLUT_KEY_LEFT )
|
||||
campos.hpr[0] += ROT_SPEED ;
|
||||
else if ( special_key == GLUT_KEY_RIGHT )
|
||||
campos.hpr[0] -= ROT_SPEED ;
|
||||
|
||||
if ( keypress == 'a' || keypress == 'A' )
|
||||
{
|
||||
campos.xyz[SG_X] -= sgSin ( campos.hpr[0] * SG_DEGREES_TO_RADIANS ) * TRANS_SPEED ;
|
||||
campos.xyz[SG_Y] += sgCos ( campos.hpr[0] * SG_DEGREES_TO_RADIANS ) * TRANS_SPEED ;
|
||||
}
|
||||
else if ( keypress == 'z' || keypress == 'Z' )
|
||||
{
|
||||
campos.xyz[SG_X] += sgSin ( campos.hpr[0] * SG_DEGREES_TO_RADIANS ) * TRANS_SPEED ;
|
||||
campos.xyz[SG_Y] -= sgCos ( campos.hpr[0] * SG_DEGREES_TO_RADIANS ) * TRANS_SPEED ;
|
||||
}
|
||||
|
||||
ssgSetCamera ( & campos ) ;
|
||||
|
||||
/* update teapot */
|
||||
|
||||
sgCoord teapotpos ;
|
||||
sgSetCoord ( & teapotpos, -280.0f, -8.0f, 3.0f, frameno/5.0f, 0.0f, 0.0f ) ;
|
||||
teapot -> setTransform ( & teapotpos ) ;
|
||||
|
||||
/* update waves */
|
||||
|
||||
sgCoord wavepos ;
|
||||
sgSetCoord ( & wavepos, 0, 0, 0, 0, 0, 0 ) ;
|
||||
wave -> setTransform ( & wavepos ) ;
|
||||
wave_obj -> updateAnimation ( (float)t ) ;
|
||||
|
||||
/* move heaven & earth ...
|
||||
if you wish to place sun, moon, planets & stars correctly then
|
||||
you will need to use SimGear Ephemeris code */
|
||||
//bodies[0] -> setDeclination ( bodies[0] -> getDeclination() - 0.01*SGD_DEGREES_TO_RADIANS );
|
||||
//bodies[1] -> setDeclination ( bodies[1] -> getDeclination() - 0.01*SGD_DEGREES_TO_RADIANS );
|
||||
|
||||
/* update sky */
|
||||
|
||||
sky -> repositionFlat ( campos.xyz, 0, dt );
|
||||
sky -> modifyVisibility ( campos.xyz[SG_Z], (float)dt );
|
||||
|
||||
double sol_angle = bodies[0]->getAngle();
|
||||
double sky_brightness = (1.0 + cos(sol_angle))/2.0; // 0.0 - 1.0
|
||||
double scene_brightness = pow(sky_brightness,0.5);
|
||||
|
||||
/* set sky color */
|
||||
sky_color[0] = base_sky_color[0] * (float)sky_brightness;
|
||||
sky_color[1] = base_sky_color[1] * (float)sky_brightness;
|
||||
sky_color[2] = base_sky_color[2] * (float)sky_brightness;
|
||||
sky_color[3] = base_sky_color[3];
|
||||
|
||||
/* set cloud and fog color */
|
||||
cloud_color[0] = fog_color[0] = base_fog_color[0] * (float)sky_brightness;
|
||||
cloud_color[1] = fog_color[1] = base_fog_color[1] * (float)sky_brightness;
|
||||
cloud_color[2] = fog_color[2] = base_fog_color[2] * (float)sky_brightness;
|
||||
cloud_color[3] = fog_color[3] = base_fog_color[3];
|
||||
|
||||
/* repaint the sky */
|
||||
sky -> repaint ( sky_color, fog_color, cloud_color, sol_angle, nplanets, planet_data, nstars, star_data );
|
||||
|
||||
/* set light source */
|
||||
sgCoord solpos;
|
||||
bodies[0] -> getPosition ( & solpos );
|
||||
ssgGetLight ( 0 ) -> setPosition ( solpos.xyz ) ;
|
||||
|
||||
scene_ambient[0] = base_ambient[0] * (float)scene_brightness;
|
||||
scene_ambient[1] = base_ambient[1] * (float)scene_brightness;
|
||||
scene_ambient[2] = base_ambient[2] * (float)scene_brightness;
|
||||
scene_ambient[3] = 1.0;
|
||||
|
||||
scene_diffuse[0] = base_diffuse[0] * (float)scene_brightness;
|
||||
scene_diffuse[1] = base_diffuse[1] * (float)scene_brightness;
|
||||
scene_diffuse[2] = base_diffuse[2] * (float)scene_brightness;
|
||||
scene_diffuse[3] = 1.0;
|
||||
|
||||
scene_specular[0] = base_specular[0] * (float)scene_brightness;
|
||||
scene_specular[1] = base_specular[1] * (float)scene_brightness;
|
||||
scene_specular[2] = base_specular[2] * (float)scene_brightness;
|
||||
scene_specular[3] = 1.0;
|
||||
// GL_LIGHT_MODEL_AMBIENT has a default non-zero value so if
|
||||
// we only update GL_AMBIENT for our lights we will never get
|
||||
// a completely dark scene. So, we set GL_LIGHT_MODEL_AMBIENT
|
||||
// explicitely to black.
|
||||
glLightModelfv( GL_LIGHT_MODEL_AMBIENT, black );
|
||||
ssgGetLight( 0 ) -> setColour( GL_AMBIENT, scene_ambient );
|
||||
ssgGetLight( 0 ) -> setColour( GL_DIFFUSE, scene_diffuse );
|
||||
ssgGetLight( 0 ) -> setColour( GL_SPECULAR, scene_specular );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT window reshape event
|
||||
*/
|
||||
|
||||
static void reshape ( int w, int h )
|
||||
{
|
||||
glViewport ( 0, 0, w, h ) ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
The GLUT keyboard/mouse events
|
||||
*/
|
||||
|
||||
static void keyboard ( unsigned char key, int x, int y )
|
||||
{
|
||||
keypress = key;
|
||||
|
||||
if ( key == 'f' || key == 'F' )
|
||||
/* fullscreen */
|
||||
glutFullScreen();
|
||||
else if ( key == 'w' || key == 'W' )
|
||||
/* wireframe */
|
||||
wireframe = TRUE ;
|
||||
else if ( key == 's' || key == 'S' )
|
||||
/* fill */
|
||||
wireframe = FALSE ;
|
||||
else if ( key == ' ' )
|
||||
/* show/hide gui */
|
||||
displayGUI = ! displayGUI ;
|
||||
else if ( key == 'q' || key == 'Q' || key == 27 /* esc */ )
|
||||
/* quit */
|
||||
exit ( 0 ) ;
|
||||
}
|
||||
|
||||
static void keyboard_up ( unsigned char key, int x, int y )
|
||||
{
|
||||
keypress = 0;
|
||||
}
|
||||
|
||||
static void special ( int key, int x, int y )
|
||||
{
|
||||
mods = glutGetModifiers();
|
||||
special_key = key;
|
||||
}
|
||||
|
||||
static void special_up ( int key, int x, int y )
|
||||
{
|
||||
mods = glutGetModifiers();
|
||||
if ( special_key == key )
|
||||
special_key = 0;
|
||||
}
|
||||
|
||||
static void motionfn ( int x, int y )
|
||||
{
|
||||
if ( displayGUI )
|
||||
puMouse ( x, y ) ;
|
||||
}
|
||||
|
||||
static void mousefn ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( displayGUI )
|
||||
puMouse ( button, updown, x, y ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
The GLUT redraw event
|
||||
*/
|
||||
|
||||
static void redraw ()
|
||||
{
|
||||
update_motion () ;
|
||||
|
||||
glClearColor ( fog_color[0], fog_color[1], fog_color[2], fog_color[3] ) ;
|
||||
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
if ( wireframe )
|
||||
glPolygonMode ( GL_FRONT_AND_BACK, GL_LINE ) ;
|
||||
else
|
||||
glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL ) ;
|
||||
|
||||
/* Adjust fog based on visibility (when in clouds) */
|
||||
GLfloat fog_exp2_density = (float)sqrt_m_log01 / sky->getVisibility();
|
||||
glEnable( GL_FOG );
|
||||
glFogf ( GL_FOG_DENSITY, fog_exp2_density);
|
||||
glFogi ( GL_FOG_MODE, GL_EXP2 );
|
||||
glFogfv ( GL_FOG_COLOR, fog_color );
|
||||
|
||||
/* Draw scene */
|
||||
|
||||
// we need a white diffuse light for the phase of the moon
|
||||
ssgGetLight( 0 ) -> setColour( GL_DIFFUSE, white );
|
||||
|
||||
sky -> preDraw ( );
|
||||
|
||||
// return to the desired diffuse color
|
||||
ssgGetLight( 0 ) -> setColour( GL_DIFFUSE, scene_diffuse );
|
||||
|
||||
ssgCullAndDraw ( scene ) ;
|
||||
sky -> postDraw ( campos.xyz[SG_Z] ); /* altitude */
|
||||
|
||||
/* Draw gui */
|
||||
|
||||
glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL ) ;
|
||||
if ( displayGUI )
|
||||
puDisplay () ;
|
||||
|
||||
glutPostRedisplay () ;
|
||||
glutSwapBuffers () ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void init_graphics ()
|
||||
{
|
||||
int fake_argc = 1 ;
|
||||
char *fake_argv[3] ;
|
||||
fake_argv[0] = "ssgExample" ;
|
||||
fake_argv[1] = "Simple Scene Graph : Example Program." ;
|
||||
fake_argv[2] = NULL ;
|
||||
|
||||
/* Initialise GLUT */
|
||||
|
||||
glutInitWindowPosition ( 0, 0 ) ;
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInit ( &fake_argc, fake_argv ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
glutCreateWindow ( fake_argv[1] ) ;
|
||||
glutDisplayFunc ( redraw ) ;
|
||||
glutReshapeFunc ( reshape ) ;
|
||||
glutKeyboardFunc ( keyboard ) ;
|
||||
glutKeyboardUpFunc ( keyboard_up ) ;
|
||||
glutSpecialFunc ( special ) ;
|
||||
glutSpecialUpFunc ( special_up ) ;
|
||||
glutMouseFunc ( mousefn ) ;
|
||||
glutMotionFunc ( motionfn ) ;
|
||||
|
||||
/* Initialise SSG */
|
||||
|
||||
puInit () ;
|
||||
ssgInit () ;
|
||||
|
||||
/* Some basic OpenGL setup */
|
||||
|
||||
glEnable ( GL_DEPTH_TEST ) ;
|
||||
|
||||
/* Set up the viewing parameters */
|
||||
|
||||
ssgSetFOV ( 60, 45 ) ;
|
||||
ssgSetNearFar ( 1, 200000 ) ; /* nb. skydome is scalable ... so far can be reduced */
|
||||
|
||||
/* Set up the Sun */
|
||||
|
||||
sgVec3 solposn ;
|
||||
sgSetVec3 ( solposn, 0, 0, 0 ) ;
|
||||
ssgGetLight ( 0 ) -> setPosition ( solposn ) ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Load a simple database
|
||||
*/
|
||||
|
||||
static void load_database ()
|
||||
{
|
||||
/* Set up the path to the data files */
|
||||
|
||||
ssgModelPath ( "data" ) ;
|
||||
ssgTexturePath ( "data" ) ;
|
||||
|
||||
/* Setup teapot state */
|
||||
|
||||
teapot_state = new ssgSimpleState () ;
|
||||
teapot_state -> setTexture ( "data/candy.rgb" ) ;
|
||||
teapot_state -> enable ( GL_TEXTURE_2D ) ;
|
||||
teapot_state -> setShadeModel ( GL_SMOOTH ) ;
|
||||
teapot_state -> enable ( GL_CULL_FACE ) ;
|
||||
teapot_state -> enable ( GL_BLEND ) ;
|
||||
teapot_state -> enable ( GL_LIGHTING ) ;
|
||||
teapot_state -> setColourMaterial ( GL_AMBIENT_AND_DIFFUSE ) ;
|
||||
teapot_state -> setMaterial ( GL_EMISSION, 0, 0, 0, 1 ) ;
|
||||
teapot_state -> setMaterial ( GL_SPECULAR, 1, 1, 1, 1 ) ;
|
||||
teapot_state -> setShininess ( 2 ) ;
|
||||
|
||||
/* Setup wave state */
|
||||
|
||||
wave_state = new ssgSimpleState () ;
|
||||
wave_state -> setTexture ( "data/ocean.rgb" ) ;
|
||||
wave_state -> enable ( GL_TEXTURE_2D ) ;
|
||||
wave_state -> setShadeModel ( GL_SMOOTH ) ;
|
||||
wave_state -> enable ( GL_CULL_FACE ) ;
|
||||
wave_state -> enable ( GL_BLEND ) ;
|
||||
wave_state -> enable ( GL_LIGHTING ) ;
|
||||
wave_state -> setColourMaterial ( GL_AMBIENT_AND_DIFFUSE ) ;
|
||||
wave_state -> setMaterial ( GL_EMISSION, 0, 0, 0, 1 ) ;
|
||||
wave_state -> setMaterial ( GL_SPECULAR, 1, 1, 1, 1 ) ;
|
||||
wave_state -> setShininess ( 5 ) ;
|
||||
|
||||
wave_train.setSpeed ( 1.0f ) ;
|
||||
wave_train.setLength ( 3.0f ) ;
|
||||
wave_train.setLambda ( 0.5f ) ;
|
||||
wave_train.setHeading ( 30.0f ) ;
|
||||
wave_train.setWaveHeight ( 1.5f ) ;
|
||||
|
||||
/* Create object */
|
||||
|
||||
tpt_obj = new ssgaTeapot ( 1000 ) ;
|
||||
tpt_obj -> setSize ( 2 ) ;
|
||||
tpt_obj -> setKidState ( teapot_state ) ;
|
||||
tpt_obj -> regenerate () ;
|
||||
|
||||
sgVec3 pos = {0, 0, 0};
|
||||
|
||||
wave_obj = new ssgaWaveSystem ( 4000 ) ;
|
||||
wave_obj->setColour ( white ) ;
|
||||
wave_obj->setSize ( 80000 ) ; /* todo: fix this ... prefer size 2000,
|
||||
but wave system has recently changed and
|
||||
no longer stretches on for 'infinity' :( */
|
||||
wave_obj->setTexScale ( 32, 32 ) ;
|
||||
wave_obj->setCenter ( pos ) ;
|
||||
wave_obj->setKidState ( wave_state ) ;
|
||||
wave_obj->setWindSpeed ( 10.0f ) ;
|
||||
wave_obj->setWaveTrain ( 0, &wave_train ) ;
|
||||
|
||||
/* Build the scene graph */
|
||||
|
||||
star_data = new sgdVec3[nstars] ;
|
||||
for ( int i = 0; i < nstars; i++ )
|
||||
{
|
||||
star_data[i][0] = ssgaRandom() * SGD_PI ;
|
||||
star_data[i][1] = ssgaRandom() * SGD_PI ;
|
||||
star_data[i][2] = ssgaRandom() ;
|
||||
}
|
||||
|
||||
/* sky */
|
||||
sky = new ssgaSky ;
|
||||
sky -> build ( 80000, 80000, nplanets, planet_data, nstars, star_data );
|
||||
/* sun */
|
||||
bodies[0] = sky -> addBody (
|
||||
NULL, // body texture
|
||||
"data/halo.rgba", // halo texture
|
||||
5000, // size
|
||||
80000, // distance
|
||||
true ); // is sun - dome painted based on this
|
||||
bodies[0] -> setDeclination ( 20*SGD_DEGREES_TO_RADIANS );
|
||||
/* moon */
|
||||
bodies[1] = sky -> addBody (
|
||||
"data/moon.rgba", // body texture
|
||||
NULL, // halo texture
|
||||
5000, // size
|
||||
80000 ); // distance
|
||||
bodies[1] -> setDeclination ( 65*SGD_DEGREES_TO_RADIANS );
|
||||
/* clouds */
|
||||
clouds[0] = sky -> addCloud (
|
||||
"data/scattered.rgba", // texture
|
||||
80000, // span
|
||||
2000, // elevation,
|
||||
100, // thickness
|
||||
100 ); // transition
|
||||
clouds[0] -> setSpeed ( 50 ) ;
|
||||
clouds[0] -> setDirection ( 45 ) ;
|
||||
clouds[1] = sky -> addCloud (
|
||||
"data/scattered.rgba", // texture
|
||||
80000, // span
|
||||
3000, // elevation,
|
||||
100, // thickness
|
||||
100 ); // transition
|
||||
clouds[1] -> setSpeed ( 20 ) ;
|
||||
clouds[1] -> setDirection ( 30 ) ;
|
||||
clouds[2] = sky -> addCloud (
|
||||
"data/scattered.rgba", // texture
|
||||
80000, // span
|
||||
1000, // elevation,
|
||||
100, // thickness
|
||||
100 ); // transition
|
||||
clouds[2] -> setSpeed ( 5 ) ;
|
||||
clouds[2] -> setDirection ( 20 ) ;
|
||||
|
||||
teapot = new ssgTransform ;
|
||||
teapot -> addKid ( tpt_obj ) ;
|
||||
|
||||
wave = new ssgTransform ;
|
||||
wave -> addKid ( wave_obj ) ;
|
||||
|
||||
scene = new ssgRoot ;
|
||||
scene -> addKid ( teapot ) ;
|
||||
scene -> addKid ( wave ) ;
|
||||
}
|
||||
|
||||
|
||||
static void init_gui ()
|
||||
{
|
||||
static puFont *sorority ;
|
||||
static fntTexFont *fnt ;
|
||||
|
||||
fnt = new fntTexFont () ;
|
||||
fnt -> load ( "data/sorority.txf" ) ;
|
||||
sorority = new puFont ( fnt, 12 ) ;
|
||||
|
||||
puSetDefaultFonts ( *sorority, *sorority ) ;
|
||||
puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ;
|
||||
puSetDefaultColourScheme ( 0.2f, 0.5f, 0.2f, 0.5f ) ;
|
||||
|
||||
puGroup *window_group = new puGroup ( 0, 0 ) ;
|
||||
|
||||
bodyRADial = new puDial ( 150, GUI_BASE+90, 50 ) ;
|
||||
bodyRADial->setWrap ( 1 ) ;
|
||||
bodyRADial->setMaxValue ( 360 ) ;
|
||||
bodyRADial->setMinValue ( 0 ) ;
|
||||
bodyRADial->setStepSize ( 0.1f ) ;
|
||||
bodyRADial->setCBMode ( PUSLIDER_ALWAYS ) ;
|
||||
bodyRADial->setCallback ( bodyRADial_cb ) ;
|
||||
bodyRADial->setLabel ( "Right Ascension" ) ;
|
||||
bodyRADial->setLabelPlace ( PUPLACE_CENTERED_RIGHT ) ;
|
||||
bodyRADial->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
bodyRADial->setLegendPlace ( PUPLACE_BOTTOM_CENTERED ) ;
|
||||
|
||||
bodyDeclDial = new puDial ( 400, GUI_BASE+90, 50 ) ;
|
||||
bodyDeclDial->setWrap ( 1 ) ;
|
||||
bodyDeclDial->setMaxValue ( 360 ) ;
|
||||
bodyDeclDial->setMinValue ( 0 ) ;
|
||||
bodyDeclDial->setStepSize ( 0.1f ) ;
|
||||
bodyDeclDial->setCBMode ( PUSLIDER_ALWAYS ) ;
|
||||
bodyDeclDial->setCallback ( bodyDeclDial_cb ) ;
|
||||
bodyDeclDial->setLabel ( "Declination" ) ;
|
||||
bodyDeclDial->setLabelPlace ( PUPLACE_CENTERED_RIGHT ) ;
|
||||
bodyDeclDial->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
bodyDeclDial->setLegendPlace ( PUPLACE_BOTTOM_CENTERED ) ;
|
||||
|
||||
bodySelectBox = new puaSelectBox ( 150, GUI_BASE+150, 300, GUI_BASE+180, bodyNameList ) ;
|
||||
bodySelectBox->setCallback ( bodySelectBox_cb ) ;
|
||||
bodySelectBox->setCurrentItem ( 0 ) ;
|
||||
bodySelectBox->setLabel ( "Edit Body" ) ;
|
||||
bodySelectBox->setLabelPlace ( PUPLACE_CENTERED_LEFT ) ;
|
||||
bodySelectBox->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
/* Set everything up on the first time around */
|
||||
bodySelectBox_cb ( bodySelectBox ) ;
|
||||
|
||||
cloudElevationSlider = new puSlider ( 150, GUI_BASE+20, 90, false, 20 ) ;
|
||||
cloudElevationSlider->setMaxValue ( 10000.0f ) ;
|
||||
cloudElevationSlider->setMinValue ( 100.0f ) ;
|
||||
cloudElevationSlider->setStepSize ( 10.0f ) ;
|
||||
cloudElevationSlider->setCBMode ( PUSLIDER_ALWAYS ) ;
|
||||
cloudElevationSlider->setCallback ( cloudElevationSlider_cb ) ;
|
||||
cloudElevationSlider->setLabel ( "Cloud Elevation" ) ;
|
||||
cloudElevationSlider->setLabelPlace ( PUPLACE_CENTERED_LEFT ) ;
|
||||
cloudElevationSlider->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
cloudEnableButton = new puButton ( 150, GUI_BASE, " " ) ;
|
||||
cloudEnableButton->setStyle ( PUSTYLE_RADIO ) ;
|
||||
cloudEnableButton->setCallback ( cloudEnableButton_cb ) ;
|
||||
cloudEnableButton->setLabel ( "Enable Cloud" ) ;
|
||||
cloudEnableButton->setLabelPlace ( PUPLACE_CENTERED_LEFT ) ;
|
||||
cloudEnableButton->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
cloudSelectBox = new puaSelectBox ( 150, GUI_BASE+50, 300, GUI_BASE+80, cloudNameList ) ;
|
||||
cloudSelectBox->setCallback ( cloudSelectBox_cb ) ;
|
||||
cloudSelectBox->setCurrentItem ( 0 ) ;
|
||||
cloudSelectBox->setLabel ( "Edit Cloud" ) ;
|
||||
cloudSelectBox->setLabelPlace ( PUPLACE_CENTERED_LEFT ) ;
|
||||
cloudSelectBox->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
/* Set everything up on the first time around */
|
||||
cloudSelectBox_cb ( cloudSelectBox ) ;
|
||||
|
||||
window_group->close () ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
The works.
|
||||
*/
|
||||
|
||||
int main ( int, char ** )
|
||||
{
|
||||
init_graphics () ;
|
||||
load_database () ;
|
||||
init_gui () ;
|
||||
glutMainLoop () ;
|
||||
return 0 ;
|
||||
}
|
||||
87
examples/src/ssg/sky/sky.dsp
Normal file
87
examples/src/ssg/sky/sky.dsp
Normal file
@@ -0,0 +1,87 @@
|
||||
# Microsoft Developer Studio Project File - Name="sky" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=sky - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "sky.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "sky.mak" CFG="sky - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "sky - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "sky - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "sky - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0xc09 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sg.lib ssg.lib pui.lib puAux.lib fnt.lib ul.lib ssgAux.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "sky - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0xc09 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sg_d.lib ssg_d.lib pui_d.lib puAux_d.lib fnt_d.lib ul_d.lib ssgAux_d.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "sky - Win32 Release"
|
||||
# Name "sky - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sky.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
12
examples/src/ssg/state_test/Makefile.am
Normal file
12
examples/src/ssg/state_test/Makefile.am
Normal file
@@ -0,0 +1,12 @@
|
||||
if BUILD_SSG
|
||||
|
||||
noinst_PROGRAMS = stest
|
||||
|
||||
stest_SOURCES = stest.cxx
|
||||
|
||||
stest_LDADD = -lplibssg -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS)
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = herring.inta stest.dsp
|
||||
|
||||
BIN
examples/src/ssg/state_test/herring.inta
Normal file
BIN
examples/src/ssg/state_test/herring.inta
Normal file
Binary file not shown.
323
examples/src/ssg/state_test/stest.cxx
Normal file
323
examples/src/ssg/state_test/stest.cxx
Normal file
@@ -0,0 +1,323 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: stest.cxx 2099 2006-11-03 20:04:40Z fayjf $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <plib/ssg.h>
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static ssgRoot *scene = NULL ;
|
||||
static ssgTransform *object = NULL ;
|
||||
static ssgStateSelector *big_red_switch = NULL ;
|
||||
|
||||
/*
|
||||
Something to make some interesting motion
|
||||
for both Object and the camera.
|
||||
*/
|
||||
|
||||
static void update_motion ()
|
||||
{
|
||||
static int frameno = 0 ;
|
||||
|
||||
frameno++ ;
|
||||
|
||||
sgCoord campos ;
|
||||
sgCoord objpos ;
|
||||
|
||||
/*
|
||||
Spin Object, make the camera pan sinusoidally left and right
|
||||
*/
|
||||
|
||||
sgSetCoord ( & campos, 0.0f, -5.0f, 1.0f,
|
||||
/*25.0 * sin(frameno/100.0)*/0.0f, 0.0f, 0.0f ) ;
|
||||
sgSetCoord ( & objpos, 0.0f, 0.0f, 0.0f, (float)frameno, 0.0f, 0.0f ) ;
|
||||
|
||||
ssgSetCamera ( & campos ) ;
|
||||
object -> setTransform ( & objpos ) ;
|
||||
|
||||
if ( frameno % 600 == 0 )
|
||||
big_red_switch -> selectStep ( 0 ) ;
|
||||
|
||||
if ( frameno % 600 == 300 )
|
||||
big_red_switch -> selectStep ( 1 ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT window reshape event
|
||||
*/
|
||||
|
||||
static void reshape ( int w, int h )
|
||||
{
|
||||
glViewport ( 0, 0, w, h ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT keyboard event
|
||||
*/
|
||||
|
||||
static void keyboard ( unsigned char, int, int )
|
||||
{
|
||||
exit ( 0 ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT redraw event
|
||||
*/
|
||||
|
||||
static void redraw ()
|
||||
{
|
||||
update_motion () ;
|
||||
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
ssgCullAndDraw ( scene ) ;
|
||||
|
||||
glutPostRedisplay () ;
|
||||
glutSwapBuffers () ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void init_graphics ()
|
||||
{
|
||||
int fake_argc = 1 ;
|
||||
char *fake_argv[3] ;
|
||||
fake_argv[0] = "Viewer" ;
|
||||
fake_argv[1] = "Simple Scene Graph : Viewer Program." ;
|
||||
fake_argv[2] = NULL ;
|
||||
|
||||
/*
|
||||
Initialise GLUT
|
||||
*/
|
||||
|
||||
glutInitWindowPosition ( 0, 0 ) ;
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInit ( &fake_argc, fake_argv ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
glutCreateWindow ( fake_argv[1] ) ;
|
||||
glutDisplayFunc ( redraw ) ;
|
||||
glutReshapeFunc ( reshape ) ;
|
||||
glutKeyboardFunc ( keyboard ) ;
|
||||
|
||||
/*
|
||||
Initialise SSG
|
||||
*/
|
||||
|
||||
ssgInit () ;
|
||||
|
||||
/*
|
||||
Some basic OpenGL setup
|
||||
*/
|
||||
|
||||
glClearColor ( 0.2f, 0.7f, 1.0f, 1.0f ) ;
|
||||
glEnable ( GL_DEPTH_TEST ) ;
|
||||
|
||||
/*
|
||||
Set up the viewing parameters
|
||||
*/
|
||||
|
||||
ssgSetFOV ( 60.0f, 0.0f ) ;
|
||||
ssgSetNearFar ( 1.0f, 700.0f ) ;
|
||||
|
||||
/*
|
||||
Set up the Sun.
|
||||
*/
|
||||
|
||||
sgVec3 sunposn ;
|
||||
sgSetVec3 ( sunposn, 0.2f, -0.5f, 0.5f ) ;
|
||||
ssgGetLight ( 0 ) -> setPosition ( sunposn ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static ssgEntity *make_herring ()
|
||||
{
|
||||
big_red_switch = new ssgStateSelector ( 2 ) ;
|
||||
|
||||
ssgSimpleState *st0 = new ssgSimpleState ;
|
||||
ssgSimpleState *st1 = new ssgSimpleState ;
|
||||
|
||||
/* Texture ... or not */
|
||||
|
||||
st0 -> setTexture ( "herring.inta" ) ;
|
||||
st0 -> enable ( GL_TEXTURE_2D ) ;
|
||||
|
||||
st1 -> disable ( GL_TEXTURE_2D ) ;
|
||||
|
||||
/* Other Stuff */
|
||||
|
||||
st0 -> setShadeModel ( GL_SMOOTH ) ;
|
||||
st1 -> setShadeModel ( GL_SMOOTH ) ;
|
||||
|
||||
st0 -> enable ( GL_CULL_FACE ) ;
|
||||
st1 -> enable ( GL_CULL_FACE ) ;
|
||||
|
||||
st0 -> setTranslucent () ;
|
||||
st1 -> setTranslucent () ;
|
||||
|
||||
st0 -> enable ( GL_ALPHA_TEST ) ;
|
||||
st1 -> enable ( GL_ALPHA_TEST ) ;
|
||||
|
||||
st0 -> setAlphaClamp ( 0.9f ) ;
|
||||
st1 -> setAlphaClamp ( 0.9f ) ;
|
||||
|
||||
st0 -> enable ( GL_BLEND ) ;
|
||||
st1 -> enable ( GL_BLEND ) ;
|
||||
|
||||
/* Lighting (where the magic happens) */
|
||||
|
||||
/* A RED herring (because the polygon is red). */
|
||||
st0 -> enable ( GL_LIGHTING ) ;
|
||||
st0 -> enable ( GL_COLOR_MATERIAL ) ;
|
||||
st0 -> setColourMaterial ( GL_AMBIENT_AND_DIFFUSE ) ;
|
||||
st0 -> setMaterial ( GL_EMISSION, 0, 0, 0, 1 ) ;
|
||||
st0 -> setMaterial ( GL_SPECULAR, 0, 0, 0, 1 ) ;
|
||||
st0 -> setShininess ( 0 ) ;
|
||||
|
||||
/* Hopefully, a GREEN rectangle. */
|
||||
st1 -> enable ( GL_LIGHTING ) ;
|
||||
st1 -> disable ( GL_COLOR_MATERIAL ) ;
|
||||
st1 -> setMaterial ( GL_AMBIENT , 0, 1, 0, 1 ) ;
|
||||
st1 -> setMaterial ( GL_DIFFUSE , 0, 1, 0, 1 ) ;
|
||||
st1 -> setMaterial ( GL_EMISSION, 0, 0, 0, 1 ) ;
|
||||
st1 -> setMaterial ( GL_SPECULAR, 0, 0, 0, 1 ) ;
|
||||
st1 -> setShininess ( 0 ) ;
|
||||
|
||||
/* Set up the selector */
|
||||
|
||||
big_red_switch -> setStep ( 0, st0 ) ;
|
||||
big_red_switch -> setStep ( 1, st1 ) ;
|
||||
|
||||
big_red_switch -> selectStep ( 0 ) ; /* Textured! */
|
||||
|
||||
sgVec4 *scolors = new sgVec4 [ 1 ] ;
|
||||
sgVec3 *scoords = new sgVec3 [ 6 ] ;
|
||||
sgVec2 *tcoords = new sgVec2 [ 6 ] ;
|
||||
sgVec3 *snorms = new sgVec3 [ 1 ] ;
|
||||
|
||||
/* RED! */
|
||||
sgSetVec4 ( scolors [ 0 ], 1.0f, 0.0f, 0.0f, 1.0f ) ;
|
||||
sgSetVec3 ( snorms[0], 0.0f, 1.0f, 0.0f ) ;
|
||||
|
||||
sgSetVec3(scoords[0], -1.0, 0.0, 0.0 ) ;
|
||||
sgSetVec3(scoords[1], 1.0, 0.0, 0.0 ) ;
|
||||
sgSetVec3(scoords[2], -1.0, 0.0, 1.0 ) ;
|
||||
sgSetVec3(scoords[3], 1.0, 0.0, 1.0 ) ;
|
||||
sgSetVec3(scoords[4], -1.0, 0.0, 0.0 ) ;
|
||||
sgSetVec3(scoords[5], 1.0, 0.0, 0.0 ) ;
|
||||
|
||||
sgSetVec2(tcoords[0], 0.0, 0.0 ) ;
|
||||
sgSetVec2(tcoords[1], 1.0, 0.0 ) ;
|
||||
sgSetVec2(tcoords[2], 0.0, 1.0 ) ;
|
||||
sgSetVec2(tcoords[3], 1.0, 1.0 ) ;
|
||||
sgSetVec2(tcoords[4], 0.0, 0.0 ) ;
|
||||
sgSetVec2(tcoords[5], 1.0, 0.0 ) ;
|
||||
|
||||
ssgLeaf *gset = new ssgVTable ( GL_TRIANGLE_STRIP,
|
||||
6, scoords,
|
||||
1, snorms,
|
||||
6, tcoords,
|
||||
1, scolors ) ;
|
||||
|
||||
gset -> setState ( big_red_switch ) ;
|
||||
|
||||
return gset ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Load a simple database
|
||||
*/
|
||||
|
||||
static void load_database ()
|
||||
{
|
||||
/*
|
||||
Set up the path to the data files
|
||||
*/
|
||||
|
||||
ssgModelPath ( "." ) ;
|
||||
ssgTexturePath ( "." ) ;
|
||||
|
||||
/*
|
||||
Create a root node - and a transform to position
|
||||
the object beneath that (in the tree that is).
|
||||
*/
|
||||
|
||||
scene = new ssgRoot ;
|
||||
object = new ssgTransform ;
|
||||
|
||||
/*
|
||||
Load the models - optimise them a bit
|
||||
and then add them into the scene.
|
||||
*/
|
||||
|
||||
ssgEntity *obj_obj = make_herring () ;
|
||||
|
||||
object -> addKid ( obj_obj ) ;
|
||||
|
||||
//ssgFlatten ( obj_obj ) ;
|
||||
//ssgStripify ( object ) ;
|
||||
scene -> addKid ( object ) ;
|
||||
scene -> print () ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The works.
|
||||
*/
|
||||
|
||||
int main ( int, char ** )
|
||||
{
|
||||
init_graphics () ;
|
||||
load_database () ;
|
||||
glutMainLoop () ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
88
examples/src/ssg/state_test/stest.dsp
Normal file
88
examples/src/ssg/state_test/stest.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="stest" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=stest - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "stest.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "stest.mak" CFG="stest - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "stest - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "stest - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "stest - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg.lib sg.lib ul.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /out:"stest.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "stest - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg_d.lib sg_d.lib ul_d.lib opengl32.lib glu32.lib glut32.lib Shlwapi.lib /nologo /subsystem:console /debug /machine:I386 /out:"stest.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "stest - Win32 Release"
|
||||
# Name "stest - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\stest.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
14
examples/src/ssg/tux/Makefile.am
Normal file
14
examples/src/ssg/tux/Makefile.am
Normal file
@@ -0,0 +1,14 @@
|
||||
if BUILD_SSG
|
||||
|
||||
noinst_PROGRAMS = tux_example WavingFlagDemo
|
||||
|
||||
tux_example_SOURCES = tux_example.cxx
|
||||
WavingFlagDemo_SOURCES = WavingFlag.cxx WavingFlagDemo.cxx WavingFlag.h
|
||||
|
||||
tux_example_LDADD = -lplibssg -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS)
|
||||
WavingFlagDemo_LDADD = -lplibssg -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS)
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = tux_example.dsp WavingFlag.dsp
|
||||
|
||||
203
examples/src/ssg/tux/WavingFlag.cxx
Normal file
203
examples/src/ssg/tux/WavingFlag.cxx
Normal file
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: WavingFlag.cxx 2099 2006-11-03 20:04:40Z fayjf $
|
||||
*/
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <plib/ssg.h>
|
||||
#include "WavingFlag.h"
|
||||
|
||||
WavingFlag::WavingFlag( sgVec4 color, char *texture1, char *texture2, int s )
|
||||
{
|
||||
size = s;
|
||||
int numVertices = size*size;
|
||||
branch = new ssgBranch();
|
||||
branch->clrTraversalMaskBits ( SSGTRAV_HOT ) ;
|
||||
|
||||
colors = new ssgColourArray( numVertices );
|
||||
normals = new ssgNormalArray( numVertices );
|
||||
texCoords = new ssgTexCoordArray( numVertices );
|
||||
vertices = new ssgVertexArray( numVertices );
|
||||
int i;
|
||||
for ( i = 0; i < numVertices; i++ )
|
||||
{
|
||||
sgVec3 n = { 0.0, 0.0, 0.0 };
|
||||
sgVec2 t = { 0.0, 0.0 };
|
||||
colors->add( color );
|
||||
normals->add( n );
|
||||
texCoords->add( t );
|
||||
vertices->add( n );
|
||||
}
|
||||
ssgSimpleState *state1 = new ssgSimpleState ;
|
||||
if ( texture1 )
|
||||
{
|
||||
state1->setTexture( texture1 ) ;
|
||||
state1->enable( GL_TEXTURE_2D ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
state1->disable( GL_TEXTURE_2D ) ;
|
||||
}
|
||||
state1->enable( GL_LIGHTING ) ;
|
||||
state1->setShadeModel( GL_SMOOTH ) ;
|
||||
state1->enable( GL_COLOR_MATERIAL ) ;
|
||||
state1->setColourMaterial( GL_AMBIENT_AND_DIFFUSE ) ;
|
||||
state1->setMaterial( GL_EMISSION, 0.91f, 0.41f, 0.81f, .94f ) ;
|
||||
state1->setMaterial( GL_SPECULAR, 0.91f, 0.41f, 0.81f, .94f ) ;
|
||||
state1->setShininess( 0.3f ) ;
|
||||
state1->setTranslucent() ;
|
||||
state1->enable( GL_BLEND ) ;
|
||||
state1->enable ( GL_ALPHA_TEST ) ;
|
||||
state1->setAlphaClamp ( 0.0f ) ;
|
||||
|
||||
ssgSimpleState *state2 = new ssgSimpleState ;
|
||||
if ( texture2 )
|
||||
{
|
||||
state2->setTexture( texture2 ) ;
|
||||
state2->enable( GL_TEXTURE_2D ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( texture1 )
|
||||
{
|
||||
state2->setTexture( texture1 ) ;
|
||||
state2->enable( GL_TEXTURE_2D ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
state2->disable( GL_TEXTURE_2D ) ;
|
||||
}
|
||||
}
|
||||
state2->enable( GL_LIGHTING ) ;
|
||||
state2->setShadeModel( GL_SMOOTH ) ;
|
||||
state2->enable( GL_COLOR_MATERIAL ) ;
|
||||
state2->setColourMaterial( GL_AMBIENT_AND_DIFFUSE ) ;
|
||||
state2->setMaterial( GL_EMISSION, 0.91f, 0.41f, 0.81f, .94f ) ;
|
||||
state2->setMaterial( GL_SPECULAR, 0.91f, 0.41f, 0.81f, .94f ) ;
|
||||
state2->setShininess( 0.3f ) ;
|
||||
state2->setTranslucent() ;
|
||||
state2->enable( GL_BLEND ) ;
|
||||
state2->enable ( GL_ALPHA_TEST ) ;
|
||||
state2->setAlphaClamp ( 0.0f ) ;
|
||||
|
||||
branch = new ssgBranch;
|
||||
int x,z;
|
||||
for ( x = 0; x < size; x++ )
|
||||
{
|
||||
ssgIndexArray *indices = new ssgIndexArray( size*2 ); // one side of the flag
|
||||
ssgIndexArray *indices2 = new ssgIndexArray( size*2 ); // and the other side
|
||||
for ( z = 0; z < size; z++ )
|
||||
{
|
||||
int i = x*size + z;
|
||||
|
||||
float *v = vertices->get( i );
|
||||
v[0] = (float)x/(size - 1.0f);
|
||||
v[1] = 0.0;
|
||||
v[2] = (float)z/(size - 1.0f);
|
||||
|
||||
float *t = texCoords->get( i );
|
||||
sgSetVec2( t, v[0], v[2] );
|
||||
|
||||
indices->add( i );
|
||||
indices->add( i+size );
|
||||
indices2->add( i+size );
|
||||
indices2->add( i );
|
||||
}
|
||||
if ( x < size-1 )
|
||||
{
|
||||
ssgLeaf *l = new ssgVtxArray( GL_TRIANGLE_STRIP,
|
||||
vertices,
|
||||
normals,
|
||||
texCoords,
|
||||
colors,
|
||||
indices );
|
||||
l->setState ( state1 );
|
||||
branch->addKid( l );
|
||||
ssgLeaf *l2 = new ssgVtxArray( GL_TRIANGLE_STRIP,
|
||||
vertices,
|
||||
normals,
|
||||
texCoords,
|
||||
colors,
|
||||
indices2 );
|
||||
l2->setState ( state2 );
|
||||
branch->addKid( l2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WavingFlag::~WavingFlag()
|
||||
{
|
||||
}
|
||||
|
||||
void WavingFlag::animate( float time, float windVelocity )
|
||||
{
|
||||
if ( windVelocity < 3.0 ) windVelocity = 3.0;
|
||||
if ( windVelocity > 25.0 ) windVelocity = 25.0;
|
||||
float r = 0.6f/windVelocity; // half wave height
|
||||
float w = windVelocity/2.0f; // angular acceleration
|
||||
float k = windVelocity*3.0f; // wave number
|
||||
float d = (1.0f-windVelocity/25.0f)*(SG_PI/2.0f);
|
||||
|
||||
int x,z;
|
||||
for ( z = size-1; z >= 0; z-- )
|
||||
{
|
||||
for ( x = 1; x < size; x++ )
|
||||
{
|
||||
int i = x*size + z;
|
||||
|
||||
float *v = vertices->get( i );
|
||||
v[0] = ((float)x * (float)cos(d)) / (size - 1.0f);
|
||||
float a = k*(v[0]) - w*time; // phase angle
|
||||
v[1] = r * (float)cos( a );
|
||||
v[0] -= v[1];
|
||||
v[2] = ((float)z - (float)x * (float)sin(d)) / (size - 1.0f);
|
||||
float *n = normals->get( i );
|
||||
n[0] = (float)cos(d);
|
||||
n[1] = v[1];
|
||||
//d *= 1.002;
|
||||
}
|
||||
k *= 0.9f;
|
||||
}
|
||||
if ( d > SG_PI/2.0 ) printf ("Problems\n");
|
||||
branch -> dirtyBSphere () ;
|
||||
}
|
||||
|
||||
ssgEntity *WavingFlag::getObject()
|
||||
{
|
||||
return branch;
|
||||
}
|
||||
|
||||
96
examples/src/ssg/tux/WavingFlag.dsp
Normal file
96
examples/src/ssg/tux/WavingFlag.dsp
Normal file
@@ -0,0 +1,96 @@
|
||||
# Microsoft Developer Studio Project File - Name="WavingFlag" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=WavingFlag - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "WavingFlag.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "WavingFlag.mak" CFG="WavingFlag - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "WavingFlag - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "WavingFlag - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "WavingFlag - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg.lib sg.lib ul.lib glut32.lib opengl32.lib glu32.lib /nologo /subsystem:console /machine:I386 /out:"WavingFlag.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "WavingFlag - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg_d.lib sg_d.lib ul_d.lib glut32.lib opengl32.lib glu32.lib /nologo /subsystem:console /debug /machine:I386 /out:"WavingFlag.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "WavingFlag - Win32 Release"
|
||||
# Name "WavingFlag - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WavingFlag.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WavingFlag.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WavingFlagDemo.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
44
examples/src/ssg/tux/WavingFlag.h
Normal file
44
examples/src/ssg/tux/WavingFlag.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: WavingFlag.h 1551 2002-09-01 12:04:53Z ude $
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _WAVINGFLAG_
|
||||
#define _WAVINGFLAG_
|
||||
|
||||
class WavingFlag
|
||||
{
|
||||
public:
|
||||
WavingFlag( sgVec4 color, char *texture1=NULL, char *texture2=NULL, int s=5 );
|
||||
~WavingFlag();
|
||||
void animate( float time, float windVelocity );
|
||||
ssgEntity *getObject();
|
||||
private:
|
||||
ssgBranch *branch;
|
||||
ssgColourArray *colors;
|
||||
ssgNormalArray *normals;
|
||||
ssgTexCoordArray *texCoords;
|
||||
ssgVertexArray *vertices;
|
||||
int size;
|
||||
};
|
||||
|
||||
#endif
|
||||
194
examples/src/ssg/tux/WavingFlagDemo.cxx
Normal file
194
examples/src/ssg/tux/WavingFlagDemo.cxx
Normal file
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: WavingFlagDemo.cxx 1551 2002-09-01 12:04:53Z ude $
|
||||
*/
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <plib/ssg.h>
|
||||
#include "WavingFlag.h"
|
||||
|
||||
|
||||
static WavingFlag* flag = NULL ;
|
||||
static float flagTime = 0.0f ;
|
||||
static ssgRoot* scene = NULL ;
|
||||
|
||||
/*
|
||||
The GLUT window reshape event
|
||||
*/
|
||||
|
||||
static void reshape ( int w, int h )
|
||||
{
|
||||
glViewport ( 0, 0, w, h ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT keyboard event
|
||||
*/
|
||||
|
||||
static void keyboard ( unsigned char, int, int )
|
||||
{
|
||||
exit ( 0 ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void idle ()
|
||||
{
|
||||
static int lastTime = 0;
|
||||
int time = glutGet((GLenum)GLUT_ELAPSED_TIME);
|
||||
if (time != lastTime) {
|
||||
lastTime = time;
|
||||
flagTime += 0.02f ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
The GLUT redraw event
|
||||
*/
|
||||
|
||||
static void redraw ()
|
||||
{
|
||||
sgCoord campos ;
|
||||
sgSetCoord ( & campos, 0.0f, -3.0f, 0.0f, 0.0f, 0.0f, 0.0f ) ;
|
||||
ssgSetCamera ( & campos ) ;
|
||||
|
||||
flag -> animate( flagTime, 20 );
|
||||
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
ssgCullAndDraw ( scene ) ;
|
||||
|
||||
glutPostRedisplay () ;
|
||||
glutSwapBuffers () ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void init_graphics ()
|
||||
{
|
||||
int fake_argc = 1 ;
|
||||
char *fake_argv[3] ;
|
||||
fake_argv[0] = "ssgExample" ;
|
||||
fake_argv[1] = "Waving Flag Example Program." ;
|
||||
fake_argv[2] = NULL ;
|
||||
|
||||
/*
|
||||
Initialise GLUT
|
||||
*/
|
||||
|
||||
glutInitWindowPosition ( 0, 0 ) ;
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInit ( &fake_argc, fake_argv ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
glutCreateWindow ( fake_argv[1] ) ;
|
||||
glutDisplayFunc ( redraw ) ;
|
||||
glutReshapeFunc ( reshape ) ;
|
||||
glutKeyboardFunc ( keyboard ) ;
|
||||
glutIdleFunc ( idle ) ;
|
||||
|
||||
/*
|
||||
Initialise SSG
|
||||
*/
|
||||
|
||||
ssgInit () ;
|
||||
|
||||
/*
|
||||
Some basic OpenGL setup
|
||||
*/
|
||||
|
||||
glClearColor ( 0.2f, 0.7f, 1.0f, 1.0f ) ;
|
||||
glEnable ( GL_DEPTH_TEST ) ;
|
||||
|
||||
/*
|
||||
Set up the viewing parameters
|
||||
*/
|
||||
|
||||
ssgSetFOV ( 60.0f, 0.0f ) ;
|
||||
ssgSetNearFar ( 1.0f, 700.0f ) ;
|
||||
|
||||
/*
|
||||
Set up the Sun.
|
||||
*/
|
||||
|
||||
sgVec3 sunposn ;
|
||||
sgSetVec3 ( sunposn, 0.2f, -0.5f, 0.5f ) ;
|
||||
ssgGetLight ( 0 ) -> setPosition ( sunposn ) ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Load a simple database
|
||||
*/
|
||||
|
||||
static void load_database ()
|
||||
{
|
||||
/*
|
||||
Set up the path to the data files
|
||||
*/
|
||||
|
||||
ssgModelPath ( "data" ) ;
|
||||
ssgTexturePath ( "data" ) ;
|
||||
|
||||
/*
|
||||
Create a root node and the flag.
|
||||
*/
|
||||
|
||||
scene = new ssgRoot ;
|
||||
|
||||
sgVec4 flagColor = { 1.0f, 0.0f, 0.0f, 1.0f };
|
||||
flag = new WavingFlag ( flagColor, "data/Penguin_body.rgb", "data/Penguin_body.rgb" ) ;
|
||||
|
||||
scene -> addKid ( flag -> getObject() ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The works.
|
||||
*/
|
||||
|
||||
int main ( int, char ** )
|
||||
{
|
||||
init_graphics () ;
|
||||
load_database () ;
|
||||
glutMainLoop () ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
BIN
examples/src/ssg/tux/data/Penguin_beak.rgb
Normal file
BIN
examples/src/ssg/tux/data/Penguin_beak.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/tux/data/Penguin_body.rgb
Normal file
BIN
examples/src/ssg/tux/data/Penguin_body.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/tux/data/embossed_herring.bmp
Normal file
BIN
examples/src/ssg/tux/data/embossed_herring.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
81
examples/src/ssg/tux/data/pedestal.ac
Normal file
81
examples/src/ssg/tux/data/pedestal.ac
Normal file
@@ -0,0 +1,81 @@
|
||||
AC3Db
|
||||
MATERIAL "" rgb 1 1 1 amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10 trans 0
|
||||
MATERIAL "" rgb 1 1 1 amb 0.2 0.2 0.2 emis 1 1 1 spec 0.502 0.502 0.502 shi 0 trans 0
|
||||
OBJECT world
|
||||
kids 2
|
||||
OBJECT poly
|
||||
name "box"
|
||||
texture "wood.rgb"
|
||||
texrep 5 5
|
||||
numvert 8
|
||||
-1.29615 -0.6 -1.29615
|
||||
-1 0 -1
|
||||
1 0 -1
|
||||
1.3 -0.6 -1.29615
|
||||
-1.29615 -0.6 1.3
|
||||
-1 0 1
|
||||
1 0 1
|
||||
1.3 -0.6 1.3
|
||||
numsurf 6
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
0 0 0
|
||||
1 0.114074 0.114074
|
||||
2 0.884445 0.114074
|
||||
3 1 0
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
6 0.884445 0.884445
|
||||
7 1 1
|
||||
3 1 0
|
||||
2 0.884445 0.114074
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
7 1 1
|
||||
6 0.884445 0.884445
|
||||
5 0.114074 0.884445
|
||||
4 0 1
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
4 0 1
|
||||
5 0.114074 0.884445
|
||||
1 0.114074 0.114074
|
||||
0 0 0
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
1 0.114074 0.114074
|
||||
5 0.114074 0.884445
|
||||
6 0.884445 0.884445
|
||||
2 0.884445 0.114074
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
4 0 1
|
||||
0 0 0
|
||||
3 1 0
|
||||
7 1 1
|
||||
kids 0
|
||||
OBJECT poly
|
||||
name "rect"
|
||||
loc -0.0500002 0 -2.5
|
||||
texture "embossed_herring.bmp"
|
||||
texrep 20 30
|
||||
numvert 4
|
||||
-17.95 -0.7 -18.6
|
||||
17.95 -0.7 -18.6
|
||||
17.95 -0.7 18.6
|
||||
-17.95 -0.7 18.6
|
||||
numsurf 1
|
||||
SURF 0x0
|
||||
mat 1
|
||||
refs 4
|
||||
3 0 0
|
||||
2 1 0
|
||||
1 1 1
|
||||
0 0 1
|
||||
kids 0
|
||||
81
examples/src/ssg/tux/data/pedestal.safe
Normal file
81
examples/src/ssg/tux/data/pedestal.safe
Normal file
@@ -0,0 +1,81 @@
|
||||
AC3Db
|
||||
MATERIAL "" rgb 1 1 1 amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10 trans 0
|
||||
MATERIAL "" rgb 1 1 1 amb 0.2 0.2 0.2 emis 1 1 1 spec 0.502 0.502 0.502 shi 0 trans 0
|
||||
OBJECT world
|
||||
kids 2
|
||||
OBJECT poly
|
||||
name "box"
|
||||
texture "wood.rgb"
|
||||
texrep 5 5
|
||||
numvert 8
|
||||
-1.29615 -0.6 -1.29615
|
||||
-1 0 -1
|
||||
1 0 -1
|
||||
1.3 -0.6 -1.29615
|
||||
-1.29615 -0.6 1.3
|
||||
-1 0 1
|
||||
1 0 1
|
||||
1.3 -0.6 1.3
|
||||
numsurf 6
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
0 0 0
|
||||
1 0.114074 0.114074
|
||||
2 0.884445 0.114074
|
||||
3 1 0
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
6 0.884445 0.884445
|
||||
7 1 1
|
||||
3 1 0
|
||||
2 0.884445 0.114074
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
7 1 1
|
||||
6 0.884445 0.884445
|
||||
5 0.114074 0.884445
|
||||
4 0 1
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
4 0 1
|
||||
5 0.114074 0.884445
|
||||
1 0.114074 0.114074
|
||||
0 0 0
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
1 0.114074 0.114074
|
||||
5 0.114074 0.884445
|
||||
6 0.884445 0.884445
|
||||
2 0.884445 0.114074
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
4 0 1
|
||||
0 0 0
|
||||
3 1 0
|
||||
7 1 1
|
||||
kids 0
|
||||
OBJECT poly
|
||||
name "rect"
|
||||
loc -0.0500002 0 -2.5
|
||||
texture "embossed_herring.rgb"
|
||||
texrep 20 30
|
||||
numvert 4
|
||||
-17.95 -0.7 -18.6
|
||||
17.95 -0.7 -18.6
|
||||
17.95 -0.7 18.6
|
||||
-17.95 -0.7 18.6
|
||||
numsurf 1
|
||||
SURF 0x0
|
||||
mat 1
|
||||
refs 4
|
||||
3 0 0
|
||||
2 1 0
|
||||
1 1 1
|
||||
0 0 1
|
||||
kids 0
|
||||
1695
examples/src/ssg/tux/data/tuxedo.ac
Normal file
1695
examples/src/ssg/tux/data/tuxedo.ac
Normal file
File diff suppressed because it is too large
Load Diff
BIN
examples/src/ssg/tux/data/wood.rgb
Normal file
BIN
examples/src/ssg/tux/data/wood.rgb
Normal file
Binary file not shown.
228
examples/src/ssg/tux/tux_example.cxx
Normal file
228
examples/src/ssg/tux/tux_example.cxx
Normal file
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: tux_example.cxx 2099 2006-11-03 20:04:40Z fayjf $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <plib/ssg.h>
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static ssgRoot *scene = NULL ;
|
||||
static ssgTransform *penguin = NULL ;
|
||||
static ssgTransform *pedestal = NULL ;
|
||||
|
||||
|
||||
/*
|
||||
Something to make some interesting motion
|
||||
for both Tux and the camera.
|
||||
*/
|
||||
|
||||
static void update_motion ()
|
||||
{
|
||||
static int frameno = 0 ;
|
||||
|
||||
frameno++ ;
|
||||
|
||||
sgCoord campos ;
|
||||
sgCoord tuxpos ;
|
||||
|
||||
/*
|
||||
Spin Tux, make the camera pan sinusoidally left and right
|
||||
*/
|
||||
|
||||
sgSetCoord ( & campos, 0.0f, -5.0f, 1.0f, 25.0f * (float)sin(frameno/100.0), 0.0f, 0.0f ) ;
|
||||
sgSetCoord ( & tuxpos, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, frameno/100.0f ) ;
|
||||
|
||||
ssgSetCamera ( & campos ) ;
|
||||
penguin -> setTransform ( & tuxpos ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT window reshape event
|
||||
*/
|
||||
|
||||
static void reshape ( int w, int h )
|
||||
{
|
||||
glViewport ( 0, 0, w, h ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT keyboard event
|
||||
*/
|
||||
|
||||
static void keyboard ( unsigned char, int, int )
|
||||
{
|
||||
exit ( 0 ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT redraw event
|
||||
*/
|
||||
|
||||
static void redraw ()
|
||||
{
|
||||
update_motion () ;
|
||||
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
ssgCullAndDraw ( scene ) ;
|
||||
|
||||
glutPostRedisplay () ;
|
||||
glutSwapBuffers () ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void init_graphics ()
|
||||
{
|
||||
int fake_argc = 1 ;
|
||||
char *fake_argv[3] ;
|
||||
fake_argv[0] = "ssgExample" ;
|
||||
fake_argv[1] = "Simple Scene Graph : Example Program." ;
|
||||
fake_argv[2] = NULL ;
|
||||
|
||||
/*
|
||||
Initialise GLUT
|
||||
*/
|
||||
|
||||
glutInitWindowPosition ( 0, 0 ) ;
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInit ( &fake_argc, fake_argv ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
glutCreateWindow ( fake_argv[1] ) ;
|
||||
glutDisplayFunc ( redraw ) ;
|
||||
glutReshapeFunc ( reshape ) ;
|
||||
glutKeyboardFunc ( keyboard ) ;
|
||||
|
||||
/*
|
||||
Initialise SSG
|
||||
*/
|
||||
|
||||
ssgInit () ;
|
||||
|
||||
/*
|
||||
Some basic OpenGL setup
|
||||
*/
|
||||
|
||||
glClearColor ( 0.2f, 0.7f, 1.0f, 1.0f ) ;
|
||||
glEnable ( GL_DEPTH_TEST ) ;
|
||||
|
||||
/*
|
||||
Set up the viewing parameters
|
||||
*/
|
||||
|
||||
ssgSetFOV ( 60.0f, 0.0f ) ;
|
||||
ssgSetNearFar ( 1.0f, 700.0f ) ;
|
||||
|
||||
/*
|
||||
Set up the Sun.
|
||||
*/
|
||||
|
||||
sgVec3 sunposn ;
|
||||
sgSetVec3 ( sunposn, 0.2f, -0.5f, 0.5f ) ;
|
||||
ssgGetLight ( 0 ) -> setPosition ( sunposn ) ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Load a simple database
|
||||
*/
|
||||
|
||||
static void load_database ()
|
||||
{
|
||||
/*
|
||||
Set up the path to the data files
|
||||
*/
|
||||
|
||||
ssgModelPath ( "data" ) ;
|
||||
ssgTexturePath ( "data" ) ;
|
||||
|
||||
/*
|
||||
Create a root node - and a transform to position
|
||||
the pedestal - and another to position the penguin
|
||||
beneath that (in the tree that is).
|
||||
*/
|
||||
|
||||
scene = new ssgRoot ;
|
||||
pedestal = new ssgTransform ;
|
||||
penguin = new ssgTransform ;
|
||||
|
||||
/*
|
||||
Load the models - optimise them a bit
|
||||
and then add them into the scene.
|
||||
*/
|
||||
|
||||
ssgEntity *ped_obj = ssgLoadAC ( "pedestal.ac" ) ;
|
||||
ssgEntity *tux_obj = ssgLoadAC ( "tuxedo.ac" ) ;
|
||||
|
||||
penguin -> addKid ( tux_obj ) ;
|
||||
pedestal -> addKid ( ped_obj ) ;
|
||||
|
||||
ssgFlatten ( tux_obj ) ;
|
||||
ssgFlatten ( ped_obj ) ;
|
||||
ssgStripify ( penguin ) ;
|
||||
ssgStripify ( pedestal ) ;
|
||||
|
||||
pedestal -> addKid ( penguin ) ;
|
||||
scene -> addKid ( pedestal ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The works.
|
||||
*/
|
||||
|
||||
int main ( int, char ** )
|
||||
{
|
||||
init_graphics () ;
|
||||
load_database () ;
|
||||
glutMainLoop () ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
88
examples/src/ssg/tux/tux_example.dsp
Normal file
88
examples/src/ssg/tux/tux_example.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="tux_example" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=tux_example - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "tux_example.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "tux_example.mak" CFG="tux_example - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "tux_example - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "tux_example - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "tux_example - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg.lib sg.lib ul.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /out:"tux_example.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "tux_example - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg_d.lib sg_d.lib ul_d.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /out:"tux_example.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "tux_example - Win32 Release"
|
||||
# Name "tux_example - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tux_example.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
12
examples/src/ssg/tween_test/Makefile.am
Normal file
12
examples/src/ssg/tween_test/Makefile.am
Normal file
@@ -0,0 +1,12 @@
|
||||
if BUILD_SSG
|
||||
|
||||
noinst_PROGRAMS = tween_test
|
||||
|
||||
tween_test_SOURCES = tween_test.cxx
|
||||
|
||||
tween_test_LDADD = -lplibssgaux -lplibssg -lplibsg -lplibpw -lplibul $(OGL_LIBS)
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = tween_test.dsp
|
||||
|
||||
255
examples/src/ssg/tween_test/tween_test.cxx
Normal file
255
examples/src/ssg/tween_test/tween_test.cxx
Normal file
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: tween_test.cxx 2099 2006-11-03 20:04:40Z fayjf $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <GL/gl.h>
|
||||
#include <plib/ssg.h>
|
||||
#include <plib/ssgAux.h>
|
||||
#include <plib/ul.h>
|
||||
#include <plib/pw.h>
|
||||
|
||||
static ssgRoot *scene = NULL ;
|
||||
static ssgTweenController *tween_ctrl = NULL ;
|
||||
|
||||
|
||||
/*
|
||||
Something to make some interesting motion
|
||||
*/
|
||||
|
||||
static void update_motion ()
|
||||
{
|
||||
static int frameno = 0 ;
|
||||
|
||||
frameno++ ;
|
||||
|
||||
sgCoord campos ;
|
||||
|
||||
/*
|
||||
Make the camera pan sinusoidally left and right
|
||||
morphing the sphere/spike as we go.
|
||||
*/
|
||||
|
||||
tween_ctrl -> selectBank ( (float)fabs(sin(frameno/100.0)) ) ;
|
||||
|
||||
sgSetCoord ( & campos, 0.0f, -5.0f, 0.0f, 25.0f * (float)sin(frameno/100.0), 0.0f, 0.0f ) ;
|
||||
ssgSetCamera ( & campos ) ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
The GLUT redraw event
|
||||
*/
|
||||
|
||||
static void redraw ()
|
||||
{
|
||||
glClearColor ( 0.5f, 0.1f, 0.1f, 1.0 ) ;
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
update_motion () ;
|
||||
|
||||
ssgCullAndDraw ( scene ) ;
|
||||
}
|
||||
|
||||
|
||||
static void init_graphics ()
|
||||
{
|
||||
pwInit ( 100, 100, 640, 480, false, "PLIB Window Demo", true, 0 ) ;
|
||||
pwSetCallbacks ( NULL, NULL, NULL, NULL, NULL ) ;
|
||||
|
||||
/*
|
||||
Initialise SSG
|
||||
*/
|
||||
|
||||
ssgInit () ;
|
||||
|
||||
/*
|
||||
Some basic OpenGL setup
|
||||
*/
|
||||
|
||||
glClearColor ( 0.2f, 0.7f, 1.0f, 1.0f ) ;
|
||||
glEnable ( GL_DEPTH_TEST ) ;
|
||||
|
||||
/*
|
||||
Set up the viewing parameters
|
||||
*/
|
||||
|
||||
ssgSetFOV ( 60.0f, 0.0f ) ;
|
||||
ssgSetNearFar ( 1.0f, 700.0f ) ;
|
||||
|
||||
/*
|
||||
Set up the Sun.
|
||||
*/
|
||||
|
||||
sgVec4 black = { 0,0,0,1 } ;
|
||||
sgVec3 sunposn ;
|
||||
sgSetVec3 ( sunposn, 0.2f, -0.0f, 0.5f ) ;
|
||||
ssgGetLight ( 0 ) -> setPosition ( sunposn ) ;
|
||||
ssgGetLight ( 0 ) -> setColour ( GL_SPECULAR, black ) ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Load a simple database
|
||||
*/
|
||||
|
||||
static void load_database ()
|
||||
{
|
||||
/*
|
||||
Create a root node with a Tween controller beneath it.
|
||||
*/
|
||||
|
||||
scene = new ssgRoot ;
|
||||
tween_ctrl = new ssgTweenController ;
|
||||
scene -> addKid ( tween_ctrl ) ;
|
||||
|
||||
/*
|
||||
Construct a sphere (which we'll use as a template
|
||||
and then discard
|
||||
*/
|
||||
|
||||
ssgaSphere *sp = new ssgaSphere ( 100 ) ;
|
||||
|
||||
/*
|
||||
For each ssgVtxTable within the sphere, generate
|
||||
an ssgTween node
|
||||
*/
|
||||
|
||||
for ( int i = 0 ; i < sp -> getNumKids () ; i++ )
|
||||
{
|
||||
ssgVtxTable *vt = (ssgVtxTable *)( sp -> getKid ( i ) ) ;
|
||||
|
||||
assert ( vt -> isAKindOf ( ssgTypeVtxTable () ) ) ;
|
||||
|
||||
/*
|
||||
Make two new sets of vertex array.
|
||||
*/
|
||||
|
||||
ssgVertexArray *v0 = new ssgVertexArray ;
|
||||
ssgNormalArray *n0 = new ssgNormalArray ;
|
||||
ssgTexCoordArray *t0 = new ssgTexCoordArray ;
|
||||
ssgColourArray *c0 = new ssgColourArray ;
|
||||
|
||||
ssgVertexArray *v1 = new ssgVertexArray ;
|
||||
ssgNormalArray *n1 = new ssgNormalArray ;
|
||||
ssgTexCoordArray *t1 = new ssgTexCoordArray ;
|
||||
ssgColourArray *c1 = new ssgColourArray ;
|
||||
|
||||
/*
|
||||
For every vertex in the sphere's VtxTable...
|
||||
*/
|
||||
|
||||
for ( int i = 0 ; i < vt -> getNumVertices () ; i++ )
|
||||
{
|
||||
/*
|
||||
Copy the sphere's vertex (unmolested) into
|
||||
the vertex arrays that are destined to become
|
||||
bank zero.
|
||||
*/
|
||||
|
||||
v0 -> add ( vt -> getVertex (i) ) ;
|
||||
n0 -> add ( vt -> getNormal (i) ) ;
|
||||
t0 -> add ( vt -> getTexCoord (i) ) ;
|
||||
c0 -> add ( vt -> getColour (i) ) ;
|
||||
|
||||
/*
|
||||
For bank one, make some vertices half
|
||||
the usual size - and others twice the
|
||||
usual size. This is a spikey ball.
|
||||
*/
|
||||
|
||||
sgVec3 vx ;
|
||||
sgVec4 co ;
|
||||
|
||||
sgCopyVec3 ( vx, vt -> getVertex (i) ) ;
|
||||
sgScaleVec3 ( vx, (i&7) ? 0.5f : 2.0f ) ;
|
||||
|
||||
/*
|
||||
Put random colours on the vertices.
|
||||
*/
|
||||
|
||||
sgSetVec4 ( co, (float)(rand()&0xFF)/255.0f,
|
||||
(float)(rand()&0xFF)/255.0f,
|
||||
(float)(rand()&0xFF)/255.0f, 1.0f ) ;
|
||||
|
||||
/*
|
||||
Cheat and make the normals and texture coords be
|
||||
the same as the sphere.
|
||||
*/
|
||||
|
||||
v1 -> add ( vx ) ;
|
||||
n1 -> add ( vt -> getNormal (i) ) ;
|
||||
t1 -> add ( vt -> getTexCoord (i) ) ;
|
||||
c1 -> add ( co ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
For each VtxTable in the sphere, create a
|
||||
Tween node that morphs between the sphere
|
||||
and the spikey sphere.
|
||||
*/
|
||||
|
||||
ssgTween *tw = new ssgTween ( GL_TRIANGLE_STRIP ) ;
|
||||
tw -> newBank ( v0, n0, t0, c0 ) ;
|
||||
tw -> newBank ( v1, n1, t1, c1 ) ;
|
||||
|
||||
/*
|
||||
Add it into the tween controller
|
||||
(although there could be a lot of hierarchy
|
||||
between the two if you wanted that)
|
||||
*/
|
||||
|
||||
tween_ctrl -> addKid ( tw ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The works.
|
||||
*/
|
||||
|
||||
int main ( int, char ** )
|
||||
{
|
||||
init_graphics () ;
|
||||
load_database () ;
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
ulMilliSecondSleep ( 16 ) ;
|
||||
redraw () ;
|
||||
pwSwapBuffers () ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
90
examples/src/ssg/tween_test/tween_test.dsp
Normal file
90
examples/src/ssg/tween_test/tween_test.dsp
Normal file
@@ -0,0 +1,90 @@
|
||||
# Microsoft Developer Studio Project File - Name="tween_test" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=tween_test - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "tween_test.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "tween_test.mak" CFG="tween_test - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "tween_test - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "tween_test - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "tween_test - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg.lib sg.lib ul.lib pw.lib winmm.lib opengl32.lib glu32.lib glut32.lib ssgAux.lib /nologo /subsystem:console /machine:I386 /out:"tween_test.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "tween_test - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg_d.lib ssgAux_d.lib sg_d.lib ul_d.lib pw_d.lib winmm.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /out:"tween_test.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "tween_test - Win32 Release"
|
||||
# Name "tween_test - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tween_test.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
17
examples/src/ssg/viewer/Makefile.am
Normal file
17
examples/src/ssg/viewer/Makefile.am
Normal file
@@ -0,0 +1,17 @@
|
||||
if BUILD_SSG
|
||||
|
||||
noinst_PROGRAMS = viewer pview
|
||||
|
||||
viewer_SOURCES = viewer.cxx
|
||||
|
||||
pview_SOURCES = pview.cxx
|
||||
|
||||
viewer_LDADD = -lplibssg -lplibpuaux -lplibpu -lplibfnt -lplibsg -lplibul $(GLUT_LIBS) \
|
||||
$(OGL_LIBS)
|
||||
|
||||
pview_LDADD = -lplibssg -lplibpu -lplibfnt -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS)
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = viewer.dsp
|
||||
|
||||
10
examples/src/ssg/viewer/data/NOTES
Normal file
10
examples/src/ssg/viewer/data/NOTES
Normal file
@@ -0,0 +1,10 @@
|
||||
This directory contains sample VRML scenes made at the IICM.
|
||||
Distribute them freely as long as you mention their origin.
|
||||
They are also available at http://hgiicm.tu-graz.ac.at/C3d.
|
||||
|
||||
Most of the scenes were created with Wavefont's Advanced Visualizer
|
||||
and converted with scripts into SDF, the (old) native format of the
|
||||
Harmony 3D scene viewer. VRweb was used to convert these files into
|
||||
VRML.
|
||||
|
||||
mpichler@iicm.tu-graz.ac.at
|
||||
BIN
examples/src/ssg/viewer/data/Pbody.rgb
Normal file
BIN
examples/src/ssg/viewer/data/Pbody.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/viewer/data/Penguin_beak.rgb
Normal file
BIN
examples/src/ssg/viewer/data/Penguin_beak.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/viewer/data/Penguin_body.rgb
Normal file
BIN
examples/src/ssg/viewer/data/Penguin_body.rgb
Normal file
Binary file not shown.
299
examples/src/ssg/viewer/data/animated.ASE
Normal file
299
examples/src/ssg/viewer/data/animated.ASE
Normal file
@@ -0,0 +1,299 @@
|
||||
*3DSMAX_ASCIIEXPORT 200
|
||||
*COMMENT "AsciiExport Version 2.00 - Sun Oct 24 23:45:37 2004"
|
||||
*SCENE {
|
||||
*SCENE_FILENAME ""
|
||||
*SCENE_FIRSTFRAME 0
|
||||
*SCENE_LASTFRAME 100
|
||||
*SCENE_FRAMESPEED 30
|
||||
*SCENE_TICKSPERFRAME 160
|
||||
*SCENE_BACKGROUND_STATIC 0.0000 0.0000 0.0000
|
||||
*SCENE_AMBIENT_STATIC 0.0000 0.0000 0.0000
|
||||
}
|
||||
*MATERIAL_LIST {
|
||||
*MATERIAL_COUNT 2
|
||||
*MATERIAL 0 {
|
||||
*MATERIAL_NAME "Brown"
|
||||
*MATERIAL_CLASS "Standard"
|
||||
*MATERIAL_AMBIENT 0.5020 0.5020 0.5020
|
||||
*MATERIAL_DIFFUSE 0.5020 0.5020 0.5020
|
||||
*MATERIAL_SPECULAR 0.5020 0.5020 0.5020
|
||||
*MATERIAL_SHINE 0.2500
|
||||
*MATERIAL_SHINESTRENGTH 0.0500
|
||||
*MATERIAL_TRANSPARENCY 0.0000
|
||||
*MATERIAL_WIRESIZE 1.0000
|
||||
*MATERIAL_SHADING Blinn
|
||||
*MATERIAL_XP_FALLOFF 0.0000
|
||||
*MATERIAL_SELFILLUM 0.0000
|
||||
*MATERIAL_FALLOFF In
|
||||
*MATERIAL_XP_TYPE Filter
|
||||
*MAP_DIFFUSE {
|
||||
*MAP_NAME "Map #11"
|
||||
*MAP_CLASS "Bitmap"
|
||||
*MAP_SUBNO 1
|
||||
*MAP_AMOUNT 1.0000
|
||||
*BITMAP "brown.bmp"
|
||||
*MAP_TYPE Screen
|
||||
*UVW_U_OFFSET 0.0000
|
||||
*UVW_V_OFFSET 0.0000
|
||||
*UVW_U_TILING 1.0000
|
||||
*UVW_V_TILING 1.0000
|
||||
*UVW_ANGLE 0.0000
|
||||
*UVW_BLUR 1.0000
|
||||
*UVW_BLUR_OFFSET 0.0000
|
||||
*UVW_NOUSE_AMT 1.0000
|
||||
*UVW_NOISE_SIZE 1.0000
|
||||
*UVW_NOISE_LEVEL 1
|
||||
*UVW_NOISE_PHASE 0.0000
|
||||
*BITMAP_FILTER Pyramidal
|
||||
}
|
||||
}
|
||||
*MATERIAL 1 {
|
||||
*MATERIAL_NAME "Grey"
|
||||
*MATERIAL_CLASS "Standard"
|
||||
*MATERIAL_AMBIENT 0.5020 0.5020 0.5020
|
||||
*MATERIAL_DIFFUSE 0.5020 0.5020 0.5020
|
||||
*MATERIAL_SPECULAR 0.5020 0.5020 0.5020
|
||||
*MATERIAL_SHINE 0.2500
|
||||
*MATERIAL_SHINESTRENGTH 0.0500
|
||||
*MATERIAL_TRANSPARENCY 0.0000
|
||||
*MATERIAL_WIRESIZE 1.0000
|
||||
*MATERIAL_SHADING Blinn
|
||||
*MATERIAL_XP_FALLOFF 0.0000
|
||||
*MATERIAL_SELFILLUM 0.0000
|
||||
*MATERIAL_FALLOFF In
|
||||
*MATERIAL_XP_TYPE Filter
|
||||
*MAP_DIFFUSE {
|
||||
*MAP_NAME "Map #12"
|
||||
*MAP_CLASS "Bitmap"
|
||||
*MAP_SUBNO 1
|
||||
*MAP_AMOUNT 1.0000
|
||||
*BITMAP "gray.bmp"
|
||||
*MAP_TYPE Screen
|
||||
*UVW_U_OFFSET 0.0000
|
||||
*UVW_V_OFFSET 0.0000
|
||||
*UVW_U_TILING 1.0000
|
||||
*UVW_V_TILING 1.0000
|
||||
*UVW_ANGLE 0.0000
|
||||
*UVW_BLUR 1.0000
|
||||
*UVW_BLUR_OFFSET 0.0000
|
||||
*UVW_NOUSE_AMT 1.0000
|
||||
*UVW_NOISE_SIZE 1.0000
|
||||
*UVW_NOISE_LEVEL 1
|
||||
*UVW_NOISE_PHASE 0.0000
|
||||
*BITMAP_FILTER Pyramidal
|
||||
}
|
||||
}
|
||||
}
|
||||
*GEOMOBJECT {
|
||||
*NODE_NAME "Box01"
|
||||
*NODE_TM {
|
||||
*NODE_NAME "Box01"
|
||||
*INHERIT_POS 0 0 0
|
||||
*INHERIT_ROT 0 0 0
|
||||
*INHERIT_SCL 0 0 0
|
||||
*TM_ROW0 1.0000 0.0000 0.0000
|
||||
*TM_ROW1 0.0000 1.0000 0.0000
|
||||
*TM_ROW2 0.0000 0.0000 1.0000
|
||||
*TM_ROW3 0.0000 0.0000 0.0000
|
||||
*TM_POS 0.0000 0.0000 0.0000
|
||||
*TM_ROTAXIS 0.0000 0.0000 0.0000
|
||||
*TM_ROTANGLE 0.0000
|
||||
*TM_SCALE 1.0000 1.0000 1.0000
|
||||
*TM_SCALEAXIS 0.0000 0.0000 0.0000
|
||||
*TM_SCALEAXISANG 0.0000
|
||||
}
|
||||
*MESH {
|
||||
*TIMEVALUE 0
|
||||
*MESH_NUMVERTEX 8
|
||||
*MESH_NUMFACES 12
|
||||
*MESH_VERTEX_LIST {
|
||||
*MESH_VERTEX 0 -5.0000 -5.0000 0.0000
|
||||
*MESH_VERTEX 1 5.0000 -5.0000 0.0000
|
||||
*MESH_VERTEX 2 -5.0000 5.0000 0.0000
|
||||
*MESH_VERTEX 3 5.0000 5.0000 0.0000
|
||||
*MESH_VERTEX 4 -5.0000 -5.0000 2.0000
|
||||
*MESH_VERTEX 5 5.0000 -5.0000 2.0000
|
||||
*MESH_VERTEX 6 -5.0000 5.0000 2.0000
|
||||
*MESH_VERTEX 7 5.0000 5.0000 2.0000
|
||||
}
|
||||
*MESH_FACE_LIST {
|
||||
*MESH_FACE 0: A: 0 B: 2 C: 3 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 2 *MESH_MTLID 1
|
||||
*MESH_FACE 1: A: 3 B: 1 C: 0 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 2 *MESH_MTLID 1
|
||||
*MESH_FACE 2: A: 4 B: 5 C: 7 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 3 *MESH_MTLID 0
|
||||
*MESH_FACE 3: A: 7 B: 6 C: 4 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 3 *MESH_MTLID 0
|
||||
*MESH_FACE 4: A: 0 B: 1 C: 5 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 4 *MESH_MTLID 4
|
||||
*MESH_FACE 5: A: 5 B: 4 C: 0 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 4 *MESH_MTLID 4
|
||||
*MESH_FACE 6: A: 1 B: 3 C: 7 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 5 *MESH_MTLID 3
|
||||
*MESH_FACE 7: A: 7 B: 5 C: 1 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 5 *MESH_MTLID 3
|
||||
*MESH_FACE 8: A: 3 B: 2 C: 6 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 6 *MESH_MTLID 5
|
||||
*MESH_FACE 9: A: 6 B: 7 C: 3 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 6 *MESH_MTLID 5
|
||||
*MESH_FACE 10: A: 2 B: 0 C: 4 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 7 *MESH_MTLID 2
|
||||
*MESH_FACE 11: A: 4 B: 6 C: 2 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 7 *MESH_MTLID 2
|
||||
}
|
||||
*MESH_NUMTVERTEX 0
|
||||
*MESH_NORMALS {
|
||||
*MESH_FACENORMAL 0 0.0000 0.0000 -1.0000
|
||||
*MESH_VERTEXNORMAL 0 0.0000 0.0000 -1.0000
|
||||
*MESH_VERTEXNORMAL 2 0.0000 0.0000 -1.0000
|
||||
*MESH_VERTEXNORMAL 3 0.0000 0.0000 -1.0000
|
||||
*MESH_FACENORMAL 1 0.0000 0.0000 -1.0000
|
||||
*MESH_VERTEXNORMAL 3 0.0000 0.0000 -1.0000
|
||||
*MESH_VERTEXNORMAL 1 0.0000 0.0000 -1.0000
|
||||
*MESH_VERTEXNORMAL 0 0.0000 0.0000 -1.0000
|
||||
*MESH_FACENORMAL 2 0.0000 0.0000 1.0000
|
||||
*MESH_VERTEXNORMAL 4 0.0000 0.0000 1.0000
|
||||
*MESH_VERTEXNORMAL 5 0.0000 0.0000 1.0000
|
||||
*MESH_VERTEXNORMAL 7 0.0000 0.0000 1.0000
|
||||
*MESH_FACENORMAL 3 0.0000 0.0000 1.0000
|
||||
*MESH_VERTEXNORMAL 7 0.0000 0.0000 1.0000
|
||||
*MESH_VERTEXNORMAL 6 0.0000 0.0000 1.0000
|
||||
*MESH_VERTEXNORMAL 4 0.0000 0.0000 1.0000
|
||||
*MESH_FACENORMAL 4 0.0000 -1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 0 0.0000 -1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 1 0.0000 -1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 5 0.0000 -1.0000 0.0000
|
||||
*MESH_FACENORMAL 5 0.0000 -1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 5 0.0000 -1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 4 0.0000 -1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 0 0.0000 -1.0000 0.0000
|
||||
*MESH_FACENORMAL 6 1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 1 1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 3 1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 7 1.0000 0.0000 0.0000
|
||||
*MESH_FACENORMAL 7 1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 7 1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 5 1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 1 1.0000 0.0000 0.0000
|
||||
*MESH_FACENORMAL 8 0.0000 1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 3 0.0000 1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 2 0.0000 1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 6 0.0000 1.0000 0.0000
|
||||
*MESH_FACENORMAL 9 0.0000 1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 6 0.0000 1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 7 0.0000 1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 3 0.0000 1.0000 0.0000
|
||||
*MESH_FACENORMAL 10 -1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 2 -1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 0 -1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 4 -1.0000 0.0000 0.0000
|
||||
*MESH_FACENORMAL 11 -1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 4 -1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 6 -1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 2 -1.0000 0.0000 0.0000
|
||||
}
|
||||
}
|
||||
*PROP_MOTIONBLUR 0
|
||||
*PROP_CASTSHADOW 1
|
||||
*PROP_RECVSHADOW 1
|
||||
*WIREFRAME_COLOR 0.5255 0.0235 0.0235
|
||||
}
|
||||
*GEOMOBJECT {
|
||||
*NODE_NAME "Box02"
|
||||
*NODE_TM {
|
||||
*NODE_NAME "Box02"
|
||||
*INHERIT_POS 0 0 0
|
||||
*INHERIT_ROT 0 0 0
|
||||
*INHERIT_SCL 0 0 0
|
||||
*TM_ROW0 1.0000 0.0000 0.0000
|
||||
*TM_ROW1 0.0000 1.0000 0.0000
|
||||
*TM_ROW2 0.0000 0.0000 1.0000
|
||||
*TM_ROW3 5.0000 0.0000 0.0000
|
||||
*TM_POS 5.0000 0.0000 0.0000
|
||||
*TM_ROTAXIS 0.0000 0.0000 0.0000
|
||||
*TM_ROTANGLE 0.0000
|
||||
*TM_SCALE 1.0000 1.0000 1.0000
|
||||
*TM_SCALEAXIS 0.0000 0.0000 0.0000
|
||||
*TM_SCALEAXISANG 0.0000
|
||||
}
|
||||
*MESH {
|
||||
*TIMEVALUE 0
|
||||
*MESH_NUMVERTEX 8
|
||||
*MESH_NUMFACES 12
|
||||
*MESH_VERTEX_LIST {
|
||||
*MESH_VERTEX 0 5.0000 -5.0000 0.0000
|
||||
*MESH_VERTEX 1 15.0000 -5.0000 0.0000
|
||||
*MESH_VERTEX 2 5.0000 5.0000 0.0000
|
||||
*MESH_VERTEX 3 15.0000 5.0000 0.0000
|
||||
*MESH_VERTEX 4 5.0000 -5.0000 2.0000
|
||||
*MESH_VERTEX 5 15.0000 -5.0000 2.0000
|
||||
*MESH_VERTEX 6 5.0000 5.0000 2.0000
|
||||
*MESH_VERTEX 7 15.0000 5.0000 2.0000
|
||||
}
|
||||
*MESH_FACE_LIST {
|
||||
*MESH_FACE 0: A: 0 B: 2 C: 3 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 2 *MESH_MTLID 1
|
||||
*MESH_FACE 1: A: 3 B: 1 C: 0 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 2 *MESH_MTLID 1
|
||||
*MESH_FACE 2: A: 4 B: 5 C: 7 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 3 *MESH_MTLID 0
|
||||
*MESH_FACE 3: A: 7 B: 6 C: 4 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 3 *MESH_MTLID 0
|
||||
*MESH_FACE 4: A: 0 B: 1 C: 5 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 4 *MESH_MTLID 4
|
||||
*MESH_FACE 5: A: 5 B: 4 C: 0 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 4 *MESH_MTLID 4
|
||||
*MESH_FACE 6: A: 1 B: 3 C: 7 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 5 *MESH_MTLID 3
|
||||
*MESH_FACE 7: A: 7 B: 5 C: 1 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 5 *MESH_MTLID 3
|
||||
*MESH_FACE 8: A: 3 B: 2 C: 6 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 6 *MESH_MTLID 5
|
||||
*MESH_FACE 9: A: 6 B: 7 C: 3 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 6 *MESH_MTLID 5
|
||||
*MESH_FACE 10: A: 2 B: 0 C: 4 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 7 *MESH_MTLID 2
|
||||
*MESH_FACE 11: A: 4 B: 6 C: 2 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 7 *MESH_MTLID 2
|
||||
}
|
||||
*MESH_NUMTVERTEX 0
|
||||
*MESH_NORMALS {
|
||||
*MESH_FACENORMAL 0 0.0000 0.0000 -1.0000
|
||||
*MESH_VERTEXNORMAL 0 0.0000 0.0000 -1.0000
|
||||
*MESH_VERTEXNORMAL 2 0.0000 0.0000 -1.0000
|
||||
*MESH_VERTEXNORMAL 3 0.0000 0.0000 -1.0000
|
||||
*MESH_FACENORMAL 1 0.0000 0.0000 -1.0000
|
||||
*MESH_VERTEXNORMAL 3 0.0000 0.0000 -1.0000
|
||||
*MESH_VERTEXNORMAL 1 0.0000 0.0000 -1.0000
|
||||
*MESH_VERTEXNORMAL 0 0.0000 0.0000 -1.0000
|
||||
*MESH_FACENORMAL 2 0.0000 0.0000 1.0000
|
||||
*MESH_VERTEXNORMAL 4 0.0000 0.0000 1.0000
|
||||
*MESH_VERTEXNORMAL 5 0.0000 0.0000 1.0000
|
||||
*MESH_VERTEXNORMAL 7 0.0000 0.0000 1.0000
|
||||
*MESH_FACENORMAL 3 0.0000 0.0000 1.0000
|
||||
*MESH_VERTEXNORMAL 7 0.0000 0.0000 1.0000
|
||||
*MESH_VERTEXNORMAL 6 0.0000 0.0000 1.0000
|
||||
*MESH_VERTEXNORMAL 4 0.0000 0.0000 1.0000
|
||||
*MESH_FACENORMAL 4 0.0000 -1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 0 0.0000 -1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 1 0.0000 -1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 5 0.0000 -1.0000 0.0000
|
||||
*MESH_FACENORMAL 5 0.0000 -1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 5 0.0000 -1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 4 0.0000 -1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 0 0.0000 -1.0000 0.0000
|
||||
*MESH_FACENORMAL 6 1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 1 1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 3 1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 7 1.0000 0.0000 0.0000
|
||||
*MESH_FACENORMAL 7 1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 7 1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 5 1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 1 1.0000 0.0000 0.0000
|
||||
*MESH_FACENORMAL 8 0.0000 1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 3 0.0000 1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 2 0.0000 1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 6 0.0000 1.0000 0.0000
|
||||
*MESH_FACENORMAL 9 0.0000 1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 6 0.0000 1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 7 0.0000 1.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 3 0.0000 1.0000 0.0000
|
||||
*MESH_FACENORMAL 10 -1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 2 -1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 0 -1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 4 -1.0000 0.0000 0.0000
|
||||
*MESH_FACENORMAL 11 -1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 4 -1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 6 -1.0000 0.0000 0.0000
|
||||
*MESH_VERTEXNORMAL 2 -1.0000 0.0000 0.0000
|
||||
}
|
||||
}
|
||||
*PROP_MOTIONBLUR 0
|
||||
*PROP_CASTSHADOW 1
|
||||
*PROP_RECVSHADOW 1
|
||||
*TM_ANIMATION {
|
||||
*NODE_NAME "Box02"
|
||||
*CONTROL_ROT_TCB {
|
||||
*CONTROL_TCB_ROT_KEY 0 1.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
|
||||
*CONTROL_TCB_ROT_KEY 1600 0.0000 -1.0000 -0.0000 0.3491 0.0000 0.0000 0.0000 0.0000 0.0000
|
||||
}
|
||||
}
|
||||
*WIREFRAME_COLOR 0.2235 0.0314 0.5333
|
||||
}
|
||||
571
examples/src/ssg/viewer/data/ant_vr.wrl
Normal file
571
examples/src/ssg/viewer/data/ant_vr.wrl
Normal file
@@ -0,0 +1,571 @@
|
||||
#VRML V1.0 ascii
|
||||
|
||||
Separator {
|
||||
|
||||
DEF SceneInfo Info {
|
||||
string "Converted by wcvt2pov v2.6c and the datafat munger"
|
||||
}
|
||||
DEF RearBody Separator {
|
||||
Material {
|
||||
diffuseColor 0.36 0.20 0.09
|
||||
ambientColor 0.03 0.02 0
|
||||
}
|
||||
Coordinate3 {
|
||||
point [
|
||||
-0.08 0.17 0.70,
|
||||
-0.08 0.01 0.70,
|
||||
-0.24 -0.15 0.52,
|
||||
-0.24 0.34 0.52,
|
||||
0.08 0.01 0.70,
|
||||
0.24 -0.15 0.52,
|
||||
0.08 0.17 0.70,
|
||||
0.24 0.34 0.52,
|
||||
-0.21 -0.12 0.19,
|
||||
-0.21 0.31 0.19,
|
||||
0.21 -0.12 0.19,
|
||||
0.21 0.31 0.19,
|
||||
-0.08 0.01 0,
|
||||
-0.08 0.17 0,
|
||||
0.08 0.01 0,
|
||||
0.08 0.17 0,
|
||||
-0 0.09 0.70,
|
||||
-0 0.09 0
|
||||
]
|
||||
}
|
||||
|
||||
IndexedFaceSet {
|
||||
coordIndex [
|
||||
2, 1, 0, -1,
|
||||
3, 2, 0, -1,
|
||||
5, 4, 1, -1,
|
||||
2, 5, 1, -1,
|
||||
7, 6, 4, -1,
|
||||
5, 7, 4, -1,
|
||||
3, 0, 6, -1,
|
||||
7, 3, 6, -1,
|
||||
8, 2, 3, -1,
|
||||
9, 8, 3, -1,
|
||||
10, 5, 2, -1,
|
||||
8, 10, 2, -1,
|
||||
11, 7, 5, -1,
|
||||
10, 11, 5, -1,
|
||||
9, 3, 7, -1,
|
||||
11, 9, 7, -1,
|
||||
12, 8, 9, -1,
|
||||
13, 12, 9, -1,
|
||||
14, 10, 8, -1,
|
||||
12, 14, 8, -1,
|
||||
15, 11, 10, -1,
|
||||
14, 15, 10, -1,
|
||||
13, 9, 11, -1,
|
||||
15, 13, 11, -1,
|
||||
16, 0, 1, -1,
|
||||
16, 1, 4, -1,
|
||||
16, 4, 6, -1,
|
||||
16, 6, 0, -1,
|
||||
17, 12, 13, -1,
|
||||
17, 14, 12, -1,
|
||||
17, 15, 14, -1,
|
||||
17, 13, 15, -1
|
||||
]
|
||||
}
|
||||
}
|
||||
DEF MidBody Separator {
|
||||
Material {
|
||||
diffuseColor 0.36 0.20 0.09
|
||||
ambientColor 0.03 0.02 0
|
||||
}
|
||||
Coordinate3 {
|
||||
point [
|
||||
-0.10 -0 -0.29,
|
||||
-0.10 0.19 -0.29,
|
||||
-0.13 0.22 -0.14,
|
||||
-0.13 -0.03 -0.14,
|
||||
0.09 0.19 -0.29,
|
||||
0.13 0.22 -0.14,
|
||||
0.09 -0 -0.29,
|
||||
0.13 -0.03 -0.14,
|
||||
-0.10 0.19 0,
|
||||
-0.10 -0 0,
|
||||
0.09 0.19 0,
|
||||
0.09 -0 0,
|
||||
-0 0.09 -0.29,
|
||||
-0 0.09 0
|
||||
]
|
||||
}
|
||||
|
||||
IndexedFaceSet {
|
||||
coordIndex [
|
||||
2, 1, 0, -1,
|
||||
3, 2, 0, -1,
|
||||
5, 4, 1, -1,
|
||||
2, 5, 1, -1,
|
||||
7, 6, 4, -1,
|
||||
5, 7, 4, -1,
|
||||
3, 0, 6, -1,
|
||||
7, 3, 6, -1,
|
||||
8, 2, 3, -1,
|
||||
9, 8, 3, -1,
|
||||
10, 5, 2, -1,
|
||||
8, 10, 2, -1,
|
||||
11, 7, 5, -1,
|
||||
10, 11, 5, -1,
|
||||
9, 3, 7, -1,
|
||||
11, 9, 7, -1,
|
||||
12, 0, 1, -1,
|
||||
12, 1, 4, -1,
|
||||
12, 4, 6, -1,
|
||||
12, 6, 0, -1,
|
||||
13, 8, 9, -1,
|
||||
13, 10, 8, -1,
|
||||
13, 11, 10, -1,
|
||||
13, 9, 11, -1
|
||||
]
|
||||
}
|
||||
}
|
||||
DEF Head Separator {
|
||||
Material {
|
||||
diffuseColor 0.36 0.20 0.09
|
||||
ambientColor 0.03 0.02 0
|
||||
}
|
||||
Coordinate3 {
|
||||
point [
|
||||
-0.10 0.19 -0.30,
|
||||
-0.15 0.25 -0.41,
|
||||
0.10 0.19 -0.30,
|
||||
0.15 0.25 -0.41,
|
||||
-0.10 -0.01 -0.30,
|
||||
-0.15 -0.06 -0.41,
|
||||
0.10 -0.01 -0.30,
|
||||
0.15 -0.06 -0.41,
|
||||
-0.10 0.19 -0.52,
|
||||
0.10 0.19 -0.52,
|
||||
-0.05 0.02 -0.65,
|
||||
0.05 0.02 -0.65,
|
||||
-0 0.09 -0.30,
|
||||
-0 0.11 -0.59
|
||||
]
|
||||
}
|
||||
|
||||
IndexedFaceSet {
|
||||
coordIndex [
|
||||
2, 1, 0, -1,
|
||||
2, 3, 1, -1,
|
||||
0, 5, 4, -1,
|
||||
0, 1, 5, -1,
|
||||
4, 7, 6, -1,
|
||||
4, 5, 7, -1,
|
||||
6, 3, 2, -1,
|
||||
6, 7, 3, -1,
|
||||
3, 8, 1, -1,
|
||||
3, 9, 8, -1,
|
||||
1, 10, 5, -1,
|
||||
1, 8, 10, -1,
|
||||
5, 11, 7, -1,
|
||||
5, 10, 11, -1,
|
||||
7, 9, 3, -1,
|
||||
7, 11, 9, -1,
|
||||
0, 12, 2, -1,
|
||||
4, 12, 0, -1,
|
||||
6, 12, 4, -1,
|
||||
2, 12, 6, -1,
|
||||
9, 13, 8, -1,
|
||||
8, 13, 10, -1,
|
||||
10, 13, 11, -1,
|
||||
11, 13, 9, -1
|
||||
]
|
||||
}
|
||||
}
|
||||
DEF RightFrontLeg Separator {
|
||||
Material {
|
||||
diffuseColor 0.36 0.20 0.09
|
||||
ambientColor 0.03 0.02 0
|
||||
}
|
||||
Coordinate3 {
|
||||
point [
|
||||
-0.61 -0.34 -0.70,
|
||||
-0.61 -0.34 -0.70,
|
||||
-0.55 -0.09 -0.67,
|
||||
-0.57 -0.09 -0.64,
|
||||
-0.61 -0.34 -0.70,
|
||||
-0.52 -0.11 -0.65,
|
||||
-0.61 -0.34 -0.70,
|
||||
-0.55 -0.11 -0.62,
|
||||
-0.29 0.10 -0.46,
|
||||
-0.32 0.10 -0.42,
|
||||
-0.27 0.06 -0.45,
|
||||
-0.30 0.06 -0.41,
|
||||
-0.04 0.10 -0.25,
|
||||
-0.07 0.10 -0.22,
|
||||
-0.04 0.05 -0.25,
|
||||
-0.07 0.05 -0.22,
|
||||
-0.61 -0.34 -0.70,
|
||||
-0.06 0.08 -0.24
|
||||
]
|
||||
}
|
||||
|
||||
IndexedFaceSet {
|
||||
coordIndex [
|
||||
2, 1, 0, -1,
|
||||
3, 2, 0, -1,
|
||||
5, 4, 1, -1,
|
||||
2, 5, 1, -1,
|
||||
7, 6, 4, -1,
|
||||
5, 7, 4, -1,
|
||||
3, 0, 6, -1,
|
||||
7, 3, 6, -1,
|
||||
8, 2, 3, -1,
|
||||
9, 8, 3, -1,
|
||||
10, 5, 2, -1,
|
||||
8, 10, 2, -1,
|
||||
11, 7, 5, -1,
|
||||
10, 11, 5, -1,
|
||||
9, 3, 7, -1,
|
||||
11, 9, 7, -1,
|
||||
12, 8, 9, -1,
|
||||
13, 12, 9, -1,
|
||||
14, 10, 8, -1,
|
||||
12, 14, 8, -1,
|
||||
15, 11, 10, -1,
|
||||
14, 15, 10, -1,
|
||||
13, 9, 11, -1,
|
||||
15, 13, 11, -1,
|
||||
16, 0, 1, -1,
|
||||
16, 1, 4, -1,
|
||||
16, 4, 6, -1,
|
||||
16, 6, 0, -1,
|
||||
17, 12, 13, -1,
|
||||
17, 14, 12, -1,
|
||||
17, 15, 14, -1,
|
||||
17, 13, 15, -1
|
||||
]
|
||||
}
|
||||
}
|
||||
DEF Right3rdLeg Separator {
|
||||
Material {
|
||||
diffuseColor 0.36 0.20 0.09
|
||||
ambientColor 0.03 0.02 0
|
||||
}
|
||||
Coordinate3 {
|
||||
point [
|
||||
-0.80 -0.34 0.01,
|
||||
-0.80 -0.34 0.01,
|
||||
-0.73 -0.09 -0.01,
|
||||
-0.72 -0.09 0.01,
|
||||
-0.80 -0.34 0.01,
|
||||
-0.70 -0.11 -0.01,
|
||||
-0.79 -0.34 0.01,
|
||||
-0.69 -0.11 0.01,
|
||||
-0.40 0.10 -0.07,
|
||||
-0.40 0.10 -0.03,
|
||||
-0.38 0.06 -0.08,
|
||||
-0.37 0.06 -0.03,
|
||||
-0.09 0.10 -0.13,
|
||||
-0.08 0.10 -0.08,
|
||||
-0.09 0.05 -0.13,
|
||||
-0.08 0.05 -0.08,
|
||||
-0.80 -0.34 0.01,
|
||||
-0.08 0.08 -0.11
|
||||
]
|
||||
}
|
||||
|
||||
IndexedFaceSet {
|
||||
coordIndex [
|
||||
2, 1, 0, -1,
|
||||
3, 2, 0, -1,
|
||||
5, 4, 1, -1,
|
||||
2, 5, 1, -1,
|
||||
7, 6, 4, -1,
|
||||
5, 7, 4, -1,
|
||||
3, 0, 6, -1,
|
||||
7, 3, 6, -1,
|
||||
8, 2, 3, -1,
|
||||
9, 8, 3, -1,
|
||||
10, 5, 2, -1,
|
||||
8, 10, 2, -1,
|
||||
11, 7, 5, -1,
|
||||
10, 11, 5, -1,
|
||||
9, 3, 7, -1,
|
||||
11, 9, 7, -1,
|
||||
12, 8, 9, -1,
|
||||
13, 12, 9, -1,
|
||||
14, 10, 8, -1,
|
||||
12, 14, 8, -1,
|
||||
15, 11, 10, -1,
|
||||
14, 15, 10, -1,
|
||||
13, 9, 11, -1,
|
||||
15, 13, 11, -1,
|
||||
16, 0, 1, -1,
|
||||
16, 1, 4, -1,
|
||||
16, 4, 6, -1,
|
||||
16, 6, 0, -1,
|
||||
17, 12, 13, -1,
|
||||
17, 14, 12, -1,
|
||||
17, 15, 14, -1,
|
||||
17, 13, 15, -1
|
||||
]
|
||||
}
|
||||
}
|
||||
DEF RightRearLeg Separator {
|
||||
Material {
|
||||
diffuseColor 0.36 0.20 0.09
|
||||
ambientColor 0.03 0.02 0
|
||||
}
|
||||
Coordinate3 {
|
||||
point [
|
||||
-0.62 -0.34 0.41,
|
||||
-0.63 -0.34 0.41,
|
||||
-0.58 -0.09 0.35,
|
||||
-0.56 -0.09 0.38,
|
||||
-0.62 -0.34 0.41,
|
||||
-0.56 -0.11 0.33,
|
||||
-0.62 -0.34 0.41,
|
||||
-0.54 -0.11 0.36,
|
||||
-0.33 0.10 0.13,
|
||||
-0.30 0.10 0.17,
|
||||
-0.31 0.06 0.12,
|
||||
-0.28 0.06 0.15,
|
||||
-0.09 0.10 -0.06,
|
||||
-0.06 0.10 -0.03,
|
||||
-0.09 0.05 -0.06,
|
||||
-0.06 0.05 -0.03,
|
||||
-0.62 -0.34 0.41,
|
||||
-0.07 0.08 -0.05
|
||||
]
|
||||
}
|
||||
|
||||
IndexedFaceSet {
|
||||
coordIndex [
|
||||
2, 1, 0, -1,
|
||||
3, 2, 0, -1,
|
||||
5, 4, 1, -1,
|
||||
2, 5, 1, -1,
|
||||
7, 6, 4, -1,
|
||||
5, 7, 4, -1,
|
||||
3, 0, 6, -1,
|
||||
7, 3, 6, -1,
|
||||
8, 2, 3, -1,
|
||||
9, 8, 3, -1,
|
||||
10, 5, 2, -1,
|
||||
8, 10, 2, -1,
|
||||
11, 7, 5, -1,
|
||||
10, 11, 5, -1,
|
||||
9, 3, 7, -1,
|
||||
11, 9, 7, -1,
|
||||
12, 8, 9, -1,
|
||||
13, 12, 9, -1,
|
||||
14, 10, 8, -1,
|
||||
12, 14, 8, -1,
|
||||
15, 11, 10, -1,
|
||||
14, 15, 10, -1,
|
||||
13, 9, 11, -1,
|
||||
15, 13, 11, -1,
|
||||
16, 0, 1, -1,
|
||||
16, 1, 4, -1,
|
||||
16, 4, 6, -1,
|
||||
16, 6, 0, -1,
|
||||
17, 12, 13, -1,
|
||||
17, 14, 12, -1,
|
||||
17, 15, 14, -1,
|
||||
17, 13, 15, -1
|
||||
]
|
||||
}
|
||||
}
|
||||
DEF LeftFrontLeg Separator {
|
||||
Material {
|
||||
diffuseColor 0.36 0.20 0.09
|
||||
ambientColor 0.03 0.02 0
|
||||
}
|
||||
Coordinate3 {
|
||||
point [
|
||||
0.55 -0.09 -0.67,
|
||||
0.61 -0.34 -0.70,
|
||||
0.61 -0.34 -0.70,
|
||||
0.57 -0.09 -0.64,
|
||||
0.52 -0.11 -0.65,
|
||||
0.61 -0.34 -0.70,
|
||||
0.55 -0.11 -0.62,
|
||||
0.61 -0.34 -0.70,
|
||||
0.29 0.10 -0.46,
|
||||
0.32 0.10 -0.42,
|
||||
0.27 0.06 -0.45,
|
||||
0.30 0.06 -0.41,
|
||||
0.04 0.10 -0.25,
|
||||
0.07 0.10 -0.22,
|
||||
0.04 0.05 -0.25,
|
||||
0.07 0.05 -0.22,
|
||||
0.61 -0.34 -0.70,
|
||||
0.06 0.08 -0.24
|
||||
]
|
||||
}
|
||||
|
||||
IndexedFaceSet {
|
||||
coordIndex [
|
||||
2, 1, 0, -1,
|
||||
2, 0, 3, -1,
|
||||
1, 5, 4, -1,
|
||||
1, 4, 0, -1,
|
||||
5, 7, 6, -1,
|
||||
5, 6, 4, -1,
|
||||
7, 2, 3, -1,
|
||||
7, 3, 6, -1,
|
||||
3, 0, 8, -1,
|
||||
3, 8, 9, -1,
|
||||
0, 4, 10, -1,
|
||||
0, 10, 8, -1,
|
||||
4, 6, 11, -1,
|
||||
4, 11, 10, -1,
|
||||
6, 3, 9, -1,
|
||||
6, 9, 11, -1,
|
||||
9, 8, 12, -1,
|
||||
9, 12, 13, -1,
|
||||
8, 10, 14, -1,
|
||||
8, 14, 12, -1,
|
||||
10, 11, 15, -1,
|
||||
10, 15, 14, -1,
|
||||
11, 9, 13, -1,
|
||||
11, 13, 15, -1,
|
||||
1, 2, 16, -1,
|
||||
5, 1, 16, -1,
|
||||
7, 5, 16, -1,
|
||||
2, 7, 16, -1,
|
||||
13, 12, 17, -1,
|
||||
12, 14, 17, -1,
|
||||
14, 15, 17, -1,
|
||||
15, 13, 17, -1
|
||||
]
|
||||
}
|
||||
}
|
||||
DEF Left3rdLeg Separator {
|
||||
Material {
|
||||
diffuseColor 0.36 0.20 0.09
|
||||
ambientColor 0.03 0.02 0
|
||||
}
|
||||
Coordinate3 {
|
||||
point [
|
||||
0.73 -0.09 -0.01,
|
||||
0.80 -0.34 0.01,
|
||||
0.80 -0.34 0.01,
|
||||
0.72 -0.09 0.01,
|
||||
0.70 -0.11 -0.01,
|
||||
0.80 -0.34 0.01,
|
||||
0.69 -0.11 0.01,
|
||||
0.79 -0.34 0.01,
|
||||
0.40 0.10 -0.07,
|
||||
0.40 0.10 -0.03,
|
||||
0.38 0.06 -0.08,
|
||||
0.37 0.06 -0.03,
|
||||
0.09 0.10 -0.13,
|
||||
0.08 0.10 -0.08,
|
||||
0.09 0.05 -0.13,
|
||||
0.08 0.05 -0.08,
|
||||
0.80 -0.34 0.01,
|
||||
0.08 0.08 -0.11
|
||||
]
|
||||
}
|
||||
|
||||
IndexedFaceSet {
|
||||
coordIndex [
|
||||
2, 1, 0, -1,
|
||||
2, 0, 3, -1,
|
||||
1, 5, 4, -1,
|
||||
1, 4, 0, -1,
|
||||
5, 7, 6, -1,
|
||||
5, 6, 4, -1,
|
||||
7, 2, 3, -1,
|
||||
7, 3, 6, -1,
|
||||
3, 0, 8, -1,
|
||||
3, 8, 9, -1,
|
||||
0, 4, 10, -1,
|
||||
0, 10, 8, -1,
|
||||
4, 6, 11, -1,
|
||||
4, 11, 10, -1,
|
||||
6, 3, 9, -1,
|
||||
6, 9, 11, -1,
|
||||
9, 8, 12, -1,
|
||||
9, 12, 13, -1,
|
||||
8, 10, 14, -1,
|
||||
8, 14, 12, -1,
|
||||
10, 11, 15, -1,
|
||||
10, 15, 14, -1,
|
||||
11, 9, 13, -1,
|
||||
11, 13, 15, -1,
|
||||
1, 2, 16, -1,
|
||||
5, 1, 16, -1,
|
||||
7, 5, 16, -1,
|
||||
2, 7, 16, -1,
|
||||
13, 12, 17, -1,
|
||||
12, 14, 17, -1,
|
||||
14, 15, 17, -1,
|
||||
15, 13, 17, -1
|
||||
]
|
||||
}
|
||||
}
|
||||
DEF LeftRearLeg Separator {
|
||||
Material {
|
||||
diffuseColor 0.36 0.20 0.09
|
||||
ambientColor 0.03 0.02 0
|
||||
}
|
||||
Coordinate3 {
|
||||
point [
|
||||
0.58 -0.09 0.35,
|
||||
0.63 -0.34 0.41,
|
||||
0.62 -0.34 0.41,
|
||||
0.56 -0.09 0.38,
|
||||
0.56 -0.11 0.33,
|
||||
0.62 -0.34 0.41,
|
||||
0.54 -0.11 0.36,
|
||||
0.62 -0.34 0.41,
|
||||
0.33 0.10 0.13,
|
||||
0.30 0.10 0.17,
|
||||
0.31 0.06 0.12,
|
||||
0.28 0.06 0.15,
|
||||
0.09 0.10 -0.06,
|
||||
0.06 0.10 -0.03,
|
||||
0.09 0.05 -0.06,
|
||||
0.06 0.05 -0.03,
|
||||
0.62 -0.34 0.41,
|
||||
0.07 0.08 -0.05
|
||||
]
|
||||
}
|
||||
|
||||
IndexedFaceSet {
|
||||
coordIndex [
|
||||
2, 1, 0, -1,
|
||||
2, 0, 3, -1,
|
||||
1, 5, 4, -1,
|
||||
1, 4, 0, -1,
|
||||
5, 7, 6, -1,
|
||||
5, 6, 4, -1,
|
||||
7, 2, 3, -1,
|
||||
7, 3, 6, -1,
|
||||
3, 0, 8, -1,
|
||||
3, 8, 9, -1,
|
||||
0, 4, 10, -1,
|
||||
0, 10, 8, -1,
|
||||
4, 6, 11, -1,
|
||||
4, 11, 10, -1,
|
||||
6, 3, 9, -1,
|
||||
6, 9, 11, -1,
|
||||
9, 8, 12, -1,
|
||||
9, 12, 13, -1,
|
||||
8, 10, 14, -1,
|
||||
8, 14, 12, -1,
|
||||
10, 11, 15, -1,
|
||||
10, 15, 14, -1,
|
||||
11, 9, 13, -1,
|
||||
11, 13, 15, -1,
|
||||
1, 2, 16, -1,
|
||||
5, 1, 16, -1,
|
||||
7, 5, 16, -1,
|
||||
2, 7, 16, -1,
|
||||
13, 12, 17, -1,
|
||||
12, 14, 17, -1,
|
||||
14, 15, 17, -1,
|
||||
15, 13, 17, -1
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BIN
examples/src/ssg/viewer/data/brown.bmp
Normal file
BIN
examples/src/ssg/viewer/data/brown.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
examples/src/ssg/viewer/data/default.txf
Normal file
BIN
examples/src/ssg/viewer/data/default.txf
Normal file
Binary file not shown.
2978
examples/src/ssg/viewer/data/door.ase
Normal file
2978
examples/src/ssg/viewer/data/door.ase
Normal file
File diff suppressed because it is too large
Load Diff
BIN
examples/src/ssg/viewer/data/embossed_herring.bmp
Normal file
BIN
examples/src/ssg/viewer/data/embossed_herring.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
BIN
examples/src/ssg/viewer/data/gray.bmp
Normal file
BIN
examples/src/ssg/viewer/data/gray.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
81
examples/src/ssg/viewer/data/pedestal.ac
Normal file
81
examples/src/ssg/viewer/data/pedestal.ac
Normal file
@@ -0,0 +1,81 @@
|
||||
AC3Db
|
||||
MATERIAL "" rgb 1 1 1 amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10 trans 0
|
||||
MATERIAL "" rgb 1 1 1 amb 0.2 0.2 0.2 emis 1 1 1 spec 0.502 0.502 0.502 shi 0 trans 0
|
||||
OBJECT world
|
||||
kids 2
|
||||
OBJECT poly
|
||||
name "box"
|
||||
texture "wood.rgb"
|
||||
texrep 5 5
|
||||
numvert 8
|
||||
-1.29615 -0.6 -1.29615
|
||||
-1 0 -1
|
||||
1 0 -1
|
||||
1.3 -0.6 -1.29615
|
||||
-1.29615 -0.6 1.3
|
||||
-1 0 1
|
||||
1 0 1
|
||||
1.3 -0.6 1.3
|
||||
numsurf 6
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
0 0 0
|
||||
1 0.114074 0.114074
|
||||
2 0.884445 0.114074
|
||||
3 1 0
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
6 0.884445 0.884445
|
||||
7 1 1
|
||||
3 1 0
|
||||
2 0.884445 0.114074
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
7 1 1
|
||||
6 0.884445 0.884445
|
||||
5 0.114074 0.884445
|
||||
4 0 1
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
4 0 1
|
||||
5 0.114074 0.884445
|
||||
1 0.114074 0.114074
|
||||
0 0 0
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
1 0.114074 0.114074
|
||||
5 0.114074 0.884445
|
||||
6 0.884445 0.884445
|
||||
2 0.884445 0.114074
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
4 0 1
|
||||
0 0 0
|
||||
3 1 0
|
||||
7 1 1
|
||||
kids 0
|
||||
OBJECT poly
|
||||
name "rect"
|
||||
loc -0.0500002 0 -2.5
|
||||
texture "embossed_herring.bmp"
|
||||
texrep 20 30
|
||||
numvert 4
|
||||
-17.95 -0.7 -18.6
|
||||
17.95 -0.7 -18.6
|
||||
17.95 -0.7 18.6
|
||||
-17.95 -0.7 18.6
|
||||
numsurf 1
|
||||
SURF 0x0
|
||||
mat 1
|
||||
refs 4
|
||||
3 0 0
|
||||
2 1 0
|
||||
1 1 1
|
||||
0 0 1
|
||||
kids 0
|
||||
BIN
examples/src/ssg/viewer/data/plane.3ds
Normal file
BIN
examples/src/ssg/viewer/data/plane.3ds
Normal file
Binary file not shown.
589
examples/src/ssg/viewer/data/plib.ac
Normal file
589
examples/src/ssg/viewer/data/plib.ac
Normal file
@@ -0,0 +1,589 @@
|
||||
AC3Db
|
||||
MATERIAL "ac3dmat3" rgb 1 0 0 amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10 trans 0
|
||||
MATERIAL "ac3dmat5" rgb 1 1 0 amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10 trans 0
|
||||
MATERIAL "ac3dmat6" rgb 0 1 0 amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10 trans 0
|
||||
MATERIAL "ac3dmat9" rgb 0 0 1 amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10 trans 0
|
||||
OBJECT world
|
||||
kids 1
|
||||
OBJECT poly
|
||||
name "poly"
|
||||
loc 0.05 -0.05 0.15
|
||||
numvert 64
|
||||
-1.85 -0.25 1.05
|
||||
-1.45 -0.25 0.45
|
||||
-1.45 -0.25 1.05
|
||||
-1.15 -0.25 0.35
|
||||
-0.85 -0.25 -0.15
|
||||
-0.95 -0.25 0.15
|
||||
-0.85 -0.25 -0.45
|
||||
-1.45 0.25 1.05
|
||||
-1.45 0.25 0.45
|
||||
-1.85 0.25 1.05
|
||||
-0.95 0.25 0.15
|
||||
-0.85 0.25 -0.15
|
||||
-1.15 0.25 0.35
|
||||
-0.85 0.25 -0.45
|
||||
0.05 -0.25 0.75
|
||||
-0.35 -0.25 0.75
|
||||
0.05 -0.25 1.05
|
||||
-0.75 -0.25 1.05
|
||||
0.05 0.25 1.05
|
||||
-0.35 0.25 0.75
|
||||
0.05 0.25 0.75
|
||||
-0.75 0.25 1.05
|
||||
0.25 -0.25 1.05
|
||||
0.25 0.25 1.05
|
||||
0.65 0.25 1.05
|
||||
0.65 -0.25 1.05
|
||||
0.85 -0.25 1.05
|
||||
0.85 0.25 1.05
|
||||
1.25 0.25 1.05
|
||||
1.25 -0.25 1.05
|
||||
1.55 0.25 0.95
|
||||
1.55 -0.25 0.95
|
||||
1.75 0.25 0.75
|
||||
1.75 -0.25 0.75
|
||||
1.85 0.25 0.45
|
||||
1.85 -0.25 0.45
|
||||
1.85 0.25 0.15
|
||||
1.85 -0.25 0.15
|
||||
1.75 0.25 -0.15
|
||||
1.75 -0.25 -0.15
|
||||
1.55 0.25 -0.35
|
||||
1.55 -0.25 -0.35
|
||||
1.25 0.25 -0.45
|
||||
1.25 -0.25 -0.45
|
||||
-1.85 -0.25 -1.05
|
||||
-1.45 -0.25 -1.05
|
||||
-0.95 -0.25 -0.75
|
||||
-1.15 -0.25 -0.95
|
||||
-1.85 0.25 -1.05
|
||||
-1.45 0.25 -1.05
|
||||
-1.15 0.25 -0.95
|
||||
-0.95 0.25 -0.75
|
||||
-0.35 -0.25 -1.05
|
||||
-0.75 -0.25 -1.05
|
||||
-0.75 0.25 -1.05
|
||||
-0.35 0.25 -1.05
|
||||
0.65 -0.25 -1.05
|
||||
0.25 -0.25 -1.05
|
||||
0.65 0.25 -1.05
|
||||
0.25 0.25 -1.05
|
||||
1.25 -0.25 -1.05
|
||||
0.85 -0.25 -1.05
|
||||
1.25 0.25 -1.05
|
||||
0.85 0.25 -1.05
|
||||
numsurf 80
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
0 0 -5.67663e-08
|
||||
1 0.4 0.285714
|
||||
2 0.4 -5.67663e-08
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
3 0.7 0.333333
|
||||
4 1 0.571429
|
||||
5 0.9 0.428571
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
1 0.4 0.285714
|
||||
4 1 0.571429
|
||||
3 0.7 0.333333
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
1 0.4 0.285714
|
||||
6 1 0.714286
|
||||
4 1 0.571429
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
7 0 0
|
||||
8 0 0
|
||||
9 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
10 0 0
|
||||
11 0 0
|
||||
12 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
12 0 0
|
||||
11 0 0
|
||||
8 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
11 0 0
|
||||
13 0 0
|
||||
8 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 4
|
||||
1 0 0
|
||||
8 0 0
|
||||
7 0 0
|
||||
2 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 4
|
||||
2 0 0
|
||||
7 0 0
|
||||
9 0 0
|
||||
0 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 4
|
||||
4 0 0
|
||||
11 0 0
|
||||
10 0 0
|
||||
5 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 4
|
||||
5 0 0
|
||||
10 0 0
|
||||
12 0 0
|
||||
3 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 4
|
||||
3 0 0
|
||||
12 0 0
|
||||
8 0 0
|
||||
1 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 4
|
||||
6 0 0
|
||||
13 0 0
|
||||
11 0 0
|
||||
4 0 0
|
||||
SURF 0x20
|
||||
mat 1
|
||||
refs 3
|
||||
14 1 0.142857
|
||||
15 0.5 0.142857
|
||||
16 1 -5.67663e-08
|
||||
SURF 0x20
|
||||
mat 1
|
||||
refs 3
|
||||
16 1 -5.67663e-08
|
||||
15 0.5 0.142857
|
||||
17 0 -5.67663e-08
|
||||
SURF 0x20
|
||||
mat 1
|
||||
refs 3
|
||||
18 0 0
|
||||
19 0 0
|
||||
20 0 0
|
||||
SURF 0x20
|
||||
mat 1
|
||||
refs 3
|
||||
21 0 0
|
||||
19 0 0
|
||||
18 0 0
|
||||
SURF 0x20
|
||||
mat 1
|
||||
refs 4
|
||||
14 0 0
|
||||
20 0 0
|
||||
19 0 0
|
||||
15 0 0
|
||||
SURF 0x20
|
||||
mat 1
|
||||
refs 4
|
||||
16 0 0
|
||||
18 0 0
|
||||
20 0 0
|
||||
14 0 0
|
||||
SURF 0x20
|
||||
mat 1
|
||||
refs 4
|
||||
17 0 0
|
||||
21 0 0
|
||||
18 0 0
|
||||
16 0 0
|
||||
SURF 0x20
|
||||
mat 2
|
||||
refs 4
|
||||
22 0 0
|
||||
23 0 0
|
||||
24 0 0
|
||||
25 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 4
|
||||
26 0 0
|
||||
27 0 0
|
||||
28 0 0
|
||||
29 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 4
|
||||
29 0 0
|
||||
28 0 0
|
||||
30 0 0
|
||||
31 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 4
|
||||
31 0 0
|
||||
30 0 0
|
||||
32 0 0
|
||||
33 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 4
|
||||
33 0 0
|
||||
32 0 0
|
||||
34 0 0
|
||||
35 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 4
|
||||
35 0 0
|
||||
34 0 0
|
||||
36 0 0
|
||||
37 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 4
|
||||
37 0 0
|
||||
36 0 0
|
||||
38 0 0
|
||||
39 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 4
|
||||
39 0 0
|
||||
38 0 0
|
||||
40 0 0
|
||||
41 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 4
|
||||
41 0 0
|
||||
40 0 0
|
||||
42 0 0
|
||||
43 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
26 0 1
|
||||
29 0.4 1
|
||||
43 0.4 0.285714
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
31 0.7 0.952381
|
||||
33 0.9 0.857143
|
||||
29 0.4 1
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
29 0.4 1
|
||||
33 0.9 0.857143
|
||||
43 0.4 0.285714
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
41 0.7 0.333333
|
||||
43 0.4 0.285714
|
||||
39 0.9 0.428571
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
39 0.9 0.428571
|
||||
43 0.4 0.285714
|
||||
37 1 0.571429
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
37 1 0.571429
|
||||
43 0.4 0.285714
|
||||
35 1 0.714286
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
33 0.9 0.857143
|
||||
35 1 0.714286
|
||||
43 0.4 0.285714
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
42 0 0
|
||||
28 0 0
|
||||
27 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
28 0 0
|
||||
32 0 0
|
||||
30 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
42 0 0
|
||||
32 0 0
|
||||
28 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
38 0 0
|
||||
42 0 0
|
||||
40 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
36 0 0
|
||||
42 0 0
|
||||
38 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
34 0 0
|
||||
42 0 0
|
||||
36 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
42 0 0
|
||||
34 0 0
|
||||
32 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
44 0 1
|
||||
1 0.4 0.285714
|
||||
0 0 -5.67663e-08
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
45 0.4 1
|
||||
1 0.4 0.285714
|
||||
44 0 1
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
46 0.9 0.857143
|
||||
45 0.4 1
|
||||
47 0.7 0.952381
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
46 0.9 0.857143
|
||||
1 0.4 0.285714
|
||||
45 0.4 1
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
46 0.9 0.857143
|
||||
6 1 0.714286
|
||||
1 0.4 0.285714
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
9 0 0
|
||||
8 0 0
|
||||
48 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
48 0 0
|
||||
8 0 0
|
||||
49 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
50 0 0
|
||||
49 0 0
|
||||
51 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
49 0 0
|
||||
8 0 0
|
||||
51 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 3
|
||||
8 0 0
|
||||
13 0 0
|
||||
51 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 4
|
||||
0 0 0
|
||||
9 0 0
|
||||
48 0 0
|
||||
44 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 4
|
||||
44 0 0
|
||||
48 0 0
|
||||
49 0 0
|
||||
45 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 4
|
||||
45 0 0
|
||||
49 0 0
|
||||
50 0 0
|
||||
47 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 4
|
||||
47 0 0
|
||||
50 0 0
|
||||
51 0 0
|
||||
46 0 0
|
||||
SURF 0x20
|
||||
mat 0
|
||||
refs 4
|
||||
46 0 0
|
||||
51 0 0
|
||||
13 0 0
|
||||
6 0 0
|
||||
SURF 0x20
|
||||
mat 1
|
||||
refs 3
|
||||
52 0.5 1
|
||||
53 0 1
|
||||
15 0.5 0.142857
|
||||
SURF 0x20
|
||||
mat 1
|
||||
refs 3
|
||||
15 0.5 0.142857
|
||||
53 0 1
|
||||
17 0 -5.67663e-08
|
||||
SURF 0x20
|
||||
mat 1
|
||||
refs 3
|
||||
19 0 0
|
||||
54 0 0
|
||||
55 0 0
|
||||
SURF 0x20
|
||||
mat 1
|
||||
refs 3
|
||||
21 0 0
|
||||
54 0 0
|
||||
19 0 0
|
||||
SURF 0x20
|
||||
mat 1
|
||||
refs 4
|
||||
52 0 0
|
||||
55 0 0
|
||||
54 0 0
|
||||
53 0 0
|
||||
SURF 0x20
|
||||
mat 1
|
||||
refs 4
|
||||
15 0 0
|
||||
19 0 0
|
||||
55 0 0
|
||||
52 0 0
|
||||
SURF 0x20
|
||||
mat 1
|
||||
refs 4
|
||||
53 0 0
|
||||
54 0 0
|
||||
21 0 0
|
||||
17 0 0
|
||||
SURF 0x20
|
||||
mat 2
|
||||
refs 3
|
||||
25 1 -5.67663e-08
|
||||
56 1 1
|
||||
22 0 -5.67663e-08
|
||||
SURF 0x20
|
||||
mat 2
|
||||
refs 3
|
||||
56 1 1
|
||||
57 0 1
|
||||
22 0 -5.67663e-08
|
||||
SURF 0x20
|
||||
mat 2
|
||||
refs 3
|
||||
23 0 0
|
||||
58 0 0
|
||||
24 0 0
|
||||
SURF 0x20
|
||||
mat 2
|
||||
refs 3
|
||||
23 0 0
|
||||
59 0 0
|
||||
58 0 0
|
||||
SURF 0x20
|
||||
mat 2
|
||||
refs 4
|
||||
25 0 0
|
||||
24 0 0
|
||||
58 0 0
|
||||
56 0 0
|
||||
SURF 0x20
|
||||
mat 2
|
||||
refs 4
|
||||
56 0 0
|
||||
58 0 0
|
||||
59 0 0
|
||||
57 0 0
|
||||
SURF 0x20
|
||||
mat 2
|
||||
refs 4
|
||||
57 0 0
|
||||
59 0 0
|
||||
23 0 0
|
||||
22 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
60 0.4 -5.67663e-08
|
||||
61 0 -5.67663e-08
|
||||
43 0.4 0.285714
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
61 0 -5.67663e-08
|
||||
26 0 1
|
||||
43 0.4 0.285714
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
62 0 0
|
||||
63 0 0
|
||||
42 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 3
|
||||
63 0 0
|
||||
27 0 0
|
||||
42 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 4
|
||||
61 0 0
|
||||
63 0 0
|
||||
27 0 0
|
||||
26 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 4
|
||||
43 0 0
|
||||
42 0 0
|
||||
62 0 0
|
||||
60 0 0
|
||||
SURF 0x20
|
||||
mat 3
|
||||
refs 4
|
||||
60 0 0
|
||||
62 0 0
|
||||
63 0 0
|
||||
61 0 0
|
||||
kids 0
|
||||
BIN
examples/src/ssg/viewer/data/sorority.txf
Normal file
BIN
examples/src/ssg/viewer/data/sorority.txf
Normal file
Binary file not shown.
81
examples/src/ssg/viewer/data/test.ac
Normal file
81
examples/src/ssg/viewer/data/test.ac
Normal file
@@ -0,0 +1,81 @@
|
||||
AC3Db
|
||||
MATERIAL "" rgb 1 1 1 amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10 trans 0
|
||||
MATERIAL "" rgb 1 1 1 amb 0.2 0.2 0.2 emis 1 1 1 spec 0.502 0.502 0.502 shi 0 trans 0
|
||||
OBJECT world
|
||||
kids 2
|
||||
OBJECT poly
|
||||
name "box"
|
||||
texture "wood.rgb"
|
||||
texrep 5 5
|
||||
numvert 8
|
||||
-1.29615 -0.6 -1.29615
|
||||
-1 0 -1
|
||||
1 0 -1
|
||||
1.3 -0.6 -1.29615
|
||||
-1.29615 -0.6 1.3
|
||||
-1 0 1
|
||||
1 0 1
|
||||
1.3 -0.6 1.3
|
||||
numsurf 6
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
0 0 0
|
||||
1 0.114074 0.114074
|
||||
2 0.884445 0.114074
|
||||
3 1 0
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
6 0.884445 0.884445
|
||||
7 1 1
|
||||
3 1 0
|
||||
2 0.884445 0.114074
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
7 1 1
|
||||
6 0.884445 0.884445
|
||||
5 0.114074 0.884445
|
||||
4 0 1
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
4 0 1
|
||||
5 0.114074 0.884445
|
||||
1 0.114074 0.114074
|
||||
0 0 0
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
1 0.114074 0.114074
|
||||
5 0.114074 0.884445
|
||||
6 0.884445 0.884445
|
||||
2 0.884445 0.114074
|
||||
SURF 0x0
|
||||
mat 0
|
||||
refs 4
|
||||
4 0 1
|
||||
0 0 0
|
||||
3 1 0
|
||||
7 1 1
|
||||
kids 0
|
||||
OBJECT poly
|
||||
name "rect"
|
||||
loc -0.0500002 0 -2.5
|
||||
texture "embossed_herring.bmp"
|
||||
texrep 20 30
|
||||
numvert 4
|
||||
-17.95 -0.7 -18.6
|
||||
17.95 -0.7 -18.6
|
||||
17.95 -0.7 18.6
|
||||
-17.95 -0.7 18.6
|
||||
numsurf 1
|
||||
SURF 0x0
|
||||
mat 1
|
||||
refs 4
|
||||
3 0 0
|
||||
2 1 0
|
||||
1 1 1
|
||||
0 0 1
|
||||
kids 0
|
||||
1695
examples/src/ssg/viewer/data/tuxedo.ac
Normal file
1695
examples/src/ssg/viewer/data/tuxedo.ac
Normal file
File diff suppressed because it is too large
Load Diff
BIN
examples/src/ssg/viewer/data/wood.rgb
Normal file
BIN
examples/src/ssg/viewer/data/wood.rgb
Normal file
Binary file not shown.
191
examples/src/ssg/viewer/pview.cxx
Normal file
191
examples/src/ssg/viewer/pview.cxx
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: pview.cxx 2048 2005-09-30 18:14:09Z fayjf $
|
||||
*/
|
||||
|
||||
/*
|
||||
* pview.cxx
|
||||
*
|
||||
* By Bram Stolk.
|
||||
* Minimalistic plib viewer with a proper 'virtual ball' interface.
|
||||
* LMB for orbiting model, MMB for translation, RMB for approaching model.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include <plib/ssg.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846264338327950f
|
||||
#endif
|
||||
|
||||
static float aspectratio=1.0;
|
||||
static int winw, winh;
|
||||
static ssgRoot *scene=0;
|
||||
static ssgContext *context=0;
|
||||
static sgMat4 camtrf;
|
||||
|
||||
|
||||
static void idle(void)
|
||||
{
|
||||
context->setCamera(camtrf);
|
||||
glutPostRedisplay () ;
|
||||
}
|
||||
|
||||
|
||||
static void redraw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
if (scene) ssgCullAndDraw(scene);
|
||||
glutSwapBuffers () ;
|
||||
}
|
||||
|
||||
|
||||
static int prevx=0;
|
||||
static int prevy=0;
|
||||
static int prevbutton=-1;
|
||||
|
||||
static void mouse(int button, int state, int x, int y)
|
||||
{
|
||||
prevx=x;
|
||||
prevy=y;
|
||||
prevbutton=button;
|
||||
}
|
||||
|
||||
static void motion(int x, int y)
|
||||
{
|
||||
const float vel=220.0;
|
||||
float dx = vel * (x-prevx) / winw;
|
||||
float dy = vel * (y-prevy) / winh;
|
||||
prevx = x; prevy = y;
|
||||
|
||||
if (prevbutton==0)
|
||||
{
|
||||
sgQuat hq, vq;
|
||||
sgAngleAxisToQuat(hq, -dx, camtrf[2]);
|
||||
sgAngleAxisToQuat(vq, -dy, camtrf[0]);
|
||||
sgQuat totalq;
|
||||
sgMultQuat(totalq, vq, hq);
|
||||
sgNormalizeQuat(totalq);
|
||||
sgMat4 m;
|
||||
sgQuatToMatrix(m, totalq);
|
||||
sgPostMultMat4(camtrf, m);
|
||||
return;
|
||||
}
|
||||
if (prevbutton==1)
|
||||
{
|
||||
float curdist = sgLengthVec3(camtrf[3]);
|
||||
sgAddScaledVec3(camtrf[3], camtrf[2], dy*curdist/200.0f);
|
||||
sgAddScaledVec3(camtrf[3], camtrf[0], -dx*curdist/200.0f);
|
||||
return;
|
||||
}
|
||||
if (prevbutton==2)
|
||||
{
|
||||
float curdist = sgLengthVec3(camtrf[3]);
|
||||
sgAddScaledVec3(camtrf[3], camtrf[1], -dy*curdist/80.0f);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void reshape(int w, int h)
|
||||
{
|
||||
glViewport ( 0, 0, w, h ) ;
|
||||
|
||||
aspectratio = w / (float) h;
|
||||
winw=w; winh=h;
|
||||
float fovy = 60.0f * M_PI / 180.0f;
|
||||
float nearPlaneDistance = 0.4f;
|
||||
float farPlaneDistance = 2500.0;
|
||||
float y = (float)tan(0.5 * fovy) * nearPlaneDistance;
|
||||
float x = aspectratio * y;
|
||||
context->setFrustum(-x,x,-y,y,nearPlaneDistance,farPlaneDistance);
|
||||
}
|
||||
|
||||
|
||||
static void keyboard(unsigned char k, int, int)
|
||||
{
|
||||
if (k==27)
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc<2)
|
||||
{
|
||||
fprintf(stderr,"Usage: %s model0 [model1] .. [modeln]\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
glutInitWindowSize(512,512);
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE);
|
||||
glutCreateWindow(argv[1]);
|
||||
glutDisplayFunc(redraw);
|
||||
glutReshapeFunc(reshape);
|
||||
glutKeyboardFunc(keyboard);
|
||||
glutMouseFunc(mouse);
|
||||
glutIdleFunc(idle);
|
||||
glutMotionFunc(motion);
|
||||
|
||||
ssgInit();
|
||||
|
||||
glClearColor(0.3f,0.3f,0.55f,1.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_CULL_FACE);
|
||||
scene = new ssgRoot();
|
||||
|
||||
float amb[4]={0.2f, 0.2f, 0.2f, 1.0f};
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, amb);
|
||||
|
||||
ssgTransform *trf = new ssgTransform();
|
||||
scene->addKid(trf);
|
||||
|
||||
for (int i=1; i<argc; i++)
|
||||
trf->addKid(ssgLoad(argv[i]));
|
||||
|
||||
context = new ssgContext();
|
||||
context->makeCurrent();
|
||||
|
||||
sgVec3 off;
|
||||
sgZeroVec3(off);
|
||||
sgSubVec3(off, scene->getBSphere()->getCenter());
|
||||
|
||||
trf->setTransform(off);
|
||||
SGfloat radius = scene->getBSphere()->getRadius();
|
||||
float d = 1.8f*radius;
|
||||
if (d<0.5) d=0.5; // avoid placing near-plane beyond model
|
||||
sgMakeTransMat4(camtrf, 0, -d, 0);
|
||||
|
||||
ssgLight *light=ssgGetLight(0);
|
||||
light->setColour(GL_AMBIENT,0,0,0);
|
||||
light->setPosition(0,0,radius);
|
||||
light->on();
|
||||
|
||||
glutMainLoop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
102
examples/src/ssg/viewer/pview.dsp
Executable file
102
examples/src/ssg/viewer/pview.dsp
Executable file
@@ -0,0 +1,102 @@
|
||||
# Microsoft Developer Studio Project File - Name="pview" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=pview - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "pview.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "pview.mak" CFG="pview - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "pview - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "pview - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "pview - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\\" /I "..\..\..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "FREEGLUT_STATIC" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg_d.lib sg_d.lib fnt_d.lib pui_d.lib ul_d.lib opengl32.lib glu32.lib /nologo /subsystem:console /machine:I386 /out:"pview.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "pview - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /I "..\..\..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "FREEGLUT_STATIC" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg_d.lib sg_d.lib fnt_d.lib pui_d.lib ul_d.lib opengl32.lib glu32.lib /nologo /subsystem:console /debug /machine:I386 /out:"pview.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "pview - Win32 Release"
|
||||
# Name "pview - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\pview.cxx
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
859
examples/src/ssg/viewer/viewer.cxx
Normal file
859
examples/src/ssg/viewer/viewer.cxx
Normal file
@@ -0,0 +1,859 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: viewer.cxx 2099 2006-11-03 20:04:40Z fayjf $
|
||||
*/
|
||||
|
||||
/****
|
||||
* NAME
|
||||
* viewer - SSG model viewer
|
||||
*
|
||||
* DESCRIPTION
|
||||
* using a PUI interface, allow user to load a model,
|
||||
* animate the model, and manipulate the camera.
|
||||
* several models can be loaded at the same time.
|
||||
*
|
||||
* MODIFICATION HISTORY
|
||||
* Sep-2000 Dave McClurg <dpm@efn.org> Created
|
||||
* Sep-2001 Dave McClurg <dpm@efn.org> Added wireframe toggle
|
||||
****/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
#else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <plib/ssg.h>
|
||||
#include <plib/fnt.h>
|
||||
#include <plib/pu.h>
|
||||
#include <plib/puAux.h>
|
||||
|
||||
#define ARROWS_USED 1
|
||||
/*
|
||||
!!!FIXME!!!
|
||||
Defines what type of arrows to uses with puFileSelector
|
||||
0 - No arrows
|
||||
1 - Single move arrows
|
||||
2 - Single move and Jump 10 moves
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
scene graph
|
||||
*/
|
||||
static ssgRoot *scene = NULL ;
|
||||
static ssgContext *context = NULL ;
|
||||
static ssgEntity* camera_object = NULL ;
|
||||
|
||||
/*
|
||||
font vars
|
||||
*/
|
||||
static fntRenderer *text ;
|
||||
static fntTexFont *font ;
|
||||
|
||||
static puaFileSelector* file_selector = 0 ;
|
||||
|
||||
/*
|
||||
frame rate vars
|
||||
*/
|
||||
static int frame_counter = 0;
|
||||
static float fps = 0;
|
||||
|
||||
/*
|
||||
animation vars
|
||||
*/
|
||||
#define MAX_SPEED 60
|
||||
static const int speed_tab [] =
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60 };
|
||||
|
||||
static int speed_index = 1 ;
|
||||
//static int anim_frame ;
|
||||
static int num_anim_frames ;
|
||||
|
||||
/*
|
||||
wire vars
|
||||
*/
|
||||
static int wire_flag = 0 ;
|
||||
static sgVec4 wire_colour = { 1.0f, 1.0f, 1.0f, 1.0f } ;
|
||||
|
||||
/*
|
||||
spinner vars
|
||||
*/
|
||||
static int downx, downy; /* for tracking mouse position */
|
||||
static int downb = -1; /* and button status */
|
||||
|
||||
static GLfloat downDist, downEl, downAz, /* for saving state of things */
|
||||
downEx, downEy, downEz; /* when button is pressed */
|
||||
|
||||
static GLfloat dAz, dEl, lastAz, lastEl; /* to calculate spinning w/ polar motion */
|
||||
static GLfloat AzSpin = 0.0f, ElSpin = 0.0f;
|
||||
static int AdjustingAzEl = 0;
|
||||
|
||||
/* Minimum spin to allow in polar (lower forced to zero) */
|
||||
#define MIN_AZSPIN 0.1f
|
||||
#define MIN_ELSPIN 0.1f
|
||||
|
||||
/* Factors used in computing dAz and dEl (which determine AzSpin, ElSpin) */
|
||||
#define SLOW_DAZ 0.90f
|
||||
#define SLOW_DEL 0.90f
|
||||
#define PREV_DAZ 0.80f
|
||||
#define PREV_DEL 0.80f
|
||||
#define CUR_DAZ 0.20f
|
||||
#define CUR_DEL 0.20f
|
||||
|
||||
/*
|
||||
* polar movement parameters
|
||||
*/
|
||||
static GLfloat EyeDist= 100.0f;
|
||||
static GLfloat EyeAz = 0.0f;
|
||||
static GLfloat EyeEl = 30.0f;
|
||||
static GLfloat Ex = 0.0f;
|
||||
static GLfloat Ey = 0.0f;
|
||||
static GLfloat Ez = 0.0f;
|
||||
|
||||
#define FOVY 45.0f
|
||||
#define FOV_NEAR 0.1f
|
||||
#define FOV_FAR 10000.0f
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846264338327950f
|
||||
#endif
|
||||
|
||||
static int getWindowHeight () { return glutGet ( (GLenum) GLUT_WINDOW_HEIGHT ) ; }
|
||||
static int getWindowWidth () { return glutGet ( (GLenum) GLUT_WINDOW_WIDTH ) ; }
|
||||
|
||||
static void begin2d ( void )
|
||||
{
|
||||
int w = getWindowWidth () ;
|
||||
int h = getWindowHeight () ;
|
||||
|
||||
glDisable ( GL_LIGHTING ) ;
|
||||
glDisable ( GL_TEXTURE_2D ) ;
|
||||
glDisable ( GL_DEPTH_TEST ) ;
|
||||
glDisable ( GL_CULL_FACE ) ;
|
||||
glEnable ( GL_ALPHA_TEST ) ;
|
||||
glEnable ( GL_BLEND ) ;
|
||||
glAlphaFunc ( GL_GREATER, 0.1f ) ;
|
||||
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
|
||||
|
||||
//create an projection that acts like a 2D screen
|
||||
glMatrixMode ( GL_PROJECTION ) ;
|
||||
glPushMatrix () ;
|
||||
glLoadIdentity () ;
|
||||
glOrtho ( 0, w, 0, h, 0, 1 ) ;
|
||||
glMatrixMode ( GL_MODELVIEW ) ;
|
||||
glPushMatrix () ;
|
||||
glLoadIdentity () ;
|
||||
}
|
||||
|
||||
static void end2d ( void )
|
||||
{
|
||||
glMatrixMode ( GL_PROJECTION ) ;
|
||||
glPopMatrix () ;
|
||||
glMatrixMode ( GL_MODELVIEW ) ;
|
||||
glPopMatrix () ;
|
||||
|
||||
glDisable ( GL_ALPHA_TEST ) ;
|
||||
glDisable ( GL_BLEND ) ;
|
||||
glAlphaFunc ( GL_ALWAYS, 0.0 ) ;
|
||||
glBlendFunc ( GL_ONE, GL_ZERO ) ;
|
||||
}
|
||||
|
||||
|
||||
static void count_anim_frames( ssgEntity *e )
|
||||
{
|
||||
if ( e -> isAKindOf ( ssgTypeBranch() ) )
|
||||
{
|
||||
ssgBranch *br = (ssgBranch *) e ;
|
||||
|
||||
for ( int i = 0 ; i < br -> getNumKids () ; i++ )
|
||||
count_anim_frames ( br -> getKid ( i ) ) ;
|
||||
|
||||
if ( e -> isAKindOf ( ssgTypeSelector() ) )
|
||||
{
|
||||
ssgSelector* p = (ssgSelector*) e ;
|
||||
int num = p -> getMaxKids () ;
|
||||
if ( num > num_anim_frames )
|
||||
num_anim_frames = num ;
|
||||
}
|
||||
else if ( e -> isAKindOf ( ssgTypeTransform() ) )
|
||||
{
|
||||
ssgBase* data = e -> getUserData () ;
|
||||
if ( data != NULL && data -> isAKindOf ( ssgTypeTransformArray() ) )
|
||||
{
|
||||
ssgTransformArray* ta = (ssgTransformArray*) data ;
|
||||
int num = ta -> getNum () ;
|
||||
if ( num > num_anim_frames )
|
||||
num_anim_frames = num ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( e -> isAKindOf ( ssgTypeLeaf() ) )
|
||||
{
|
||||
ssgLeaf* leaf = (ssgLeaf *) e ;
|
||||
ssgState* st = leaf -> getState () ;
|
||||
|
||||
if ( st && st -> isAKindOf ( ssgTypeStateSelector() ) )
|
||||
{
|
||||
ssgStateSelector* ss = (ssgStateSelector*) st ;
|
||||
|
||||
int num = ss -> getNumSteps () ;
|
||||
if ( num > num_anim_frames )
|
||||
num_anim_frames = num ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// You need to have a object with animation loaded into memory for the following function to make sense.
|
||||
// Animation can be discreet (in steps) or "smooth" (fluid).
|
||||
// If you loaded an animation made of several meshes, it will use a selector and therefore always be "discreet"
|
||||
// If you loaded some transformation matrices like some rotations to rotate the flap of a plane,
|
||||
// the define DISCREET_STEPS will determine whether the animation is smooth (new code, WK) or
|
||||
// in steps ("old" code, Dave McClurg).
|
||||
//
|
||||
// The anim_frame is for discreet animation and an index determining which matrix / which selector will be used.
|
||||
//
|
||||
// typically, you will call set_anim_frame directly before you call ssgCullAndDraw
|
||||
static void set_anim_frame( ssgEntity *e, int anim_frame )
|
||||
{
|
||||
if ( e -> isAKindOf ( ssgTypeBranch() ) )
|
||||
{
|
||||
ssgBranch *br = (ssgBranch *) e ;
|
||||
|
||||
for ( int i = 0 ; i < br -> getNumKids () ; i++ )
|
||||
set_anim_frame ( br -> getKid ( i ), anim_frame ) ;
|
||||
|
||||
if ( e -> isAKindOf ( ssgTypeSelector() ) )
|
||||
{
|
||||
ssgSelector* p = (ssgSelector*) e ;
|
||||
int num = p -> getMaxKids () ;
|
||||
if ( num > 0 )
|
||||
{
|
||||
int frame = anim_frame ;
|
||||
frame %= num ;
|
||||
p -> selectStep ( frame ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( e -> isAKindOf ( ssgTypeLeaf() ) )
|
||||
{
|
||||
ssgLeaf* leaf = (ssgLeaf *) e ;
|
||||
ssgState* st = leaf -> getState () ;
|
||||
|
||||
if ( st && st -> isAKindOf ( ssgTypeStateSelector() ) )
|
||||
{
|
||||
ssgStateSelector* ss = (ssgStateSelector*) st ;
|
||||
int num = ss -> getNumSteps () ;
|
||||
if ( num > 0 )
|
||||
{
|
||||
int frame = anim_frame ;
|
||||
frame %= num ;
|
||||
ss -> selectStep ( frame ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int wire_draw ( ssgEntity* e )
|
||||
{
|
||||
if ( e -> isAKindOf ( ssgTypeLeaf() ) )
|
||||
{
|
||||
ssgLeaf* leaf = (ssgLeaf*) e ;
|
||||
leaf -> drawHighlight ( wire_colour ) ;
|
||||
}
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
|
||||
static void wire_update ( ssgEntity *e, int flag )
|
||||
{
|
||||
if ( e -> isAKindOf ( ssgTypeBranch() ) )
|
||||
{
|
||||
ssgBranch *br = (ssgBranch *) e ;
|
||||
|
||||
for ( int i = 0 ; i < br -> getNumKids () ; i++ )
|
||||
wire_update ( br -> getKid ( i ), flag ) ;
|
||||
}
|
||||
else if ( e -> isAKindOf ( ssgTypeLeaf() ) )
|
||||
{
|
||||
ssgLeaf* leaf = (ssgLeaf *) e ;
|
||||
leaf -> setCallback ( SSG_CALLBACK_POSTDRAW, flag? wire_draw: NULL ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void make_matrix( sgMat4 mat )
|
||||
{
|
||||
SGfloat angle = -EyeAz * SG_DEGREES_TO_RADIANS ;
|
||||
sgVec3 eye ;
|
||||
eye[0] = (SGfloat) cos (angle) * EyeDist + Ex ;
|
||||
eye[1] = (SGfloat) sin (angle) * EyeDist + Ey ;
|
||||
angle = EyeEl * SG_DEGREES_TO_RADIANS ;
|
||||
eye[2] = (SGfloat) sin (angle) * EyeDist + Ez ;
|
||||
|
||||
sgVec3 center ;
|
||||
sgSetVec3 ( center, Ex, Ey, Ez ) ;
|
||||
|
||||
sgVec3 up ;
|
||||
sgSetVec3 ( up, 0.0f, 0.0f, 0.1f ) ;
|
||||
|
||||
sgMakeLookAtMat4 ( mat, eye, center, up ) ;
|
||||
}
|
||||
|
||||
|
||||
static bool get_camera_dir ( ssgEntity* e, sgVec3 eye, sgVec3 target )
|
||||
{
|
||||
if ( e -> isAKindOf ( ssgTypeBranch() ) )
|
||||
{
|
||||
ssgBranch *br = (ssgBranch *) e ;
|
||||
for ( int i = 0 ; i < br -> getNumKids () ; i++ )
|
||||
{
|
||||
if ( get_camera_dir ( br -> getKid ( i ), eye, target ) )
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
else if ( e -> isAKindOf ( ssgTypeLeaf() ) )
|
||||
{
|
||||
ssgLeaf* leaf = (ssgLeaf *) e ;
|
||||
if ( leaf -> getNumVertices () >= 2 )
|
||||
{
|
||||
sgCopyVec3 ( eye, leaf -> getVertex ( 0 ) ) ;
|
||||
sgCopyVec3 ( target, leaf -> getVertex ( 1 ) ) ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
static void follow_camera ( sgMat4 mat )
|
||||
{
|
||||
if ( camera_object != NULL )
|
||||
{
|
||||
sgVec3 v1, v2 ;
|
||||
if ( camera_object -> isAKindOf ( ssgTypeTransform() ) &&
|
||||
get_camera_dir ( camera_object, v1, v2 ) )
|
||||
{
|
||||
ssgTransform* tr = (ssgTransform*) camera_object ;
|
||||
sgMat4 m ;
|
||||
tr -> getTransform ( m ) ;
|
||||
|
||||
sgVec3 up = { 0.0f, 0.0f, 1.0f } ;
|
||||
sgVec3 eye, target ;
|
||||
sgXformPnt3 ( eye, v1, m ) ;
|
||||
sgXformPnt3 ( target, v2, m ) ;
|
||||
sgMakeLookAtMat4 ( mat, eye, target, up ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
The GLUT window reshape event
|
||||
Fixed to properly maintain aspect ratio.
|
||||
*/
|
||||
|
||||
static void reshape ( int w, int h )
|
||||
{
|
||||
glViewport ( 0, 0, w, h ) ;
|
||||
|
||||
float aspect = w / (float)h;
|
||||
float angle = 0.5f * FOVY * M_PI / 180.0f;
|
||||
float y = FOV_NEAR * (float)tan(angle);
|
||||
float x = aspect * y;
|
||||
|
||||
context->setFrustum(-x,x,-y,y,FOV_NEAR,FOV_FAR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT display event
|
||||
*/
|
||||
|
||||
static void display(void)
|
||||
{
|
||||
glClearColor ( 0.2f, 0.7f, 1.0f, 1.0f ) ;
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
sgMat4 mat ;
|
||||
make_matrix ( mat ) ;
|
||||
follow_camera ( mat ) ;
|
||||
|
||||
context->setCamera ( mat );
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
glEnable( GL_DEPTH_TEST ) ;
|
||||
|
||||
/*
|
||||
update virtual time, from "real" time and speed.
|
||||
*/
|
||||
static int last_time = 0;
|
||||
int curr_time = glutGet((GLenum)GLUT_ELAPSED_TIME);
|
||||
if (last_time != 0)
|
||||
// calculate the "virtual time"
|
||||
_ssgGlobTime += 0.001f*(curr_time-last_time)*speed_tab[ speed_index ];
|
||||
|
||||
last_time = curr_time;
|
||||
|
||||
//set_anim_frame ( scene, _ssgGlobTime); // currently not needed by our sample data
|
||||
|
||||
/*
|
||||
figure out how fast this bus is going
|
||||
*/
|
||||
static int last_time2 = 0;
|
||||
if (curr_time >= last_time2 + 2000) {
|
||||
fps = frame_counter * 1000.0f / (curr_time - last_time2);
|
||||
frame_counter = 0;
|
||||
last_time2 = curr_time;
|
||||
}
|
||||
|
||||
ssgCullAndDraw ( scene ) ;
|
||||
|
||||
/*
|
||||
do the interface stuff
|
||||
*/
|
||||
|
||||
int h = getWindowHeight () ;
|
||||
|
||||
begin2d () ;
|
||||
|
||||
text -> setFont ( font ) ;
|
||||
text -> setPointSize ( 12 ) ;
|
||||
|
||||
if ( scene -> getNumKids() == 0 )
|
||||
{
|
||||
text -> begin () ;
|
||||
glColor3f ( 0.0f, 0.0f, 0.0f ) ;
|
||||
text -> start2f ( 4.0f, (float)(h-16) ) ;
|
||||
text -> puts ( "controls\n" );
|
||||
text -> puts ( " <esc> : exit\n" ) ;
|
||||
text -> puts ( " c : clear\n" ) ;
|
||||
text -> puts ( " l : load a shape or sequence\n" ) ;
|
||||
text -> puts ( " w : toggle wireframe\n" ) ;
|
||||
text -> puts ( " <key.pad.plus> : faster animation\n" ) ;
|
||||
text -> puts ( " <key.pad.minus> : slower animation\n" ) ;
|
||||
text -> puts ( " <left.mouse.button> : rotate\n" ) ;
|
||||
text -> puts ( " <right.mouse.button> : zoom\n" ) ;
|
||||
text -> end () ;
|
||||
}
|
||||
else if ( fps > 0 )
|
||||
{
|
||||
|
||||
char buffer [ PUSTRING_MAX ] ;
|
||||
text -> begin () ;
|
||||
glColor3f ( 0.0f, 0.0f, 0.0f ) ;
|
||||
text -> start2f ( 4.0f, (float)(h-16) ) ;
|
||||
sprintf ( buffer, "fps : %.02f\n", fps ) ;
|
||||
text -> puts ( buffer ) ;
|
||||
sprintf ( buffer, "dist : %.02f\n", EyeDist ) ;
|
||||
text -> puts ( buffer ) ;
|
||||
sprintf ( buffer, "anim_speed : %d fps\n", speed_tab[ speed_index ] ) ;
|
||||
text -> puts ( buffer ) ;
|
||||
sprintf ( buffer, "time : %-4d\n", curr_time ) ;
|
||||
text -> puts ( buffer ) ;
|
||||
text -> end () ;
|
||||
|
||||
}
|
||||
|
||||
glColor3f ( 1.0f, 1.0f, 1.0f ) ;
|
||||
end2d () ;
|
||||
|
||||
frame_counter ++;
|
||||
|
||||
puDisplay () ;
|
||||
|
||||
glutPostRedisplay () ;
|
||||
glutSwapBuffers () ;
|
||||
}
|
||||
|
||||
/*
|
||||
* keep them vertical; I think this makes a lot of things easier,
|
||||
* but maybe it wouldn't be too hard to adapt things to let you go
|
||||
* upside down
|
||||
*/
|
||||
static int ConstrainEl(void)
|
||||
{
|
||||
if (EyeEl <= -90) {
|
||||
EyeEl = -89.99f;
|
||||
return 1;
|
||||
} else if (EyeEl >= 90) {
|
||||
EyeEl = 89.99f;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* What to multiply number of pixels mouse moved by to get rotation amount */
|
||||
#define EL_SENS 0.5f
|
||||
#define AZ_SENS 0.5f
|
||||
|
||||
static void motion(int x, int y)
|
||||
{
|
||||
puMouse ( x, y ) ;
|
||||
|
||||
int deltax = x - downx, deltay = y - downy;
|
||||
|
||||
// if ( scene -> getNumKids() > 0 && !file_selector )
|
||||
if ( !file_selector )
|
||||
|
||||
switch (downb) {
|
||||
case GLUT_LEFT_BUTTON:
|
||||
EyeEl = downEl + EL_SENS * deltay;
|
||||
ConstrainEl();
|
||||
EyeAz = downAz + AZ_SENS * deltax;
|
||||
dAz = PREV_DAZ*dAz + CUR_DAZ*(lastAz - EyeAz);
|
||||
dEl = PREV_DEL*dEl + CUR_DEL*(lastEl - EyeEl);
|
||||
lastAz = EyeAz;
|
||||
lastEl = EyeEl;
|
||||
break;
|
||||
case GLUT_RIGHT_BUTTON:
|
||||
{
|
||||
float mult = 0.01f;
|
||||
if ( fabs(downDist) > 1.0f )
|
||||
mult = float( 0.001 * fabs(downDist) );
|
||||
EyeDist = downDist + mult*deltay;
|
||||
break;
|
||||
}
|
||||
case GLUT_MIDDLE_BUTTON:
|
||||
{
|
||||
float mult = 0.01f;
|
||||
if ( fabs(EyeDist) > 1.0f )
|
||||
mult = float( 0.0005f * fabs(EyeDist) );
|
||||
|
||||
sgMat4 mat ;
|
||||
make_matrix( mat ) ;
|
||||
|
||||
sgVec3 off;
|
||||
sgSetVec3( off, mult*deltax, 0, -mult*deltay );
|
||||
sgXformVec3( off, mat );
|
||||
|
||||
Ex -= off[0];
|
||||
Ey -= off[1];
|
||||
Ez -= off[2];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void mouse(int button, int state, int x, int y)
|
||||
{
|
||||
puMouse ( button, state, x, y ) ;
|
||||
|
||||
if (state == GLUT_DOWN && downb == -1) {
|
||||
downx = x;
|
||||
downy = y;
|
||||
downb = button;
|
||||
|
||||
// if ( scene -> getNumKids() > 0 && !file_selector )
|
||||
if (!file_selector )
|
||||
switch ( button )
|
||||
{
|
||||
case GLUT_LEFT_BUTTON:
|
||||
lastEl = downEl = EyeEl;
|
||||
lastAz = downAz = EyeAz;
|
||||
AzSpin = ElSpin = dAz = dEl = 0;
|
||||
AdjustingAzEl = 1;
|
||||
break;
|
||||
case GLUT_RIGHT_BUTTON:
|
||||
downDist = EyeDist;
|
||||
break;
|
||||
case GLUT_MIDDLE_BUTTON:
|
||||
downEx = Ex;
|
||||
downEy = Ey;
|
||||
downEz = Ez;
|
||||
break;
|
||||
}
|
||||
} else if (state == GLUT_UP && button == downb) {
|
||||
downb = -1;
|
||||
|
||||
// if ( scene -> getNumKids() > 0 && !file_selector )
|
||||
if ( !file_selector )
|
||||
switch ( button )
|
||||
{
|
||||
case GLUT_LEFT_BUTTON:
|
||||
AzSpin = -dAz;
|
||||
if (AzSpin < MIN_AZSPIN && AzSpin > -MIN_AZSPIN)
|
||||
AzSpin = 0;
|
||||
ElSpin = -dEl;
|
||||
if (ElSpin < MIN_ELSPIN && ElSpin > -MIN_ELSPIN)
|
||||
ElSpin = 0;
|
||||
AdjustingAzEl = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void special(int key, int x, int y)
|
||||
{
|
||||
puKeyboard ( key + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN ) ;
|
||||
|
||||
switch ( key )
|
||||
{
|
||||
case GLUT_KEY_LEFT:
|
||||
case GLUT_KEY_UP:
|
||||
case GLUT_KEY_RIGHT:
|
||||
case GLUT_KEY_DOWN:
|
||||
case GLUT_KEY_PAGE_UP:
|
||||
case GLUT_KEY_PAGE_DOWN:
|
||||
case GLUT_KEY_HOME:
|
||||
case GLUT_KEY_END:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void pick_cb ( puObject * )
|
||||
{
|
||||
char* str ;
|
||||
file_selector -> getValue ( &str ) ;
|
||||
|
||||
char fname [PUSTRING_MAX];
|
||||
strcpy ( fname, str ) ;
|
||||
|
||||
puDeleteObject ( file_selector ) ;
|
||||
file_selector = 0 ;
|
||||
|
||||
ssgEntity *obj = ssgLoad ( (char*)fname ); //"test_Med.ase" ) ;
|
||||
|
||||
#if 0
|
||||
ssgSaveSSG ( "temp.ssg", obj ) ;
|
||||
delete obj ;
|
||||
obj = ssgLoadSSG ( "temp.ssg" ) ;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
ssgSaveDXF ( "temp.dxf", obj ) ;
|
||||
delete obj ;
|
||||
obj = ssgLoadDXF ( "temp.dxf" ) ;
|
||||
#endif
|
||||
|
||||
if ( !obj )
|
||||
return;
|
||||
|
||||
scene -> addKid ( obj ) ;
|
||||
|
||||
num_anim_frames = 0 ;
|
||||
count_anim_frames ( scene ) ;
|
||||
wire_update ( scene, wire_flag ) ;
|
||||
|
||||
SGfloat radius = scene->getBSphere()->getRadius();
|
||||
EyeDist = float( radius * 1.5f / tan( float( FOVY/2 * SG_DEGREES_TO_RADIANS ) ) );
|
||||
if (EyeDist < FOV_NEAR*2)
|
||||
EyeDist = FOV_NEAR*2;
|
||||
|
||||
sgSphere sp = *( scene -> getBSphere() ) ;
|
||||
if ( sp.isEmpty() )
|
||||
{
|
||||
Ex = 0.0f ;
|
||||
Ey = 0.0f ;
|
||||
Ez = 0.0f ;
|
||||
}
|
||||
else
|
||||
{
|
||||
Ex = sp.getCenter()[ 0 ] ;
|
||||
Ey = sp.getCenter()[ 1 ] ;
|
||||
Ez = sp.getCenter()[ 2 ] ;
|
||||
}
|
||||
|
||||
/* try to find the animated camera */
|
||||
camera_object = scene -> getByName ( "FlyCam" ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The GLUT keyboard event
|
||||
*/
|
||||
|
||||
static void keyboard(unsigned char key, int, int)
|
||||
{
|
||||
puKeyboard ( key, PU_DOWN ) ;
|
||||
|
||||
switch ( key )
|
||||
{
|
||||
case 0x1b: //escape
|
||||
exit(0);
|
||||
break;
|
||||
case '+':
|
||||
if ( speed_tab[ speed_index ] != MAX_SPEED )
|
||||
speed_index ++ ;
|
||||
break;
|
||||
case '-':
|
||||
if ( speed_tab[ speed_index ] != 0 )
|
||||
speed_index -- ;
|
||||
break;
|
||||
case ' ':
|
||||
Ex = 0;
|
||||
Ey = 0;
|
||||
Ez = 0;
|
||||
break;
|
||||
case 'l':
|
||||
if ( !file_selector )
|
||||
{
|
||||
file_selector = new puaFileSelector ( ( 640 - 320 ) / 2, ( 480 - 270 ) / 2, 320, 270, ARROWS_USED, "data" ) ;
|
||||
file_selector -> setCallback ( pick_cb ) ;
|
||||
}
|
||||
break;
|
||||
case 'w':
|
||||
wire_flag = !wire_flag ;
|
||||
wire_update ( scene, wire_flag ) ;
|
||||
break ;
|
||||
case 'c':
|
||||
//scene -> removeKid ( obj );
|
||||
scene -> removeAllKids () ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
static void idle(void)
|
||||
{
|
||||
EyeEl += ElSpin;
|
||||
EyeAz += AzSpin;
|
||||
|
||||
/*
|
||||
* weird spin thing to make things look
|
||||
* look better when you are kept from going
|
||||
* upside down while spinning - Isn't great
|
||||
*/
|
||||
if (ConstrainEl()) {
|
||||
ElSpin = -ElSpin;
|
||||
if (fabs(ElSpin) > fabs(AzSpin))
|
||||
AzSpin = float( fabs(ElSpin) * ((AzSpin > 0) ? 1 : -1) );
|
||||
}
|
||||
|
||||
if (AdjustingAzEl) {
|
||||
dAz *= SLOW_DAZ;
|
||||
dEl *= SLOW_DEL;
|
||||
}
|
||||
}
|
||||
|
||||
static void init_graphics ()
|
||||
{
|
||||
int fake_argc = 1 ;
|
||||
char *fake_argv[3] ;
|
||||
fake_argv[0] = "Viewer" ;
|
||||
fake_argv[1] = "Simple Scene Graph : Viewer Program." ;
|
||||
fake_argv[2] = NULL ;
|
||||
|
||||
/*
|
||||
Initialise GLUT
|
||||
*/
|
||||
|
||||
glutInit ( &fake_argc, fake_argv ) ;
|
||||
glutInitWindowSize ( 640, 480 ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
glutCreateWindow ( fake_argv[1] ) ;
|
||||
glutDisplayFunc ( display ) ;
|
||||
glutReshapeFunc ( reshape ) ;
|
||||
glutKeyboardFunc ( keyboard ) ;
|
||||
glutMouseFunc ( mouse ) ;
|
||||
glutMotionFunc ( motion ) ;
|
||||
glutSpecialFunc ( special ) ;
|
||||
glutIdleFunc ( idle ) ;
|
||||
|
||||
/*
|
||||
Some basic OpenGL setup
|
||||
*/
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
glDepthFunc(GL_LESS);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
/*
|
||||
Initialise PLIB
|
||||
*/
|
||||
|
||||
ssgInit () ;
|
||||
puInit () ;
|
||||
|
||||
/*
|
||||
Set up the Sun.
|
||||
*/
|
||||
|
||||
sgVec3 sunposn ;
|
||||
sgSetVec3 ( sunposn, 200.0f, -500.0f, 500.0f ) ;
|
||||
ssgGetLight ( 0 ) -> setPosition ( sunposn ) ;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Set up the path to the data files
|
||||
*/
|
||||
|
||||
ssgModelPath ( "." ) ;
|
||||
ssgTexturePath ( "." ) ;
|
||||
|
||||
/*
|
||||
Create a root node
|
||||
*/
|
||||
|
||||
scene = new ssgRoot ;
|
||||
context = new ssgContext ;
|
||||
context->setCullface( true ) ;
|
||||
context->makeCurrent ( ) ;
|
||||
|
||||
/*
|
||||
** Set up PU
|
||||
*/
|
||||
text = new fntRenderer () ;
|
||||
font = new fntTexFont ( "data/default.txf" ) ;
|
||||
|
||||
puFont font1 ( font, 12 ) ;
|
||||
puFont font2 ( font, 15 ) ;
|
||||
puSetDefaultFonts ( font1, font2 ) ;
|
||||
puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ;
|
||||
puSetDefaultColourScheme ( 0.7f, 0.7f, 0.7f, 1.0f ) ;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
init_graphics ();
|
||||
glutMainLoop();
|
||||
return 0; /* ANSI C requires main to return int. */
|
||||
}
|
||||
|
||||
88
examples/src/ssg/viewer/viewer.dsp
Normal file
88
examples/src/ssg/viewer/viewer.dsp
Normal file
@@ -0,0 +1,88 @@
|
||||
# Microsoft Developer Studio Project File - Name="viewer" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=viewer - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "viewer.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "viewer.mak" CFG="viewer - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "viewer - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "viewer - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "viewer - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fnt.lib pui.lib puAux.lib ssg.lib sg.lib ul.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /out:"viewer.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "viewer - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ssg_d.lib sg_d.lib fnt_d.lib pui_d.lib puAux_d.lib ul_d.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /out:"viewer.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "viewer - Win32 Release"
|
||||
# Name "viewer - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\viewer.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
12
examples/src/ssg/water/Makefile.am
Normal file
12
examples/src/ssg/water/Makefile.am
Normal file
@@ -0,0 +1,12 @@
|
||||
if BUILD_SSG
|
||||
|
||||
noinst_PROGRAMS = water
|
||||
|
||||
water_SOURCES = water.cxx
|
||||
|
||||
water_LDADD = -lplibpw -lplibpuaux -lplibpu -lplibfnt -lplibssgaux -lplibssg -lplibsg -lplibul $(OGL_LIBS)
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = water.dsp README
|
||||
|
||||
56
examples/src/ssg/water/README
Normal file
56
examples/src/ssg/water/README
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
Designing Waves.
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
The PLIB ssgAux library contains a class for handling
|
||||
water waves.
|
||||
|
||||
class ssgaWaveSystem ;
|
||||
|
||||
This generates a large polygonal mesh which it distorts in
|
||||
realtime to simulate water waves.
|
||||
|
||||
The simulation uses between one and sixteen "Wave Trains" - each
|
||||
using a class:
|
||||
|
||||
class ssgaWaveTrain ;
|
||||
|
||||
The program in this directory demonstrates this system and allows
|
||||
you to play with the wave train parameters.
|
||||
|
||||
Use the 'Edit Wave Train Number' widget to select which of the
|
||||
16 wave trains you want to play with. There is a button just
|
||||
below that to enable or disable that particular wave train - and
|
||||
for convenience, there is a button to disable ALL wave trains.
|
||||
|
||||
It's often convenient to turn on just one wave train at a time
|
||||
and set it's parameters - then combine two, three or more to
|
||||
produce the final effect.
|
||||
|
||||
Each wave train has a direction in which the waves are travelling,
|
||||
a speed, a wave length (which also affects the shape of the wave),
|
||||
the height of the wave and a 'curl' term (which controls how much
|
||||
the tops of the waves bend over).
|
||||
|
||||
The appearance of waves varies greatly with the depth of the
|
||||
water - and this simulation produces the correct effects. There
|
||||
are a number of preset water depths that you can select between,
|
||||
notice that the effect of varying the depth is more pronounced
|
||||
for long Wave Lengths.
|
||||
|
||||
There are also controls to set the eyepoint pan/tilt/range and to
|
||||
toggle the system into wireframe.
|
||||
|
||||
You can determine the number of polygons used to render
|
||||
the patch of waves, the size of the wave patch and the amount
|
||||
of texture repetition with the three sliders in the bottom right.
|
||||
|
||||
Hitting the space bar toggles the GUI on and off so you can see
|
||||
your creation without any clutter on the screen.
|
||||
|
||||
Finally, when you have your waves exactly how you like them, hit
|
||||
the 'Write C++' button and a C++ subroutine to recreate the
|
||||
exact same-looking waves will be written to stdout.
|
||||
|
||||
|
||||
|
||||
BIN
examples/src/ssg/water/data/droplet.rgb
Normal file
BIN
examples/src/ssg/water/data/droplet.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/water/data/ocean.rgb
Normal file
BIN
examples/src/ssg/water/data/ocean.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/water/data/pattern.rgb
Normal file
BIN
examples/src/ssg/water/data/pattern.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/water/data/pavement.rgb
Normal file
BIN
examples/src/ssg/water/data/pavement.rgb
Normal file
Binary file not shown.
BIN
examples/src/ssg/water/data/sorority.txf
Normal file
BIN
examples/src/ssg/water/data/sorority.txf
Normal file
Binary file not shown.
991
examples/src/ssg/water/water.cxx
Normal file
991
examples/src/ssg/water/water.cxx
Normal file
@@ -0,0 +1,991 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 2001 Steve Baker
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id: water.cxx 2077 2006-04-13 16:21:42Z bram $
|
||||
*/
|
||||
|
||||
#define PU_USE_PW
|
||||
|
||||
#ifndef GL_GLEXT_PROTOTYPES
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <plib/pw.h>
|
||||
#include <plib/ssg.h>
|
||||
#include <plib/ssgAux.h>
|
||||
#include <plib/pu.h>
|
||||
#include <plib/puAux.h>
|
||||
|
||||
#ifndef GL_VERSION_1_3
|
||||
// ARB_multitexture
|
||||
#define GL_TEXTURE0 GL_TEXTURE0_ARB
|
||||
#define GL_TEXTURE1 GL_TEXTURE1_ARB
|
||||
#define glActiveTexture glActiveTextureARB
|
||||
#endif
|
||||
|
||||
#define GUI_BASE 90
|
||||
#define VIEW_GUI_BASE 30
|
||||
#define FONT_COLOUR 1,1,1,1
|
||||
|
||||
static puSlider *trainLengthSlider = (puSlider *) NULL ;
|
||||
static puSlider *trainSpeedSlider = (puSlider *) NULL ;
|
||||
static puSlider *trainLambdaSlider = (puSlider *) NULL ;
|
||||
static puSlider *trainHeightSlider = (puSlider *) NULL ;
|
||||
static puButton *trainEnableButton = (puButton *) NULL ;
|
||||
static puOneShot *trainDisableButton = (puOneShot *) NULL ;
|
||||
static puDial *trainHeadingDial = (puDial *) NULL ;
|
||||
static puaSelectBox *trainSelectBox = (puaSelectBox *) NULL ;
|
||||
static puText *timeText = (puText *) NULL ;
|
||||
|
||||
static puaSelectBox *depthSelectBox = (puaSelectBox *) NULL ;
|
||||
|
||||
static puDial *viewHeadingDial = (puDial *) NULL ;
|
||||
static puDial *viewPitchDial = (puDial *) NULL ;
|
||||
static puSlider *viewRangeSlider = (puSlider *) NULL ;
|
||||
static puButton *viewWireframeButton= (puButton *) NULL ;
|
||||
static puButton *viewEnvMapButton = (puButton *) NULL ;
|
||||
|
||||
static puOneShot *writeButton = (puOneShot *) NULL ;
|
||||
|
||||
static puSlider *waveTextureSlider = (puSlider *) NULL ;
|
||||
static puSlider *waveSizeSlider = (puSlider *) NULL ;
|
||||
static puSlider *wavePolycountSlider= (puSlider *) NULL ;
|
||||
|
||||
static ssgRoot *scene = NULL ;
|
||||
static ssgaLensFlare *sun_obj = NULL ;
|
||||
static ssgTransform *sun = NULL ;
|
||||
static ssgTransform *teapot = NULL ;
|
||||
static ssgTransform *fire = NULL ;
|
||||
static ssgTransform *pedestal = NULL ;
|
||||
static ssgaWaveSystem *ocean = NULL ;
|
||||
static ssgaParticleSystem *fountain = NULL ;
|
||||
static ssgaCube *ped_obj = NULL ;
|
||||
static ssgaTeapot *tpt_obj = NULL ;
|
||||
static ssgaFire *fire_obj = NULL ;
|
||||
|
||||
static ssgSimpleState *sea_state = NULL ;
|
||||
static ssgSimpleState *splash_state = NULL ;
|
||||
static ssgSimpleState *teapot_state = NULL ;
|
||||
static ssgSimpleState *plinth_state = NULL ;
|
||||
|
||||
static ssgContext *context = NULL ;
|
||||
|
||||
static ssgaWaveTrain trains [ 16 ] ;
|
||||
|
||||
static char *trainNameList[] =
|
||||
{
|
||||
"Train 0" , "Train 1" , "Train 2" , "Train 3" , "Train 4" ,
|
||||
"Train 5" , "Train 6" , "Train 7" , "Train 8" , "Train 9" ,
|
||||
"Train 10", "Train 11", "Train 12", "Train 13", "Train 14",
|
||||
"Train 15",
|
||||
NULL
|
||||
} ;
|
||||
|
||||
static int quit = FALSE;
|
||||
|
||||
static int curr_train = 0 ;
|
||||
static int curr_depthfunc = 0 ;
|
||||
static int wireframe = FALSE ;
|
||||
static int displayGUI = TRUE ;
|
||||
static float cam_range = 25.0f ;
|
||||
|
||||
static sgCoord campos = { { 0, -20, 8 }, { 0, -30, 0 } } ;
|
||||
static sgVec3 sunpos = { 400, 300, 50 } ;
|
||||
|
||||
static int enableTexGen ( ssgEntity * )
|
||||
{
|
||||
#ifdef GL_ARB_multitexture
|
||||
int tx ;
|
||||
glGetIntegerv ( GL_TEXTURE_BINDING_2D, &tx ) ;
|
||||
glActiveTexture ( GL_TEXTURE1 ) ;
|
||||
#endif
|
||||
glTexGeni ( GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP ) ;
|
||||
glTexGeni ( GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP ) ;
|
||||
glEnable ( GL_TEXTURE_GEN_S ) ;
|
||||
glEnable ( GL_TEXTURE_GEN_T ) ;
|
||||
#ifdef GL_ARB_multitexture
|
||||
glEnable ( GL_TEXTURE_2D ) ; /* Enables the second texture map. */
|
||||
glBindTexture ( GL_TEXTURE_2D, tx ) ;
|
||||
glActiveTexture ( GL_TEXTURE0 ) ;
|
||||
#endif
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
static int disableTexGen ( ssgEntity * )
|
||||
{
|
||||
#ifdef GL_ARB_multitexture
|
||||
glActiveTexture ( GL_TEXTURE1 ) ;
|
||||
#endif
|
||||
glDisable ( GL_TEXTURE_GEN_S ) ;
|
||||
glDisable ( GL_TEXTURE_GEN_T ) ;
|
||||
#ifdef GL_ARB_multitexture
|
||||
glDisable ( GL_TEXTURE_2D ) ; /* Disables the second texture map */
|
||||
glActiveTexture ( GL_TEXTURE0 ) ;
|
||||
#endif
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
static void writeCplusplusCode ()
|
||||
{
|
||||
if ( viewEnvMapButton -> getIntegerValue () )
|
||||
{
|
||||
printf ( "\n" ) ;
|
||||
printf ( "static int enableTexGen ( ssgEntity * )\n" ) ;
|
||||
printf ( "{\n" ) ;
|
||||
printf ( "#ifdef GL_ARB_multitexture\n" ) ;
|
||||
printf ( " int tx ;\n" ) ;
|
||||
printf ( " glGetIntegerv ( GL_TEXTURE_BINDING_2D, &tx ) ;\n" ) ;
|
||||
printf ( " glActiveTextureARB ( GL_TEXTURE1_ARB ) ;\n" ) ;
|
||||
printf ( "#endif\n" ) ;
|
||||
printf ( " glTexGeni ( GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP ) ;\n" ) ;
|
||||
printf ( " glTexGeni ( GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP ) ;\n" ) ;
|
||||
printf ( " glEnable ( GL_TEXTURE_GEN_S ) ;\n" ) ;
|
||||
printf ( " glEnable ( GL_TEXTURE_GEN_T ) ;\n" ) ;
|
||||
printf ( " glEnable ( GL_TEXTURE_2D ) ;\n" ) ;
|
||||
printf ( "#ifdef GL_ARB_multitexture\n" ) ;
|
||||
printf ( " glBindTexture ( GL_TEXTURE_2D, tx ) ;\n" ) ;
|
||||
printf ( " glActiveTextureARB ( GL_TEXTURE0_ARB ) ;\n" ) ;
|
||||
printf ( "#endif\n" ) ;
|
||||
printf ( " return TRUE ;\n" ) ;
|
||||
printf ( "} \n" ) ;
|
||||
printf ( "\n" ) ;
|
||||
printf ( "static int disableTexGen ( ssgEntity * )\n" ) ;
|
||||
printf ( "{\n" ) ;
|
||||
printf ( "#ifdef GL_ARB_multitexture\n" ) ;
|
||||
printf ( " glActiveTextureARB ( GL_TEXTURE1_ARB ) ;\n" ) ;
|
||||
printf ( "#endif\n" ) ;
|
||||
printf ( " glDisable ( GL_TEXTURE_GEN_S ) ;\n" ) ;
|
||||
printf ( " glDisable ( GL_TEXTURE_GEN_T ) ;\n" ) ;
|
||||
printf ( " glDisable ( GL_TEXTURE_2D ) ;\n" ) ;
|
||||
printf ( "#ifdef GL_ARB_multitexture\n" ) ;
|
||||
printf ( " glActiveTextureARB ( GL_TEXTURE0_ARB ) ;\n" ) ;
|
||||
printf ( "#endif\n" ) ;
|
||||
printf ( " return TRUE ;\n" ) ;
|
||||
printf ( "}\n" ) ;
|
||||
printf ( "\n" ) ;
|
||||
}
|
||||
|
||||
printf ( "\n" ) ;
|
||||
printf ( "ssgaWaveSystem *makeWaveSystem ( ssgState *state )\n" ) ;
|
||||
printf ( "{\n" ) ;
|
||||
printf ( " ssgaWaveTrain *wavetrain ;\n" ) ;
|
||||
printf ( " ssgaWaveSystem *ocean ;\n" ) ;
|
||||
printf ( " ocean = new ssgaWaveSystem ( %d ) ;\n", ocean->getNumTris() ) ;
|
||||
printf ( " ocean -> setSize ( %g ) ;\n", ocean->getSize()[0] ) ;
|
||||
printf ( " ocean -> setKidState ( state ) ;\n" ) ;
|
||||
printf ( " ocean -> setTexScale ( %g, %g ) ;\n",
|
||||
ocean->getTexScaleU (),
|
||||
ocean->getTexScaleV () ) ;
|
||||
printf ( " ocean -> setWindSpeed ( 10.0f ) ;\n\n" ) ;
|
||||
|
||||
for ( int i = 0 ; i < SSGA_MAX_WAVETRAIN ; i++ )
|
||||
{
|
||||
if ( ocean -> getWaveTrain ( i ) != NULL )
|
||||
{
|
||||
printf ( " wavetrain = new ssgaWaveTrain () ;\n" ) ;
|
||||
|
||||
printf ( " wavetrain->setSpeed ( %g ) ;\n",trains[i].getSpeed ());
|
||||
printf ( " wavetrain->setLength ( %g ) ;\n",trains[i].getLength ());
|
||||
printf ( " wavetrain->setLambda ( %g ) ;\n",trains[i].getLambda ());
|
||||
printf ( " wavetrain->setHeading ( %g ) ;\n",trains[i].getHeading ());
|
||||
printf ( " wavetrain->setWaveHeight ( %g ) ;\n",trains[i].getWaveHeight());
|
||||
|
||||
printf ( " ocean -> setWaveTrain ( %d, wavetrain ) ;\n\n", i ) ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( viewEnvMapButton -> getIntegerValue () )
|
||||
{
|
||||
printf ( " ocean -> setKidCallback ( SSG_CALLBACK_PREDRAW , enableTexGen ) ;\n" ) ;
|
||||
printf ( " ocean -> setKidCallback ( SSG_CALLBACK_POSTDRAW, disableTexGen ) ;\n" ) ;
|
||||
}
|
||||
printf ( " ocean -> regenerate () ;\n" ) ;
|
||||
printf ( " return ocean ;\n" ) ;
|
||||
printf ( "}\n" ) ;
|
||||
printf ( "\n" ) ;
|
||||
}
|
||||
|
||||
|
||||
static void waveTextureSlider_cb ( puObject *ob )
|
||||
{
|
||||
ocean -> setTexScale ( ob -> getFloatValue (),
|
||||
ob -> getFloatValue () ) ;
|
||||
}
|
||||
|
||||
|
||||
static void waveSizeSlider_cb ( puObject *ob )
|
||||
{
|
||||
cam_range = ob -> getFloatValue () ;
|
||||
ocean -> setSize ( ob -> getFloatValue () ) ;
|
||||
}
|
||||
|
||||
|
||||
static void wavePolycountSlider_cb ( puObject *ob )
|
||||
{
|
||||
ocean -> setNumTris ( ob -> getIntegerValue () ) ;
|
||||
}
|
||||
|
||||
|
||||
static void viewHeadingDial_cb ( puObject *ob )
|
||||
{
|
||||
campos.hpr[0] = ob -> getFloatValue () ;
|
||||
|
||||
sgVec3 r = { 0, -cam_range, 0 } ;
|
||||
sgMat4 mat ;
|
||||
|
||||
sgMakeRotMat4 ( mat, campos.hpr ) ;
|
||||
sgXformVec3 ( campos.xyz, r, mat ) ;
|
||||
}
|
||||
|
||||
|
||||
static void viewPitchDial_cb ( puObject *ob )
|
||||
{
|
||||
campos . hpr [ 1 ] = ob -> getFloatValue () ;
|
||||
|
||||
sgVec3 r = { 0, -cam_range, 0 } ;
|
||||
sgMat4 mat ;
|
||||
|
||||
sgMakeRotMat4 ( mat, campos.hpr ) ;
|
||||
sgXformVec3 ( campos.xyz, r, mat ) ;
|
||||
}
|
||||
|
||||
|
||||
static void viewRangeSlider_cb ( puObject *ob )
|
||||
{
|
||||
cam_range = ob -> getFloatValue () ;
|
||||
|
||||
sgVec3 r = { 0, -cam_range, 0 } ;
|
||||
sgMat4 mat ;
|
||||
|
||||
sgMakeRotMat4 ( mat, campos.hpr ) ;
|
||||
sgXformVec3 ( campos.xyz, r, mat ) ;
|
||||
}
|
||||
|
||||
|
||||
static void viewWireframeButton_cb ( puObject *ob )
|
||||
{
|
||||
wireframe = ob -> getIntegerValue () ;
|
||||
}
|
||||
|
||||
|
||||
static void viewEnvMapButton_cb ( puObject *ob )
|
||||
{
|
||||
if ( ob -> getIntegerValue () )
|
||||
{
|
||||
ocean -> setKidCallback ( SSG_CALLBACK_PREDRAW , enableTexGen ) ;
|
||||
ocean -> setKidCallback ( SSG_CALLBACK_POSTDRAW, disableTexGen ) ;
|
||||
ocean -> regenerate () ;
|
||||
}
|
||||
else
|
||||
{
|
||||
ocean -> setKidCallback ( SSG_CALLBACK_PREDRAW , NULL ) ;
|
||||
ocean -> setKidCallback ( SSG_CALLBACK_POSTDRAW, NULL ) ;
|
||||
ocean -> regenerate () ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void trainLengthSlider_cb ( puObject *ob )
|
||||
{
|
||||
trains[curr_train].setLength ( ob -> getFloatValue () ) ;
|
||||
ob -> setLegend ( ob -> getStringValue () ) ;
|
||||
}
|
||||
|
||||
|
||||
static void trainSpeedSlider_cb ( puObject *ob )
|
||||
{
|
||||
trains[curr_train].setSpeed ( ob -> getFloatValue () ) ;
|
||||
ob -> setLegend ( ob -> getStringValue () ) ;
|
||||
}
|
||||
|
||||
|
||||
static void trainLambdaSlider_cb ( puObject *ob )
|
||||
{
|
||||
trains[curr_train].setLambda ( ob -> getFloatValue () ) ;
|
||||
ob -> setLegend ( ob -> getStringValue () ) ;
|
||||
}
|
||||
|
||||
|
||||
static void trainHeightSlider_cb ( puObject *ob )
|
||||
{
|
||||
trains[curr_train].setWaveHeight ( ob -> getFloatValue () ) ;
|
||||
ob -> setLegend ( ob -> getStringValue () ) ;
|
||||
}
|
||||
|
||||
static void trainDisableButton_cb ( puObject *ob )
|
||||
{
|
||||
for ( int i = 0 ; i < SSGA_MAX_WAVETRAIN ; i++ )
|
||||
ocean -> setWaveTrain ( i, NULL ) ;
|
||||
|
||||
trainEnableButton -> setValue ( 0 ) ;
|
||||
}
|
||||
|
||||
static void writeButton_cb ( puObject *ob )
|
||||
{
|
||||
if ( ob -> getIntegerValue () )
|
||||
writeCplusplusCode () ;
|
||||
}
|
||||
|
||||
static void trainEnableButton_cb ( puObject *ob )
|
||||
{
|
||||
if ( ob -> getIntegerValue () )
|
||||
ocean -> setWaveTrain ( curr_train, & trains [ curr_train ] ) ;
|
||||
else
|
||||
ocean -> setWaveTrain ( curr_train, NULL ) ;
|
||||
}
|
||||
|
||||
static void trainHeadingDial_cb ( puObject *ob )
|
||||
{
|
||||
trains[curr_train].setHeading ( ob -> getFloatValue () ) ;
|
||||
ob -> setLegend ( ob -> getStringValue () ) ;
|
||||
}
|
||||
|
||||
static void trainSelectBox_cb ( puObject *ob )
|
||||
{
|
||||
curr_train = ((puaSelectBox *) ob) -> getCurrentItem () ;
|
||||
|
||||
if ( curr_train < 0 )
|
||||
curr_train = 0 ;
|
||||
|
||||
if ( curr_train >= SSGA_MAX_WAVETRAIN )
|
||||
curr_train = SSGA_MAX_WAVETRAIN - 1 ;
|
||||
|
||||
trainEnableButton -> setValue (
|
||||
ocean -> getWaveTrain ( curr_train ) != NULL ) ;
|
||||
|
||||
trainLengthSlider -> setValue ( trains[curr_train].getLength () ) ;
|
||||
trainSpeedSlider -> setValue ( trains[curr_train].getSpeed () ) ;
|
||||
trainLambdaSlider -> setValue ( trains[curr_train].getLambda () ) ;
|
||||
trainHeightSlider -> setValue ( trains[curr_train].getWaveHeight () ) ;
|
||||
trainHeadingDial -> setValue ( trains[curr_train].getHeading () ) ;
|
||||
}
|
||||
|
||||
|
||||
static float halfMeterEverywhere ( float x, float y )
|
||||
{
|
||||
return 0.5f ;
|
||||
}
|
||||
|
||||
|
||||
static float oneMeterEverywhere ( float x, float y )
|
||||
{
|
||||
return 1.0f ;
|
||||
}
|
||||
|
||||
|
||||
static float twoMeterEverywhere ( float x, float y )
|
||||
{
|
||||
return 1.5f ;
|
||||
}
|
||||
|
||||
|
||||
static float gentleSlope ( float x, float y )
|
||||
{
|
||||
return (1.0f + x / (ocean -> getSize ()[0] / 2.0f)) * 2.0f ;
|
||||
}
|
||||
|
||||
|
||||
static float steepSlope ( float x, float y )
|
||||
{
|
||||
return (1.0f + x / (ocean -> getSize ()[0] / 2.0f)) * 10.0f ;
|
||||
}
|
||||
|
||||
|
||||
static float stepFunction ( float x, float y )
|
||||
{
|
||||
return (x < 0.0f ) ? 0.5f : 20000.0f ;
|
||||
}
|
||||
|
||||
|
||||
static float twoBeaches ( float x, float y )
|
||||
{
|
||||
return (float) fabs ( sin( x / ocean->getSize()[0]) *
|
||||
sin(2.0f * y / ocean->getSize()[1]) * 1.5 + 0.5 ) ;
|
||||
}
|
||||
|
||||
static const ssgaWSDepthCallback depthFuncs [] =
|
||||
{
|
||||
NULL, /* Infinite depth */
|
||||
halfMeterEverywhere,
|
||||
oneMeterEverywhere,
|
||||
twoMeterEverywhere,
|
||||
gentleSlope,
|
||||
steepSlope,
|
||||
stepFunction,
|
||||
twoBeaches,
|
||||
NULL,
|
||||
} ;
|
||||
|
||||
static char *depthNames [] =
|
||||
{
|
||||
"Infinite Depth",
|
||||
"Half Meter Deep",
|
||||
"One Meter Deep",
|
||||
"Two Meters Deep",
|
||||
"Gentle Slope",
|
||||
"Steep Slope",
|
||||
"Step Function",
|
||||
"Two Curved Beaches",
|
||||
NULL,
|
||||
} ;
|
||||
|
||||
static void depthSelectBox_cb ( puObject *ob )
|
||||
{
|
||||
curr_depthfunc = ((puaSelectBox *) ob) -> getCurrentItem () ;
|
||||
|
||||
if ( curr_depthfunc < 0 )
|
||||
curr_depthfunc = 0 ;
|
||||
|
||||
if ( curr_depthfunc >= (int)(sizeof(depthFuncs)/sizeof(ssgaWSDepthCallback)))
|
||||
curr_depthfunc = (int)(sizeof(depthFuncs)/sizeof(ssgaWSDepthCallback)) - 1 ;
|
||||
|
||||
ocean -> setDepthCallback ( depthFuncs [ curr_depthfunc ] ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void update_motion ()
|
||||
{
|
||||
static ulClock ck ;
|
||||
static char s [ 128 ] ;
|
||||
|
||||
ck . update () ;
|
||||
|
||||
double t = ck . getAbsTime () ;
|
||||
float dt = (float) ck . getDeltaTime () ;
|
||||
|
||||
ocean -> setWindDirn ( (float)( 25.0 * sin ( t / 100.0 ) ) ) ;
|
||||
ocean -> updateAnimation ( (float) t ) ;
|
||||
|
||||
fountain -> update ( dt ) ;
|
||||
fire_obj -> update ( dt ) ;
|
||||
|
||||
dt = (float) ck . getDeltaTime () ;
|
||||
|
||||
sprintf ( s, "CalcTime=%1.1fms", dt * 1000.0 ) ;
|
||||
timeText->setLabel ( s ) ;
|
||||
sgCoord tptpos ;
|
||||
|
||||
context -> setCamera ( & campos ) ;
|
||||
|
||||
sgSetCoord ( & tptpos, 0.0f, 0.0f, 0.6f, (float)(t * 60), 0.0f, 0.0f ) ;
|
||||
teapot -> setTransform ( & tptpos ) ;
|
||||
sgSetCoord ( & tptpos, 0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f ) ;
|
||||
fire -> setTransform ( & tptpos ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The PW window reshape event
|
||||
*/
|
||||
|
||||
static void reshape ( int w, int h )
|
||||
{
|
||||
glViewport ( 0, 0, w, h ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The PW keyboard/mouse events
|
||||
*/
|
||||
|
||||
static void keyboard ( int key, int updown, int, int )
|
||||
{
|
||||
if ( ! puKeyboard ( key, updown ) && ( updown == PU_DOWN ) )
|
||||
{
|
||||
switch ( key )
|
||||
{
|
||||
case 0x03 :
|
||||
case 0x1B :
|
||||
case 'q' :
|
||||
exit ( 0 ) ;
|
||||
|
||||
case ' ' :
|
||||
default :
|
||||
displayGUI = ! displayGUI ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void motionfn ( int x, int y )
|
||||
{
|
||||
if ( displayGUI )
|
||||
puMouse ( x, y ) ;
|
||||
}
|
||||
|
||||
static void mousefn ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( displayGUI )
|
||||
puMouse ( button, updown, x, y ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The redraw function
|
||||
*/
|
||||
|
||||
static void main_loop ()
|
||||
{
|
||||
while ( !quit )
|
||||
{
|
||||
update_motion () ;
|
||||
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
|
||||
|
||||
if ( wireframe )
|
||||
glPolygonMode ( GL_FRONT_AND_BACK, GL_LINE ) ;
|
||||
else
|
||||
glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL ) ;
|
||||
|
||||
ssgCullAndDraw ( scene ) ;
|
||||
|
||||
glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL ) ;
|
||||
|
||||
if ( displayGUI )
|
||||
puDisplay () ;
|
||||
|
||||
pwSwapBuffers () ;
|
||||
}
|
||||
|
||||
pwCleanup () ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void init_graphics ()
|
||||
{
|
||||
/*
|
||||
Initialise PW
|
||||
*/
|
||||
pwInit ( 50, 50, 640, 480, FALSE, "Simple Scene Graph : Water Example Program.", TRUE, 0) ;
|
||||
pwSetCallbacks ( keyboard, mousefn, motionfn, reshape ) ;
|
||||
|
||||
puInit () ;
|
||||
ssgInit () ;
|
||||
|
||||
/*
|
||||
Some basic OpenGL setup
|
||||
*/
|
||||
|
||||
glClearColor ( 0.2f, 0.7f, 1.0f, 1.0f ) ;
|
||||
glEnable ( GL_DEPTH_TEST ) ;
|
||||
|
||||
/*
|
||||
Set up the viewing parameters
|
||||
*/
|
||||
context = new ssgContext () ;
|
||||
context -> setFOV ( 60.0f, 0.0f ) ;
|
||||
context -> setNearFar ( 1.0f, 700.0f ) ;
|
||||
context -> makeCurrent () ;
|
||||
|
||||
/*
|
||||
Set up the Sun.
|
||||
*/
|
||||
|
||||
ssgGetLight ( 0 ) -> setPosition ( sunpos ) ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Particle system definitions for the fountain.
|
||||
*/
|
||||
|
||||
#define SPS ssgaParticleSystem /* Too much typing! */
|
||||
|
||||
static void droplet_create ( SPS *, int, ssgaParticle *p )
|
||||
{
|
||||
float c = ((float)(rand()%100)/100.0f) * (256.0f-163.0f)/255.0f ;
|
||||
|
||||
sgSetVec4 ( p -> col, 96.0f/255.0f+c, 147.0f/255.0f+c, 163.0f/255.0f+c, 0.5);
|
||||
sgSetVec3 ( p -> pos, -2.4f, -0.1f, 1.9f ) ;
|
||||
sgSetVec3 ( p -> vel,
|
||||
-(float)(rand()%1000)/200.0f,
|
||||
(float)(rand()%1000 - 500)/400.0f,
|
||||
(float)(rand()%1000)/1000.0f + 3.0f ) ;
|
||||
sgAddScaledVec3 ( p -> pos, p -> vel, (float)(rand()%1000)/20000.0f ) ;
|
||||
sgSetVec3 ( p -> acc, 0, 0, -9.8f ) ;
|
||||
p -> time_to_live = 1 ;
|
||||
}
|
||||
|
||||
|
||||
static void init_states ()
|
||||
{
|
||||
plinth_state = new ssgSimpleState () ;
|
||||
plinth_state -> setTexture ( "data/pavement.rgb" ) ;
|
||||
plinth_state -> enable ( GL_TEXTURE_2D ) ;
|
||||
plinth_state -> setShadeModel ( GL_SMOOTH ) ;
|
||||
plinth_state -> enable ( GL_CULL_FACE ) ;
|
||||
plinth_state -> enable ( GL_BLEND ) ;
|
||||
plinth_state -> enable ( GL_LIGHTING ) ;
|
||||
plinth_state -> setColourMaterial ( GL_AMBIENT_AND_DIFFUSE ) ;
|
||||
plinth_state -> setMaterial ( GL_EMISSION, 0, 0, 0, 1 ) ;
|
||||
plinth_state -> setMaterial ( GL_SPECULAR, 1, 1, 1, 1 ) ;
|
||||
plinth_state -> setShininess ( 2 ) ;
|
||||
|
||||
teapot_state = new ssgSimpleState () ;
|
||||
teapot_state -> setTexture ( "data/pattern.rgb" ) ;
|
||||
teapot_state -> enable ( GL_TEXTURE_2D ) ;
|
||||
teapot_state -> setShadeModel ( GL_SMOOTH ) ;
|
||||
teapot_state -> enable ( GL_CULL_FACE ) ;
|
||||
teapot_state -> enable ( GL_BLEND ) ;
|
||||
teapot_state -> enable ( GL_LIGHTING ) ;
|
||||
teapot_state -> setColourMaterial ( GL_AMBIENT_AND_DIFFUSE ) ;
|
||||
teapot_state -> setMaterial ( GL_EMISSION, 0, 0, 0, 1 ) ;
|
||||
teapot_state -> setMaterial ( GL_SPECULAR, 1, 1, 1, 1 ) ;
|
||||
teapot_state -> setShininess ( 2 ) ;
|
||||
|
||||
sea_state = new ssgSimpleState () ;
|
||||
sea_state -> setTexture ( "data/ocean.rgb" ) ;
|
||||
sea_state -> setTranslucent () ;
|
||||
sea_state -> enable ( GL_TEXTURE_2D ) ;
|
||||
sea_state -> setShadeModel ( GL_SMOOTH ) ;
|
||||
sea_state -> enable ( GL_CULL_FACE ) ;
|
||||
sea_state -> enable ( GL_BLEND ) ;
|
||||
sea_state -> enable ( GL_LIGHTING ) ;
|
||||
sea_state -> setColourMaterial ( GL_AMBIENT_AND_DIFFUSE ) ;
|
||||
sea_state -> setMaterial ( GL_EMISSION, 0, 0, 0, 1 ) ;
|
||||
sea_state -> setMaterial ( GL_SPECULAR, 1, 1, 1, 1 ) ;
|
||||
sea_state -> setShininess ( 5 ) ;
|
||||
|
||||
splash_state = new ssgSimpleState () ;
|
||||
splash_state -> setTexture ( "data/droplet.rgb" ) ;
|
||||
splash_state -> setTranslucent () ;
|
||||
splash_state -> enable ( GL_TEXTURE_2D ) ;
|
||||
splash_state -> setShadeModel ( GL_SMOOTH ) ;
|
||||
splash_state -> enable ( GL_CULL_FACE ) ;
|
||||
splash_state -> enable ( GL_BLEND ) ;
|
||||
splash_state -> enable ( GL_LIGHTING ) ;
|
||||
splash_state -> setColourMaterial ( GL_EMISSION ) ;
|
||||
splash_state -> setMaterial ( GL_AMBIENT, 0, 0, 0, 1 ) ;
|
||||
splash_state -> setMaterial ( GL_DIFFUSE, 0, 0, 0, 1 ) ;
|
||||
splash_state -> setMaterial ( GL_SPECULAR, 0, 0, 0, 1 ) ;
|
||||
splash_state -> setShininess ( 0 ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void load_database ()
|
||||
{
|
||||
/* Set up the path to the data files */
|
||||
|
||||
ssgModelPath ( "data" ) ;
|
||||
ssgTexturePath ( "data" ) ;
|
||||
|
||||
/* Load the states */
|
||||
|
||||
init_states () ;
|
||||
|
||||
sgVec4 TRANSLUCENT_WHITE = { 1.0f, 1.0f, 1.0f, 0.8f } ;
|
||||
sgVec3 pos = { 0, 0, 0 } ;
|
||||
sgCoord pedpos = { { 0, 0, -1.5 }, { 0, 0, 0 } } ;
|
||||
|
||||
/* Create a the scene content. */
|
||||
|
||||
fountain = new ssgaParticleSystem ( 1000, 100, 500, TRUE,
|
||||
0.2f, 1000,
|
||||
droplet_create ) ;
|
||||
fountain -> setState ( splash_state ) ;
|
||||
|
||||
/* Set up some interesting defaults. */
|
||||
|
||||
trains[0] . setSpeed ( 3.1f ) ;
|
||||
trains[0] . setLength ( 0.8f ) ;
|
||||
trains[0] . setLambda ( 0.6f ) ;
|
||||
trains[0] . setHeading ( 47.0f ) ;
|
||||
trains[0] . setWaveHeight ( 0.2f ) ;
|
||||
|
||||
trains[1] . setSpeed ( 4.6f ) ;
|
||||
trains[1] . setLength ( 0.8f ) ;
|
||||
trains[1] . setLambda ( 1.0f ) ;
|
||||
trains[1] . setHeading ( 36.0f ) ;
|
||||
trains[1] . setWaveHeight ( 0.1f ) ;
|
||||
|
||||
trains[2] . setSpeed ( 8.5f ) ;
|
||||
trains[2] . setLength ( 0.6f ) ;
|
||||
trains[2] . setLambda ( 1.0f ) ;
|
||||
trains[2] . setHeading ( 65.0f ) ;
|
||||
trains[2] . setWaveHeight ( 0.1f ) ;
|
||||
|
||||
ocean = new ssgaWaveSystem ( 10000 ) ;
|
||||
ocean -> setColour ( TRANSLUCENT_WHITE ) ;
|
||||
ocean -> setSize ( 100 ) ;
|
||||
ocean -> setTexScale ( 3, 3 ) ;
|
||||
ocean -> setCenter ( pos ) ;
|
||||
ocean -> setDepthCallback ( depthFuncs [ curr_depthfunc ] ) ;
|
||||
ocean -> setKidState ( sea_state ) ;
|
||||
ocean -> setWindSpeed ( 10.0f ) ;
|
||||
ocean -> setWaveTrain ( 0, & trains[0] ) ;
|
||||
ocean -> setWaveTrain ( 1, & trains[1] ) ;
|
||||
ocean -> setWaveTrain ( 2, & trains[2] ) ;
|
||||
|
||||
ped_obj = new ssgaCube () ;
|
||||
ped_obj -> setSize ( 4 ) ;
|
||||
ped_obj -> setKidState ( plinth_state ) ;
|
||||
ped_obj -> regenerate () ;
|
||||
|
||||
tpt_obj = new ssgaTeapot ( 1000 ) ;
|
||||
tpt_obj -> setSize ( 2 ) ;
|
||||
tpt_obj -> setKidState ( teapot_state ) ;
|
||||
tpt_obj -> regenerate () ;
|
||||
|
||||
fire_obj = new ssgaFire ( 200 ) ;
|
||||
|
||||
/* Build the scene graph */
|
||||
|
||||
teapot = new ssgTransform ;
|
||||
teapot -> addKid ( tpt_obj ) ;
|
||||
teapot -> addKid ( fountain ) ;
|
||||
|
||||
pedestal = new ssgTransform ;
|
||||
pedestal -> setTransform ( & pedpos ) ;
|
||||
pedestal -> addKid ( ped_obj ) ;
|
||||
|
||||
sun_obj = new ssgaLensFlare () ;
|
||||
|
||||
sun = new ssgTransform ;
|
||||
sun -> setTransform ( sunpos ) ;
|
||||
sun -> addKid ( sun_obj ) ;
|
||||
|
||||
fire = new ssgTransform ;
|
||||
fire -> addKid ( fire_obj ) ;
|
||||
|
||||
scene = new ssgRoot ;
|
||||
scene -> addKid ( ocean ) ;
|
||||
scene -> addKid ( fire ) ;
|
||||
scene -> addKid ( pedestal ) ;
|
||||
scene -> addKid ( teapot ) ;
|
||||
scene -> addKid ( sun ) ;
|
||||
}
|
||||
|
||||
|
||||
static void init_gui ()
|
||||
{
|
||||
static puFont *sorority ;
|
||||
static fntTexFont *fnt ;
|
||||
|
||||
fnt = new fntTexFont () ;
|
||||
fnt -> load ( "data/sorority.txf" ) ;
|
||||
sorority = new puFont ( fnt, 12 ) ;
|
||||
|
||||
puSetDefaultFonts ( *sorority, *sorority ) ;
|
||||
puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ;
|
||||
puSetDefaultColourScheme ( 0.2f, 0.5f, 0.2f, 0.5f ) ;
|
||||
|
||||
puGroup *window_group = new puGroup ( 0, 0 ) ;
|
||||
|
||||
trainLengthSlider = new puSlider ( 200, GUI_BASE+28, 90, false, 20 ) ;
|
||||
trainLengthSlider->setMaxValue ( 20.0f ) ;
|
||||
trainLengthSlider->setMinValue ( 0.1f ) ;
|
||||
trainLengthSlider->setStepSize ( 0.1f ) ;
|
||||
trainLengthSlider->setCBMode ( PUSLIDER_ALWAYS ) ;
|
||||
trainLengthSlider->setCallback ( trainLengthSlider_cb ) ;
|
||||
trainLengthSlider->setLabel ( "Wave Length" ) ;
|
||||
trainLengthSlider->setLabelPlace ( PUPLACE_CENTERED_LEFT ) ;
|
||||
trainLengthSlider->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
trainSpeedSlider = new puSlider ( 200, GUI_BASE+56, 90, false, 20 ) ;
|
||||
trainSpeedSlider->setMaxValue ( 20.0f ) ;
|
||||
trainSpeedSlider->setMinValue ( 0.0f ) ;
|
||||
trainSpeedSlider->setStepSize ( 0.1f ) ;
|
||||
trainSpeedSlider->setCBMode ( PUSLIDER_ALWAYS ) ;
|
||||
trainSpeedSlider->setCallback ( trainSpeedSlider_cb ) ;
|
||||
trainSpeedSlider->setLabel ( "Wave Speed" ) ;
|
||||
trainSpeedSlider->setLabelPlace ( PUPLACE_CENTERED_LEFT ) ;
|
||||
trainSpeedSlider->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
trainLambdaSlider = new puSlider ( 300, GUI_BASE+28, 90, false, 20 ) ;
|
||||
trainLambdaSlider->setMaxValue ( 2.0f ) ;
|
||||
trainLambdaSlider->setMinValue ( 0.0f ) ;
|
||||
trainLambdaSlider->setStepSize ( 0.1f ) ;
|
||||
trainLambdaSlider->setCBMode ( PUSLIDER_ALWAYS ) ;
|
||||
trainLambdaSlider->setCallback ( trainLambdaSlider_cb ) ;
|
||||
trainLambdaSlider->setLabel ( "Wave Curl" ) ;
|
||||
trainLambdaSlider->setLabelPlace ( PUPLACE_CENTERED_RIGHT ) ;
|
||||
trainLambdaSlider->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
trainHeightSlider = new puSlider ( 300, GUI_BASE+56, 90, false, 20 ) ;
|
||||
trainHeightSlider->setMaxValue ( 5.0f ) ;
|
||||
trainHeightSlider->setMinValue ( 0.0f ) ;
|
||||
trainHeightSlider->setStepSize ( 0.1f ) ;
|
||||
trainHeightSlider->setCBMode ( PUSLIDER_ALWAYS ) ;
|
||||
trainHeightSlider->setCallback ( trainHeightSlider_cb ) ;
|
||||
trainHeightSlider->setLabel ( "Wave Height (meters)" ) ;
|
||||
trainHeightSlider->setLabelPlace ( PUPLACE_CENTERED_RIGHT ) ;
|
||||
trainHeightSlider->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
trainEnableButton = new puButton ( 200, GUI_BASE+84, " " ) ;
|
||||
trainEnableButton->setStyle ( PUSTYLE_RADIO ) ;
|
||||
trainEnableButton->setCallback ( trainEnableButton_cb ) ;
|
||||
trainEnableButton->setLabel ( "Enable this Wave Train" ) ;
|
||||
trainEnableButton->setLabelPlace ( PUPLACE_CENTERED_LEFT ) ;
|
||||
trainEnableButton->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
trainDisableButton = new puOneShot( 450, GUI_BASE+120,
|
||||
"Disable All WaveTrains" ) ;
|
||||
trainDisableButton->setCallback ( trainDisableButton_cb ) ;
|
||||
|
||||
trainHeadingDial = new puDial ( 300, GUI_BASE+82, 50 ) ;
|
||||
trainHeadingDial->setWrap ( 1 ) ;
|
||||
trainHeadingDial->setMaxValue ( 360 ) ;
|
||||
trainHeadingDial->setMinValue ( 0 ) ;
|
||||
trainHeadingDial->setStepSize ( 1 ) ;
|
||||
trainHeadingDial->setCBMode ( PUSLIDER_ALWAYS ) ;
|
||||
trainHeadingDial->setCallback ( trainHeadingDial_cb ) ;
|
||||
trainHeadingDial->setLabel ( "Wave Direction" ) ;
|
||||
trainHeadingDial->setLabelPlace ( PUPLACE_CENTERED_RIGHT ) ;
|
||||
trainHeadingDial->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
trainHeadingDial->setLegendPlace ( PUPLACE_BOTTOM_CENTERED ) ;
|
||||
|
||||
trainSelectBox = new puaSelectBox ( 200, GUI_BASE+109, 300, GUI_BASE+139,
|
||||
trainNameList ) ;
|
||||
trainSelectBox->setCallback ( trainSelectBox_cb ) ;
|
||||
trainSelectBox->setCurrentItem ( 0 ) ;
|
||||
trainSelectBox->setLabel ( "Edit Wave Train Number" ) ;
|
||||
trainSelectBox->setLabelPlace ( PUPLACE_CENTERED_LEFT ) ;
|
||||
trainSelectBox->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
/* Set everything up on the first time around */
|
||||
trainSelectBox_cb ( trainSelectBox ) ;
|
||||
|
||||
depthSelectBox = new puaSelectBox ( 200, GUI_BASE, 400, GUI_BASE+20,
|
||||
depthNames ) ;
|
||||
depthSelectBox->setCallback ( depthSelectBox_cb ) ;
|
||||
depthSelectBox->setCurrentItem ( 0 ) ;
|
||||
depthSelectBox->setLabel ( "Water Depth" ) ;
|
||||
depthSelectBox->setLabelPlace ( PUPLACE_CENTERED_LEFT ) ;
|
||||
depthSelectBox->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
/* Set everything up on the first time around */
|
||||
depthSelectBox_cb ( depthSelectBox ) ;
|
||||
|
||||
viewHeadingDial = new puDial ( 50, VIEW_GUI_BASE, 50 ) ;
|
||||
viewHeadingDial->setValue ( 0.0f ) ;
|
||||
viewHeadingDial->setWrap ( 1 ) ;
|
||||
viewHeadingDial->setMaxValue ( 360 ) ;
|
||||
viewHeadingDial->setMinValue ( 0 ) ;
|
||||
viewHeadingDial->setStepSize ( 0 ) ;
|
||||
viewHeadingDial->setCBMode ( PUSLIDER_ALWAYS ) ;
|
||||
viewHeadingDial->setCallback ( viewHeadingDial_cb ) ;
|
||||
viewHeadingDial->setLabel ( "Pan" ) ;
|
||||
viewHeadingDial->setLabelPlace ( PUPLACE_BOTTOM_CENTERED ) ;
|
||||
viewHeadingDial->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
viewPitchDial = new puDial ( 100, VIEW_GUI_BASE, 50 ) ;
|
||||
viewPitchDial ->setValue ( -45.0f ) ;
|
||||
viewPitchDial ->setWrap ( 1 ) ;
|
||||
viewPitchDial ->setMaxValue ( 360 ) ;
|
||||
viewPitchDial ->setMinValue ( 0 ) ;
|
||||
viewPitchDial ->setStepSize ( 0 ) ;
|
||||
viewPitchDial ->setCBMode ( PUSLIDER_ALWAYS ) ;
|
||||
viewPitchDial ->setCallback ( viewPitchDial_cb ) ;
|
||||
viewPitchDial ->setLabel ( "Tilt" ) ;
|
||||
viewPitchDial ->setLabelPlace ( PUPLACE_BOTTOM_CENTERED ) ;
|
||||
viewPitchDial ->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
viewRangeSlider = new puSlider ( 150, VIEW_GUI_BASE, 90, false, 20 ) ;
|
||||
viewRangeSlider->setValue ( 25.0f ) ;
|
||||
viewRangeSlider->setMaxValue ( 150.0f ) ;
|
||||
viewRangeSlider->setMinValue ( 0.0f ) ;
|
||||
viewRangeSlider->setStepSize ( 0 ) ;
|
||||
viewRangeSlider->setCBMode ( PUSLIDER_ALWAYS ) ;
|
||||
viewRangeSlider->setCallback ( viewRangeSlider_cb ) ;
|
||||
viewRangeSlider->setLabel ( "Range" ) ;
|
||||
viewRangeSlider->setLabelPlace ( PUPLACE_BOTTOM_CENTERED ) ;
|
||||
viewRangeSlider->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
viewWireframeButton= new puButton ( 400, VIEW_GUI_BASE, "Wireframe" ) ;
|
||||
viewWireframeButton->setCallback ( viewWireframeButton_cb ) ;
|
||||
viewWireframeButton->setValue ( FALSE ) ;
|
||||
|
||||
viewEnvMapButton= new puButton ( 300, VIEW_GUI_BASE, "Env.Map" ) ;
|
||||
viewEnvMapButton->setCallback ( viewEnvMapButton_cb ) ;
|
||||
viewEnvMapButton->setValue ( FALSE ) ;
|
||||
|
||||
writeButton = new puOneShot ( 400, VIEW_GUI_BASE + 30, "Write C++" ) ;
|
||||
writeButton->setCallback ( writeButton_cb ) ;
|
||||
writeButton->setValue ( FALSE ) ;
|
||||
|
||||
waveTextureSlider = new puSlider ( 500, VIEW_GUI_BASE , 90, false, 20 ) ;
|
||||
waveTextureSlider->setValue ( 1.0f ) ;
|
||||
waveTextureSlider->setMaxValue ( 50.0f ) ;
|
||||
waveTextureSlider->setMinValue ( 0.01f ) ;
|
||||
waveTextureSlider->setStepSize ( 0 ) ;
|
||||
waveTextureSlider->setCBMode ( PUSLIDER_ALWAYS ) ;
|
||||
waveTextureSlider->setCallback ( waveTextureSlider_cb ) ;
|
||||
waveTextureSlider->setLabel ( "Texture" ) ;
|
||||
waveTextureSlider->setLabelPlace ( PUPLACE_CENTERED_RIGHT ) ;
|
||||
waveTextureSlider->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
waveSizeSlider = new puSlider ( 500, VIEW_GUI_BASE+30, 90, false, 20 ) ;
|
||||
waveSizeSlider->setValue ( 25.0f ) ;
|
||||
waveSizeSlider->setMaxValue ( 500.0f ) ;
|
||||
waveSizeSlider->setMinValue ( 10.0f ) ;
|
||||
waveSizeSlider->setStepSize ( 0 ) ;
|
||||
waveSizeSlider->setCBMode ( PUSLIDER_ALWAYS ) ;
|
||||
waveSizeSlider->setCallback ( waveSizeSlider_cb ) ;
|
||||
waveSizeSlider->setLabel ( "Size" ) ;
|
||||
waveSizeSlider->setLabelPlace ( PUPLACE_CENTERED_RIGHT ) ;
|
||||
waveSizeSlider->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
wavePolycountSlider= new puSlider ( 500, VIEW_GUI_BASE+60, 90, false, 20 ) ;
|
||||
wavePolycountSlider->setValue ( 10000 ) ;
|
||||
wavePolycountSlider->setMaxValue ( 50000 ) ;
|
||||
wavePolycountSlider->setMinValue ( 4000 ) ;
|
||||
wavePolycountSlider->setStepSize ( 0 ) ;
|
||||
wavePolycountSlider->setCBMode ( PUSLIDER_ALWAYS ) ;
|
||||
wavePolycountSlider->setCallback ( wavePolycountSlider_cb ) ;
|
||||
wavePolycountSlider->setLabel ( "Polygons" ) ;
|
||||
wavePolycountSlider->setLabelPlace ( PUPLACE_CENTERED_RIGHT ) ;
|
||||
wavePolycountSlider->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
timeText = new puText ( 500, VIEW_GUI_BASE+80 ) ;
|
||||
timeText->setColour( PUCOL_LABEL, FONT_COLOUR ) ;
|
||||
|
||||
window_group->close () ;
|
||||
}
|
||||
|
||||
/*
|
||||
The works.
|
||||
*/
|
||||
|
||||
int main ( int, char ** )
|
||||
{
|
||||
init_graphics () ;
|
||||
load_database () ;
|
||||
init_gui () ;
|
||||
main_loop () ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
90
examples/src/ssg/water/water.dsp
Normal file
90
examples/src/ssg/water/water.dsp
Normal file
@@ -0,0 +1,90 @@
|
||||
# Microsoft Developer Studio Project File - Name="water" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=water - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "water.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "water.mak" CFG="water - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "water - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "water - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "water - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pw.lib pui.lib puAux.lib fnt.lib ssgAux.lib ssg.lib sg.lib ul.lib winmm.lib opengl32.lib glu32.lib /nologo /subsystem:console /machine:I386 /out:"water.exe" /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "water - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pw_d.lib pui_d.lib puAux_d.lib fnt_d.lib ssgAux_d.lib ssg_d.lib sg_d.lib ul_d.lib winmm.lib opengl32.lib glu32.lib /nologo /subsystem:console /debug /machine:I386 /out:"water.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "water - Win32 Release"
|
||||
# Name "water - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\water.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
Reference in New Issue
Block a user