[Opal-commits] opal/samples/playpen main.cpp,1.12,1.13
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-04-20 03:59:42
|
Update of /cvsroot/opal/opal/samples/playpen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25347/samples/playpen Modified Files: main.cpp Log Message: fixed bug in ogre sample; now model normals are unaffected by scaling Index: main.cpp =================================================================== RCS file: /cvsroot/opal/opal/samples/playpen/main.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** main.cpp 19 Apr 2005 14:02:27 -0000 1.12 --- main.cpp 20 Apr 2005 03:59:33 -0000 1.13 *************** *** 1,2 **** --- 1,29 ---- + /************************************************************************* + * * + * Open Physics Abstraction Layer * + * Copyright (C) 2004-2005 * + * Alan Fischer ala...@gm... * + * Andres Reinot an...@re... * + * Tyler Streeter tyl...@gm... * + * All rights reserved. * + * Web: opal.sourceforge.net * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file license-LGPL.txt. * + * (2) The BSD-style license that is included with this library in * + * the file license-BSD.txt. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * license-LGPL.txt and license-BSD.txt for more details. * + * * + *************************************************************************/ + #include <time.h> #include "../src/BaseOpalApp.h" *************** *** 41,48 **** /// Point where new objects are created. opal::Point3r mCreationPoint; - - /// A visual line that represents the PhysicalCamera's grasping - /// spring. - //opalSamples::OgreLine* mGraspingSpringLine; }; --- 68,71 ---- *************** *** 52,80 **** mUseShadows = true; mCreationPoint.set(-55, 60, -55); - //mGraspingSpringLine = NULL; } PlaypenApp::~PlaypenApp() { - //if (mGraspingSpringLine) - //{ - // // Destroy the grasping line and its SceneNode. - // Ogre::SceneNode* sn = mGraspingSpringLine->getParentSceneNode(); - - // // Detach and destroy all objects from the SceneNode. The - // // scene node should only have the OgreLine attached which - // // we must delete explicitly. - // while(sn->numAttachedObjects() > 0) - // { - // MovableObject* thisObject = - // sn->detachObject(static_cast<unsigned short>(0)); - // delete thisObject; - // } - - // // Destroy the SceneNodes all of its children. - // sn->removeAndDestroyAllChildren(); - // mSceneMgr->getRootSceneNode()->removeAndDestroyChild( - // sn->getName()); - //} } --- 75,82 ---- *************** *** 101,108 **** Ogre::Light* light = mSceneMgr->createLight("light0"); light->setType(Ogre::Light::LT_POINT); ! light->setDiffuseColour(1.0, 1.0, 1.0); ! light->setSpecularColour(1.0, 1.0, 1.0); light->setPosition(100.0, 300.0, 100.0); // Setup the initial camera position. mPhysicalCamera->setPosition(opal::Point3r(0, 20, 30)); --- 103,118 ---- Ogre::Light* light = mSceneMgr->createLight("light0"); light->setType(Ogre::Light::LT_POINT); ! light->setDiffuseColour(0.5, 0.5, 0.5); ! light->setSpecularColour(0.5, 0.5, 0.5); light->setPosition(100.0, 300.0, 100.0); + // Create another light source. + light = mSceneMgr->createLight("light1"); + light->setType(Ogre::Light::LT_POINT); + light->setDiffuseColour(0.5, 0.5, 0.5); + light->setSpecularColour(0.5, 0.5, 0.5); + light->setPosition(-100.0, 300.0, 100.0); + light->setVisible(false); + // Setup the initial camera position. mPhysicalCamera->setPosition(opal::Point3r(0, 20, 30)); *************** *** 112,129 **** mSceneMgr->setSkyBox(true, "Skyboxes/Gray", 5000); - // Create the visual line used to represent the PhysicalCamera's - // grasping spring. Just create two points for now that will - // be updated later. - //mGraspingSpringLine = - // new opalSamples::OgreLine(); - //mGraspingSpringLine->addPoint(0, 0, 0); - //mGraspingSpringLine->addPoint(0, 0, 0); - //mGraspingSpringLine->update(); - //SceneNode* lineNode = - // mSceneMgr->getRootSceneNode()->createChildSceneNode("graspLine"); - //lineNode->attachObject(mGraspingSpringLine); - //mGraspingSpringLine->setCastShadows(false); - //mGraspingSpringLine->setVisible(false); - // Make a sphere used to show the grasp position. Ogre::SceneNode* sphereNode = mSceneMgr->getRootSceneNode()-> --- 122,125 ---- *************** *** 178,195 **** } - //if (!mGraspingSpringLine->isVisible()) - //{ - // mGraspingSpringLine->setVisible(true); - //} - opal::Point3r desiredPos = mPhysicalCamera->getGraspGlobalPos(); Ogre::Vector3 point0(desiredPos[0], desiredPos[1], desiredPos[2]); - //mGraspingSpringLine->setPoint(0, point); opal::Point3r attachPos = mPhysicalCamera->getAttachGlobalPos(); Ogre::Vector3 point1(attachPos[0], attachPos[1], attachPos[2]); - //mGraspingSpringLine->setPoint(1, point); - //mGraspingSpringLine->update(); pickingSphere->getParentSceneNode()->setPosition(point1); --- 174,183 ---- *************** *** 225,233 **** springLine->setVisible(false); } - - //if (mGraspingSpringLine->isVisible()) - //{ - // mGraspingSpringLine->setVisible(false); - //} } --- 213,216 ---- *************** *** 363,366 **** --- 346,350 ---- sn->scale(logScale, logScale, logScale); Entity* e = mSceneMgr->createEntity(name, "log.mesh"); + e->setNormaliseNormals(true); e->setMaterialName("Textured/Wood"); sn->attachObject(e); *************** *** 509,512 **** --- 493,514 ---- } + // Toggle second light source. + if(mInputDevice->isKeyDown(KC_L) && mTimeUntilNextToggle <= 0) + { + Ogre::Light* light1 = mSceneMgr->getLight("light1"); + + if (light1->isVisible()) + { + light1->setVisible(false); + } + else + { + light1->setVisible(true); + } + + // Reset the timer for toggle keys. + mTimeUntilNextToggle = 0.5; + } + // Toggle GUI. if (mInputDevice->isKeyDown(KC_G) && mTimeUntilNextToggle <= 0) *************** *** 565,583 **** void PlaypenApp::setupInitialPhysicalEntities() { - //// Create a physical ground plane. - //mSimulator->createPlane(0, 1, 0, 0); - - //// Create a visual ground plane. - //Ogre::Plane plane(Ogre::Vector3(0, 0, -1), 0); - //Ogre::MeshManager::getSingleton().createPlane("plane", "General", - // plane, 3000, 3000, 10, 10); - //Entity* e = mSceneMgr->createEntity("ground plane", "plane"); - //e->setMaterialName("Flat/Gray"); - //Ogre::SceneNode* sn = mSceneMgr->getRootSceneNode()-> - // createChildSceneNode("ground plane"); - //sn->attachObject(e); - //Ogre::Radian angle(Ogre::Degree(90)); - //sn->rotate(Ogre::Vector3(1, 0, 0), angle); - opal::Matrix44r m; --- 567,570 ---- |