Changeset 3474
- Timestamp:
- 03/01/10 07:22:54 (5 months ago)
- Location:
- plugins/branches/0185_GEN_PHYSICS_REFACTOR_2
- Files:
-
- 3 modified
-
ZODE/src/HeightfieldResource.cpp (modified) (2 diffs)
-
ZODE/src/HeightfieldResource.hpp (modified) (1 diff)
-
ZTerrain/src/Terrain.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZODE/src/HeightfieldResource.cpp
r3463 r3474 28 28 #include <Zen/Core/Math/Math.hpp> 29 29 30 #include <boost/archive/binary_iarchive.hpp> 31 30 32 #include <boost/lexical_cast.hpp> 33 #include <boost/cstdint.hpp> 31 34 32 #include <stdio.h> 33 #include <stdlib.h> 35 #include <vector> 36 37 #include <fstream> 38 #include <sstream> 34 39 35 40 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ … … 79 84 /// While we're reading the height data, we can get the 80 85 /// height bounds of the heightmap as well. 81 /// (These may need to be scaled versions of the raw min/max 86 /// (These may need to be scaled versions of the raw min/max 82 87 /// based on the scale config param). 83 const short *pBuffer; 88 89 std::vector<boost::int16_t> buffer(widthSamples * depthSamples); 90 91 boost::int16_t min = SHRT_MAX; 92 boost::int16_t max = SHRT_MIN; 93 94 std::ifstream stream(fileName, std::ios::in|std::ios::binary); 95 96 boost::archive::binary_iarchive inputArchive(stream, boost::archive::no_header | 97 boost::archive::no_tracking); 98 99 // Read the input stream if it exists 100 if(stream.good()) 101 { 102 for(int x = 0; x < widthSamples; x++) 103 { 104 for(int y = 0; y < depthSamples; y++) 105 { 106 boost::uint16_t c; 107 inputArchive & c; 108 buffer[x * widthSamples + y] = c; 109 max = max > c ? max : c; 110 min = min < c ? min : c; 111 112 } 113 } 114 } 115 else 116 { 117 std::stringstream errorMessage; 118 errorMessage << "Error opening " << fileName 119 << "file for input." << std::endl; 120 throw Zen::Utility::runtime_exception(errorMessage.str()); 121 } 122 123 const short *pBuffer = &buffer[0]; 124 84 125 Math::Real minHeight; 85 126 Math::Real maxHeight; -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZODE/src/HeightfieldResource.hpp
r3463 r3474 91 91 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 92 92 93 #endif ZEN_ZODE_HEIGHTFIELD_RESOURCE_HPP93 #endif // ZEN_ZODE_HEIGHTFIELD_RESOURCE_HPP -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZTerrain/src/Terrain.cpp
r3109 r3474 101 101 Terrain::loadPhysicsFromRaw(const std::string& _rawFileName, size_t _size, float _maxHeight, float _scaleXY, const Math::Matrix4& _transform, bool _bSerialize) 102 102 { 103 Zen::Engine::Resource::I_ResourceService::config_type config; 104 105 config["fileName"] = _rawFileName; 106 107 m_pTerrainService->getPhysicsResourceService()->loadResource(config); 108 103 109 Zen::Engine::World::I_Terrain::pPhysicsActor_type pActor = m_pTerrainService->getPhysicsZone()->createActor(); 104 110 pActor->setCollisionShape(
