many exports to scriptengine

This commit is contained in:
cirdan 2008-01-24 22:16:53 +00:00
parent 2373b382f1
commit 491c09e235
29 changed files with 600 additions and 287 deletions

View File

@ -27,10 +27,10 @@ namespace BlueCore
AABB transformed (const Transformation& transformation) AABB transformed (const Transformation& transformation)
{ {
AABB aabb; AABB aabb;
/*
Vector3 new_max = transformation.transform (Max); Vector3 new_max = transformation.transform (Max);
Vector3 new_min = transformation.transform (Min); Vector3 new_min = transformation.transform (Min);
*/
return aabb; return aabb;
} }
}; };

View File

@ -9,6 +9,9 @@
#include "ScriptSystem_Image.h" #include "ScriptSystem_Image.h"
#include "ScriptSystem_Math.h" #include "ScriptSystem_Math.h"
#include "ScriptSystem_RigidBody.h" #include "ScriptSystem_RigidBody.h"
#include "ScriptSystem_SceneGraph.h"
#include "ScriptSystem_SceneNode.h"
#include "ScriptSystem_Model.h"
namespace BlueCore namespace BlueCore
{ {
@ -70,6 +73,9 @@ bool Application::initialize()
setupScriptSystem_Image(_ScriptSystem, _TextureManager, _Device); setupScriptSystem_Image(_ScriptSystem, _TextureManager, _Device);
setupScriptSystem_Math(_ScriptSystem); setupScriptSystem_Math(_ScriptSystem);
setupScriptSystem_RigidBody(_ScriptSystem, _Simulation); setupScriptSystem_RigidBody(_ScriptSystem, _Simulation);
setupScriptSystem_SceneGraph(_ScriptSystem);
setupScriptSystem_SceneNode(_ScriptSystem);
setupScriptSystem_Model(_ScriptSystem, _ModelManager);
if (_ScriptSystem->loadScript("main") == false) if (_ScriptSystem->loadScript("main") == false)
return false; return false;
@ -108,6 +114,21 @@ void Application::run()
_Paused = false; _Paused = false;
_Running = true; _Running = true;
ref_ptr<Mesh> star_mesh = _MeshManager->loadMesh ("stars.3ds");
ref_ptr<Texture> star_texture = _TextureManager->loadTexture ("stars.png", 0);
GLfloat lightAmbient[] = {0.0f, 0.0f, 0.0f, 1.0f} ;
GLfloat lightDiffuse[] = {1.0f, 1.0f, 1.0f, 1.0f} ;
GLfloat lightSpecular[] = {1.0f, 1.0f, 1.0f, 1.0f} ;
GLfloat lightPosition[] = { 1.0, 0.0, 0.0, 0.0};
glLightfv ( GL_LIGHT0, GL_AMBIENT, lightAmbient ) ;
glLightfv ( GL_LIGHT0, GL_DIFFUSE, lightDiffuse ) ;
glLightfv ( GL_LIGHT0, GL_SPECULAR, lightSpecular ) ;
glLightfv ( GL_LIGHT0, GL_POSITION, lightPosition );
glEnable ( GL_LIGHT0 ) ;
while (_Window->isOpen() && _Running) while (_Window->isOpen() && _Running)
{ {
double now = glfwGetTime(); double now = glfwGetTime();
@ -122,15 +143,20 @@ void Application::run()
//camera->setPosition(q.apply(Vector3(0.0, 0.0, _CameraRadius))); //camera->setPosition(q.apply(Vector3(0.0, 0.0, _CameraRadius)));
//camera->setRotation(q); //camera->setRotation(q);
//pos += 5 * _DeltaTime; //pos += 5 * _DeltaTime;
_Device->setAmbientLight(1.0, 1.0, 1.0);
if (_SceneGraph.valid()) if (_SceneGraph.valid())
{ {
_RenderQueue->clear();
_SceneGraph->update(delta);
_SceneGraph->queue(_RenderQueue); _SceneGraph->queue(_RenderQueue);
_Device->begin3D(_SceneGraph->getCamera());
_RenderQueue->render(_Device); _RenderQueue->render(_Device);
_Device->end3D();
} }
/* /*
{ {
_Device->begin3D(_Camera); _Device->begin3D(_Camera);
_Device->setAmbientLight(1.0, 1.0, 1.0);
_RenderQueue->clear(); _RenderQueue->clear();
_RenderQueue->addOpaqueItem(model, Vector3(0.0, 0.0, 0.0), _RenderQueue->addOpaqueItem(model, Vector3(0.0, 0.0, 0.0),
Quaternion()); Quaternion());
@ -139,41 +165,7 @@ void Application::run()
} }
*/ */
/* /*
device->pushAbsoluteTransformation(Vector3(), camera->getRotation()); */
class RenderState
{
bool _Blending;
GLint _BlendFuncSrc;
GLint _BlendFuncDest;
bool _DepthTest;
bool _DepthMask;
bool _Lighting;
};
GLfloat mat_specular[] =
{ 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] =
{ 2.0 };
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_specular);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_specular);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glDisable(GL_LIGHTING);
glColor4d( 1.0f, 1.0f, 1.0f, 1.0f);
device->setTexture(0, starTexture, true);
starMesh->render();
glDisable(GL_BLEND);
device->popTransformation();
*/
// device->useShader (program); // device->useShader (program);
// device->setTexture (stage, name, texture) // device->setTexture (stage, name, texture)
// device->clearTextures (stage+1); // device->clearTextures (stage+1);
@ -197,6 +189,40 @@ void Application::run()
} }
} }
_Device->pushAbsoluteTransformation(Vector3(), _SceneGraph->getCamera()->getRotation());
/*
_Device->setShaderProgram (0);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
*/
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
_Device->setTexture(0, star_texture, true);
glDisable(GL_LIGHTING);
glColor4d( 1.0f, 1.0f, 1.0f, 1.0f);
star_mesh->render();
_Device->popTransformation();
/*
class RenderState
{
bool _Blending;
GLint _BlendFuncSrc;
GLint _BlendFuncDest;
bool _DepthTest;
bool _DepthMask;
bool _Lighting;
};
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] = { 2.0 };
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_specular);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_specular);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
*/
_Device->begin2D(); _Device->begin2D();
_ScriptSystem->callFunction("OnOverlay", delta, now - _StartTime); _ScriptSystem->callFunction("OnOverlay", delta, now - _StartTime);
_Device->end2D(); _Device->end2D();

View File

@ -1,57 +0,0 @@
#include "Utilities/Referenced.h"
class File : public Referenced
{
public:
bool isOpen ();
unsigned long read (char *buffer, unsigned long size);
};
class FileSystem : public Referenced
{
public:
FileSystem();
File *openBinary (const std::string& filename);
private:
static bool _PhysfsInialized;
};
FileSystem::FileSystem()
{
PHYSFS_init (0);
std::string appdir = PHYSFS_getUserDir();
appdir += ".bluecore";
if( !PHYSFS_setWriteDir(appdir.c_str()) )
{
if( (PHYSFS_setWriteDir(PHYSFS_getUserDir())) && (PHYSFS_mkdir(".bluecore")) )
PHYSFS_setWriteDir( appdir.c_str() );
}
PHYSFS_addToSearchPath( appdir.c_str(), 0 );
PHYSFS_addToSearchPath( "data", 1 );
char **rc = PHYSFS_enumerateFiles ( "" );
for ( char **i = rc; *i != 0; i++ )
{
std::string filename ( *i );
if ( filename.substr ( filename.size() - 4, 4 ) == ".zip" )
{
PHYSFS_addToSearchPath ( ( "data/" + filename ).c_str(), 1 );
BlueCore::log << ">>> Using addon: " << filename << endlog;
}
}
PHYSFS_freeList ( rc );
}

View File

@ -42,8 +42,10 @@ else
endif endif
SRC = $(wildcard */*.cpp) $(wildcard *.cpp) SRC = $(wildcard */*.cpp) $(wildcard *.cpp)
INC = $(wildcard */*.h) $(wildcard *.h)
OBJ = $(patsubst %.cpp,%.o,$(SRC) ) OBJ = $(patsubst %.cpp,%.o,$(SRC) )
DEP = $(patsubst %.cpp,%.d,$(SRC) ) DEP = $(patsubst %.cpp,%.d,$(SRC) )
GCH = $(patsubst %.h,%.h.gch,$(INC) )
NAME = redcore$(EXT) NAME = redcore$(EXT)
@ -54,7 +56,7 @@ $(NAME): $(OBJ)
@g++ -o $(NAME) $(OBJ) $(LDFLAGS) @g++ -o $(NAME) $(OBJ) $(LDFLAGS)
@echo done @echo done
obj: $(OBJ) obj: $(OBJ)
@echo done @echo done
clean: clean:
@ -67,3 +69,7 @@ clean:
-@$(RM) $(NAME) -@$(RM) $(NAME)
-include $(SRC:%.cpp=%.d) -include $(SRC:%.cpp=%.d)
%.h.gch: %.h
@echo Compiling $@ ...
@$(CXX) $(CXXFLAGS) -o $@ $<

View File

@ -7,8 +7,6 @@
#ifndef BLUECORE_POINT_H #ifndef BLUECORE_POINT_H
#define BLUECORE_POINT_H #define BLUECORE_POINT_H
#include "rectangle.h"
namespace BlueCore namespace BlueCore
{ {
template<typename type> template<typename type>
@ -26,30 +24,9 @@ namespace BlueCore
Point2DTemplate( type x, type y ) : _x(x), _y(y) Point2DTemplate( type x, type y ) : _x(x), _y(y)
{ {
} }
bool in( const Rectangle2DTemplate<type> &rect );
}; };
#include "rectangle.h"
template<typename type>
bool Point2DTemplate<type>::in( const Rectangle2DTemplate<type> &rect )
{
if( _x < rect._x )
return false;
if( _x > (rect._x + rect._width) )
return false;
if( _y < rect._y )
return false;
if( _y > (rect._y + rect._height) )
return false;
return true;
}
typedef Point2DTemplate<int> Point2D; typedef Point2DTemplate<int> Point2D;
}; };

View File

@ -7,8 +7,8 @@
#ifndef BLUECORE_RAY_H #ifndef BLUECORE_RAY_H
#define BLUECORE_RAY_H #define BLUECORE_RAY_H
#include "scalar.h" #include "Scalar.h"
#include "vector.h" #include "Vector.h"
namespace BlueCore namespace BlueCore
{ {
@ -44,7 +44,7 @@ namespace BlueCore
* set the point * set the point
*/ */
template <class S> template <class S>
inline setPoint( const Vector3Template<S> &point ) inline void setPoint( const Vector3Template<S> &point )
{ {
this->point = point; this->point = point;
} }
@ -54,7 +54,7 @@ namespace BlueCore
* set the direction * set the direction
*/ */
template <class S> template <class S>
inline setDirection( const Vector3Template<S> &direction ) inline void setDirection( const Vector3Template<S> &direction )
{ {
this->direction = direction.normalized(); this->direction = direction.normalized();
} }

View File

@ -7,7 +7,7 @@
#ifndef BLUECORE_RECTANGLE_H #ifndef BLUECORE_RECTANGLE_H
#define BLUECORE_RECTANGLE_H #define BLUECORE_RECTANGLE_H
#include "point.h" #include "Point.h"
namespace BlueCore namespace BlueCore
{ {

View File

@ -14,19 +14,16 @@ using namespace std;
namespace BlueCore namespace BlueCore
{ {
//------------------------------------------------------------------------------
Mesh::Mesh(RenderDevice* device) : Mesh::Mesh(RenderDevice* device) :
_Device(device) _Device(device)
{ {
} }
//------------------------------------------------------------------------------
Mesh::~Mesh() Mesh::~Mesh()
{ {
clog << ">>> Mesh destructed ..."<< endline; clog << ">>> Mesh destructed ..."<< endline;
} }
//------------------------------------------------------------------------------
void Mesh::render() void Mesh::render()
{ {
@ -100,20 +97,17 @@ void Mesh::bind()
} }
#endif #endif
//------------------------------------------------------------------------------
MeshManager::MeshManager(RenderDevice* device) : MeshManager::MeshManager(RenderDevice* device) :
_Device(device) _Device(device)
{ {
BlueCore::clog << ">>> MeshManager constructed..." << endlog; BlueCore::clog << ">>> MeshManager constructed..." << endlog;
} }
//------------------------------------------------------------------------------
MeshManager::~MeshManager() MeshManager::~MeshManager()
{ {
clog << ">>> MeshManager destructed ..." << endlog; clog << ">>> MeshManager destructed ..." << endlog;
} }
//------------------------------------------------------------------------------
bool loadTrimesh(const char* filename, Mesh *mesh) bool loadTrimesh(const char* filename, Mesh *mesh)
{ {
PHYSFS_file* file = PHYSFS_openRead(filename); PHYSFS_file* file = PHYSFS_openRead(filename);
@ -193,13 +187,92 @@ bool loadTrimesh(const char* filename, Mesh *mesh)
PHYSFS_close(file); PHYSFS_close(file);
// create normlas, tangents, and binomials
clog << " create normlas..." << endline;
for (unsigned int i = 0; i < mesh->VertexBuffer.count(); i++)
{
mesh->VertexBuffer[i].normal.zero();
}
for (unsigned int i = 0; i < mesh->IndexBuffer.count(); i++)
{
const TriangleIndices& triangle = mesh->IndexBuffer[i];
Vector3Template<float> ab = mesh->VertexBuffer[ triangle.a ].point
- mesh->VertexBuffer[ triangle.b ].point;
Vector3Template<float> ac = mesh->VertexBuffer[ triangle.a ].point
- mesh->VertexBuffer[ triangle.c ].point;
Vector3Template<float> n = ab.cross(ac);
mesh->VertexBuffer[ triangle.a ].normal += n;
mesh->VertexBuffer[ triangle.a ].normal += n;
mesh->VertexBuffer[ triangle.a ].normal += n;
}
for (unsigned int i = 0; i < mesh->VertexBuffer.count(); i ++)
{
mesh->VertexBuffer[i].normal.normalize();
}
clog << " create tangents..." << endline;
mesh->TangentBuffer.create(mesh->VertexBuffer.count());
mesh->BitangentBuffer.create(mesh->VertexBuffer.count());
for (unsigned int i = 0; i < mesh->TangentBuffer.count(); i ++)
{
mesh->TangentBuffer[i].zero();
mesh->BitangentBuffer[i].zero();
}
for (unsigned int i = 0; i < mesh->IndexBuffer.count(); i ++)
{
const TriangleIndices& triangle = mesh->IndexBuffer[i];
const Vertex& v1 = mesh->VertexBuffer[triangle.a];
const Vertex& v2 = mesh->VertexBuffer[triangle.b];
const Vertex& v3 = mesh->VertexBuffer[triangle.c];
float x1 = v2.point.x - v1.point.x;
float x2 = v3.point.x - v1.point.x;
float y1 = v2.point.y - v1.point.y;
float y2 = v3.point.y - v1.point.y;
float z1 = v2.point.z - v1.point.z;
float z2 = v3.point.z - v1.point.z;
float s1 = v2.u - v1.u;
float s2 = v3.u - v1.u;
float t1 = v2.v - v1.v;
float t2 = v3.v - v1.v;
float r = 1.0f / (s1 * t2 - s2 * t1 );
Vector3Float sdir( (t2 * x1 - t1 * x2 ) * r, (t2 * y1 - t1 * y2 )
* r, (t2 * z1 - t1 * z2 ) * r);
Vector3Float tdir( (s1 * x2 - s2 * x1 ) * r, (s1 * y2 - s2 * y1 )
* r, (s1 * z2 - s2 * z1 ) * r);
mesh->TangentBuffer[triangle.a] += sdir;
mesh->TangentBuffer[triangle.b] += sdir;
mesh->TangentBuffer[triangle.c] += sdir;
mesh->BitangentBuffer[triangle.a] += tdir;
mesh->BitangentBuffer[triangle.b] += tdir;
mesh->BitangentBuffer[triangle.c] += tdir;
}
for (unsigned int i = 0; i < mesh->TangentBuffer.count(); i ++)
{
mesh->TangentBuffer[i].normalize();
mesh->BitangentBuffer[i].normalize();
}
return 0; return 0;
} }
return 1; return 1;
} }
//------------------------------------------------------------------------------
Mesh *MeshManager::loadMesh(const string &filename) Mesh *MeshManager::loadMesh(const string &filename)
{ {
// check if this mesh is already loaded // check if this mesh is already loaded
@ -310,7 +383,6 @@ Mesh *MeshManager::loadMesh(const string &filename)
return mesh; return mesh;
} }
//------------------------------------------------------------------------------
bool MeshManager::loadFromCache(Mesh *mesh, const std::string &name) bool MeshManager::loadFromCache(Mesh *mesh, const std::string &name)
{ {
std::string filename = name + ".msc"; std::string filename = name + ".msc";
@ -331,25 +403,28 @@ bool MeshManager::loadFromCache(Mesh *mesh, const std::string &name)
PHYSFS_read(file, &size, sizeof (size ), 1); PHYSFS_read(file, &size, sizeof (size ), 1);
mesh->IndexBuffer.create(size); mesh->IndexBuffer.create(size);
PHYSFS_read(file, mesh->IndexBuffer.data(), mesh->IndexBuffer.size(), 1); PHYSFS_read(file, mesh->IndexBuffer.data(), mesh->IndexBuffer.size(), 1);
#if 0
// read tangent buffer
PHYSFS_read ( file, &size, sizeof ( size ), 1 );
mesh->tangent_buffer.create ( size );
PHYSFS_read ( file, mesh->tangent_buffer.data(), mesh->tangent_buffer.size(), 1 );
// read bitangent buffer
PHYSFS_read ( file, &size, sizeof ( size ), 1 );
mesh->bitangent_buffer.create ( size );
PHYSFS_read ( file, mesh->bitangent_buffer.data(), mesh->bitangent_buffer.size(), 1 );
// read bounding sphere
PHYSFS_read ( file, &mesh->bounding_sphere, sizeof ( mesh->bounding_sphere ), 1 );
#endif
// read subsets // read subsets
PHYSFS_read(file, &size, sizeof (size ), 1); PHYSFS_read(file, &size, sizeof (size ), 1);
mesh->SubsetBuffer.create(size); mesh->SubsetBuffer.create(size);
PHYSFS_read(file, mesh->SubsetBuffer.data(), mesh->SubsetBuffer.size(), 1); PHYSFS_read(file, mesh->SubsetBuffer.data(), mesh->SubsetBuffer.size(), 1);
// read tangent buffer
PHYSFS_read(file, &size, sizeof (size ), 1);
mesh->TangentBuffer.create(size);
PHYSFS_read(file, mesh->TangentBuffer.data(), mesh->TangentBuffer.size(), 1);
// read bitangent buffer
PHYSFS_read(file, &size, sizeof (size ), 1);
mesh->BitangentBuffer.create(size);
PHYSFS_read(file, mesh->BitangentBuffer.data(),
mesh->BitangentBuffer.size(), 1);
#if 0
// read bounding sphere
PHYSFS_read ( file, &mesh->bounding_sphere, sizeof ( mesh->bounding_sphere ), 1 );
#endif
#if 0 #if 0
// read bitangent buffer // read bitangent buffer
PHYSFS_read ( file, &size, sizeof ( size ), 1 ); PHYSFS_read ( file, &size, sizeof ( size ), 1 );
@ -362,9 +437,7 @@ bool MeshManager::loadFromCache(Mesh *mesh, const std::string &name)
return true; return true;
} }
//------------------------------------------------------------------------------
bool MeshManager::saveToCache(Mesh *mesh, const std::string &name) bool MeshManager::saveToCache(Mesh *mesh, const std::string &name)
{ {
std::string filename = name + ".msc"; std::string filename = name + ".msc";
@ -391,17 +464,19 @@ bool MeshManager::saveToCache(Mesh *mesh, const std::string &name)
PHYSFS_write(file, &size, sizeof (size ), 1); PHYSFS_write(file, &size, sizeof (size ), 1);
PHYSFS_write(file, mesh->SubsetBuffer.data(), mesh->SubsetBuffer.size(), 1); PHYSFS_write(file, mesh->SubsetBuffer.data(), mesh->SubsetBuffer.size(), 1);
#if 0
// write tangent_buffer // write tangent_buffer
size = mesh->tangent_buffer.count(); size = mesh->TangentBuffer.count();
PHYSFS_write ( file, &size, sizeof ( size ), 1 ); PHYSFS_write(file, &size, sizeof (size ), 1);
PHYSFS_write ( file, mesh->tangent_buffer.data(), mesh->tangent_buffer.size(), 1 ); PHYSFS_write(file, mesh->TangentBuffer.data(), mesh->TangentBuffer.size(),
1);
// write bitangent_buffer // write bitangent_buffer
size = mesh->bitangent_buffer.count(); size = mesh->BitangentBuffer.count();
PHYSFS_write ( file, &size, sizeof ( size ), 1 ); PHYSFS_write(file, &size, sizeof (size ), 1);
PHYSFS_write ( file, mesh->bitangent_buffer.data(), mesh->bitangent_buffer.size(), 1 ); PHYSFS_write(file, mesh->BitangentBuffer.data(),
mesh->BitangentBuffer.size(), 1);
#if 0
// write bounding sphere // write bounding sphere
PHYSFS_write ( file, &mesh->bounding_sphere, sizeof ( mesh->bounding_sphere ), 1 ); PHYSFS_write ( file, &mesh->bounding_sphere, sizeof ( mesh->bounding_sphere ), 1 );

View File

@ -49,8 +49,8 @@ public:
Buffer<TriangleIndices> IndexBuffer; Buffer<TriangleIndices> IndexBuffer;
Buffer<Subset> SubsetBuffer; Buffer<Subset> SubsetBuffer;
Buffer<Vector3Float> tangents; Buffer<Vector3Float> TangentBuffer;
Buffer<Vector3Float> bitangents; Buffer<Vector3Float> BitangentBuffer;
Buffer<ShadowFace> shadowfaces; Buffer<ShadowFace> shadowfaces;
public: public:

View File

@ -19,65 +19,57 @@ namespace BlueCore
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void Model::render(RenderDevice *device) const void Model::render(RenderDevice *device) const
{ {
ModelMesh->render(); // ModelMesh->render();
/*
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
glDepthFunc ( GL_LEQUAL ); glDepthFunc ( GL_LEQUAL );
glEnable ( GL_DEPTH_TEST ); glEnable ( GL_DEPTH_TEST );
glDepthMask ( GL_TRUE ); glDepthMask ( GL_TRUE );
*/
/*
glEnableClientState (GL_VERTEX_ARRAY ); glEnableClientState (GL_VERTEX_ARRAY );
glEnableClientState (GL_TEXTURE_COORD_ARRAY ); glEnableClientState (GL_TEXTURE_COORD_ARRAY );
glEnableClientState (GL_NORMAL_ARRAY ); glEnableClientState (GL_NORMAL_ARRAY );
mesh->vertex_buffer.bind(); glMaterialfv (GL_FRONT, GL_SHININESS, &LitPass.Shininess);
mesh->index_buffer.bind(); glMaterialfv (GL_FRONT, GL_SPECULAR, ( GLfloat * ) &LitPass.Specular );
*/
/*
glMaterialfv (GL_FRONT, GL_SHININESS, &pass.Shininess);
glMaterialfv (GL_FRONT, GL_SPECULAR, ( GLfloat * ) &pass.Specular );
// setup shader // setup shader
if (pass.Program && ShaderManager::getSingleton()->usingShaders() ) if (LitPass.Program)
{ {
ShaderManager::getSingleton()->useShaderProgram(pass.Program); device->setShaderProgram(LitPass.Program);
int textureId = 0; int textureId = 0;
std::vector<Model::TextureUnit>::iterator titer;
std::vector<Model::TextureUnit>::const_iterator titer;
for (titer = LitPass.Textures.begin(); titer != LitPass.Textures.end(); titer++)
{
device->setTexture(textureId, ( *titer ).mTexture );
device->setTexture(LitPass.Program, textureId, ( *titer ).mName);
textureId++;
}
for (titer = pass.Textures.begin(); titer != pass.Textures.end(); titer++) if (LitPass.Tangents)
{ {
Renderer::getSingleton()->bindTexture(( *titer ).mTexture, textureId ); //device->setTangentBuffer(LitPass.Program, &ModelMesh->TangentBuffer, "tangent");
ShaderManager::getSingleton()->useTexture(pass.Program, textureId, ( *titer ).mName); //device->setTangentBuffer(LitPass.Program, &ModelMesh->BitangentBuffer, "bitangent");
textureId++; }
}
if (pass.Tangents)
{
ShaderManager::getSingleton()->useTangentBuffer(pass.Program, &mesh->tangent_buffer, "tangent");
ShaderManager::getSingleton()->useTangentBuffer(pass.Program, &mesh->bitangent_buffer,
"bitangent");
}
} }
/*
else else
{ {
glActiveTextureARB (GL_TEXTURE2_ARB ); int textureId = 0;
glDisable (GL_TEXTURE_2D );
glActiveTextureARB (GL_TEXTURE1_ARB );
glDisable (GL_TEXTURE_2D );
int textureId = 0;
std::vector<Model::TextureUnit>::iterator titer; std::vector<Model::TextureUnit>::iterator titer;
for (titer = pass.Textures.begin(); titer != pass.Textures.end(); titer++) for (titer = pass.Textures.begin(); titer != pass.Textures.end(); titer++)
{ {
Renderer::getSingleton()->bindTexture(( *titer ).mTexture, textureId ); Renderer::getSingleton()->bindTexture(( *titer ).mTexture, textureId );
ShaderManager::getSingleton()->useTexture(pass.Program, textureId, ( *titer ).mName); ShaderManager::getSingleton()->useTexture(pass.Program, textureId, ( *titer ).mName);
textureId++; textureId++;
break; break;
} }
} }
// render subsets // render subsets
SubsetVector::iterator iter; SubsetVector::iterator iter;
for (iter = mesh->surface_subsets.begin(); iter for (iter = mesh->surface_subsets.begin(); iter
@ -86,7 +78,20 @@ void Model::render(RenderDevice *device) const
Subset subset = *iter; Subset subset = *iter;
mesh->index_buffer.draw(subset.first, subset.count); mesh->index_buffer.draw(subset.first, subset.count);
} }
*/
ModelMesh->render();
device->setShaderProgram(0);
glActiveTextureARB (GL_TEXTURE2_ARB );
glDisable (GL_TEXTURE_2D );
glActiveTextureARB (GL_TEXTURE1_ARB );
glDisable (GL_TEXTURE_2D );
glActiveTextureARB (GL_TEXTURE0_ARB );
glDisable (GL_TEXTURE_2D );
/*
// cleanup // cleanup
if (pass.Program && ShaderManager::getSingleton()->usingShaders() ) if (pass.Program && ShaderManager::getSingleton()->usingShaders() )
{ {
@ -98,6 +103,7 @@ void Model::render(RenderDevice *device) const
} }
} }
glPopMatrix(); glPopMatrix();
glActiveTextureARB (GL_TEXTURE2_ARB ); glActiveTextureARB (GL_TEXTURE2_ARB );
@ -120,11 +126,13 @@ ModelManager::ModelManager(TextureManager *texturemanager,
_TextureManager(texturemanager), _ShaderManager(shadermanager), _TextureManager(texturemanager), _ShaderManager(shadermanager),
_MeshManager(meshmanager) _MeshManager(meshmanager)
{ {
clog << ">>> ModelManager constructed ..."<< endline;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
ModelManager::~ModelManager() ModelManager::~ModelManager()
{ {
clog << ">>> ModelManager destructed ..."<< endline;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@ -66,7 +66,7 @@ private:
const TiXmlElement* DefinitionElement); const TiXmlElement* DefinitionElement);
void unload(); void unload();
public: public:
ModelManager(TextureManager *texturemanager, ShaderManager* shadermanager, ModelManager(TextureManager *texturemanager, ShaderManager* shadermanager,

View File

@ -1,26 +0,0 @@
#ifndef NODE_H_
#define NODE_H_
class Node
{
class UpdateListener
{
virtual void update() = 0;
virtual ~UpdateListener() = 0;
};
typedef std::list<Node*> NodeContainer;
typedef std::list<Node*> NodeContainer;
Node *parent;
NodeContainer children;
Vector3 getRelativePosition;
Vector3 getAbsolutePosition;
/* ... */
bool _Updating;
void update (double time);
void render (Camera *camera, RenderDevice *device);
};
#endif /*NODE_H_*/

View File

@ -190,4 +190,51 @@ void RenderDevice::setTexture(unsigned int unit, Texture* texture, bool last)
} }
} }
void RenderDevice::setShaderProgram(ShaderProgram shader_program)
{
// if ( !_usingShaders)
// return;
glUseProgramObjectARB(shader_program);
}
void RenderDevice::setTexture(ShaderProgram shader_program,
unsigned int texture, const std::string &name)
{
// if ( !_usingShaders)
// return;
GLint location = glGetUniformLocationARB(shader_program, name.c_str() );
//if( location > 0 )
glUniform1iARB(location, texture);
}
#if 0
void RenderDevice::setTangentBuffer(ShaderProgram shader_program,
const Buffer<Vector3Float>& tangent_buffer, const std::string &name)
{
// if ( !_usingShaders || !tangent_buffer)
// return;
GLuint location = glGetAttribLocationARB(shader_program, name.c_str() );
glEnableVertexAttribArrayARB(location);
//tangent_buffer->bind();
glVertexAttribPointerARB(location, 3, GL_FLOAT, 0, 0, 0);
}
//------------------------------------------------------------------------------
void ShaderManager::disableTangentBuffer(ShaderProgram shader_program,
const std::string &name)
{
// if ( !_usingShaders)
// return;
GLuint location = glGetAttribLocationARB(shader_program, name.c_str() );
glDisableVertexAttribArrayARB(location);
}
#endif
} // namespace BlueCore } // namespace BlueCore

View File

@ -21,9 +21,9 @@ private:
ref_ptr<RenderWindow> _RenderWindow; ref_ptr<RenderWindow> _RenderWindow;
ref_ptr<Camera> _Camera; ref_ptr<Camera> _Camera;
unsigned int _ActiveTextures; unsigned int _ActiveTextures;
public: public:
RenderDevice(RenderWindow* renderWindow); RenderDevice(RenderWindow* renderWindow);
@ -45,15 +45,18 @@ public:
void setMaterial(Material *); void setMaterial(Material *);
void setTexture(unsigned int unit, Texture* texture, bool last = false); void setTexture(unsigned int unit, Texture* texture, bool last = false);
void pushAbsoluteTransformation (const Vector3&, const Quaternion&); void setShaderProgram(ShaderProgram shader_program);
void pushTransformation (const Vector3&, const Quaternion&); void setTexture(ShaderProgram shader_program, unsigned int texture,
void popTransformation (); const std::string &name);
void pushAbsoluteTransformation(const Vector3&, const Quaternion&);
void pushTransformation(const Vector3&, const Quaternion&);
void popTransformation();
void setupProjectionMatrix(); void setupProjectionMatrix();
void setupViewMatrix(); void setupViewMatrix();
sigslot::signal0<> DeviceShutdownSignal; sigslot::signal0<> DeviceShutdownSignal;
//Buffer<ShadowFace> &_ShadowFaces; //Buffer<ShadowFace> &_ShadowFaces;
}; };

View File

@ -5,7 +5,7 @@ namespace BlueCore
SceneGraph::SceneGraph() SceneGraph::SceneGraph()
{ {
_RootNode = new SceneNode(); _RootNode = new SceneNode("root node");
} }
SceneGraph::~SceneGraph() SceneGraph::~SceneGraph()
{ {
@ -22,6 +22,11 @@ void SceneGraph::setCamera(Camera *camera)
_Camera = camera; _Camera = camera;
} }
Camera* SceneGraph::getCamera()const
{
return _Camera.pointer();
}
void SceneGraph::update(Scalar time) void SceneGraph::update(Scalar time)
{ {
_RootNode->update (time); _RootNode->update (time);

View File

@ -18,7 +18,8 @@ public:
SceneNode* getRootNode(); SceneNode* getRootNode();
void setCamera(Camera *camera); void setCamera(Camera *camera);
Camera* getCamera() const;
void update(Scalar time); void update(Scalar time);
void queue (RenderQueue *queue); void queue (RenderQueue *queue);

View File

@ -107,8 +107,11 @@ void SceneNode::queue(RenderQueue *queue, Camera *camera)
{ {
if (isActive()) if (isActive())
{ {
SceneNodeList::iterator i; if (_Model.valid())
queue->addOpaqueItem(_Model, _AbsoluteTransformation.translation,
_AbsoluteTransformation.rotation);
SceneNodeList::iterator i;
for (i = _Children.begin(); i != _Children.end(); i++) for (i = _Children.begin(); i != _Children.end(); i++)
{ {
( *i )->queue(queue, camera); ( *i )->queue(queue, camera);
@ -138,13 +141,33 @@ void SceneNode::setRelativeRotation(const Quaternion &rotation)
void SceneNode::updateAbsoluteTransformation() void SceneNode::updateAbsoluteTransformation()
{ {
/* if (_Parent)
if (_Parent ) {
_AbsoluteTranslation = _Parent->getAbsoluteTranslation() _AbsoluteTransformation.translation = _Parent->getAbsoluteTransformation().translation
+_Parent->getAbsoluteRotation().inversed() * _RelativeTranslation; +_Parent->getAbsoluteTransformation().rotation.inversed().apply(_RelativeTransformation.translation);
else }
_AbsoluteTranslation = _RelativeTranslation; else
*/ _AbsoluteTransformation.translation = _RelativeTransformation.translation;
}
void SceneNode::setRigidBody(RigidBody* body)
{
_RigidBody = body;
}
RigidBody* SceneNode::getRigidBody()
{
return _RigidBody.pointer();
}
void SceneNode::setModel(Model* model)
{
_Model = model;
}
Model* SceneNode::getModel()
{
return _Model.pointer();
} }
} // namespace BlueCore } // namespace BlueCore

View File

@ -32,8 +32,8 @@ class SceneNode : public Referenced, public Named, public Activated
Transformation _RelativeTransformation; Transformation _RelativeTransformation;
Transformation _AbsoluteTransformation; Transformation _AbsoluteTransformation;
weak_ptr<RigidBody> _RigidBody; ref_ptr<RigidBody> _RigidBody;
weak_ptr<Model> _Model; ref_ptr<Model> _Model;
public: public:
@ -44,6 +44,12 @@ class SceneNode : public Referenced, public Named, public Activated
SceneNode *getParent() const; SceneNode *getParent() const;
const SceneNodeList &getChildren() const; const SceneNodeList &getChildren() const;
void setRigidBody (RigidBody* body);
RigidBody* getRigidBody ();
void setModel (Model* body);
Model* getModel ();
void attach(SceneNode *node); void attach(SceneNode *node);
void detach(SceneNode *node); void detach(SceneNode *node);
void detachAll(); void detachAll();

View File

@ -15,10 +15,9 @@ using namespace std;
namespace BlueCore namespace BlueCore
{ {
//--------------------------------------------------------------------------
static ScriptSystem* gScriptSystem = 0; static ScriptSystem* gScriptSystem = 0;
//--------------------------------------------------------------------------
void _sq_compiler_error_handler(HSQUIRRELVM vm, const SQChar *error, void _sq_compiler_error_handler(HSQUIRRELVM vm, const SQChar *error,
const SQChar *source, SQInteger line, SQInteger column) const SQChar *source, SQInteger line, SQInteger column)
{ {
@ -26,7 +25,6 @@ void _sq_compiler_error_handler(HSQUIRRELVM vm, const SQChar *error,
<< error << endlog; << error << endlog;
} }
//--------------------------------------------------------------------------
static SQInteger _sq_runtime_error_handler(HSQUIRRELVM vm) static SQInteger _sq_runtime_error_handler(HSQUIRRELVM vm)
{ {
const SQChar *error = 0; const SQChar *error = 0;
@ -46,7 +44,6 @@ static SQInteger _sq_runtime_error_handler(HSQUIRRELVM vm)
return 0; return 0;
} }
//--------------------------------------------------------------------------
void _sq_print(HSQUIRRELVM vm, const SQChar* s, ...) void _sq_print(HSQUIRRELVM vm, const SQChar* s, ...)
{ {
va_list vl; va_list vl;
@ -55,7 +52,6 @@ void _sq_print(HSQUIRRELVM vm, const SQChar* s, ...)
va_end ( vl ); va_end ( vl );
} }
//--------------------------------------------------------------------------
static SQInteger _sq_require(HSQUIRRELVM v) static SQInteger _sq_require(HSQUIRRELVM v)
{ {
const SQChar *scriptname = 0; const SQChar *scriptname = 0;
@ -69,7 +65,6 @@ static SQInteger _sq_require(HSQUIRRELVM v)
return 0; return 0;
} }
//--------------------------------------------------------------------------
SQInteger _sq_file_reader(SQUserPointer file) SQInteger _sq_file_reader(SQUserPointer file)
{ {
char c; char c;
@ -82,7 +77,6 @@ SQInteger _sq_file_reader(SQUserPointer file)
return 0; return 0;
} }
//--------------------------------------------------------------------------
ScriptSystem::ScriptSystem() ScriptSystem::ScriptSystem()
{ {
gScriptSystem = this; gScriptSystem = this;
@ -103,20 +97,17 @@ ScriptSystem::ScriptSystem()
clog << ">>> ScriptSystem constructed ..."<< endlog; clog << ">>> ScriptSystem constructed ..."<< endlog;
} }
//--------------------------------------------------------------------------
ScriptSystem::~ScriptSystem() ScriptSystem::~ScriptSystem()
{ {
sq_close(_VM); sq_close(_VM);
clog << ">>> ScriptSystem destructed ..."<< endlog; clog << ">>> ScriptSystem destructed ..."<< endlog;
} }
//--------------------------------------------------------------------------
HSQUIRRELVM ScriptSystem::getVM() HSQUIRRELVM ScriptSystem::getVM()
{ {
return _VM; return _VM;
} }
//--------------------------------------------------------------------------
bool ScriptSystem::loadScript(const std::string &name) bool ScriptSystem::loadScript(const std::string &name)
{ {
for (unsigned int i = 0; i < _LoadedScripts.size(); i++) for (unsigned int i = 0; i < _LoadedScripts.size(); i++)
@ -136,7 +127,6 @@ bool ScriptSystem::loadScript(const std::string &name)
return false; return false;
} }
//--------------------------------------------------------------------------
bool ScriptSystem::executeScript(const std::string &name) bool ScriptSystem::executeScript(const std::string &name)
{ {
string filename = name + ".nut"; string filename = name + ".nut";
@ -172,7 +162,6 @@ bool ScriptSystem::executeScript(const std::string &name)
return true; return true;
} }
//--------------------------------------------------------------------------
void ScriptSystem::callFunction(const std::string &name) void ScriptSystem::callFunction(const std::string &name)
{ {
sq_pushroottable(_VM); sq_pushroottable(_VM);
@ -186,7 +175,6 @@ void ScriptSystem::callFunction(const std::string &name)
sq_pop(_VM, 1); sq_pop(_VM, 1);
} }
//--------------------------------------------------------------------------
void ScriptSystem::callFunction(const std::string &name, double value) void ScriptSystem::callFunction(const std::string &name, double value)
{ {
sq_pushroottable(_VM); sq_pushroottable(_VM);
@ -201,7 +189,8 @@ void ScriptSystem::callFunction(const std::string &name, double value)
sq_pop(_VM, 1); sq_pop(_VM, 1);
} }
void ScriptSystem::callFunction(const std::string &name, double value1, double value2) void ScriptSystem::callFunction(const std::string &name, double value1,
double value2)
{ {
sq_pushroottable(_VM); sq_pushroottable(_VM);
sq_pushstring(_VM, name.c_str(), -1); sq_pushstring(_VM, name.c_str(), -1);

View File

@ -0,0 +1,75 @@
#include "ScriptSystem_Model.h"
namespace BlueCore
{
//------------------------------------------------------------------------------
static weak_ptr<ModelManager> gModelManager;
//------------------------------------------------------------------------------
static SQInteger _model_releasehook(SQUserPointer p, SQInteger size)
{
Model *model = (Model *)p;
if (model)
model->removeReference();
return 1;
}
//------------------------------------------------------------------------------
static SQInteger _model_constructor(HSQUIRRELVM vm)
{
SQInteger argc = sq_gettop(vm);
Model *model = 0;
if (argc > 1)
{
const SQChar *name = 0;
sq_getstring(vm, 2, &name);
if (gModelManager.valid())
{
model = gModelManager->loadModel(name);
if (model)
model->addReference();
}
}
sq_setinstanceup(vm, 1, (void *)model );
sq_setreleasehook(vm, 1, _model_releasehook);
return 0;
}
//------------------------------------------------------------------------------
void setupScriptSystem_Model(ScriptSystem* scriptsystem, ModelManager* modelmanager)
{
if (scriptsystem && modelmanager)
{
HSQUIRRELVM vm = scriptsystem->getVM();
gModelManager = modelmanager;
sq_pushroottable(vm);
// push class
sq_pushstring(vm, "Model", -1);
if (SQ_SUCCEEDED(sq_newclass(vm, SQFalse) ) )
{
// register constructor
sq_pushstring(vm, "constructor", -1);
sq_newclosure(vm, _model_constructor, 0);
sq_newslot(vm, -3, false);
// create class
sq_newslot(vm, -3, false);
}
sq_poptop(vm);
}
}
}

View File

@ -0,0 +1,14 @@
#ifndef BLUECORE_SCRIPTING_MODEL_H
#define BLUECORE_SCRIPTING_MODEL_H
#include "ModelManager.h"
#include "ScriptSystem.h"
#include "squirrel.h"
namespace BlueCore
{
void setupScriptSystem_Model(ScriptSystem* scriptsystem, ModelManager* modelmanager);
}
#endif

View File

@ -48,6 +48,22 @@ static SQInteger _set_camera(HSQUIRRELVM v)
return 0; return 0;
} }
static SQInteger _attach_node(HSQUIRRELVM v)
{
SceneGraph *scenegraph = 0;
sq_getinstanceup(v, 1, ( void ** ) &scenegraph, 0);
if (scenegraph)
{
SceneNode *node;
sq_getinstanceup (v, 2, ( void ** ) &node, 0);
scenegraph->getRootNode()->attach(node);
}
return 0;
}
void setupScriptSystem_SceneGraph(ScriptSystem* scriptsystem) void setupScriptSystem_SceneGraph(ScriptSystem* scriptsystem)
{ {
if (scriptsystem == 0) if (scriptsystem == 0)
@ -71,6 +87,10 @@ void setupScriptSystem_SceneGraph(ScriptSystem* scriptsystem)
sq_newclosure(vm, _set_camera, 0); sq_newclosure(vm, _set_camera, 0);
sq_newslot(vm, -3, false); sq_newslot(vm, -3, false);
sq_pushstring(vm, "attachNode", -1);
sq_newclosure(vm, _attach_node, 0);
sq_newslot(vm, -3, false);
// create class // create class
sq_newslot(vm, -3, false); sq_newslot(vm, -3, false);
} }

View File

@ -1,5 +1,5 @@
#ifndef BLUECORE_SCRIPTING_CAMERA_H #ifndef BLUECORE_SCRIPTING_SCENEGRAPH_H
#define BLUECORE_SCRIPTING_CAMERA_H #define BLUECORE_SCRIPTING_SCENEGRAPH_H
#include "ScriptSystem.h" #include "ScriptSystem.h"

View File

@ -0,0 +1,119 @@
#include "ScriptSystem_SceneNode.h"
#include "ScriptSystem_Math.h"
#include "SceneNode.h"
namespace BlueCore
{
static SQInteger _scenenode_releasehook(SQUserPointer p, SQInteger size)
{
SceneNode *node = (SceneNode *)p;
if (node)
node->removeReference();
return 1;
}
static SQInteger _scenenode_constructor(HSQUIRRELVM vm)
{
SQInteger argc = sq_gettop(vm);
SceneNode *node = 0;
if (argc > 1)
{
const SQChar *name = 0;
sq_getstring(vm, 2, &name);
node = new SceneNode (name);
if (node)
node->addReference();
}
sq_setinstanceup(vm, 1, (void *)node );
sq_setreleasehook(vm, 1, _scenenode_releasehook);
return 0;
}
static SQInteger _set_model(HSQUIRRELVM v)
{
SceneNode *node = 0;
sq_getinstanceup(v, 1, ( void ** ) &node, 0);
if (node)
{
Model *model;
sq_getinstanceup(v, 2, ( void ** ) &model, 0);
node->setModel(model);
}
return 0;
}
static SQInteger _set_position(HSQUIRRELVM v)
{
SceneNode *node = 0;
sq_getinstanceup(v, 1, ( void ** ) &node, 0);
if (node)
{
Vector3 position;
int argc = sq_gettop(v);
if (argc == 2)
{
_getvectorvalues(v, 2, position.x, position.y, position.z);
}
else if (argc == 4)
{
sq_getfloat(v, 2, &position.x);
sq_getfloat(v, 3, &position.y);
sq_getfloat(v, 4, &position.z);
}
node->setRelativeTranslation(position);
}
return 0;
}
void setupScriptSystem_SceneNode(ScriptSystem* scriptsystem)
{
if (scriptsystem)
{
HSQUIRRELVM vm = scriptsystem->getVM();
sq_pushroottable(vm);
// push class
sq_pushstring(vm, "SceneNode", -1);
if (SQ_SUCCEEDED(sq_newclass(vm, SQFalse) ) )
{
// register constructor
sq_pushstring(vm, "constructor", -1);
sq_newclosure(vm, _scenenode_constructor, 0);
sq_newslot(vm, -3, false);
sq_pushstring(vm, "setModel", -1);
sq_newclosure(vm, _set_model, 0);
sq_newslot(vm, -3, false);
sq_pushstring(vm, "setPosition", -1);
sq_newclosure(vm, _set_position, 0);
sq_newslot(vm, -3, false);
// create class
sq_newslot(vm, -3, false);
}
sq_poptop(vm);
}
}
}

View File

@ -0,0 +1,13 @@
#ifndef BLUECORE_SCRIPTING_SCENE_NODE_H
#define BLUECORE_SCRIPTING_SCENE_NODE_H
#include "ScriptSystem.h"
#include "squirrel.h"
namespace BlueCore
{
void setupScriptSystem_SceneNode(ScriptSystem* scriptsystem);
}
#endif

View File

@ -14,7 +14,7 @@ using namespace std;
namespace BlueCore namespace BlueCore
{ {
//------------------------------------------------------------------------------
ShaderManager::ShaderManager(RenderWindow* renderwindow) : ShaderManager::ShaderManager(RenderWindow* renderwindow) :
_usingShaders(true), _RenderWindow(renderwindow) _usingShaders(true), _RenderWindow(renderwindow)
{ {
@ -33,13 +33,11 @@ ShaderManager::ShaderManager(RenderWindow* renderwindow) :
clog << " shaders not supported!"<< endlog; clog << " shaders not supported!"<< endlog;
} }
//------------------------------------------------------------------------------
ShaderManager::~ShaderManager() ShaderManager::~ShaderManager()
{ {
clog << ">>> ShaderManager destructed ..."<< endlog; clog << ">>> ShaderManager destructed ..."<< endlog;
} }
//------------------------------------------------------------------------------
void ShaderManager::shutdown() void ShaderManager::shutdown()
{ {
clog << ">>> ShaderManager shutting down ..."<< endlog; clog << ">>> ShaderManager shutting down ..."<< endlog;
@ -66,19 +64,16 @@ void ShaderManager::shutdown()
fragment_shader.clear(); fragment_shader.clear();
} }
//------------------------------------------------------------------------------
void ShaderManager::WindowCloseSlot() void ShaderManager::WindowCloseSlot()
{ {
shutdown(); shutdown();
} }
//------------------------------------------------------------------------------
bool ShaderManager::usingShaders() bool ShaderManager::usingShaders()
{ {
return _usingShaders; return _usingShaders;
} }
//------------------------------------------------------------------------------
void printInfoLog(GLhandleARB obj) void printInfoLog(GLhandleARB obj)
{ {
int infologLength = 0; int infologLength = 0;
@ -100,7 +95,6 @@ void printInfoLog(GLhandleARB obj)
} }
} }
//------------------------------------------------------------------------------
VertexShader ShaderManager::loadVertexShader(const string &name) VertexShader ShaderManager::loadVertexShader(const string &name)
{ {
if ( !_usingShaders) if ( !_usingShaders)
@ -116,9 +110,9 @@ VertexShader ShaderManager::loadVertexShader(const string &name)
return result->second; return result->second;
} }
string filename = name + ".vert"; //string filename = name + ".vert";
PHYSFS_file *file = PHYSFS_openRead(filename.c_str() ); PHYSFS_file *file = PHYSFS_openRead(name.c_str() );
if ( !file) if ( !file)
{ {
@ -148,7 +142,6 @@ VertexShader ShaderManager::loadVertexShader(const string &name)
return shader; return shader;
} }
//------------------------------------------------------------------------------
FragmentShader ShaderManager::loadFragmentShader(const string &name) FragmentShader ShaderManager::loadFragmentShader(const string &name)
{ {
if ( !_usingShaders) if ( !_usingShaders)
@ -164,9 +157,9 @@ FragmentShader ShaderManager::loadFragmentShader(const string &name)
return result->second; return result->second;
} }
string filename = name + ".frag"; //string filename = name + ".frag";
PHYSFS_file *file = PHYSFS_openRead(filename.c_str() ); PHYSFS_file *file = PHYSFS_openRead(name.c_str() );
if ( !file) if ( !file)
{ {
@ -198,7 +191,6 @@ FragmentShader ShaderManager::loadFragmentShader(const string &name)
return shader; return shader;
} }
//------------------------------------------------------------------------------
ShaderProgram ShaderManager::loadShaderProgram(const std::string &name) ShaderProgram ShaderManager::loadShaderProgram(const std::string &name)
{ {
if ( !_usingShaders) if ( !_usingShaders)
@ -276,7 +268,6 @@ ShaderProgram ShaderManager::loadShaderProgram(const std::string &name)
} }
//------------------------------------------------------------------------------
void ShaderManager::useShaderProgram(ShaderProgram shader_program) void ShaderManager::useShaderProgram(ShaderProgram shader_program)
{ {
if ( !_usingShaders) if ( !_usingShaders)
@ -285,7 +276,6 @@ void ShaderManager::useShaderProgram(ShaderProgram shader_program)
glUseProgramObjectARB(shader_program); glUseProgramObjectARB(shader_program);
} }
//------------------------------------------------------------------------------
void ShaderManager::useTexture(ShaderProgram shader_program, void ShaderManager::useTexture(ShaderProgram shader_program,
unsigned int texture, const std::string &name) unsigned int texture, const std::string &name)
{ {
@ -298,7 +288,7 @@ void ShaderManager::useTexture(ShaderProgram shader_program,
glUniform1iARB(location, texture); glUniform1iARB(location, texture);
} }
/* /*
//------------------------------------------------------------------------------
void ShaderManager::useTangentBuffer ( void ShaderManager::useTangentBuffer (
ShaderProgram shader_program, ShaderProgram shader_program,
TangentBuffer *tangent_buffer, TangentBuffer *tangent_buffer,
@ -316,7 +306,7 @@ void ShaderManager::useTexture(ShaderProgram shader_program,
glVertexAttribPointerARB ( location, 3, GL_FLOAT, 0, 0, 0 ); glVertexAttribPointerARB ( location, 3, GL_FLOAT, 0, 0, 0 );
} }
//------------------------------------------------------------------------------
void ShaderManager::disableTangentBuffer ( void ShaderManager::disableTangentBuffer (
ShaderProgram shader_program, ShaderProgram shader_program,
const std::string &name ) const std::string &name )

View File

@ -1,11 +0,0 @@
#include <string>
#include <map>
class IniParser
{
std::map<std::string, std::string> _Pairs;
void parse (const std::string &text)
{
}
}

View File

@ -81,8 +81,15 @@ function Initialize()
::body = RigidBody(); ::body = RigidBody();
::camera = Camera(); ::camera = Camera();
::mainSceneGraph = SceneGraph(); ::mainSceneGraph = SceneGraph();
::camera.lookAt (0.0, 0.0, 0.0); // ::camera.lookAt (0.0, 0.0, 0.0);
::mainSceneGraph.setCamera (::camera); ::mainSceneGraph.setCamera (::camera);
setSceneGraph(::mainSceneGraph);
local model = Model ("combat");
local node = SceneNode("test");
node.setModel (model);
node.setPosition (0.0, 0.0, -50.0);
::mainSceneGraph.attachNode (node);
} }
function OnFrame (delta, total) function OnFrame (delta, total)
@ -101,10 +108,11 @@ function OnOverlay (delta, total)
::frameCount = 0; ::frameCount = 0;
::lastFPS -= 0.1; ::lastFPS -= 0.1;
} }
/*
if (total < 2.0) if (total < 2.0)
::logo.draw (0.5, 0.5); ::logo.draw (0.5, 0.5);
else else
*/
{ {
v <- ::body.getPosition(); v <- ::body.getPosition();
::font.print(10, 40, "Position: " + v.x + ", " + v.y + ", " + v.z, 1, 1 ); ::font.print(10, 40, "Position: " + v.x + ", " + v.y + ", " + v.z, 1, 1 );
@ -125,7 +133,7 @@ function OnOverlay (delta, total)
function OnStep (delta, total) function OnStep (delta, total)
{ {
::body.applyLocalForce( Vector(1.0, 0.0, 1.0) ); ::body.applyLocalForce( Vector(0.0, 0.0, 1.0) );
} }
function Shutdown() function Shutdown()

View File

@ -16,7 +16,9 @@ SceneGraph
* make ShaderProgram a class * make ShaderProgram a class
* create RenderSet AND/OR RenderQueue * create RenderSet AND/OR RenderQueue
* RenderQueueVisitor * RenderQueueVisitor
* reimport input class
* use vbos for meshes and tangents
#if 0 #if 0
/* /*