mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-15 18:39:51 +00:00
Updating everything
This commit is contained in:
parent
ed7cb1dc67
commit
2b3e75718c
@ -13,6 +13,7 @@
|
|||||||
#include "OgreTextureManager.h"
|
#include "OgreTextureManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using namespace Ogre;
|
using namespace Ogre;
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
@ -20,9 +21,11 @@ namespace MWWorld
|
|||||||
PhysicsSystem::PhysicsSystem(OEngine::Render::OgreRenderer &_rend) :
|
PhysicsSystem::PhysicsSystem(OEngine::Render::OgreRenderer &_rend) :
|
||||||
mRender(_rend), mEngine(0), mFreeFly (true)
|
mRender(_rend), mEngine(0), mFreeFly (true)
|
||||||
{
|
{
|
||||||
|
playerphysics = new playerMove;
|
||||||
// Create physics. shapeLoader is deleted by the physic engine
|
// Create physics. shapeLoader is deleted by the physic engine
|
||||||
NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader();
|
NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader();
|
||||||
mEngine = new OEngine::Physic::PhysicEngine(shapeLoader);
|
mEngine = new OEngine::Physic::PhysicEngine(shapeLoader);
|
||||||
|
playerphysics->mEngine = mEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicsSystem::~PhysicsSystem()
|
PhysicsSystem::~PhysicsSystem()
|
||||||
@ -68,55 +71,90 @@ namespace MWWorld
|
|||||||
{
|
{
|
||||||
//set the DebugRenderingMode. To disable it,set it to 0
|
//set the DebugRenderingMode. To disable it,set it to 0
|
||||||
//eng->setDebugRenderingMode(1);
|
//eng->setDebugRenderingMode(1);
|
||||||
|
|
||||||
|
|
||||||
//set the walkdirection to 0 (no movement) for every actor)
|
//set the walkdirection to 0 (no movement) for every actor)
|
||||||
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
|
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
|
||||||
{
|
{
|
||||||
OEngine::Physic::PhysicActor* act = it->second;
|
OEngine::Physic::PhysicActor* act = it->second;
|
||||||
act->setWalkDirection(btVector3(0,0,0));
|
act->setWalkDirection(btVector3(0,0,0));
|
||||||
}
|
}
|
||||||
|
playerMove::playercmd& pm_ref = playerphysics->cmd;
|
||||||
|
|
||||||
|
pm_ref.rightmove = 0;
|
||||||
|
pm_ref.forwardmove = 0;
|
||||||
|
pm_ref.upmove = 0;
|
||||||
|
//playerphysics->ps.move_type = PM_NOCLIP;
|
||||||
for (std::vector<std::pair<std::string, Ogre::Vector3> >::const_iterator iter (actors.begin());
|
for (std::vector<std::pair<std::string, Ogre::Vector3> >::const_iterator iter (actors.begin());
|
||||||
iter!=actors.end(); ++iter)
|
iter!=actors.end(); ++iter)
|
||||||
{
|
{
|
||||||
OEngine::Physic::PhysicActor* act = mEngine->getCharacter(iter->first);
|
OEngine::Physic::PhysicActor* act = mEngine->getCharacter(iter->first);
|
||||||
|
//if(iter->first == "player")
|
||||||
|
// std::cout << "This is player\n";
|
||||||
//dirty stuff to get the camera orientation. Must be changed!
|
//dirty stuff to get the camera orientation. Must be changed!
|
||||||
|
|
||||||
Ogre::SceneNode *sceneNode = mRender.getScene()->getSceneNode (iter->first);
|
Ogre::SceneNode *sceneNode = mRender.getScene()->getSceneNode (iter->first);
|
||||||
Ogre::Vector3 dir;
|
Ogre::Vector3 dir;
|
||||||
Ogre::Node* yawNode = sceneNode->getChildIterator().getNext();
|
Ogre::Node* yawNode = sceneNode->getChildIterator().getNext();
|
||||||
Ogre::Node* pitchNode = yawNode->getChildIterator().getNext();
|
Ogre::Node* pitchNode = yawNode->getChildIterator().getNext();
|
||||||
|
Ogre::Quaternion yawQuat = yawNode->getOrientation();
|
||||||
|
Ogre::Quaternion pitchQuat = pitchNode->getOrientation();
|
||||||
|
Ogre::Quaternion both = yawQuat * pitchQuat;
|
||||||
|
|
||||||
|
playerphysics->ps.viewangles.x = 0;
|
||||||
|
playerphysics->ps.viewangles.z = 0;
|
||||||
|
playerphysics->ps.viewangles.y = both.getYaw().valueDegrees() *-1 + 90;
|
||||||
|
//playerphysics->ps.viewangles.z = both.getPitch().valueDegrees();
|
||||||
|
|
||||||
|
|
||||||
if(mFreeFly)
|
if(mFreeFly)
|
||||||
{
|
{
|
||||||
Ogre::Quaternion yawQuat = yawNode->getOrientation();
|
|
||||||
Ogre::Quaternion pitchQuat = pitchNode->getOrientation();
|
|
||||||
Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);
|
Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);
|
||||||
|
pm_ref.rightmove = -dir1.x;
|
||||||
|
pm_ref.forwardmove = dir1.z;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//std::cout << "Current angle" << yawQuat.getYaw().valueDegrees() - 90<< "\n";
|
||||||
|
//playerphysics->ps.viewangles.x = pitchQuat.getPitch().valueDegrees();
|
||||||
|
//std::cout << "Pitch: " << yawQuat.getPitch() << "Yaw:" << yawQuat.getYaw() << "Roll: " << yawQuat.getRoll() << "\n";
|
||||||
dir = 0.07*(yawQuat*pitchQuat*dir1);
|
dir = 0.07*(yawQuat*pitchQuat*dir1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Ogre::Quaternion quat = yawNode->getOrientation();
|
Ogre::Quaternion quat = yawNode->getOrientation();
|
||||||
Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);
|
Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);
|
||||||
|
pm_ref.rightmove = -dir1.x;
|
||||||
|
pm_ref.forwardmove = dir1.z;
|
||||||
|
|
||||||
dir = 0.025*(quat*dir1);
|
dir = 0.025*(quat*dir1);
|
||||||
}
|
}
|
||||||
|
Pmove(playerphysics);
|
||||||
|
|
||||||
//set the walk direction
|
//set the walk direction
|
||||||
act->setWalkDirection(btVector3(dir.x,-dir.z,dir.y));
|
act->setWalkDirection(btVector3(dir.x,-dir.z,dir.y));
|
||||||
}
|
}
|
||||||
mEngine->stepSimulation(duration);
|
//mEngine->stepSimulation(duration);
|
||||||
|
Pmove(playerphysics);
|
||||||
std::vector< std::pair<std::string, Ogre::Vector3> > response;
|
std::vector< std::pair<std::string, Ogre::Vector3> > response;
|
||||||
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
|
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
|
||||||
{
|
{
|
||||||
btVector3 newPos = it->second->getPosition();
|
btVector3 newPos = it->second->getPosition();
|
||||||
|
|
||||||
Ogre::Vector3 coord(newPos.x(), newPos.y(), newPos.z());
|
Ogre::Vector3 coord(newPos.x(), newPos.y(), newPos.z());
|
||||||
|
if(it->first == "player"){
|
||||||
|
|
||||||
|
coord = playerphysics->ps.origin;
|
||||||
|
//std::cout << "Coord" << coord << "\n";
|
||||||
|
coord = Ogre::Vector3(coord.x, coord.z, coord.y); //x, z, -y
|
||||||
|
|
||||||
|
}
|
||||||
response.push_back(std::pair<std::string, Ogre::Vector3>(it->first, coord));
|
response.push_back(std::pair<std::string, Ogre::Vector3>(it->first, coord));
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsSystem::addObject (const std::string& handle, const std::string& mesh,
|
void PhysicsSystem::addObject (const std::string& handle, const std::string& mesh,
|
||||||
const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position)
|
const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position)
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <openengine/ogre/renderer.hpp>
|
#include <openengine/ogre/renderer.hpp>
|
||||||
#include <openengine/bullet/physic.hpp>
|
#include <openengine/bullet/physic.hpp>
|
||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
|
#include <openengine/bullet/pmove.h>
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
@ -49,6 +50,7 @@ namespace MWWorld
|
|||||||
OEngine::Render::OgreRenderer &mRender;
|
OEngine::Render::OgreRenderer &mRender;
|
||||||
OEngine::Physic::PhysicEngine* mEngine;
|
OEngine::Physic::PhysicEngine* mEngine;
|
||||||
bool mFreeFly;
|
bool mFreeFly;
|
||||||
|
playerMove* playerphysics;
|
||||||
|
|
||||||
PhysicsSystem (const PhysicsSystem&);
|
PhysicsSystem (const PhysicsSystem&);
|
||||||
PhysicsSystem& operator= (const PhysicsSystem&);
|
PhysicsSystem& operator= (const PhysicsSystem&);
|
||||||
|
@ -32,7 +32,7 @@ void newtrace(traceResults* const results, const Ogre::Vector3& start, const Ogr
|
|||||||
Ogre::Vector3 endReplace = startReplace;
|
Ogre::Vector3 endReplace = startReplace;
|
||||||
endReplace.y -= .25;
|
endReplace.y -= .25;
|
||||||
|
|
||||||
const bool hasHit = NewPhysicsTrace<collisionWorldTrace>(&out, startReplace, endReplace, BBHalfExtents, Ogre::Vector3(0.0f, rotation, 0.0f), isInterior, enginePass);
|
const bool hasHit = NewPhysicsTrace<collisionWorldTrace>(&out, start, end, BBHalfExtents, Ogre::Vector3(0.0f, rotation, 0.0f), isInterior, enginePass);
|
||||||
if(hasHit)
|
if(hasHit)
|
||||||
std::cout << "Has hit\n";
|
std::cout << "Has hit\n";
|
||||||
if (out.fraction < 0.001f)
|
if (out.fraction < 0.001f)
|
||||||
@ -102,7 +102,7 @@ const bool NewPhysicsTrace(NewPhysTraceResults* const out, const Ogre::Vector3&
|
|||||||
const btVector3 btend(end.x, end.y, end.z);
|
const btVector3 btend(end.x, end.y, end.z);
|
||||||
const btQuaternion btrot(rotation.y, rotation.x, rotation.z);
|
const btQuaternion btrot(rotation.y, rotation.x, rotation.z);
|
||||||
|
|
||||||
const btBoxShape newshape(btVector3(1000, 1000, 1000) );
|
const btBoxShape newshape(btVector3(BBHalfExtents.x, BBHalfExtents.y, BBHalfExtents.z));
|
||||||
const btTransform from(btrot, btstart);
|
const btTransform from(btrot, btstart);
|
||||||
const btTransform to(btrot, btend);
|
const btTransform to(btrot, btend);
|
||||||
float x = from.getOrigin().getX();
|
float x = from.getOrigin().getX();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user