Moved material property and texture management back to Simulator/Objects/
Working on scalable texture sizes.
This commit is contained in:
parent
2cd7fb198e
commit
d4988dc104
4 changed files with 21 additions and 11 deletions
|
@ -2,7 +2,9 @@ noinst_LIBRARIES = libObjects.a
|
||||||
|
|
||||||
libObjects_a_SOURCES = \
|
libObjects_a_SOURCES = \
|
||||||
fragment.cxx fragment.hxx \
|
fragment.cxx fragment.hxx \
|
||||||
|
material.cxx material.hxx \
|
||||||
materialmgr.cxx materialmgr.hxx \
|
materialmgr.cxx materialmgr.hxx \
|
||||||
obj.cxx obj.hxx
|
obj.cxx obj.hxx \
|
||||||
|
texload.c texload.h colours.h
|
||||||
|
|
||||||
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator
|
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
#include <Misc/fgstream.hxx>
|
#include <Misc/fgstream.hxx>
|
||||||
#include <Main/options.hxx>
|
#include <Main/options.hxx>
|
||||||
#include <Main/views.hxx>
|
#include <Main/views.hxx>
|
||||||
#include <Misc/texload.h>
|
|
||||||
#include <Scenery/tile.hxx>
|
#include <Scenery/tile.hxx>
|
||||||
|
|
||||||
#include "materialmgr.hxx"
|
#include "materialmgr.hxx"
|
||||||
|
@ -62,6 +61,7 @@ fgMATERIAL_MGR material_mgr;
|
||||||
// Constructor
|
// Constructor
|
||||||
FGMaterialSlot::FGMaterialSlot ( void ) { }
|
FGMaterialSlot::FGMaterialSlot ( void ) { }
|
||||||
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
FGMaterialSlot::~FGMaterialSlot ( void ) {
|
FGMaterialSlot::~FGMaterialSlot ( void ) {
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ fgMATERIAL_MGR::load_lib ( void )
|
||||||
in >> m;
|
in >> m;
|
||||||
|
|
||||||
// if ( current_options.get_textures() ) {
|
// if ( current_options.get_textures() ) {
|
||||||
// m.load_texture( current_options.get_fg_root() );
|
// m.load_texture( current_options.get_fg_root() );
|
||||||
// }
|
// }
|
||||||
|
|
||||||
FGMaterialSlot m_slot;
|
FGMaterialSlot m_slot;
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
#include <map> // STL associative "array"
|
#include <map> // STL associative "array"
|
||||||
#include <vector> // STL "array"
|
#include <vector> // STL "array"
|
||||||
|
|
||||||
#include <Misc/material.hxx>
|
#include "material.hxx"
|
||||||
|
|
||||||
FG_USING_STD(string);
|
FG_USING_STD(string);
|
||||||
FG_USING_STD(map);
|
FG_USING_STD(map);
|
||||||
|
@ -123,6 +123,7 @@ public:
|
||||||
|
|
||||||
// friend istream& operator >> ( istream& in, FGMaterialSlot& m );
|
// friend istream& operator >> ( istream& in, FGMaterialSlot& m );
|
||||||
|
|
||||||
|
inline FGMaterial get_m() const { return m; }
|
||||||
inline void set_m( FGMaterial new_m ) { m = new_m; }
|
inline void set_m( FGMaterial new_m ) { m = new_m; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,7 @@ int fgObjLoad( const string& path, fgTILE *t) {
|
||||||
int last1 = 0, last2 = 0, odd = 0;
|
int last1 = 0, last2 = 0, odd = 0;
|
||||||
double (*nodes)[3];
|
double (*nodes)[3];
|
||||||
Point3D center;
|
Point3D center;
|
||||||
|
double tex_width = 1000.0, tex_height = 1000.0;
|
||||||
|
|
||||||
// printf("loading %s\n", path.c_str() );
|
// printf("loading %s\n", path.c_str() );
|
||||||
|
|
||||||
|
@ -242,7 +243,13 @@ int fgObjLoad( const string& path, fgTILE *t) {
|
||||||
"Ack! unknown usemtl name = " << material
|
"Ack! unknown usemtl name = " << material
|
||||||
<< " in " << path );
|
<< " in " << path );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the texture width and height values for this
|
||||||
|
// material
|
||||||
|
FGMaterial m = fragment.material_ptr->get_m();
|
||||||
|
tex_width = m.get_xsize();
|
||||||
|
tex_height = m.get_ysize();
|
||||||
|
cout << "(w) = " << tex_width << " (h) = " << tex_width << endl;
|
||||||
// initialize the fragment transformation matrix
|
// initialize the fragment transformation matrix
|
||||||
/*
|
/*
|
||||||
for ( i = 0; i < 16; i++ ) {
|
for ( i = 0; i < 16; i++ ) {
|
||||||
|
@ -414,8 +421,8 @@ int fgObjLoad( const string& path, fgTILE *t) {
|
||||||
xglNormal3dv(normals[n1]);
|
xglNormal3dv(normals[n1]);
|
||||||
if ( in.get( c ) && c == '/' ) {
|
if ( in.get( c ) && c == '/' ) {
|
||||||
in >> tex;
|
in >> tex;
|
||||||
pp.setx( tex_coords[tex][0] );
|
pp.setx( tex_coords[tex][0] * (1000.0 / tex_width) );
|
||||||
pp.sety( tex_coords[tex][1] );
|
pp.sety( tex_coords[tex][1] * (1000.0 / tex_height) );
|
||||||
} else {
|
} else {
|
||||||
in.putback( c );
|
in.putback( c );
|
||||||
pp = calc_tex_coords(nodes[n1], center);
|
pp = calc_tex_coords(nodes[n1], center);
|
||||||
|
@ -427,8 +434,8 @@ int fgObjLoad( const string& path, fgTILE *t) {
|
||||||
xglNormal3dv(normals[n2]);
|
xglNormal3dv(normals[n2]);
|
||||||
if ( in.get( c ) && c == '/' ) {
|
if ( in.get( c ) && c == '/' ) {
|
||||||
in >> tex;
|
in >> tex;
|
||||||
pp.setx( tex_coords[tex][0] );
|
pp.setx( tex_coords[tex][0] * (1000.0 / tex_width) );
|
||||||
pp.sety( tex_coords[tex][1] );
|
pp.sety( tex_coords[tex][1] * (1000.0 / tex_height) );
|
||||||
} else {
|
} else {
|
||||||
in.putback( c );
|
in.putback( c );
|
||||||
pp = calc_tex_coords(nodes[n2], center);
|
pp = calc_tex_coords(nodes[n2], center);
|
||||||
|
@ -454,8 +461,8 @@ int fgObjLoad( const string& path, fgTILE *t) {
|
||||||
xglNormal3dv(normals[n3]);
|
xglNormal3dv(normals[n3]);
|
||||||
if ( in.get( c ) && c == '/' ) {
|
if ( in.get( c ) && c == '/' ) {
|
||||||
in >> tex;
|
in >> tex;
|
||||||
pp.setx( tex_coords[tex][0] );
|
pp.setx( tex_coords[tex][0] * (1000.0 / tex_width) );
|
||||||
pp.sety( tex_coords[tex][1] );
|
pp.sety( tex_coords[tex][1] * (1000.0 / tex_height) );
|
||||||
} else {
|
} else {
|
||||||
in.putback( c );
|
in.putback( c );
|
||||||
pp = calc_tex_coords(nodes[n3], center);
|
pp = calc_tex_coords(nodes[n3], center);
|
||||||
|
|
Loading…
Add table
Reference in a new issue