I tried now:
virtual void Collision(Entity* collidedEntity, const Vec3& position, const Vec3& normal, float speed);
static void CollisionHook(Entity* entity0, Entity* entity1, float* position, float* normal, float speed);
- in App.h
and:
void Collision(Entity* collidedEntity, const Vec3& position, const Vec3& normal, float speed){
}
void CollisionHook(Entity* entity0, Entity* entity1, float* position, float* normal, float speed){
System::Print("Entity: " + entity0->GetKeyValue("name") + " collided with: " + entity1->GetKeyValue("name"));
}
- in App.cpp
The error is:
(it's german hope you can read it. it means 'external unresolved symbol...')
i thougt i forgot to link any library but everything is set ok (or is some code wrong?)
//Complete files:
App.cpp:
#include "App.h"
using namespace Leadwerks;
App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}
App::~App() { delete world; delete window; }
Vec3 camerarotation;
#if defined (PLATFORM_WINDOWS) || defined (PLATFORM_MACOS)
bool freelookmode=true;
#else
bool freelookmode=false;
#endif
Pivot* player;
float moveSpeed;
float strafeSpeed;
bool sprinting = false;
float jumpAcc;
bool setCrouch = false;
bool isCrouching = false;
float playerHeight;
Vec3 playerMovement;
float sprintSpeed = 1.4;
float crouchSpeed = 0.6;
int pause = 1;
Vec3 mouseposition;
float pausex;
float pausey;
void MapLoader(Entity* entity, Object* extra){
((App*)extra)->LoadMapEntity(entity);
}
Entity* trigger1;
bool App::Start()
{
//Create a window
window = Window::Create("White");
//Create a context
context = Context::Create(window);
//Create a world
world = World::Create();
//Create a camera
camera = Camera::Create();
camera->Move(0,2,0);
//Hide the mouse cursor
window->HideMouse();
std::string mapname = System::GetProperty("map","Maps/start.map");
Map::Load(mapname, MapLoader, (Object*)this);
//Move the mouse to the center of the screen
window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2);
player = Pivot::Create();
player->SetPhysicsMode(Entity::CharacterPhysics);
player->SetPosition(0,2,0);
player->SetMass(1);
playerHeight = 1.7;
strafeSpeed = 35;
moveSpeed = 35;
jumpAcc = 100;
pausex = 0;
pausey = 0;
mouseposition = window->GetMousePosition();
trigger1->AddHook(Entity::CollisionHook, (void*)CollisionHook);
return true;
}
void App::LoadMapEntity(Entity* e){
if(e->GetKeyValue("name") == "trigger1"){
trigger1 = e;
}
}
void Collision(Entity* collidedEntity, const Vec3& position, const Vec3& normal, float speed){
}
void CollisionHook(Entity* entity0, Entity* entity1, float* position, float* normal, float speed){
System::Print("Entity: " + entity0->GetKeyValue("name") + " collided with: " + entity1->GetKeyValue("name"));
}
bool App::Loop()
{
//Close the window to end the program
if (window->Closed()) return false;
//Press escape to end freelook mode
if (window->KeyHit(Key::Escape))
{
exit(0);
}
.... Everything else has to do with character controllers, movement etc. so it's not really needed
App.h:
#pragma once
#include "Leadwerks.h"
using namespace Leadwerks;
class App
{
public:
Window* window;
Context* context;
World* world;
Camera* camera;
App();
virtual ~App();
void LoadMapEntity(Entity* e);
virtual bool Start();
virtual bool Loop();
virtual void Collision(Entity* collidedEntity, const Vec3& position, const Vec3& normal, float speed);
static void CollisionHook(Entity* entity0, Entity* entity1, float* position, float* normal, float speed);
};
- Mex
//Edit:
if I add 'App::' in front of both function in App.cpp then i got the error: (translated by google translator:) Access violation when reading at position. I think something with my rguments is wrong but what?
:/