From: <de...@us...> - 2004-01-01 19:42:57
|
Update of /cvsroot/csp/APPLICATIONS/CSPSim/Source In directory sc8-pr-cvs1:/tmp/cvs-serv26201 Modified Files: VirtualScene.cpp ScreenInfo.cpp ObjectModel.cpp LogoScreen.cpp HID.cpp GameScreen.cpp EventMapIndex.cpp CSPSim.cpp AircraftObject.cpp Log Message: see CHANGES.current Index: VirtualScene.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/VirtualScene.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** VirtualScene.cpp 20 Oct 2003 00:23:23 -0000 1.15 --- VirtualScene.cpp 1 Jan 2004 19:42:53 -0000 1.16 *************** *** 175,178 **** --- 175,180 ---- m_NearView = NULL; m_ViewAngle = 60.0; + m_NearPlane = 2.0; + m_Aspect = static_cast<float>(g_ScreenWidth)/g_ScreenHeight; m_ViewDistance = 30000.0; m_SpinTheWorld = false; *************** *** 393,398 **** camera->setPerspective(m_ViewAngle, 1.0, 2.0f, m_ViewDistance); #else ! float aspect = ((float)g_ScreenWidth) / g_ScreenHeight; ! m_FarView->setProjectionMatrixAsPerspective(m_ViewAngle, aspect, 2.0f, m_ViewDistance); #endif CullVisitor = m_FarView->getCullVisitor(); --- 395,399 ---- camera->setPerspective(m_ViewAngle, 1.0, 2.0f, m_ViewDistance); #else ! m_FarView->setProjectionMatrixAsPerspective(m_ViewAngle, m_Aspect, m_NearPlane, m_ViewDistance); #endif CullVisitor = m_FarView->getCullVisitor(); *************** *** 408,412 **** camera->setPerspective(m_ViewAngle, 1.0, 0.01f, 100.0); #else ! m_NearView->setProjectionMatrixAsPerspective(m_ViewAngle, aspect, 0.01f, 100.0); #endif CullVisitor = m_NearView->getCullVisitor(); --- 409,413 ---- camera->setPerspective(m_ViewAngle, 1.0, 0.01f, 100.0); #else ! m_NearView->setProjectionMatrixAsPerspective(m_ViewAngle, m_Aspect, 0.01f, 100.0); #endif CullVisitor = m_NearView->getCullVisitor(); *************** *** 480,514 **** #endif - /***** - * code which could be used in replacement of osg::camera - ******/ - - //osgUtil::SceneView contains all the functionality of the "old" - //osg::Camera. When you think "Camera" and "No Producer", use - //osgUtil::SceneView and osg::RefMatrix: - // - // - // osg::ref_ptr<osg::RefMatrix> projectionMatrix = new osg::RefMatrix; - // - // double verticalFieldOfView = 45.0; // Degrees - // double aspectRatio = 1.0; // verticalFOV == horizontalFOV - // double nearClip = 1.0; - // double farClip = 1e4; - // projectionMatrix->makeProjection( verticalFieldOfView, - // aspectRatio, - // nearClip, farClip ); - // - // osg::BoundingSphere bs = rootNode->getBound(); - // osg::ref_ptr<osg::RefMatrix> modelViewMatrix = new osg::RefMatrix; - // modelViewMatrix->setLookAt( - // bs.center() - osg::Vec3(0.0, bs.radius()*2.5, 0.0), // Eye - // bs.center(), // Center - // osg::Vec3(0,0,1.0) ); // Up - // - // // Here it is. The next two lines is the sum total of what - // // osgCamera did. - // sceneView->setProjectionMatrix( projectionMatrix.get() ); - // sceneView->setModelViewMatrix( modelViewMatrix.get() ); - m_GlobalFrame->setPosition(simdata::toOSG(-eyePos)); --- 481,484 ---- *************** *** 744,747 **** --- 714,725 ---- { m_ViewAngle = value; + } + + void VirtualScene::setNearPlane(float value) { + m_NearPlane = value; + } + + void VirtualScene::setAspect(float value) { + m_Aspect = value; } Index: ScreenInfo.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/ScreenInfo.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ScreenInfo.cpp 21 Dec 2003 10:44:32 -0000 1.23 --- ScreenInfo.cpp 1 Jan 2004 19:42:53 -0000 1.24 *************** *** 81,86 **** osg::StateSet *ss = getOrCreateStateSet(); ss->setTextureAttributeAndModes(1, new osg::Texture2D, osg::StateAttribute::OFF); ! ss->setTextureAttributeAndModes(2, new osg::Texture2D, osg::StateAttribute::OFF); ! ss->setTextureAttributeAndModes(3, new osg::Texture2D, osg::StateAttribute::OFF); } --- 81,86 ---- osg::StateSet *ss = getOrCreateStateSet(); ss->setTextureAttributeAndModes(1, new osg::Texture2D, osg::StateAttribute::OFF); ! //ss->setTextureAttributeAndModes(2, new osg::Texture2D, osg::StateAttribute::OFF); ! //ss->setTextureAttributeAndModes(3, new osg::Texture2D, osg::StateAttribute::OFF); } Index: ObjectModel.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/ObjectModel.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** ObjectModel.cpp 21 Dec 2003 10:21:03 -0000 1.24 --- ObjectModel.cpp 1 Jan 2004 19:42:53 -0000 1.25 *************** *** 608,616 **** osg::Node *addEffect(osg::Node *model_node) { // add an osgFX effect ! osgFX::SpecularHighlights* effect = new osgFX::SpecularHighlights; effect->setTextureUnit(1); effect->addChild(model_node); return effect; ! } SceneModel::SceneModel(simdata::Ref<ObjectModel> const & model) { --- 608,616 ---- osg::Node *addEffect(osg::Node *model_node) { // add an osgFX effect ! osgFX::SpecularHighlights *effect = new osgFX::SpecularHighlights; effect->setTextureUnit(1); effect->addChild(model_node); return effect; ! } SceneModel::SceneModel(simdata::Ref<ObjectModel> const & model) { *************** *** 625,630 **** // create a working copy ModelCopy model_copy; ! //model_node = model_copy(model_node); ! model_node = model_copy(addEffect(model_node)); std::cout << "MODEL COPIED\n"; --- 625,631 ---- // create a working copy ModelCopy model_copy; ! model_node = model_copy(model_node); ! // XXX add effect or not ! model_node = addEffect(model_node); std::cout << "MODEL COPIED\n"; Index: LogoScreen.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/LogoScreen.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** LogoScreen.cpp 28 Dec 2003 19:56:15 -0000 1.14 --- LogoScreen.cpp 1 Jan 2004 19:42:53 -0000 1.15 *************** *** 132,136 **** geom->setUseDisplayList(false); ! scale = 0.5f * 0.9f; w = scale * m_width; h = scale * m_height; --- 132,136 ---- geom->setUseDisplayList(false); ! scale = 0.5f * 1.0f; w = scale * m_width; h = scale * m_height; Index: HID.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/HID.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** HID.cpp 20 Oct 2003 00:23:23 -0000 1.11 --- HID.cpp 1 Jan 2004 19:42:53 -0000 1.12 *************** *** 211,215 **** if (*id) { if (!m_Object->onMapEvent(MapEvent::CommandEvent(id, m_MouseEventX, m_MouseEventY))) { ! std::cout << "Missing HID interface for command '" << id << "'\n"; } } --- 211,215 ---- if (*id) { if (!m_Object->onMapEvent(MapEvent::CommandEvent(id, m_MouseEventX, m_MouseEventY))) { ! std::cout << "VirtualHID::onUpdate: Missing HID interface for command '" << id << "'\n"; } } Index: GameScreen.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/GameScreen.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** GameScreen.cpp 20 Oct 2003 00:23:23 -0000 1.28 --- GameScreen.cpp 1 Jan 2004 19:42:53 -0000 1.29 *************** *** 304,308 **** simdata::Vector3 upVec = dynamic->getUpDirection(); simdata::Vector3 objectDir = dynamic->getDirection(); ! camPos = objectPos + 500.0 * objectDir + ( 12.0 - (rand() % 5) ) * (objectDir^upVec) + ( 6.0 + (rand () % 3) ) * upVec; } else { --- 304,309 ---- simdata::Vector3 upVec = dynamic->getUpDirection(); simdata::Vector3 objectDir = dynamic->getDirection(); ! double speed_level = dynamic->getSpeed()/50.0; ! camPos = objectPos + 900.0* objectDir + ( 12.0 - (rand() % 5) ) * (objectDir^upVec) + ( 6.0 + (rand () % 3) ) * upVec; } else { *************** *** 770,780 **** } } ! ! VirtualBattlefield *battlefield = CSPSim::theSim->getBattlefield(); ! if (battlefield) { ! float h = 1.0 + battlefield->getGroundElevation(eyePos.x(), eyePos.y(), m_CameraHint); m_CameraOnGround = (eyePos.z() <= h); if (m_CameraOnGround) { if (m_LookRelative) { simdata::Vector3 adjustment = eyePos - lookPos; double dh = h - lookPos.z(); --- 771,784 ---- } } ! VirtualBattlefield *battlefield = CSPSim::theSim->getBattlefield(); ! if (battlefield) { ! simdata::Ref<TerrainObject> const terrain = scene->getTerrain(); ! simdata::Vector3 normal; ! double const SAFETY = 1.0; ! float h = SAFETY + terrain->getGroundElevation(eyePos.x(), eyePos.y(), normal, m_CameraHint); m_CameraOnGround = (eyePos.z() <= h); if (m_CameraOnGround) { if (m_LookRelative) { + simdata::Vector3 adjustment = eyePos - lookPos; double dh = h - lookPos.z(); *************** *** 789,795 **** //m_CameraGroundAngle = asin(dh, m_disToObject) - asin(dz, m_disToObject); //m_PanRateX = 0.0; ! } else { ! eyePos.z() = h; ! } } battlefield->updateOrigin(eyePos); --- 793,836 ---- //m_CameraGroundAngle = asin(dh, m_disToObject) - asin(dz, m_disToObject); //m_PanRateX = 0.0; ! ! /*double alpha_2 = simdata::toRadians(scene->getViewAngle())/2.0; ! double near_dist = scene->getNearPlane(); ! double aspect = scene->getAspect(); ! simdata::Vector3 eye_look = lookPos - eyePos; ! double eye_look_length = eye_look.length(); ! simdata::Vector3 eye_look_unit = (1.0/eye_look_length)*eye_look; ! simdata::Vector3 up_vec_unit = upVec.normalized(); ! simdata::Vector3 edge=near_dist*eye_look_unit+tan(alpha_2)*near_dist*(up_vec_unit+aspect*eye_look_unit^up_vec_unit); ! double edge_length = edge.length(); ! double phi = acos(near_dist/edge_length); ! double b = sqrt(edge_length*edge_length ! +eye_look_length*eye_look_length-2.0*eye_look_length*edge_length*cos(phi)); ! double sin_beta = edge_length*sin(phi)/b; ! double sin_theta = (lookPos.z()-terrain->getGroundElevation(lookPos.x(),lookPos.y(),m_CameraHint))/b; ! double gamma = asin(sin_beta)-asin(sin_theta); ! if (gamma <=0) { ! simdata::Vector3 u = -cos(gamma)*simdata::Vector3(eye_look.x(),eye_look.y(),0.0).normalized() ! +sin(gamma)*normal; ! simdata::Vector3 safe_eye_pos = lookPos + eye_look_length*u; ! safe_eye_pos.z() += SAFETY; ! if (eyePos.z() < safe_eye_pos.z()) { ! static i = 0; ! //std::cout << "\nold eyePos = " << eyePos << "\n"; ! //std::cout << "ground at eyePos = " << terrain->getGroundElevation(eyePos.x(), eyePos.y(), normal, m_CameraHint) << "\n"; ! if (++i%30 == 0) { ! std::cout << "edge_length = " << edge_length << "\n"; ! std::cout << "cos_alpha = " << near_dist/edge_length << "\n"; ! std::cout << "phi =" << phi << "\n"; ! } ! eyePos = safe_eye_pos; ! //std::cout << "new eyePos = " << safe_eye_pos << "\n"; ! } ! } ! if (eyePos.z() < h) ! eyePos.z() = h;*/ ! } else { ! //std::cout << "eyePos.z() = h;\n"; ! eyePos.z() = h; ! } } battlefield->updateOrigin(eyePos); Index: EventMapIndex.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/EventMapIndex.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** EventMapIndex.cpp 20 Oct 2003 00:23:23 -0000 1.8 --- EventMapIndex.cpp 1 Jan 2004 19:42:53 -0000 1.9 *************** *** 36,40 **** #include <SimData/FileUtility.h> ! #include <assert.h> --- 36,40 ---- #include <SimData/FileUtility.h> ! #include <cassert> *************** *** 65,78 **** void EventMapIndex::loadAllMaps() { ! std::string path; ! osgDB::DirectoryContents dc; ! osgDB::DirectoryContents::iterator file; ! path = getConfigPath("InputMapPath"); CSP_LOG(APP, INFO, "Looking for human interface device mappings in '" << path << "'"); ! dc = osgDB::getDirectoryContents(path); ! for (file = dc.begin(); file != dc.end(); file++) { std::string fn = simdata::ospath::join(path, *file); ! if (osgDB::getFileExtension(fn) != "hid") continue; ! load(fn); } } --- 65,75 ---- void EventMapIndex::loadAllMaps() { ! std::string path = getConfigPath("InputMapPath"); CSP_LOG(APP, INFO, "Looking for human interface device mappings in '" << path << "'"); ! osgDB::DirectoryContents dc = osgDB::getDirectoryContents(path); ! for (osgDB::DirectoryContents::const_iterator file = dc.begin(); file != dc.end(); ++file) { std::string fn = simdata::ospath::join(path, *file); ! if (osgDB::getFileExtension(fn) == "hid") ! load(fn); } } Index: CSPSim.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/CSPSim.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** CSPSim.cpp 28 Dec 2003 19:56:30 -0000 1.39 --- CSPSim.cpp 1 Jan 2004 19:42:53 -0000 1.40 *************** *** 264,267 **** --- 264,268 ---- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + // should run in its own thread logoScreen.onRender(); SDL_GL_SwapBuffers(); Index: AircraftObject.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/AircraftObject.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** AircraftObject.cpp 20 Oct 2003 01:27:10 -0000 1.33 --- AircraftObject.cpp 1 Jan 2004 19:42:53 -0000 1.34 *************** *** 56,60 **** BIND_ACTION("SMOKE_OFF", SmokeOff); BIND_ACTION("SMOKE_TOGGLE", SmokeToggle); ! BIND_ACTION("MARKERS_TOGGLE", MarkersToggle); CSP_LOG(OBJECT, DEBUG, "... AircraftObject::AircraftObject()"); --- 56,60 ---- BIND_ACTION("SMOKE_OFF", SmokeOff); BIND_ACTION("SMOKE_TOGGLE", SmokeToggle); ! BIND_ACTION("MARKS_TOGGLE", MarkersToggle); CSP_LOG(OBJECT, DEBUG, "... AircraftObject::AircraftObject()"); |