This commit is contained in:
Alexander Deynichenko
2013-02-25 07:23:44 +04:00
parent 35ff18a6a1
commit 03b62f3315
809 changed files with 211135 additions and 0 deletions

View 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

View 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 ;
}

View 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