mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-17 23:27:37 +00:00
GRIM/EMI: Add drawing of meshes
This only adds in drawing of meshes, textures are still not done, and skeletal animation is fully missing, however, this commit marks the first one where anything 3D is visible in EMI.
This commit is contained in:
parent
85b99d5c64
commit
3b87c4f66b
@ -36,6 +36,7 @@
|
|||||||
#include "engines/grim/costume/head.h"
|
#include "engines/grim/costume/head.h"
|
||||||
#include "engines/grim/costume/main_model_component.h"
|
#include "engines/grim/costume/main_model_component.h"
|
||||||
#include "engines/grim/costume/colormap_component.h"
|
#include "engines/grim/costume/colormap_component.h"
|
||||||
|
#include "engines/grim/costume/emimesh_component.h"
|
||||||
#include "engines/grim/costume/keyframe_component.h"
|
#include "engines/grim/costume/keyframe_component.h"
|
||||||
#include "engines/grim/costume/mesh_component.h"
|
#include "engines/grim/costume/mesh_component.h"
|
||||||
#include "engines/grim/costume/lua_var_component.h"
|
#include "engines/grim/costume/lua_var_component.h"
|
||||||
@ -344,7 +345,7 @@ Component *Costume::loadComponentEMI(Component *parent, int parentID, const char
|
|||||||
|
|
||||||
if (FROM_BE_32(tag) == MKTAG('m','e','s','h')) {
|
if (FROM_BE_32(tag) == MKTAG('m','e','s','h')) {
|
||||||
Debug::warning(Debug::Costumes, "Actor::loadComponentEMI Implement MESH-handling: %s" , name);
|
Debug::warning(Debug::Costumes, "Actor::loadComponentEMI Implement MESH-handling: %s" , name);
|
||||||
//return new EMIMeshComponent(parent, parentID, name, prevComponent, tag);
|
return new EMIMeshComponent(parent, parentID, name, prevComponent, tag);
|
||||||
} else if (FROM_BE_32(tag) == MKTAG('s','k','e','l')) {
|
} else if (FROM_BE_32(tag) == MKTAG('s','k','e','l')) {
|
||||||
Debug::warning(Debug::Costumes, "Actor::loadComponentEMI Implement SKEL-handling: %s" , name);
|
Debug::warning(Debug::Costumes, "Actor::loadComponentEMI Implement SKEL-handling: %s" , name);
|
||||||
//return new ModelComponent(parent, parentID, name, prevComponent, tag);
|
//return new ModelComponent(parent, parentID, name, prevComponent, tag);
|
||||||
|
@ -41,6 +41,8 @@ class PrimitiveObject;
|
|||||||
class Font;
|
class Font;
|
||||||
class TextObject;
|
class TextObject;
|
||||||
class Material;
|
class Material;
|
||||||
|
class EMIModel;
|
||||||
|
class EMIMeshFace;
|
||||||
class ModelNode;
|
class ModelNode;
|
||||||
class Mesh;
|
class Mesh;
|
||||||
class MeshFace;
|
class MeshFace;
|
||||||
@ -106,6 +108,7 @@ public:
|
|||||||
virtual void rotateViewpoint(const Math::Angle &angle, const Math::Vector3d &axis) = 0;
|
virtual void rotateViewpoint(const Math::Angle &angle, const Math::Vector3d &axis) = 0;
|
||||||
virtual void translateViewpointFinish() = 0;
|
virtual void translateViewpointFinish() = 0;
|
||||||
|
|
||||||
|
virtual void drawEMIModelFace(const EMIModel* model, const EMIMeshFace* face) = 0;
|
||||||
virtual void drawModelFace(const MeshFace *face, float *vertices, float *vertNormals, float *textureVerts) = 0;
|
virtual void drawModelFace(const MeshFace *face, float *vertices, float *vertNormals, float *textureVerts) = 0;
|
||||||
virtual void drawSprite(const Sprite *sprite) = 0;
|
virtual void drawSprite(const Sprite *sprite) = 0;
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "engines/grim/lipsync.h"
|
#include "engines/grim/lipsync.h"
|
||||||
#include "engines/grim/bitmap.h"
|
#include "engines/grim/bitmap.h"
|
||||||
#include "engines/grim/primitives.h"
|
#include "engines/grim/primitives.h"
|
||||||
|
#include "engines/grim/modelemi.h"
|
||||||
#include "engines/grim/model.h"
|
#include "engines/grim/model.h"
|
||||||
#include "engines/grim/set.h"
|
#include "engines/grim/set.h"
|
||||||
|
|
||||||
@ -426,6 +427,34 @@ void GfxOpenGL::set3DMode() {
|
|||||||
glDepthFunc(GL_LESS);
|
glDepthFunc(GL_LESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GfxOpenGL::drawEMIModelFace(const EMIModel* model, const EMIMeshFace* face) {
|
||||||
|
int *indices = (int*)face->_indexes;
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
glDisable(GL_ALPHA_TEST);
|
||||||
|
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
for (int j = 0; j < face->_faceLength * 3; j++) {
|
||||||
|
|
||||||
|
int index = indices[j];
|
||||||
|
if (face->_hasTexture) {
|
||||||
|
glTexCoord2f(model->_texVerts[index].getX(), model->_texVerts[index].getY());
|
||||||
|
}
|
||||||
|
glColor4ub(model->_colorMap[index].r,model->_colorMap[index].g,model->_colorMap[index].b,model->_colorMap[index].a);
|
||||||
|
|
||||||
|
Math::Vector3d normal = model->_normals[index];
|
||||||
|
Math::Vector3d vertex = model->_vertices[index];
|
||||||
|
|
||||||
|
// Transform vertices (or maybe we should have done this already?)
|
||||||
|
|
||||||
|
glNormal3fv(normal.getData());
|
||||||
|
glVertex3fv(vertex.getData());
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glEnable(GL_ALPHA_TEST);
|
||||||
|
glColor3f(1.0f,1.0f,1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
void GfxOpenGL::drawModelFace(const MeshFace *face, float *vertices, float *vertNormals, float *textureVerts) {
|
void GfxOpenGL::drawModelFace(const MeshFace *face, float *vertices, float *vertNormals, float *textureVerts) {
|
||||||
// Support transparency in actor objects, such as the message tube
|
// Support transparency in actor objects, such as the message tube
|
||||||
// in Manny's Office
|
// in Manny's Office
|
||||||
|
@ -78,6 +78,7 @@ public:
|
|||||||
void rotateViewpoint(const Math::Angle &angle, const Math::Vector3d &axis);
|
void rotateViewpoint(const Math::Angle &angle, const Math::Vector3d &axis);
|
||||||
void translateViewpointFinish();
|
void translateViewpointFinish();
|
||||||
|
|
||||||
|
void drawEMIModelFace(const EMIModel* model, const EMIMeshFace* face);
|
||||||
void drawModelFace(const MeshFace *face, float *vertices, float *vertNormals, float *textureVerts);
|
void drawModelFace(const MeshFace *face, float *vertices, float *vertNormals, float *textureVerts);
|
||||||
void drawSprite(const Sprite *sprite);
|
void drawSprite(const Sprite *sprite);
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "engines/grim/lipsync.h"
|
#include "engines/grim/lipsync.h"
|
||||||
#include "engines/grim/bitmap.h"
|
#include "engines/grim/bitmap.h"
|
||||||
#include "engines/grim/primitives.h"
|
#include "engines/grim/primitives.h"
|
||||||
|
#include "engines/grim/modelemi.h"
|
||||||
#include "engines/grim/model.h"
|
#include "engines/grim/model.h"
|
||||||
#include "engines/grim/set.h"
|
#include "engines/grim/set.h"
|
||||||
|
|
||||||
@ -467,6 +468,32 @@ void GfxTinyGL::getShadowColor(byte *r, byte *g, byte *b) {
|
|||||||
*b = _shadowColorB;
|
*b = _shadowColorB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GfxTinyGL::drawEMIModelFace(const EMIModel* model, const EMIMeshFace* face) {
|
||||||
|
int *indices = (int*)face->_indexes;
|
||||||
|
tglDisable(TGL_DEPTH_TEST);
|
||||||
|
tglDisable(TGL_ALPHA_TEST);
|
||||||
|
|
||||||
|
tglBegin(TGL_TRIANGLES);
|
||||||
|
for (int j = 0; j < face->_faceLength * 3; j++) {
|
||||||
|
|
||||||
|
int index = indices[j];
|
||||||
|
if (face->_hasTexture) {
|
||||||
|
tglTexCoord2f(model->_texVerts[index].getX(), model->_texVerts[index].getY());
|
||||||
|
}
|
||||||
|
//tglColor4ub(model->_colorMap[index].r,model->_colorMap[index].g,model->_colorMap[index].b,model->_colorMap[index].a);
|
||||||
|
|
||||||
|
Math::Vector3d normal = model->_normals[index];
|
||||||
|
Math::Vector3d vertex = model->_vertices[index];
|
||||||
|
|
||||||
|
tglNormal3f(normal.x(), normal.y(), normal.z());
|
||||||
|
tglVertex3f(vertex.x(), vertex.y(), vertex.z());
|
||||||
|
}
|
||||||
|
tglEnd();
|
||||||
|
|
||||||
|
tglEnable(TGL_DEPTH_TEST);
|
||||||
|
tglEnable(TGL_ALPHA_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
void GfxTinyGL::drawModelFace(const MeshFace *face, float *vertices, float *vertNormals, float *textureVerts) {
|
void GfxTinyGL::drawModelFace(const MeshFace *face, float *vertices, float *vertNormals, float *textureVerts) {
|
||||||
tglNormal3fv(const_cast<float *>(face->_normal.getData()));
|
tglNormal3fv(const_cast<float *>(face->_normal.getData()));
|
||||||
tglBegin(TGL_POLYGON);
|
tglBegin(TGL_POLYGON);
|
||||||
|
@ -69,6 +69,7 @@ public:
|
|||||||
void rotateViewpoint(const Math::Angle &angle, const Math::Vector3d &axis);
|
void rotateViewpoint(const Math::Angle &angle, const Math::Vector3d &axis);
|
||||||
void translateViewpointFinish();
|
void translateViewpointFinish();
|
||||||
|
|
||||||
|
void drawEMIModelFace(const EMIModel* model, const EMIMeshFace* face);
|
||||||
void drawModelFace(const MeshFace *face, float *vertices, float *vertNormals, float *textureVerts);
|
void drawModelFace(const MeshFace *face, float *vertices, float *vertNormals, float *textureVerts);
|
||||||
void drawSprite(const Sprite *sprite);
|
void drawSprite(const Sprite *sprite);
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ void EMIModel::draw() {
|
|||||||
// We will need to add a call to the skeleton, to get the modified vertices, but for now,
|
// We will need to add a call to the skeleton, to get the modified vertices, but for now,
|
||||||
// I'll be happy with just static drawing
|
// I'll be happy with just static drawing
|
||||||
for(int i = 0; i < _numFaces; i++) {
|
for(int i = 0; i < _numFaces; i++) {
|
||||||
//g_driver->drawEMIModelFace(this, &_faces[i]);
|
g_driver->drawEMIModelFace(this, &_faces[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user