Skip to content

Commit

Permalink
fixed agent normals problem and VC2015 stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
maptube committed Nov 24, 2017
1 parent 0bbd3f6 commit 932032f
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 8 deletions.
2 changes: 2 additions & 0 deletions GeoGL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
<ClCompile Include="geogl\clipper\clipper.cpp" />
<ClCompile Include="geogl\cuboid.cpp" />
<ClCompile Include="geogl\cylinder.cpp" />
<ClCompile Include="GeoGL\data\datatable.cpp" />
<ClCompile Include="GeoGL\data\gtfs\GTFSFile.cpp" />
<ClCompile Include="GeoGL\data\gtfs\GTFSUtils.cpp" />
<ClCompile Include="geogl\DebugUtils.cpp" />
Expand Down Expand Up @@ -256,6 +257,7 @@
<ClInclude Include="geogl\clipper\clipper.hpp" />
<ClInclude Include="geogl\cuboid.h" />
<ClInclude Include="geogl\cylinder.h" />
<ClInclude Include="GeoGL\data\datatable.h" />
<ClInclude Include="geogl\DebugUtils.h" />
<ClInclude Include="geogl\ellipsoid.h" />
<ClInclude Include="geogl\EllipsoidOrbitController.h" />
Expand Down
6 changes: 6 additions & 0 deletions GeoGL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@
<ClCompile Include="GeoGL\data\gtfs\GTFSUtils.cpp">
<Filter>Source Files\data\gtfs</Filter>
</ClCompile>
<ClCompile Include="GeoGL\data\datatable.cpp">
<Filter>Source Files\data</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="geogl\BBox.h">
Expand Down Expand Up @@ -677,6 +680,9 @@
<ClInclude Include="GeoGL\data\gtfs\GTFSUtils.h">
<Filter>Header Files\data\gtfs</Filter>
</ClInclude>
<ClInclude Include="GeoGL\data\datatable.h">
<Filter>Header Files\data</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="shaders\diffuse.frag">
Expand Down
2 changes: 1 addition & 1 deletion GeoGL/abm/Agents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace ABM {
//create agent mesh lookup - a better way of doing this might be to create the shape when the breed is created i.e. dynamically,
//but, since there are a limited number at the moment, we might as well do it here...
_AgentMeshes["turtle"]=new Turtle(1.0,gengine::PositionColourNormal);
_AgentMeshes["sphere"]=new Sphere(1.0,10,10);
_AgentMeshes["sphere"]=new Sphere(1.0,1.0,1.0,10,10,gengine::PositionColourNormal);
_AgentMeshes["cube"]=new Cuboid(1.0,1.0,1.0);
_AgentMeshes["cylinder"]=new Cylinder(1.0,1.0,8);
_AgentMeshes["pyramid4"]=new Pyramid4(1.0,1.0,1.0);
Expand Down
2 changes: 1 addition & 1 deletion GeoGL/mesh2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ void Mesh2::SetMatrix(const glm::mat4& matrix) {
/// <summary>
void Mesh2::AttachTexture(unsigned int TextureUnitNum, gengine::Texture2D* Texture) {
drawObject._textures[TextureUnitNum]=Texture;
cout<<"Num textures = "<<drawObject._textures.size()<<endl;
// cout<<"Num textures = "<<drawObject._textures.size()<<endl;
}

/// <summary>
Expand Down
7 changes: 5 additions & 2 deletions GeoGL/sphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,20 @@ void Sphere::init2(double A, double B, double C, int WidthSegments, int HeightSe
int ilat2=(ilat+1)%HeightSegments; int ilon2=(ilon+1)%WidthSegments;
//work out four patch coordinates based on current lat/lon angles +- each combination of next lat/lon coord
glm::vec3 Pa,Pb,Pc,Pd;
glm::vec3 Na, Nb, Nc, Nd; //normals
//TODO: you might want to check the orientation of the point
Pa.x=sinlon[ilon]; Pa.y=coslon[ilon]*sinlat[ilat]; Pa.z=coslon[ilon]*coslat[ilat];
Pb.x=sinlon[ilon2]; Pb.y=coslon[ilon2]*sinlat[ilat]; Pb.z=coslon[ilon2]*coslat[ilat];
Pc.x=sinlon[ilon2]; Pc.y=coslon[ilon2]*sinlat[ilat2]; Pc.z=coslon[ilon2]*coslat[ilat2];
Pd.x=sinlon[ilon]; Pd.y=coslon[ilon]*sinlat[ilat2]; Pd.z=coslon[ilon]*coslat[ilat2];
//TODO: could do with texture and normals being calculated here
Na = Pa; Nb = Pb; Nc = Pc; Nd = Pd;
//NOTE: the mesh AddVertex code takes care of the VertexFormat if we're not using all the vertex data (i.e. colour/texture/normal absent)

//Pa,Pb,Pc,Pd are clockwise, so add in reverse
AddFace(Pa,Pd,Pc,glm::vec3(0,1.0,0),glm::vec3(0,1.0,0),glm::vec3(0,1.0,0));
AddFace(Pa,Pc,Pb,glm::vec3(0,1.0,0),glm::vec3(0,1.0,0),glm::vec3(0,1.0,0));
//TODO: you need to check the vertex format here and add in normals if needed - this can make a nice smooth sphere
AddFace(Pa,Pd,Pc,glm::vec3(0,1.0,0),glm::vec3(0,1.0,0),glm::vec3(0,1.0,0),Na,Nd,Nc);
AddFace(Pa,Pc,Pb,glm::vec3(0,1.0,0),glm::vec3(0,1.0,0),glm::vec3(0,1.0,0),Na,Nc,Nb);
}
}

Expand Down
2 changes: 1 addition & 1 deletion GeoGL/tiledearth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
using namespace gengine;

//these constants define the resolution of the data at each LOD level and the number of levels created
const int TiledEarth::LODDepth=5; //5; //4; //3; //4;
const int TiledEarth::LODDepth=4; //5; //4; //3; //4;
const int TiledEarth::LODWidthSegments=40; //40
const int TiledEarth::LODHeightSegments=40; //40

Expand Down
5 changes: 3 additions & 2 deletions GeoGL/turtle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ void Turtle::init(float TurtleSize, gengine::VertexFormat VF)
glm::vec3 cyan(0.0,1.0,1.0);
glm::vec3 magenta(1.0,0.0,1.0);

//NOTE: I've slightly fiddled the normals on the top faces to make the agents look more stylised
//top
AddFace(p[4],p[2],p[0],green,green,green,n[4],n[2],n[0]);
AddFace(p[4],p[1],p[2],green,green,green,n[4],n[1],n[2]);
AddFace(p[4], p[2], p[0], green, green, green, n[0], n[4], n[0]); // n[4], n[2], n[0]);
AddFace(p[4], p[1], p[2], green, green, green, n[0], n[0], n[4]); // n[4], n[1], n[2]);
//base
AddFace(p[3],p[0],p[2],red,red,red,n[3],n[0],n[2]);
AddFace(p[3],p[2],p[1],red,red,red,n[3],n[2],n[1]);
Expand Down
2 changes: 1 addition & 1 deletion usr/model_tubenetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const std::string ModelTubeNetwork::RealTimePositionsURL =
const float ModelTubeNetwork::LineSize = 25; //size of track - was 50
const int ModelTubeNetwork::LineTubeSegments = 10; //number of segments making up the tube geometry
const float ModelTubeNetwork::StationSize = 50.0f; //size of station geometry object
const float ModelTubeNetwork::TrainSize = 150.0f; //size of train geometry object
const float ModelTubeNetwork::TrainSize = 300.0f; // 150.0f; //size of train geometry object

/// <summary>
/// Create a Tube Network containing a model of the tube and train agents which run around the track. You have to call load() with the relevant file names to load the
Expand Down

0 comments on commit 932032f

Please sign in to comment.