)
set(LUGARU_H
- ${SRCDIR}/Animation/Animation.h
- ${SRCDIR}/Animation/Joint.h
- ${SRCDIR}/Animation/Muscle.h
- ${SRCDIR}/Animation/Skeleton.h
- ${SRCDIR}/Audio/openal_wrapper.h
- ${SRCDIR}/Audio/Sounds.h
- ${SRCDIR}/Devtools/ConsoleCmds.h
- ${SRCDIR}/Environment/Lights.h
- ${SRCDIR}/Environment/Skybox.h
- ${SRCDIR}/Environment/Terrain.h
- ${SRCDIR}/Graphic/gamegl.h
- ${SRCDIR}/Graphic/Models.h
- ${SRCDIR}/Graphic/Sprite.h
- ${SRCDIR}/Graphic/Stereo.h
- ${SRCDIR}/Graphic/Text.h
- ${SRCDIR}/Graphic/Texture.h
- ${SRCDIR}/Level/Campaign.h
- ${SRCDIR}/Level/Dialog.h
- ${SRCDIR}/Level/Hotspot.h
- ${SRCDIR}/Math/Frustum.h
- ${SRCDIR}/Math/PhysicsMath.h
- ${SRCDIR}/Math/Quaternions.h
- ${SRCDIR}/Math/Random.h
- ${SRCDIR}/Menu/Menu.h
- ${SRCDIR}/Objects/Objects.h
- ${SRCDIR}/Objects/Person.h
- ${SRCDIR}/Objects/Weapons.h
+ ${SRCDIR}/Animation/Animation.hpp
+ ${SRCDIR}/Animation/Joint.hpp
+ ${SRCDIR}/Animation/Muscle.hpp
+ ${SRCDIR}/Animation/Skeleton.hpp
+ ${SRCDIR}/Audio/openal_wrapper.hpp
+ ${SRCDIR}/Audio/Sounds.hpp
+ ${SRCDIR}/Devtools/ConsoleCmds.hpp
+ ${SRCDIR}/Environment/Lights.hpp
+ ${SRCDIR}/Environment/Skybox.hpp
+ ${SRCDIR}/Environment/Terrain.hpp
+ ${SRCDIR}/Graphic/gamegl.hpp
+ ${SRCDIR}/Graphic/Models.hpp
+ ${SRCDIR}/Graphic/Sprite.hpp
+ ${SRCDIR}/Graphic/Stereo.hpp
+ ${SRCDIR}/Graphic/Text.hpp
+ ${SRCDIR}/Graphic/Texture.hpp
+ ${SRCDIR}/Level/Campaign.hpp
+ ${SRCDIR}/Level/Dialog.hpp
+ ${SRCDIR}/Level/Hotspot.hpp
+ ${SRCDIR}/Math/Frustum.hpp
+ ${SRCDIR}/Math/PhysicsMath.hpp
+ ${SRCDIR}/Math/Quaternions.hpp
+ ${SRCDIR}/Math/Random.hpp
+ ${SRCDIR}/Menu/Menu.hpp
+ ${SRCDIR}/Objects/Objects.hpp
+ ${SRCDIR}/Objects/Person.hpp
+ ${SRCDIR}/Objects/Weapons.hpp
${SRCDIR}/Thirdparty/optionparser.h
- ${SRCDIR}/User/Account.h
- ${SRCDIR}/User/Settings.h
+ ${SRCDIR}/User/Account.hpp
+ ${SRCDIR}/User/Settings.hpp
${SRCDIR}/Utils/binio.h
- ${SRCDIR}/Utils/Folders.h
- ${SRCDIR}/Utils/ImageIO.h
- ${SRCDIR}/Utils/Input.h
+ ${SRCDIR}/Utils/Folders.hpp
+ ${SRCDIR}/Utils/ImageIO.hpp
+ ${SRCDIR}/Utils/Input.hpp
${SRCDIR}/Utils/private.h
- ${SRCDIR}/Game.h
+ ${SRCDIR}/Game.hpp
)
)
set(LUGARU_H
${LUGARU_H}
- ${SRCDIR}/MacCompatibility.h
+ ${SRCDIR}/MacCompatibility.hpp
)
endif(UNIX)
set(LUGARU_H
${LUGARU_H}
- ${SRCDIR}/WinDefs.h
- ${SRCDIR}/win-res/resource.h)
+ ${SRCDIR}/WinDefs.hpp
+ ${SRCDIR}/win-res/resource.hpp)
endif(WIN32)
if(APPLE)
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Animation/Animation.h"
-#include "Animation/Skeleton.h"
-#include "Utils/Folders.h"
-#include "Game.h"
+#include "Animation/Animation.hpp"
+
+#include "Animation/Skeleton.hpp"
+#include "Game.hpp"
+#include "Utils/Folders.hpp"
extern bool visibleloading;
+++ /dev/null
-/*
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef ANIMATION_H
-#define ANIMATION_H
-
-#include <vector>
-#include "Math/Quaternions.h"
-
-enum anim_attack_type {
- neutral, normalattack, reversed, reversal
-};
-
-enum anim_height_type {
- lowheight, middleheight, highheight
-};
-
-enum animation_types {
-#define DECLARE_ANIM(id, ...) id,
-#include "Animation.def"
-#undef DECLARE_ANIM
- animation_count
-};
-
-enum animation_bit_offsets {
-#define DECLARE_ANIM_BIT(bit) o_##bit,
-#include "Animation.def"
-#undef DECLARE_ANIM_BIT
- animation_bit_count
-};
-
-enum animation_bits_def {
-#define DECLARE_ANIM_BIT(bit) bit = 1 << o_##bit,
-#include "Animation.def"
-#undef DECLARE_ANIM_BIT
-};
-
-static const int animation_bits[animation_count] = {
-#define DECLARE_ANIM(id, name, height, type, bits) bits,
-#include "Animation.def"
-#undef DECLARE_ANIM
-};
-
-struct AnimationFrameJointInfo
-{
- XYZ position;
- float twist;
- float twist2;
- bool onground;
-};
-
-struct AnimationFrame
-{
- void loadBaseInfo(FILE* tfile);
- void loadTwist2(FILE* tfile);
- void loadLabel(FILE* tfile);
- void loadWeaponTarget(FILE* tfile);
-
- std::vector<AnimationFrameJointInfo> joints;
- XYZ forward;
- int label;
- XYZ weapontarget;
- float speed;
-};
-
-class Animation
-{
-public:
- static std::vector<Animation> animations;
- static void loadAll();
-
- anim_height_type height;
- anim_attack_type attack;
- int numjoints;
-
- std::vector<AnimationFrame> frames;
-
- XYZ offset;
-
- Animation();
- Animation(const std::string& fileName, anim_height_type aheight, anim_attack_type aattack);
-};
-#endif
--- /dev/null
+/*
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _ANIMATION_HPP_
+#define _ANIMATION_HPP_
+
+#include "Math/Quaternions.hpp"
+
+#include <vector>
+
+enum anim_attack_type {
+ neutral, normalattack, reversed, reversal
+};
+
+enum anim_height_type {
+ lowheight, middleheight, highheight
+};
+
+enum animation_types {
+#define DECLARE_ANIM(id, ...) id,
+#include "Animation.def"
+#undef DECLARE_ANIM
+ animation_count
+};
+
+enum animation_bit_offsets {
+#define DECLARE_ANIM_BIT(bit) o_##bit,
+#include "Animation.def"
+#undef DECLARE_ANIM_BIT
+ animation_bit_count
+};
+
+enum animation_bits_def {
+#define DECLARE_ANIM_BIT(bit) bit = 1 << o_##bit,
+#include "Animation.def"
+#undef DECLARE_ANIM_BIT
+};
+
+static const int animation_bits[animation_count] = {
+#define DECLARE_ANIM(id, name, height, type, bits) bits,
+#include "Animation.def"
+#undef DECLARE_ANIM
+};
+
+struct AnimationFrameJointInfo
+{
+ XYZ position;
+ float twist;
+ float twist2;
+ bool onground;
+};
+
+struct AnimationFrame
+{
+ void loadBaseInfo(FILE* tfile);
+ void loadTwist2(FILE* tfile);
+ void loadLabel(FILE* tfile);
+ void loadWeaponTarget(FILE* tfile);
+
+ std::vector<AnimationFrameJointInfo> joints;
+ XYZ forward;
+ int label;
+ XYZ weapontarget;
+ float speed;
+};
+
+class Animation
+{
+public:
+ static std::vector<Animation> animations;
+ static void loadAll();
+
+ anim_height_type height;
+ anim_attack_type attack;
+ int numjoints;
+
+ std::vector<AnimationFrame> frames;
+
+ XYZ offset;
+
+ Animation();
+ Animation(const std::string& fileName, anim_height_type aheight, anim_attack_type aattack);
+};
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Animation/Joint.h"
+#include "Animation/Joint.hpp"
+
#include "Utils/binio.h"
Joint::Joint() :
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _JOINT_H_
-#define _JOINT_H_
-
-#include "Math/Quaternions.h"
-#include <vector>
-
-enum bodypart {
- head, neck,
- leftshoulder, leftelbow, leftwrist, lefthand,
- rightshoulder, rightelbow, rightwrist, righthand,
- abdomen, lefthip, righthip, groin,
- leftknee, leftankle, leftfoot,
- rightknee, rightankle, rightfoot
-};
-
-class Joint
-{
-public:
- XYZ position;
- XYZ oldposition;
- XYZ realoldposition;
- XYZ velocity;
- XYZ oldvelocity;
- XYZ startpos;
- float blurred;
- float length;
- float mass;
- bool lower;
- bool hasparent;
- bool locked;
- int modelnum;
- bool visible;
- Joint* parent;
- bool sametwist;
- bodypart label;
- int hasgun;
- float delay;
- XYZ velchange;
-
- Joint();
- void load(FILE* tfile, std::vector<Joint>& joints);
-};
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _JOINT_HPP_
+#define _JOINT_HPP_
+
+#include "Math/Quaternions.hpp"
+
+#include <vector>
+
+enum bodypart {
+ head, neck,
+ leftshoulder, leftelbow, leftwrist, lefthand,
+ rightshoulder, rightelbow, rightwrist, righthand,
+ abdomen, lefthip, righthip, groin,
+ leftknee, leftankle, leftfoot,
+ rightknee, rightankle, rightfoot
+};
+
+class Joint
+{
+public:
+ XYZ position;
+ XYZ oldposition;
+ XYZ realoldposition;
+ XYZ velocity;
+ XYZ oldvelocity;
+ XYZ startpos;
+ float blurred;
+ float length;
+ float mass;
+ bool lower;
+ bool hasparent;
+ bool locked;
+ int modelnum;
+ bool visible;
+ Joint* parent;
+ bool sametwist;
+ bodypart label;
+ int hasgun;
+ float delay;
+ XYZ velchange;
+
+ Joint();
+ void load(FILE* tfile, std::vector<Joint>& joints);
+};
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Animation/Muscle.h"
+#include "Animation/Muscle.hpp"
+
#include "Utils/binio.h"
extern float multiplier;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _MUSCLE_H_
-#define _MUSCLE_H_
-
-#include <vector>
-#include "Animation/Joint.h"
-
-enum muscle_type {boneconnect, constraint, muscle};
-
-class Muscle
-{
-public:
- std::vector<int> vertices;
- std::vector<int> verticeslow;
- std::vector<int> verticesclothes;
- float length;
- float targetlength;
- Joint* parent1;
- Joint* parent2;
- float maxlength;
- float minlength;
- muscle_type type;
- bool visible;
- float rotate1, rotate2, rotate3;
- float lastrotate1, lastrotate2, lastrotate3;
- float oldrotate1, oldrotate2, oldrotate3;
- float newrotate1, newrotate2, newrotate3;
-
- float strength;
-
- Muscle();
- void load(FILE* tfile, int vertexNum, std::vector<Joint>& joints);
- void loadVerticesLow(FILE* tfile, int vertexNum);
- void loadVerticesClothes(FILE* tfile, int vertexNum);
- void DoConstraint(bool spinny);
-};
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _MUSCLE_HPP_
+#define _MUSCLE_HPP_
+
+#include "Animation/Joint.hpp"
+
+#include <vector>
+
+enum muscle_type {boneconnect, constraint, muscle};
+
+class Muscle
+{
+public:
+ std::vector<int> vertices;
+ std::vector<int> verticeslow;
+ std::vector<int> verticesclothes;
+ float length;
+ float targetlength;
+ Joint* parent1;
+ Joint* parent2;
+ float maxlength;
+ float minlength;
+ muscle_type type;
+ bool visible;
+ float rotate1, rotate2, rotate3;
+ float lastrotate1, lastrotate2, lastrotate3;
+ float oldrotate1, oldrotate2, oldrotate3;
+ float newrotate1, newrotate2, newrotate3;
+
+ float strength;
+
+ Muscle();
+ void load(FILE* tfile, int vertexNum, std::vector<Joint>& joints);
+ void loadVerticesLow(FILE* tfile, int vertexNum);
+ void loadVerticesClothes(FILE* tfile, int vertexNum);
+ void DoConstraint(bool spinny);
+};
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-/**> HEADER FILES <**/
-#include "Game.h"
-#include "Animation/Animation.h"
-#include "Animation/Skeleton.h"
-#include "Audio/openal_wrapper.h"
-#include "Utils/Folders.h"
+#include "Animation/Skeleton.hpp"
+
+#include "Animation/Animation.hpp"
+#include "Audio/openal_wrapper.hpp"
+#include "Game.hpp"
+#include "Utils/Folders.hpp"
extern float multiplier;
extern float gravity;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _SKELETON_H_
-#define _SKELETON_H_
-
-/**> HEADER FILES <**/
-#include "Animation/Animation.h"
-#include "Animation/Joint.h"
-#include "Animation/Muscle.h"
-#include "Graphic/gamegl.h"
-#include "Graphic/Models.h"
-#include "Graphic/Sprite.h"
-#include "Math/Quaternions.h"
-#include "Objects/Objects.h"
-#include "Utils/binio.h"
-
-const int max_joints = 50;
-
-class Skeleton
-{
-public:
- std::vector<Joint> joints;
-
- std::vector<Muscle> muscles;
-
- int selected;
-
- int forwardjoints[3];
- XYZ forward;
-
- int id;
-
- int lowforwardjoints[3];
- XYZ lowforward;
-
- XYZ specialforward[5];
- int jointlabels[max_joints];
-
- Model model[7];
- Model modellow;
- Model modelclothes;
- int num_models;
-
- Model drawmodel;
- Model drawmodellow;
- Model drawmodelclothes;
-
- bool clothes;
- bool spinny;
-
- GLubyte skinText[512 * 512 * 3];
- int skinsize;
-
- float checkdelay;
-
- float longdead;
- bool broken;
-
- int free;
- int oldfree;
- float freetime;
- bool freefall;
-
- void FindForwards();
- float DoConstraints(XYZ *coords, float *scale);
- void DoGravity(float *scale);
- void FindRotationJoint(int which);
- void FindRotationJointSameTwist(int which);
- void FindRotationMuscle(int which, int animation);
- void Load(const std::string& fileName, const std::string& lowfileName, const std::string& clothesfileName, const std::string& modelfileName, const std::string& model2fileName, const std::string& model3fileName, const std::string& model4fileName, const std::string& model5fileNamee, const std::string& model6fileName, const std::string& model7fileName, const std::string& modellowfileName, const std::string& modelclothesfileName, bool aclothes);
-
- Skeleton();
-
-private:
- // convenience functions
- // only for Skeleton.cpp
- inline Joint& joint(int bodypart) { return joints[jointlabels[bodypart]]; }
- inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; }
- inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; }
-
-};
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _SKELETON_HPP_
+#define _SKELETON_HPP_
+
+#include "Animation/Animation.hpp"
+#include "Animation/Joint.hpp"
+#include "Animation/Muscle.hpp"
+#include "Graphic/gamegl.hpp"
+#include "Graphic/Models.hpp"
+#include "Graphic/Sprite.hpp"
+#include "Math/Quaternions.hpp"
+#include "Objects/Objects.hpp"
+#include "Utils/binio.h"
+
+const int max_joints = 50;
+
+class Skeleton
+{
+public:
+ std::vector<Joint> joints;
+
+ std::vector<Muscle> muscles;
+
+ int selected;
+
+ int forwardjoints[3];
+ XYZ forward;
+
+ int id;
+
+ int lowforwardjoints[3];
+ XYZ lowforward;
+
+ XYZ specialforward[5];
+ int jointlabels[max_joints];
+
+ Model model[7];
+ Model modellow;
+ Model modelclothes;
+ int num_models;
+
+ Model drawmodel;
+ Model drawmodellow;
+ Model drawmodelclothes;
+
+ bool clothes;
+ bool spinny;
+
+ GLubyte skinText[512 * 512 * 3];
+ int skinsize;
+
+ float checkdelay;
+
+ float longdead;
+ bool broken;
+
+ int free;
+ int oldfree;
+ float freetime;
+ bool freefall;
+
+ void FindForwards();
+ float DoConstraints(XYZ *coords, float *scale);
+ void DoGravity(float *scale);
+ void FindRotationJoint(int which);
+ void FindRotationJointSameTwist(int which);
+ void FindRotationMuscle(int which, int animation);
+ void Load(const std::string& fileName, const std::string& lowfileName, const std::string& clothesfileName, const std::string& modelfileName, const std::string& model2fileName, const std::string& model3fileName, const std::string& model4fileName, const std::string& model5fileNamee, const std::string& model6fileName, const std::string& model7fileName, const std::string& modellowfileName, const std::string& modelclothesfileName, bool aclothes);
+
+ Skeleton();
+
+private:
+ // convenience functions
+ // only for Skeleton.cpp
+ inline Joint& joint(int bodypart) { return joints[jointlabels[bodypart]]; }
+ inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; }
+ inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; }
+
+};
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Audio/openal_wrapper.h"
-#include "Audio/Sounds.h"
-#include "Math/Quaternions.h"
-#include "Utils/Folders.h"
+#include "Audio/Sounds.hpp"
+
+#include "Audio/openal_wrapper.hpp"
+#include "Utils/Folders.hpp"
struct OPENAL_SAMPLE *samp[sounds_count];
+++ /dev/null
-/*
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef SOUNDS_H
-#define SOUNDS_H
-
-enum sound_types {
-#define DECLARE_SOUND(id, filename) id,
-#include "Sounds.def"
-#undef DECLARE_SOUND
- sounds_count
-};
-
-extern struct OPENAL_SAMPLE *samp[sounds_count];
-extern int channels[];
-
-extern void loadAllSounds();
-
-extern void addEnvSound(XYZ coords, float vol = 16, float life = .4);
-
-extern void emit_sound_at(int soundid, const XYZ &pos = XYZ(), float vol = 256.f);
-extern void emit_sound_np(int soundid, float vol = 256.f);
-extern void emit_stream_at(int soundid, const XYZ &pos = XYZ(), float vol = 256.f);
-extern void emit_stream_np(int soundid, float vol = 256.f);
-extern void resume_stream(int soundid);
-extern void pause_sound(int soundid);
-
-extern int footstepsound, footstepsound2, footstepsound3, footstepsound4;
-#endif
--- /dev/null
+/*
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _SOUNDS_HPP_
+#define _SOUNDS_HPP_
+
+#include "Math/Quaternions.hpp"
+
+enum sound_types {
+#define DECLARE_SOUND(id, filename) id,
+#include "Sounds.def"
+#undef DECLARE_SOUND
+ sounds_count
+};
+
+extern struct OPENAL_SAMPLE *samp[sounds_count];
+extern int channels[];
+
+extern void loadAllSounds();
+
+extern void addEnvSound(XYZ coords, float vol = 16, float life = .4);
+
+extern void emit_sound_at(int soundid, const XYZ &pos = XYZ(), float vol = 256.f);
+extern void emit_sound_np(int soundid, float vol = 256.f);
+extern void emit_stream_at(int soundid, const XYZ &pos = XYZ(), float vol = 256.f);
+extern void emit_stream_np(int soundid, float vol = 256.f);
+extern void resume_stream(int soundid);
+extern void pause_sound(int soundid);
+
+extern int footstepsound, footstepsound2, footstepsound3, footstepsound4;
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "Audio/openal_wrapper.hpp"
+
+#include "Audio/Sounds.hpp"
+#include "Game.hpp"
+#include "Math/Quaternions.hpp"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "Math/Quaternions.h"
-#include "Audio/openal_wrapper.h"
-#include "Audio/Sounds.h"
-#include "Game.h"
-
extern float slomofreq;
// NOTE:
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef OPENAL_WRAPPER_H
-#define OPENAL_WRAPPER_H
-
-#ifdef _WIN32
-#include <malloc.h>
-#endif
-
-#include "AL/al.h"
-#include "AL/alc.h"
-
-#include "ogg/ogg.h"
-#include "vorbis/vorbisfile.h"
-
-#include "Math/Quaternions.h"
-#include "MacCompatibility.h"
-
-#if 0 /* this should only be enable if OPENAL doesn't provide AL_API on all platforms */
-#if (!defined(WIN32) && !defined(_WIN32) && !defined(__WIN32__) && !defined(_WIN64) && !defined(_WIN32_WCE) && !defined(_XBOX)) || (defined(__GNUC__) && defined(WIN32))
-#ifndef __cdecl
-#define __cdecl
-#endif
-#ifndef __stdcall
-#define __stdcall
-#endif
-#endif
-
-#if defined(_WIN32_WCE)
-#define AL_API _cdecl
-#define F_CALLBACKAPI _cdecl
-#else
-#define AL_API __stdcall
-#define F_CALLBACKAPI __stdcall
-#endif
-
-#ifdef DLL_EXPORTS
-#define DLL_API __declspec(dllexport)
-#else
-#if defined(__LCC__) || defined(__MINGW32__) || defined(__CYGWIN32__)
-#define DLL_API AL_API
-#else
-#define DLL_API
-#endif /* __LCC__ || __MINGW32__ || __CYGWIN32__ */
-#endif /* DLL_EXPORTS */
-#endif /* if 0 */
-
-
-typedef struct OPENAL_SAMPLE OPENAL_SAMPLE;
-typedef OPENAL_SAMPLE OPENAL_STREAM;
-typedef struct OPENAL_DSPUNIT OPENAL_DSPUNIT;
-
-enum OPENAL_OUTPUTTYPES {
- OPENAL_OUTPUT_NOSOUND, /* NoSound driver, all calls to this succeed but do nothing. */
- OPENAL_OUTPUT_OSS, /* Linux/Unix OSS (Open Sound System) driver, i.e. the kernel sound drivers. */
- OPENAL_OUTPUT_ALSA, /* Linux Alsa driver. */
-};
-
-#define OPENAL_LOOP_OFF 0x00000001 /* For non looping samples. */
-#define OPENAL_LOOP_NORMAL 0x00000002 /* For forward looping samples. */
-#define OPENAL_HW3D 0x00001000 /* Attempts to make samples use 3d hardware acceleration. (if the card supports it) */
-#define OPENAL_2D 0x00002000 /* Tells software (not hardware) based sample not to be included in 3d processing. */
-#define OPENAL_FREE -1 /* value to play on any free channel, or to allocate a sample in a free sample slot. */
-#define OPENAL_ALL -3 /* for a channel index , this flag will affect ALL channels available! Not supported by every function. */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#undef AL_API
-#define AL_API
-
- AL_API void OPENAL_3D_Listener_SetAttributes(const float *pos, const float *vel, float fx, float fy, float fz, float tx, float ty, float tz);
- AL_API signed char OPENAL_3D_SetAttributes(int channel, const float *pos, const float *vel);
- AL_API signed char OPENAL_3D_SetAttributes_(int channel, const XYZ &pos, const float *vel);
- AL_API signed char OPENAL_Init(int mixrate, int maxsoftwarechannels, unsigned int flags);
- AL_API void OPENAL_Close();
- AL_API OPENAL_SAMPLE *OPENAL_Sample_Load(int index, const char *name_or_data, unsigned int mode, int offset, int length);
- AL_API void OPENAL_Sample_Free(OPENAL_SAMPLE *sptr);
- AL_API signed char OPENAL_SetFrequency(int channel, bool slomo = false);
- AL_API signed char OPENAL_SetVolume(int channel, int vol);
- AL_API signed char OPENAL_SetPaused(int channel, signed char paused);
- AL_API void OPENAL_SetSFXMasterVolume(int volume);
- AL_API signed char OPENAL_StopSound(int channel);
- AL_API signed char OPENAL_Stream_SetMode(OPENAL_STREAM *stream, unsigned int mode);
- AL_API void OPENAL_Update();
- AL_API signed char OPENAL_SetOutput(int outputtype);
- void PlaySoundEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
- void PlayStreamEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _OPENAL_WRAPPER_HPP_
+#define _OPENAL_WRAPPER_HPP_
+
+#include "MacCompatibility.hpp"
+#include "Math/Quaternions.hpp"
+
+#include <AL/al.h>
+#include <AL/alc.h>
+#include <ogg/ogg.h>
+#include <vorbis/vorbisfile.h>
+
+#ifdef _WIN32
+#include <malloc.h>
+#endif
+
+#if 0 /* this should only be enable if OPENAL doesn't provide AL_API on all platforms */
+#if (!defined(WIN32) && !defined(_WIN32) && !defined(__WIN32__) && !defined(_WIN64) && !defined(_WIN32_WCE) && !defined(_XBOX)) || (defined(__GNUC__) && defined(WIN32))
+#ifndef __cdecl
+#define __cdecl
+#endif
+#ifndef __stdcall
+#define __stdcall
+#endif
+#endif
+
+#if defined(_WIN32_WCE)
+#define AL_API _cdecl
+#define F_CALLBACKAPI _cdecl
+#else
+#define AL_API __stdcall
+#define F_CALLBACKAPI __stdcall
+#endif
+
+#ifdef DLL_EXPORTS
+#define DLL_API __declspec(dllexport)
+#else
+#if defined(__LCC__) || defined(__MINGW32__) || defined(__CYGWIN32__)
+#define DLL_API AL_API
+#else
+#define DLL_API
+#endif /* __LCC__ || __MINGW32__ || __CYGWIN32__ */
+#endif /* DLL_EXPORTS */
+#endif /* if 0 */
+
+
+typedef struct OPENAL_SAMPLE OPENAL_SAMPLE;
+typedef OPENAL_SAMPLE OPENAL_STREAM;
+typedef struct OPENAL_DSPUNIT OPENAL_DSPUNIT;
+
+enum OPENAL_OUTPUTTYPES {
+ OPENAL_OUTPUT_NOSOUND, /* NoSound driver, all calls to this succeed but do nothing. */
+ OPENAL_OUTPUT_OSS, /* Linux/Unix OSS (Open Sound System) driver, i.e. the kernel sound drivers. */
+ OPENAL_OUTPUT_ALSA, /* Linux Alsa driver. */
+};
+
+#define OPENAL_LOOP_OFF 0x00000001 /* For non looping samples. */
+#define OPENAL_LOOP_NORMAL 0x00000002 /* For forward looping samples. */
+#define OPENAL_HW3D 0x00001000 /* Attempts to make samples use 3d hardware acceleration. (if the card supports it) */
+#define OPENAL_2D 0x00002000 /* Tells software (not hardware) based sample not to be included in 3d processing. */
+#define OPENAL_FREE -1 /* value to play on any free channel, or to allocate a sample in a free sample slot. */
+#define OPENAL_ALL -3 /* for a channel index , this flag will affect ALL channels available! Not supported by every function. */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#undef AL_API
+#define AL_API
+
+ AL_API void OPENAL_3D_Listener_SetAttributes(const float *pos, const float *vel, float fx, float fy, float fz, float tx, float ty, float tz);
+ AL_API signed char OPENAL_3D_SetAttributes(int channel, const float *pos, const float *vel);
+ AL_API signed char OPENAL_3D_SetAttributes_(int channel, const XYZ &pos, const float *vel);
+ AL_API signed char OPENAL_Init(int mixrate, int maxsoftwarechannels, unsigned int flags);
+ AL_API void OPENAL_Close();
+ AL_API OPENAL_SAMPLE *OPENAL_Sample_Load(int index, const char *name_or_data, unsigned int mode, int offset, int length);
+ AL_API void OPENAL_Sample_Free(OPENAL_SAMPLE *sptr);
+ AL_API signed char OPENAL_SetFrequency(int channel, bool slomo = false);
+ AL_API signed char OPENAL_SetVolume(int channel, int vol);
+ AL_API signed char OPENAL_SetPaused(int channel, signed char paused);
+ AL_API void OPENAL_SetSFXMasterVolume(int volume);
+ AL_API signed char OPENAL_StopSound(int channel);
+ AL_API signed char OPENAL_Stream_SetMode(OPENAL_STREAM *stream, unsigned int mode);
+ AL_API void OPENAL_Update();
+ AL_API signed char OPENAL_SetOutput(int outputtype);
+ void PlaySoundEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
+ void PlayStreamEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Game.h"
-#include "Devtools/ConsoleCmds.h"
-#include "Level/Dialog.h"
-#include "Level/Hotspot.h"
-#include "Utils/Folders.h"
+#include "Devtools/ConsoleCmds.hpp"
+
+#include "Game.hpp"
+#include "Level/Dialog.hpp"
+#include "Level/Hotspot.hpp"
+#include "Utils/Folders.hpp"
const char *cmd_names[cmd_count] = {
#define DECLARE_COMMAND(cmd) #cmd,
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-typedef void (*console_handler)(const char *args);
-
-#define DECLARE_COMMAND(cmd) void ch_##cmd(const char *args);
-#include "ConsoleCmds.def"
-#undef DECLARE_COMMAND
-
-/* FIXME - This is only to get cmd_count, not very clean */
-enum console_command {
-#define DECLARE_COMMAND(cmd) cmd_##cmd,
-#include "ConsoleCmds.def"
-#undef DECLARE_COMMAND
- cmd_count
-};
-
-extern const char *cmd_names[cmd_count];
-
-extern console_handler cmd_handlers[cmd_count];
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+typedef void (*console_handler)(const char *args);
+
+#define DECLARE_COMMAND(cmd) void ch_##cmd(const char *args);
+#include "ConsoleCmds.def"
+#undef DECLARE_COMMAND
+
+/* FIXME - This is only to get cmd_count, not very clean */
+enum console_command {
+#define DECLARE_COMMAND(cmd) cmd_##cmd,
+#include "ConsoleCmds.def"
+#undef DECLARE_COMMAND
+ cmd_count
+};
+
+extern const char *cmd_names[cmd_count];
+
+extern console_handler cmd_handlers[cmd_count];
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-/**> HEADER FILES <**/
-#include "Environment/Lights.h"
+#include "Environment/Lights.hpp"
void SetUpLight(Light* whichsource, int whichlight)
{
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _LIGHTS_H_
-#define _LIGHTS_H_
-
-
-/**> HEADER FILES <**/
-#include "Graphic/gamegl.h"
-#include "Math/Quaternions.h"
-
-class Light
-{
-public:
- GLint type;
- GLfloat color[3];
- GLfloat ambient[3];
- int attach;
- XYZ location;
- inline void setColors(GLfloat cr, GLfloat cg, GLfloat cb,
- GLfloat ar, GLfloat ag, GLfloat ab) {
- color[0] = cr;
- color[1] = cg;
- color[2] = cb;
- ambient[0] = ar;
- ambient[1] = ag;
- ambient[2] = ab;
- }
-};
-
-void SetUpLight(Light* whichsource, int whichlight);
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _LIGHTS_HPP_
+#define _LIGHTS_HPP_
+
+#include "Graphic/gamegl.hpp"
+#include "Math/Quaternions.hpp"
+
+class Light
+{
+public:
+ GLint type;
+ GLfloat color[3];
+ GLfloat ambient[3];
+ int attach;
+ XYZ location;
+ inline void setColors(GLfloat cr, GLfloat cg, GLfloat cb,
+ GLfloat ar, GLfloat ag, GLfloat ab) {
+ color[0] = cr;
+ color[1] = cg;
+ color[2] = cb;
+ ambient[0] = ar;
+ ambient[1] = ag;
+ ambient[2] = ab;
+ }
+};
+
+void SetUpLight(Light* whichsource, int whichlight);
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Environment/Skybox.h"
-#include "Game.h"
+#include "Environment/Skybox.hpp"
+
+#include "Game.hpp"
extern float viewdistance;
extern float blurness;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _SKYBOX_H_
-#define _SKYBOX_H_
-
-#include "Graphic/gamegl.h"
-#include "Graphic/Texture.h"
-#include "Math/Quaternions.h"
-#include "Math/Quaternions.h"
-#include "Utils/ImageIO.h"
-
-class SkyBox
-{
-public:
- Texture front, left, back, right, up, down;
-
- void load(const std::string& ffront, const std::string& fleft, const std::string& fback,
- const std::string& fright, const std::string& fup, const std::string& fdown);
- void draw();
-
- SkyBox() {}
- ~SkyBox();
-};
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _SKYBOX_HPP_
+#define _SKYBOX_HPP_
+
+#include "Graphic/gamegl.hpp"
+#include "Graphic/Texture.hpp"
+#include "Math/Quaternions.hpp"
+#include "Math/Quaternions.hpp"
+#include "Utils/ImageIO.hpp"
+
+class SkyBox
+{
+public:
+ Texture front, left, back, right, up, down;
+
+ void load(const std::string& ffront, const std::string& fleft, const std::string& fback,
+ const std::string& fright, const std::string& fup, const std::string& fdown);
+ void draw();
+
+ SkyBox() {}
+ ~SkyBox();
+};
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Game.h"
-#include "Environment/Terrain.h"
-#include "Objects/Objects.h"
-#include "Utils/Folders.h"
+#include "Environment/Terrain.hpp"
+
+#include "Game.hpp"
+#include "Objects/Objects.hpp"
+#include "Utils/Folders.hpp"
extern XYZ viewer;
extern float viewdistance;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _TERRAIN_H_
-#define _TERRAIN_H_
-
-#include "Environment/Lights.h"
-#include "Graphic/gamegl.h"
-#include "Graphic/Texture.h"
-#include "Math/Frustum.h"
-#include "Math/Quaternions.h"
-#include "Math/Quaternions.h"
-#include "Utils/ImageIO.h"
-
-#define max_terrain_size 256
-#define curr_terrain_size size
-#define subdivision 64
-#define max_patch_elements (max_terrain_size/subdivision)*(max_terrain_size/subdivision)*54
-
-#define allfirst 0
-#define mixed 1
-#define allsecond 2
-
-#define max_decals 1000
-
-#define shadowdecal 0
-#define footprintdecal 1
-#define blooddecal 2
-#define blooddecalfast 3
-#define shadowdecalpermanent 4
-#define breakdecal 5
-#define blooddecalslow 6
-#define bodyprintdecal 7
-
-#define snowyenvironment 0
-#define grassyenvironment 1
-#define desertenvironment 2
-//
-// Model Structures
-//
-
-class Terrain
-{
-public:
- Texture bloodtexture;
- Texture bloodtexture2;
- Texture shadowtexture;
- Texture footprinttexture;
- Texture bodyprinttexture;
- Texture breaktexture;
- Texture terraintexture;
- short size;
-
- int patchobjectnum[subdivision][subdivision];
- int patchobjects[subdivision][subdivision][300];
-
- float scale;
- int type;
- float heightmap[max_terrain_size + 1][max_terrain_size + 1];
- XYZ normals[max_terrain_size][max_terrain_size];
- XYZ facenormals[max_terrain_size][max_terrain_size];
- XYZ triangles[(max_terrain_size - 1) * (max_terrain_size - 1) * 2][3];
- float colors[max_terrain_size][max_terrain_size][4];
- float opacityother[max_terrain_size][max_terrain_size];
- float texoffsetx[max_terrain_size][max_terrain_size];
- float texoffsety[max_terrain_size][max_terrain_size];
- int numtris[subdivision][subdivision];
- int textureness[subdivision][subdivision];
-
- GLfloat vArray[(max_patch_elements)*subdivision*subdivision];
-
- bool visible[subdivision][subdivision];
- float avgypatch[subdivision][subdivision];
- float maxypatch[subdivision][subdivision];
- float minypatch[subdivision][subdivision];
- float heightypatch[subdivision][subdivision];
-
- int patch_elements;
-
- float decaltexcoords[max_decals][3][2];
- XYZ decalvertex[max_decals][3];
- int decaltype[max_decals];
- float decalopacity[max_decals];
- float decalrotation[max_decals];
- float decalalivetime[max_decals];
- float decalbrightness[max_decals];
- XYZ decalposition[max_decals];
- int numdecals;
-
- void AddObject(XYZ where, float radius, int id);
- void DeleteDecal(int which);
- void MakeDecal(int type, XYZ where, float size, float opacity, float rotation);
- void MakeDecalLock(int type, XYZ where, int whichx, int whichy, float size, float opacity, float rotation);
- int lineTerrain(XYZ p1, XYZ p2, XYZ *p);
- float getHeight(float pointx, float pointz);
- float getOpacity(float pointx, float pointz);
- XYZ getLighting(float pointx, float pointz);
- XYZ getNormal(float pointx, float pointz);
- void UpdateVertexArray(int whichx, int whichy);
- void UpdateTransparency(int whichx, int whichy);
- void UpdateTransparencyother(int whichx, int whichy);
- void UpdateTransparencyotherother(int whichx, int whichy);
- bool load(const std::string& fileName);
- void CalculateNormals();
- void drawdecals();
- void draw(int layer);
- void drawpatch(int whichx, int whichy, float opacity);
- void drawpatchother(int whichx, int whichy, float opacity);
- void drawpatchotherother(int whichx, int whichy, float opacity);
- void DoShadows();
-
- Terrain();
- ~Terrain();
-};
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _TERRAIN_HPP_
+#define _TERRAIN_HPP_
+
+#include "Environment/Lights.hpp"
+#include "Graphic/gamegl.hpp"
+#include "Graphic/Texture.hpp"
+#include "Math/Frustum.hpp"
+#include "Math/Quaternions.hpp"
+#include "Utils/ImageIO.hpp"
+
+#define max_terrain_size 256
+#define curr_terrain_size size
+#define subdivision 64
+#define max_patch_elements (max_terrain_size/subdivision)*(max_terrain_size/subdivision)*54
+
+#define allfirst 0
+#define mixed 1
+#define allsecond 2
+
+#define max_decals 1000
+
+#define shadowdecal 0
+#define footprintdecal 1
+#define blooddecal 2
+#define blooddecalfast 3
+#define shadowdecalpermanent 4
+#define breakdecal 5
+#define blooddecalslow 6
+#define bodyprintdecal 7
+
+#define snowyenvironment 0
+#define grassyenvironment 1
+#define desertenvironment 2
+//
+// Model Structures
+//
+
+class Terrain
+{
+public:
+ Texture bloodtexture;
+ Texture bloodtexture2;
+ Texture shadowtexture;
+ Texture footprinttexture;
+ Texture bodyprinttexture;
+ Texture breaktexture;
+ Texture terraintexture;
+ short size;
+
+ int patchobjectnum[subdivision][subdivision];
+ int patchobjects[subdivision][subdivision][300];
+
+ float scale;
+ int type;
+ float heightmap[max_terrain_size + 1][max_terrain_size + 1];
+ XYZ normals[max_terrain_size][max_terrain_size];
+ XYZ facenormals[max_terrain_size][max_terrain_size];
+ XYZ triangles[(max_terrain_size - 1) * (max_terrain_size - 1) * 2][3];
+ float colors[max_terrain_size][max_terrain_size][4];
+ float opacityother[max_terrain_size][max_terrain_size];
+ float texoffsetx[max_terrain_size][max_terrain_size];
+ float texoffsety[max_terrain_size][max_terrain_size];
+ int numtris[subdivision][subdivision];
+ int textureness[subdivision][subdivision];
+
+ GLfloat vArray[(max_patch_elements)*subdivision*subdivision];
+
+ bool visible[subdivision][subdivision];
+ float avgypatch[subdivision][subdivision];
+ float maxypatch[subdivision][subdivision];
+ float minypatch[subdivision][subdivision];
+ float heightypatch[subdivision][subdivision];
+
+ int patch_elements;
+
+ float decaltexcoords[max_decals][3][2];
+ XYZ decalvertex[max_decals][3];
+ int decaltype[max_decals];
+ float decalopacity[max_decals];
+ float decalrotation[max_decals];
+ float decalalivetime[max_decals];
+ float decalbrightness[max_decals];
+ XYZ decalposition[max_decals];
+ int numdecals;
+
+ void AddObject(XYZ where, float radius, int id);
+ void DeleteDecal(int which);
+ void MakeDecal(int type, XYZ where, float size, float opacity, float rotation);
+ void MakeDecalLock(int type, XYZ where, int whichx, int whichy, float size, float opacity, float rotation);
+ int lineTerrain(XYZ p1, XYZ p2, XYZ *p);
+ float getHeight(float pointx, float pointz);
+ float getOpacity(float pointx, float pointz);
+ XYZ getLighting(float pointx, float pointz);
+ XYZ getNormal(float pointx, float pointz);
+ void UpdateVertexArray(int whichx, int whichy);
+ void UpdateTransparency(int whichx, int whichy);
+ void UpdateTransparencyother(int whichx, int whichy);
+ void UpdateTransparencyotherother(int whichx, int whichy);
+ bool load(const std::string& fileName);
+ void CalculateNormals();
+ void drawdecals();
+ void draw(int layer);
+ void drawpatch(int whichx, int whichy, float opacity);
+ void drawpatchother(int whichx, int whichy, float opacity);
+ void drawpatchotherother(int whichx, int whichy, float opacity);
+ void DoShadows();
+
+ Terrain();
+ ~Terrain();
+};
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "SDL_thread.h"
-#include "Game.h"
-#include "Audio/openal_wrapper.h"
-#include "Level/Dialog.h"
+#include "Game.hpp"
+#include "Audio/openal_wrapper.hpp"
+#include "Level/Dialog.hpp"
+
+#include <SDL_thread.h>
extern int mainmenu;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _GAME_H_
-#define _GAME_H_
-
-#include "SDL.h"
-
-#include "Animation/Skeleton.h"
-#include "Audio/Sounds.h"
-#include "Environment/Lights.h"
-#include "Environment/Skybox.h"
-#include "Environment/Terrain.h"
-#include "Graphic/gamegl.h"
-#include "Graphic/Models.h"
-#include "Graphic/Sprite.h"
-#include "Graphic/Stereo.h"
-#include "Graphic/Text.h"
-#include "Graphic/Texture.h"
-#include "Objects/Objects.h"
-#include "Objects/Person.h"
-#include "Objects/Weapons.h"
-#include "Thirdparty/optionparser.h"
-#include "User/Account.h"
-#include "Utils/binio.h"
-#include "Utils/ImageIO.h"
-
-#include <fstream>
-
-#define NB_CAMPAIGN_MENU_ITEM 7
-
-namespace Game
-{
-extern Texture terraintexture;
-extern Texture terraintexture2;
-extern Texture loadscreentexture;
-extern Texture Maparrowtexture;
-extern Texture Mapboxtexture;
-extern Texture Mapcircletexture;
-extern Texture cursortexture;
-extern GLuint screentexture;
-extern GLuint screentexture2;
-extern Texture Mainmenuitems[10];
-
-extern int selected;
-extern int keyselect;
-
-extern int newdetail;
-extern int newscreenwidth;
-extern int newscreenheight;
-
-extern bool gameon;
-extern float deltah, deltav;
-extern int mousecoordh, mousecoordv;
-extern int oldmousecoordh, oldmousecoordv;
-extern float yaw, pitch;
-extern SkyBox *skybox;
-extern bool cameramode;
-extern bool firstload;
-
-extern float leveltime;
-extern float wonleveltime;
-extern float loadtime;
-
-extern Model hawk;
-extern XYZ hawkcoords;
-extern XYZ realhawkcoords;
-extern Texture hawktexture;
-extern float hawkyaw;
-extern float hawkcalldelay;
-
-extern Model eye;
-extern Model iris;
-extern Model cornea;
-
-extern bool stealthloading;
-extern int loading;
-
-extern int musictype;
-
-extern XYZ mapcenter;
-extern float mapradius;
-
-extern Text *text;
-extern float fps;
-
-extern bool editorenabled;
-extern int editortype;
-extern float editorsize;
-extern float editoryaw;
-extern float editorpitch;
-
-extern int tryquit;
-
-extern XYZ pathpoint[30];
-extern int numpathpoints;
-extern int numpathpointconnect[30];
-extern int pathpointconnect[30][30];
-extern int pathpointselected;
-
-extern int endgame;
-extern bool scoreadded;
-extern int numchallengelevels;
-
-extern bool console;
-extern std::string consoletext[15];
-extern std::string displaytext[15];
-extern float displaytime[15];
-extern float displayblinkdelay;
-extern bool displayblink;
-extern unsigned displayselected;
-extern float consoleblinkdelay;
-extern bool consoleblink;
-extern unsigned consoleselected;
-
-extern int oldenvironment;
-extern int targetlevel;
-extern float changedelay;
-
-extern bool waiting;
-
-extern unsigned short crouchkey, jumpkey, forwardkey, backkey, leftkey, rightkey, drawkey, throwkey, attackkey;
-extern unsigned short consolekey;
-
-void newGame();
-void deleteGame();
-
-void InitGame();
-void LoadStuff();
-void LoadScreenTexture();
-void LoadingScreen();
-int DrawGLScene(StereoSide side);
-void playdialoguescenesound();
-int findClosestPlayer();
-void Loadlevel(int which);
-void Loadlevel(const std::string& name);
-void Tick();
-void TickOnce();
-void TickOnceAfter();
-void SetUpLighting();
-GLvoid ReSizeGLScene(float fov, float near);
-int checkcollide(XYZ startpoint, XYZ endpoint);
-int checkcollide(XYZ startpoint, XYZ endpoint, int what);
-
-void fireSound(int sound = fireendsound);
-
-void inputText(std::string& str, unsigned* charselected);
-void flash(float amount = 1, int delay = 1);
-}
-
-#ifndef __forceinline
-# ifdef __GNUC__
-# define __forceinline inline __attribute__((always_inline))
-# endif
-#endif
-
-static __forceinline void swap_gl_buffers(void)
-{
- extern SDL_Window *sdlwindow;
- SDL_GL_SwapWindow(sdlwindow);
-
- // try to limit this to 60fps, even if vsync fails.
- Uint32 now;
- static Uint32 frameticks = 0;
- const Uint32 endticks = (frameticks + 16);
- while ((now = SDL_GetTicks()) < endticks) { /* spin. */ }
- frameticks = now;
-}
-
-extern "C" {
- void UndefinedSymbolToExposeStubbedCode(void);
-}
-//#define STUBBED(x) UndefinedSymbolToExposeStubbedCode();
-#define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } }
-//#define STUBBED(x)
-
-enum maptypes {
- mapkilleveryone, mapgosomewhere,
- mapkillsomeone, mapkillmost // These two are unused
-};
-
-enum pathtypes {wpkeepwalking, wppause};
-
-extern const char *pathtypenames[2];
-
-enum editortypes {typeactive, typesitting, typesittingwall, typesleeping,
- typedead1, typedead2, typedead3, typedead4
- };
-
-extern const char *editortypenames[8];
-
-extern const char *rabbitskin[10];
-
-extern const char *wolfskin[3];
-
-extern const char **creatureskin[2];
-
-SDL_bool sdlEventProc(const SDL_Event &e);
-
-
-
-enum optionIndex { UNKNOWN, HELP, FULLSCREEN, NOMOUSEGRAB, SOUND, OPENALINFO, SHOWRESOLUTIONS, DEVTOOLS };
-/* Number of options + 1 */
-const int commandLineOptionsNumber = 9;
-
-extern const option::Descriptor usage[13];
-
-extern option::Option commandLineOptions[commandLineOptionsNumber];
-extern option::Option* commandLineOptionsBuffer;
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _GAME_HPP_
+#define _GAME_HPP_
+
+#include "Animation/Skeleton.hpp"
+#include "Audio/Sounds.hpp"
+#include "Environment/Lights.hpp"
+#include "Environment/Skybox.hpp"
+#include "Environment/Terrain.hpp"
+#include "Graphic/gamegl.hpp"
+#include "Graphic/Models.hpp"
+#include "Graphic/Sprite.hpp"
+#include "Graphic/Stereo.hpp"
+#include "Graphic/Text.hpp"
+#include "Graphic/Texture.hpp"
+#include "Objects/Objects.hpp"
+#include "Objects/Person.hpp"
+#include "Objects/Weapons.hpp"
+#include "Thirdparty/optionparser.h"
+#include "User/Account.hpp"
+#include "Utils/binio.h"
+#include "Utils/ImageIO.hpp"
+
+#include <fstream>
+#include <SDL.h>
+
+#define NB_CAMPAIGN_MENU_ITEM 7
+
+namespace Game
+{
+extern Texture terraintexture;
+extern Texture terraintexture2;
+extern Texture loadscreentexture;
+extern Texture Maparrowtexture;
+extern Texture Mapboxtexture;
+extern Texture Mapcircletexture;
+extern Texture cursortexture;
+extern GLuint screentexture;
+extern GLuint screentexture2;
+extern Texture Mainmenuitems[10];
+
+extern int selected;
+extern int keyselect;
+
+extern int newdetail;
+extern int newscreenwidth;
+extern int newscreenheight;
+
+extern bool gameon;
+extern float deltah, deltav;
+extern int mousecoordh, mousecoordv;
+extern int oldmousecoordh, oldmousecoordv;
+extern float yaw, pitch;
+extern SkyBox *skybox;
+extern bool cameramode;
+extern bool firstload;
+
+extern float leveltime;
+extern float wonleveltime;
+extern float loadtime;
+
+extern Model hawk;
+extern XYZ hawkcoords;
+extern XYZ realhawkcoords;
+extern Texture hawktexture;
+extern float hawkyaw;
+extern float hawkcalldelay;
+
+extern Model eye;
+extern Model iris;
+extern Model cornea;
+
+extern bool stealthloading;
+extern int loading;
+
+extern int musictype;
+
+extern XYZ mapcenter;
+extern float mapradius;
+
+extern Text *text;
+extern float fps;
+
+extern bool editorenabled;
+extern int editortype;
+extern float editorsize;
+extern float editoryaw;
+extern float editorpitch;
+
+extern int tryquit;
+
+extern XYZ pathpoint[30];
+extern int numpathpoints;
+extern int numpathpointconnect[30];
+extern int pathpointconnect[30][30];
+extern int pathpointselected;
+
+extern int endgame;
+extern bool scoreadded;
+extern int numchallengelevels;
+
+extern bool console;
+extern std::string consoletext[15];
+extern std::string displaytext[15];
+extern float displaytime[15];
+extern float displayblinkdelay;
+extern bool displayblink;
+extern unsigned displayselected;
+extern float consoleblinkdelay;
+extern bool consoleblink;
+extern unsigned consoleselected;
+
+extern int oldenvironment;
+extern int targetlevel;
+extern float changedelay;
+
+extern bool waiting;
+
+extern unsigned short crouchkey, jumpkey, forwardkey, backkey, leftkey, rightkey, drawkey, throwkey, attackkey;
+extern unsigned short consolekey;
+
+void newGame();
+void deleteGame();
+
+void InitGame();
+void LoadStuff();
+void LoadScreenTexture();
+void LoadingScreen();
+int DrawGLScene(StereoSide side);
+void playdialoguescenesound();
+int findClosestPlayer();
+void Loadlevel(int which);
+void Loadlevel(const std::string& name);
+void Tick();
+void TickOnce();
+void TickOnceAfter();
+void SetUpLighting();
+GLvoid ReSizeGLScene(float fov, float near);
+int checkcollide(XYZ startpoint, XYZ endpoint);
+int checkcollide(XYZ startpoint, XYZ endpoint, int what);
+
+void fireSound(int sound = fireendsound);
+
+void inputText(std::string& str, unsigned* charselected);
+void flash(float amount = 1, int delay = 1);
+}
+
+#ifndef __forceinline
+# ifdef __GNUC__
+# define __forceinline inline __attribute__((always_inline))
+# endif
+#endif
+
+static __forceinline void swap_gl_buffers(void)
+{
+ extern SDL_Window *sdlwindow;
+ SDL_GL_SwapWindow(sdlwindow);
+
+ // try to limit this to 60fps, even if vsync fails.
+ Uint32 now;
+ static Uint32 frameticks = 0;
+ const Uint32 endticks = (frameticks + 16);
+ while ((now = SDL_GetTicks()) < endticks) { /* spin. */ }
+ frameticks = now;
+}
+
+extern "C" {
+ void UndefinedSymbolToExposeStubbedCode(void);
+}
+//#define STUBBED(x) UndefinedSymbolToExposeStubbedCode();
+#define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } }
+//#define STUBBED(x)
+
+enum maptypes {
+ mapkilleveryone, mapgosomewhere,
+ mapkillsomeone, mapkillmost // These two are unused
+};
+
+enum pathtypes {wpkeepwalking, wppause};
+
+extern const char *pathtypenames[2];
+
+enum editortypes {typeactive, typesitting, typesittingwall, typesleeping,
+ typedead1, typedead2, typedead3, typedead4
+ };
+
+extern const char *editortypenames[8];
+
+extern const char *rabbitskin[10];
+
+extern const char *wolfskin[3];
+
+extern const char **creatureskin[2];
+
+SDL_bool sdlEventProc(const SDL_Event &e);
+
+
+
+enum optionIndex { UNKNOWN, HELP, FULLSCREEN, NOMOUSEGRAB, SOUND, OPENALINFO, SHOWRESOLUTIONS, DEVTOOLS };
+/* Number of options + 1 */
+const int commandLineOptionsNumber = 9;
+
+extern const option::Descriptor usage[13];
+
+extern option::Option commandLineOptions[commandLineOptionsNumber];
+extern option::Option* commandLineOptionsBuffer;
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Game.h"
-#include "Audio/openal_wrapper.h"
-#include "Level/Awards.h"
-#include "Level/Dialog.h"
-#include "Level/Hotspot.h"
-#include "Menu/Menu.h"
-#include "Utils/Input.h"
+#include "Game.hpp"
+
+#include "Audio/openal_wrapper.hpp"
+#include "Level/Awards.hpp"
+#include "Level/Dialog.hpp"
+#include "Level/Hotspot.hpp"
+#include "Menu/Menu.hpp"
+#include "Utils/Input.hpp"
extern XYZ viewer;
extern int environment;
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Game.h"
-#include "Animation/Animation.h"
-#include "Audio/openal_wrapper.h"
-#include "Graphic/Texture.h"
-#include "Menu/Menu.h"
-#include "Utils/Folders.h"
+#include "Game.hpp"
+
+#include "Animation/Animation.hpp"
+#include "Audio/openal_wrapper.hpp"
+#include "Graphic/Texture.hpp"
+#include "Menu/Menu.hpp"
+#include "Utils/Folders.hpp"
extern float screenwidth, screenheight;
extern float viewdistance;
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
}
-//TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
+//TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.hpp
void Game::LoadStuff()
{
static float temptexdetail;
// Enable full math definitions
#define _USE_MATH_DEFINES
+#include "Game.hpp"
+
+#include "Animation/Animation.hpp"
+#include "Audio/openal_wrapper.hpp"
+#include "Devtools/ConsoleCmds.hpp"
+#include "Level/Awards.hpp"
+#include "Level/Campaign.hpp"
+#include "Level/Dialog.hpp"
+#include "Level/Hotspot.hpp"
+#include "Menu/Menu.hpp"
+#include "User/Settings.hpp"
+#include "Utils/Folders.hpp"
+#include "Utils/Input.hpp"
+
#if PLATFORM_UNIX
#include <sys/stat.h>
#include <sys/types.h>
#include <direct.h>
#endif
-
-#include <limits>
-#include <ctime>
+#include <algorithm>
#include <cmath>
+#include <ctime>
#include <dirent.h>
-#include "Game.h"
-#include "Animation/Animation.h"
-#include "Audio/openal_wrapper.h"
-#include "Devtools/ConsoleCmds.h"
-#include "Level/Awards.h"
-#include "Level/Campaign.h"
-#include "Level/Dialog.h"
-#include "Level/Hotspot.h"
-#include "Menu/Menu.h"
-#include "User/Settings.h"
-#include "Utils/Folders.h"
-#include "Utils/Input.h"
-
-#include <algorithm>
+#include <limits>
#include <set>
using namespace std;
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "SDL.h"
+#include "Graphic/Stereo.hpp"
+#include "Math/Quaternions.hpp"
+#include "Objects/Weapons.hpp"
+#include <SDL.h>
#include <string>
-#include "Graphic/Stereo.h"
-#include "Math/Quaternions.h"
-#include "Objects/Weapons.h"
-
bool visibleloading = 0;
float volume = 0;
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Game.h"
-#include "Graphic/Models.h"
-#include "Utils/Folders.h"
+#include "Graphic/Models.hpp"
+
+#include "Game.hpp"
+#include "Utils/Folders.hpp"
extern float multiplier;
extern float viewdistance;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _MODELS_H_
-#define _MODELS_H_
-
-/**> Model Loading <**/
-//
-// Model Maximums
-//
-#include "Graphic/gamegl.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <vector>
-
-#include "Environment/Terrain.h"
-#include "Graphic/Texture.h"
-#include "Math/Quaternions.h"
-#include "Utils/binio.h"
-
-//
-// Textures List
-//
-typedef struct {
- long xsz, ysz;
- GLubyte *txt;
-} ModelTexture;
-
-//
-// Model Structures
-//
-
-class TexturedTriangle
-{
-public:
- short vertex[3];
- float gx[3], gy[3];
-};
-
-#define max_model_decals 300
-
-#define nothing 0
-#define normaltype 4
-#define notextype 1
-#define rawtype 2
-#define decalstype 3
-
-class Model
-{
-public:
- short vertexNum, TriangleNum;
- bool hastexture;
-
- int type, oldtype;
-
- int* possible;
- int* owner;
- XYZ* vertex;
- XYZ* normals;
- XYZ* facenormals;
- TexturedTriangle* Triangles;
- GLfloat* vArray;
-
- /*int possible[max_model_vertex];
- int owner[max_textured_triangle];
- XYZ vertex[max_model_vertex];
- XYZ normals[max_model_vertex];
- XYZ facenormals[max_textured_triangle];
- TexturedTriangle Triangles[max_textured_triangle];
- GLfloat vArray[max_textured_triangle*24];*/
-
- Texture textureptr;
- ModelTexture modelTexture;
- int numpossible;
- bool color;
-
- XYZ boundingspherecenter;
- float boundingsphereradius;
-
- float*** decaltexcoords;
- XYZ** decalvertex;
- int* decaltype;
- float* decalopacity;
- float* decalrotation;
- float* decalalivetime;
- XYZ* decalposition;
-
- /*float decaltexcoords[max_model_decals][3][2];
- XYZ decalvertex[max_model_decals][3];
- int decaltype[max_model_decals];
- float decalopacity[max_model_decals];
- float decalrotation[max_model_decals];
- float decalalivetime[max_model_decals];
- XYZ decalposition[max_model_decals];*/
-
- int numdecals;
-
- bool flat;
-
- void DeleteDecal(int which);
- void MakeDecal(int atype, XYZ *where, float *size, float *opacity, float *rotation);
- void MakeDecal(int atype, XYZ where, float size, float opacity, float rotation);
- void drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloodtexture2, Texture breaktexture);
- int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate);
- int SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate);
- int LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate);
- int LineCheckPossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate);
- int LineCheckSlidePossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate);
- void UpdateVertexArray();
- void UpdateVertexArrayNoTex();
- void UpdateVertexArrayNoTexNoNorm();
- bool loadnotex(const std::string& filename);
- bool loadraw(const std::string& filename);
- bool load(const std::string& filename, bool texture);
- bool loaddecal(const std::string& filename, bool texture);
- void Scale(float xscale, float yscale, float zscale);
- void FlipTexCoords();
- void UniformTexCoords();
- void ScaleTexCoords(float howmuch);
- void ScaleNormals(float xscale, float yscale, float zscale);
- void Translate(float xtrans, float ytrans, float ztrans);
- void CalculateNormals(bool facenormalise);
- void draw();
- void drawdifftex(GLuint texture);
- void drawdifftex(Texture texture);
- void drawimmediate();
- void Rotate(float xang, float yang, float zang);
- ~Model();
- void deallocate();
- Model();
-};
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _MODELS_HPP_
+#define _MODELS_HPP_
+
+#include "Environment/Terrain.hpp"
+#include "Graphic/gamegl.hpp"
+#include "Graphic/Texture.hpp"
+#include "Math/Quaternions.hpp"
+#include "Utils/binio.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <vector>
+
+//
+// Textures List
+//
+typedef struct {
+ long xsz, ysz;
+ GLubyte *txt;
+} ModelTexture;
+
+//
+// Model Structures
+//
+
+class TexturedTriangle
+{
+public:
+ short vertex[3];
+ float gx[3], gy[3];
+};
+
+#define max_model_decals 300
+
+#define nothing 0
+#define normaltype 4
+#define notextype 1
+#define rawtype 2
+#define decalstype 3
+
+class Model
+{
+public:
+ short vertexNum, TriangleNum;
+ bool hastexture;
+
+ int type, oldtype;
+
+ int* possible;
+ int* owner;
+ XYZ* vertex;
+ XYZ* normals;
+ XYZ* facenormals;
+ TexturedTriangle* Triangles;
+ GLfloat* vArray;
+
+ /*int possible[max_model_vertex];
+ int owner[max_textured_triangle];
+ XYZ vertex[max_model_vertex];
+ XYZ normals[max_model_vertex];
+ XYZ facenormals[max_textured_triangle];
+ TexturedTriangle Triangles[max_textured_triangle];
+ GLfloat vArray[max_textured_triangle*24];*/
+
+ Texture textureptr;
+ ModelTexture modelTexture;
+ int numpossible;
+ bool color;
+
+ XYZ boundingspherecenter;
+ float boundingsphereradius;
+
+ float*** decaltexcoords;
+ XYZ** decalvertex;
+ int* decaltype;
+ float* decalopacity;
+ float* decalrotation;
+ float* decalalivetime;
+ XYZ* decalposition;
+
+ /*float decaltexcoords[max_model_decals][3][2];
+ XYZ decalvertex[max_model_decals][3];
+ int decaltype[max_model_decals];
+ float decalopacity[max_model_decals];
+ float decalrotation[max_model_decals];
+ float decalalivetime[max_model_decals];
+ XYZ decalposition[max_model_decals];*/
+
+ int numdecals;
+
+ bool flat;
+
+ void DeleteDecal(int which);
+ void MakeDecal(int atype, XYZ *where, float *size, float *opacity, float *rotation);
+ void MakeDecal(int atype, XYZ where, float size, float opacity, float rotation);
+ void drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloodtexture2, Texture breaktexture);
+ int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate);
+ int SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate);
+ int LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate);
+ int LineCheckPossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate);
+ int LineCheckSlidePossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate);
+ void UpdateVertexArray();
+ void UpdateVertexArrayNoTex();
+ void UpdateVertexArrayNoTexNoNorm();
+ bool loadnotex(const std::string& filename);
+ bool loadraw(const std::string& filename);
+ bool load(const std::string& filename, bool texture);
+ bool loaddecal(const std::string& filename, bool texture);
+ void Scale(float xscale, float yscale, float zscale);
+ void FlipTexCoords();
+ void UniformTexCoords();
+ void ScaleTexCoords(float howmuch);
+ void ScaleNormals(float xscale, float yscale, float zscale);
+ void Translate(float xtrans, float ytrans, float ztrans);
+ void CalculateNormals(bool facenormalise);
+ void draw();
+ void drawdifftex(GLuint texture);
+ void drawdifftex(Texture texture);
+ void drawimmediate();
+ void Rotate(float xang, float yang, float zang);
+ ~Model();
+ void deallocate();
+ Model();
+};
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Game.h"
-#include "Graphic/Sprite.h"
-#include "Objects/Person.h"
+#include "Graphic/Sprite.hpp"
+
+#include "Game.hpp"
+#include "Objects/Person.hpp"
extern XYZ viewer;
extern float viewdistance;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _SPRITE_H_
-#define _SPRITE_H_
-
-#include "Environment/Lights.h"
-#include "Environment/Terrain.h"
-#include "Graphic/gamegl.h"
-#include "Graphic/Texture.h"
-#include "Math/Frustum.h"
-#include "Math/Quaternions.h"
-#include "Math/Quaternions.h"
-#include "Objects/Objects.h"
-#include "Utils/ImageIO.h"
-
-#include <vector>
-
-#define max_sprites 20000
-
-enum {
- cloudsprite = 0,
- bloodsprite,
- flamesprite,
- smoketype,
- weaponflamesprite,
- cloudimpactsprite,
- snowsprite,
- weaponshinesprite,
- bloodflamesprite,
- breathsprite,
- splintersprite,
- spritenumber
-};
-
-class Sprite
-{
-private:
- XYZ oldposition;
- XYZ position;
- XYZ velocity;
- float size;
- float initialsize;
- int type;
- int special;
- float color[3];
- float opacity;
- float rotation;
- float alivetime;
- float speed;
- float rotatespeed;
-
- static float checkdelay;
-
- static vector<Sprite*> sprites;
-
-public:
- static void DeleteSprite(int which);
- static void MakeSprite(int atype, XYZ where, XYZ avelocity, float red, float green, float blue, float asize, float aopacity);
- static void Draw();
- static void deleteSprites() {
- sprites.clear();
- }
- static void setLastSpriteSpecial(int s) {
- sprites.back()->special = s;
- }
- static void setLastSpriteSpeed(int s) {
- sprites.back()->speed = s;
- }
- static void setLastSpriteAlivetime(float al) {
- sprites.back()->alivetime = al;
- }
- static void clearTextures();
-
- static Texture cloudtexture;
- static Texture bloodtexture;
- static Texture flametexture;
- static Texture smoketexture;
-
- static Texture cloudimpacttexture;
- static Texture snowflaketexture;
- static Texture shinetexture;
- static Texture bloodflametexture;
-
- static Texture splintertexture;
-
- static Texture leaftexture;
- static Texture toothtexture;
-
- Sprite();
- ~Sprite();
-};
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _SPRITE_HPP_
+#define _SPRITE_HPP_
+
+#include "Environment/Lights.hpp"
+#include "Environment/Terrain.hpp"
+#include "Graphic/gamegl.hpp"
+#include "Graphic/Texture.hpp"
+#include "Math/Frustum.hpp"
+#include "Math/Quaternions.hpp"
+#include "Objects/Objects.hpp"
+#include "Utils/ImageIO.hpp"
+
+#include <vector>
+
+#define max_sprites 20000
+
+enum {
+ cloudsprite = 0,
+ bloodsprite,
+ flamesprite,
+ smoketype,
+ weaponflamesprite,
+ cloudimpactsprite,
+ snowsprite,
+ weaponshinesprite,
+ bloodflamesprite,
+ breathsprite,
+ splintersprite,
+ spritenumber
+};
+
+class Sprite
+{
+private:
+ XYZ oldposition;
+ XYZ position;
+ XYZ velocity;
+ float size;
+ float initialsize;
+ int type;
+ int special;
+ float color[3];
+ float opacity;
+ float rotation;
+ float alivetime;
+ float speed;
+ float rotatespeed;
+
+ static float checkdelay;
+
+ static vector<Sprite*> sprites;
+
+public:
+ static void DeleteSprite(int which);
+ static void MakeSprite(int atype, XYZ where, XYZ avelocity, float red, float green, float blue, float asize, float aopacity);
+ static void Draw();
+ static void deleteSprites() {
+ sprites.clear();
+ }
+ static void setLastSpriteSpecial(int s) {
+ sprites.back()->special = s;
+ }
+ static void setLastSpriteSpeed(int s) {
+ sprites.back()->speed = s;
+ }
+ static void setLastSpriteAlivetime(float al) {
+ sprites.back()->alivetime = al;
+ }
+ static void clearTextures();
+
+ static Texture cloudtexture;
+ static Texture bloodtexture;
+ static Texture flametexture;
+ static Texture smoketexture;
+
+ static Texture cloudimpacttexture;
+ static Texture snowflaketexture;
+ static Texture shinetexture;
+ static Texture bloodflametexture;
+
+ static Texture splintertexture;
+
+ static Texture leaftexture;
+ static Texture toothtexture;
+
+ Sprite();
+ ~Sprite();
+};
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Game.h"
-#include "Graphic/Stereo.h"
+#include "Graphic/Stereo.hpp"
+#include "Game.hpp"
extern int kContextWidth;
extern int kContextHeight;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef STEREO_H_
-#define STEREO_H_
-
-enum StereoMode {
- stereoNone,
- stereoAnaglyph, /* red/cyan */
- stereoHorizontalInterlaced, /* some 3D monitors */
- stereoVerticalInterlaced,
- stereoHorizontalSplit, /* cross-eyed view */
- stereoVerticalSplit,
- stereoOpenGL, /* Whatever OpenGL does, if supported */
- stereoCount /* must be last element */
-};
-
-
-enum StereoSide {
- // Code multiplies by StereoSide to calculate camera offsets
- stereoLeft = -1,
- stereoCenter = 0,
- stereoRight = 1
-};
-
-extern StereoMode stereomode;
-extern StereoMode newstereomode;
-extern float stereoseparation;
-extern bool stereoreverse;
-
-bool CanInitStereo(StereoMode mode);
-void InitStereo(StereoMode mode);
-const std::string StereoModeName(StereoMode mode);
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _STEREO_HPP_
+#define _STEREO_HPP_
+
+#include <string>
+
+enum StereoMode {
+ stereoNone,
+ stereoAnaglyph, /* red/cyan */
+ stereoHorizontalInterlaced, /* some 3D monitors */
+ stereoVerticalInterlaced,
+ stereoHorizontalSplit, /* cross-eyed view */
+ stereoVerticalSplit,
+ stereoOpenGL, /* Whatever OpenGL does, if supported */
+ stereoCount /* must be last element */
+};
+
+
+enum StereoSide {
+ // Code multiplies by StereoSide to calculate camera offsets
+ stereoLeft = -1,
+ stereoCenter = 0,
+ stereoRight = 1
+};
+
+extern StereoMode stereomode;
+extern StereoMode newstereomode;
+extern float stereoseparation;
+extern bool stereoreverse;
+
+bool CanInitStereo(StereoMode mode);
+void InitStereo(StereoMode mode);
+const std::string StereoModeName(StereoMode mode);
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-/**> HEADER FILES <**/
-#include "Graphic/Text.h"
-#include "Game.h"
+#include "Graphic/Text.hpp"
+
+#include "Game.hpp"
void Text::LoadFontTexture(const std::string& fileName)
{
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _TEXT_H_
-#define _TEXT_H_
-
-/**> HEADER FILES <**/
-#include "Graphic/gamegl.h"
-#include "Graphic/Texture.h"
-#include "Math/Quaternions.h"
-#include "Utils/ImageIO.h"
-
-class Text
-{
-public:
- Texture FontTexture;
- GLuint base;
-
- void LoadFontTexture(const std::string& fileName);
- void BuildFont();
- void glPrint(float x, float y, const char *string, int set, float size, float width, float height);
- void glPrintOutline(float x, float y, const char *string, int set, float size, float width, float height);
- void glPrint(float x, float y, const char *string, int set, float size, float width, float height, int start, int end);
- void glPrintOutline(float x, float y, const char *string, int set, float size, float width, float height, int start, int end);
- void glPrintOutlined(float x, float y, const char *string, int set, float size, float width, float height);
- void glPrintOutlined(float r, float g, float b, float x, float y, const char *string, int set, float size, float width, float height);
-
- Text();
- ~Text();
-
-private:
- void _glPrint(float x, float y, const char *string, int set, float size, float width, float height, int start, int end, int offset);
-};
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _TEXT_HPP_
+#define _TEXT_HPP_
+
+#include "Graphic/gamegl.hpp"
+#include "Graphic/Texture.hpp"
+#include "Math/Quaternions.hpp"
+#include "Utils/ImageIO.hpp"
+
+class Text
+{
+public:
+ Texture FontTexture;
+ GLuint base;
+
+ void LoadFontTexture(const std::string& fileName);
+ void BuildFont();
+ void glPrint(float x, float y, const char *string, int set, float size, float width, float height);
+ void glPrintOutline(float x, float y, const char *string, int set, float size, float width, float height);
+ void glPrint(float x, float y, const char *string, int set, float size, float width, float height, int start, int end);
+ void glPrintOutline(float x, float y, const char *string, int set, float size, float width, float height, int start, int end);
+ void glPrintOutlined(float x, float y, const char *string, int set, float size, float width, float height);
+ void glPrintOutlined(float r, float g, float b, float x, float y, const char *string, int set, float size, float width, float height);
+
+ Text();
+ ~Text();
+
+private:
+ void _glPrint(float x, float y, const char *string, int set, float size, float width, float height, int start, int end, int offset);
+};
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Graphic/gamegl.h"
-#include "Graphic/Texture.h"
-#include "Utils/Folders.h"
-#include "Utils/ImageIO.h"
+#include "Graphic/Texture.hpp"
+
+#include "Utils/Folders.hpp"
+#include "Utils/ImageIO.hpp"
using namespace std;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _TEXTURE_H_
-#define _TEXTURE_H_
-
-#include <map>
-#include <vector>
-#include <string>
-using namespace std;
-
-class TextureRes
-{
-private:
- static vector<TextureRes*> list;
-
- GLuint id;
- string filename;
- bool hasMipmap;
- bool isSkin;
- int skinsize;
- GLubyte* data;
- int datalen;
-
- void load();
-
-public:
- TextureRes(const string& filename, bool hasMipmap);
- TextureRes(const string& filename, bool hasMipmap, GLubyte* array, int* skinsize);
- ~TextureRes();
- void bind();
-};
-
-class Texture
-{
-private:
- TextureRes* tex;
-public:
- inline Texture(): tex(NULL) {}
- void load(const string& filename, bool hasMipmap);
- void load(const string& filename, bool hasMipmap, GLubyte* array, int* skinsizep);
- void destroy();
- void bind();
-};
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _TEXTURE_HPP_
+#define _TEXTURE_HPP_
+
+#include "Graphic/gamegl.hpp"
+
+#include <map>
+#include <string>
+#include <vector>
+
+using namespace std;
+
+class TextureRes
+{
+private:
+ static vector<TextureRes*> list;
+
+ GLuint id;
+ string filename;
+ bool hasMipmap;
+ bool isSkin;
+ int skinsize;
+ GLubyte* data;
+ int datalen;
+
+ void load();
+
+public:
+ TextureRes(const string& filename, bool hasMipmap);
+ TextureRes(const string& filename, bool hasMipmap, GLubyte* array, int* skinsize);
+ ~TextureRes();
+ void bind();
+};
+
+class Texture
+{
+private:
+ TextureRes* tex;
+public:
+ inline Texture(): tex(NULL) {}
+ void load(const string& filename, bool hasMipmap);
+ void load(const string& filename, bool hasMipmap, GLubyte* array, int* skinsizep);
+ void destroy();
+ void bind();
+};
+
+#endif
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _LUGARU_GL_H_
-#define _LUGARU_GL_H_
-
-
-#include <cstring>
-#include <iostream>
-#include <fstream>
-#include <algorithm>
-#include <map>
-#include <string>
-
-#ifdef WIN32
- #define WIN32_LEAN_AND_MEAN
- #define Polygon WinPolygon
- #include <windows.h>
- #undef Polygon
-#endif
-
-#define GL_GLEXT_PROTOTYPES 1
-#include "GL/gl.h"
-#include "GL/glu.h"
-#include "GL/glext.h"
-#include "MacCompatibility.h"
-
-using namespace std;
-
-/* !!! FIXME: until we replace logger better. --ryan. */
-#define LOGFUNC
-void LOG(const std::string &fmt, ...);
-
-#endif
-
-
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _GAMEGL_HPP_
+#define _GAMEGL_HPP_
+
+#include "MacCompatibility.hpp"
+
+#include <algorithm>
+#include <cstring>
+#include <fstream>
+#include <iostream>
+#include <map>
+#include <string>
+
+#ifdef WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #define Polygon WinPolygon
+ #include <windows.h>
+ #undef Polygon
+#endif
+
+#define GL_GLEXT_PROTOTYPES 1
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include <GL/glext.h>
+
+using namespace std;
+
+/* !!! FIXME: until we replace logger better. --ryan. */
+#define LOGFUNC
+void LOG(const std::string &fmt, ...);
+
+#endif
+
+
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Level/Awards.h"
-#include "Objects/Person.h"
-#include "Game.h"
+#include "Level/Awards.hpp"
+
+#include "Game.hpp"
+#include "Objects/Person.hpp"
int bonus;
float bonusvalue;
+++ /dev/null
-/*
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef AWARDS_H
-#define AWARDS_H
-
-enum bonus_types {
-#define DECLARE_BONUS(id, ...) id,
-#include "Bonuses.def"
-#undef DECLARE_BONUS
- bonus_count
-};
-
-extern const char *bonus_names[bonus_count];
-
-extern int bonus;
-extern float bonusvalue;
-extern float bonustotal;
-extern float bonustime;
-extern float startbonustotal;
-extern float bonusnum[100];
-
-extern void award_bonus(int playerid, int bonusid, int alt_value = 0);
-
-enum award_types {
-#define DECLARE_AWARD(id, name) id,
-#include "Awards.def"
-#undef DECLARE_AWARD
- award_count
-};
-
-extern const char *award_names[award_count];
-
-extern int award_awards(int *);
-
-extern float damagetaken;
-extern int numfalls;
-extern int numflipfail;
-extern int numseen;
-extern int numresponded;
-extern int numstaffattack;
-extern int numswordattack;
-extern int numknifeattack;
-extern int numunarmedattack;
-extern int numescaped;
-extern int numflipped;
-extern int numwallflipped;
-extern int numthrowkill;
-extern int numafterkill;
-extern int numreversals;
-extern int numattacks;
-extern int maxalarmed;
-#endif
-
--- /dev/null
+/*
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _AWARDS_HPP_
+#define _AWARDS_HPP_
+
+enum bonus_types {
+#define DECLARE_BONUS(id, ...) id,
+#include "Bonuses.def"
+#undef DECLARE_BONUS
+ bonus_count
+};
+
+extern const char *bonus_names[bonus_count];
+
+extern int bonus;
+extern float bonusvalue;
+extern float bonustotal;
+extern float bonustime;
+extern float startbonustotal;
+extern float bonusnum[100];
+
+extern void award_bonus(int playerid, int bonusid, int alt_value = 0);
+
+enum award_types {
+#define DECLARE_AWARD(id, name) id,
+#include "Awards.def"
+#undef DECLARE_AWARD
+ award_count
+};
+
+extern const char *award_names[award_count];
+
+extern int award_awards(int *);
+
+extern float damagetaken;
+extern int numfalls;
+extern int numflipfail;
+extern int numseen;
+extern int numresponded;
+extern int numstaffattack;
+extern int numswordattack;
+extern int numknifeattack;
+extern int numunarmedattack;
+extern int numescaped;
+extern int numflipped;
+extern int numwallflipped;
+extern int numthrowkill;
+extern int numafterkill;
+extern int numreversals;
+extern int numattacks;
+extern int maxalarmed;
+#endif
+
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Game.h"
-#include "Level/Campaign.h"
-#include "Utils/Folders.h"
+#include "Level/Campaign.hpp"
+
+#include "Game.hpp"
+#include "Utils/Folders.hpp"
#include <dirent.h>
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <vector>
-#include <string>
-
-#include "Math/Quaternions.h"
-
-extern bool campaign;
-
-extern int actuallevel;
-
-std::vector<std::string> ListCampaigns();
-void LoadCampaign();
-
-class CampaignLevel
-{
-private:
- int width;
- struct Position {
- int x, y;
- };
-public:
- std::string mapname;
- std::string description;
- int choosenext;
- /*
- 0 = Immediately load next level at the end of this one.
- 1 = Go back to the world map.
- 2 = Don't bring up the Fiery loading screen. Maybe other things, I've not investigated.
- */
- //int numnext; // 0 on final level. As David said: he meant to add story branching, but he eventually hadn't.
- std::vector<int> nextlevel;
- Position location;
- CampaignLevel();
- int getStartX();
- int getStartY();
- int getEndX();
- int getEndY();
- XYZ getCenter();
- int getWidth();
- std::istream& operator<< (std::istream& is);
- friend std::istream& operator>> (std::istream& is, CampaignLevel& cl) {
- return cl << is;
- }
-};
-
-extern std::vector<CampaignLevel> campaignlevels;
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "Math/Quaternions.hpp"
+
+#include <string>
+#include <vector>
+
+extern bool campaign;
+
+extern int actuallevel;
+
+std::vector<std::string> ListCampaigns();
+void LoadCampaign();
+
+class CampaignLevel
+{
+private:
+ int width;
+ struct Position {
+ int x, y;
+ };
+public:
+ std::string mapname;
+ std::string description;
+ int choosenext;
+ /*
+ 0 = Immediately load next level at the end of this one.
+ 1 = Go back to the world map.
+ 2 = Don't bring up the Fiery loading screen. Maybe other things, I've not investigated.
+ */
+ //int numnext; // 0 on final level. As David said: he meant to add story branching, but he eventually hadn't.
+ std::vector<int> nextlevel;
+ Position location;
+ CampaignLevel();
+ int getStartX();
+ int getStartY();
+ int getEndX();
+ int getEndY();
+ XYZ getCenter();
+ int getWidth();
+ std::istream& operator<< (std::istream& is);
+ friend std::istream& operator>> (std::istream& is, CampaignLevel& cl) {
+ return cl << is;
+ }
+};
+
+extern std::vector<CampaignLevel> campaignlevels;
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Game.h"
+#include "Level/Dialog.hpp"
-#include "Level/Dialog.h"
-#include "Objects/Person.h"
+#include "Game.hpp"
+#include "Objects/Person.hpp"
#include "Utils/binio.h"
-#include "Utils/Folders.h"
-#include "Utils/Input.h"
+#include "Utils/Folders.hpp"
+#include "Utils/Input.hpp"
extern int hostile;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _DIALOG_H_
-#define _DIALOG_H_
-
-#include "stdio.h"
-#include <vector>
-
-#include "Math/Quaternions.h"
-
-class DialogScene
-{
-public:
- DialogScene(FILE* tfile);
- DialogScene(ifstream &ipstream);
- void save(FILE* tfile);
-
- int location;
- float color[3];
- int sound;
- std::string text;
- std::string name;
- XYZ camera;
- float camerayaw;
- float camerapitch;
- int participantfocus;
- int participantaction;
- XYZ participantfacing[10];
-};
-
-class Dialog
-{
-public:
- Dialog(FILE* tfile);
- Dialog(int type, std::string filename);
- void tick(int id);
- void play();
- void save(FILE* tfile);
-
- int type;
- int gonethrough;
- std::vector<DialogScene> scenes;
- XYZ participantlocation[10];
- float participantyaw[10];
-
- static void loadDialogs(FILE*);
- static void saveDialogs(FILE*);
-
- static bool inDialog() { return (indialogue != -1); }
- static Dialog& currentDialog() { return dialogs[whichdialogue]; }
- static DialogScene& currentScene() { return currentDialog().scenes[indialogue]; }
-
- static int indialogue;
- static int whichdialogue;
- static bool directing;
- static float dialoguetime;
- static std::vector<Dialog> dialogs;
-};
-
-#endif /*_DIALOG_H_*/
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _DIALOG_HPP_
+#define _DIALOG_HPP_
+
+#include "Math/Quaternions.hpp"
+
+#include <stdio.h>
+#include <vector>
+
+class DialogScene
+{
+public:
+ DialogScene(FILE* tfile);
+ DialogScene(ifstream &ipstream);
+ void save(FILE* tfile);
+
+ int location;
+ float color[3];
+ int sound;
+ std::string text;
+ std::string name;
+ XYZ camera;
+ float camerayaw;
+ float camerapitch;
+ int participantfocus;
+ int participantaction;
+ XYZ participantfacing[10];
+};
+
+class Dialog
+{
+public:
+ Dialog(FILE* tfile);
+ Dialog(int type, std::string filename);
+ void tick(int id);
+ void play();
+ void save(FILE* tfile);
+
+ int type;
+ int gonethrough;
+ std::vector<DialogScene> scenes;
+ XYZ participantlocation[10];
+ float participantyaw[10];
+
+ static void loadDialogs(FILE*);
+ static void saveDialogs(FILE*);
+
+ static bool inDialog() { return (indialogue != -1); }
+ static Dialog& currentDialog() { return dialogs[whichdialogue]; }
+ static DialogScene& currentScene() { return currentDialog().scenes[indialogue]; }
+
+ static int indialogue;
+ static int whichdialogue;
+ static bool directing;
+ static float dialoguetime;
+ static std::vector<Dialog> dialogs;
+};
+
+#endif /*_DIALOG_H_*/
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Level/Hotspot.h"
+#include "Level/Hotspot.hpp"
std::vector<Hotspot> Hotspot::hotspots;
int Hotspot::current = 0;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _HOTSPOT_H_
-#define _HOTSPOT_H_
-
-#include "Math/Quaternions.h"
-#include <vector>
-
-class Hotspot
-{
-public:
- static std::vector<Hotspot> hotspots;
- static int current;
- static int killhotspot;
-
- Hotspot();
- Hotspot(XYZ position, int type, float size);
-
- XYZ position;
- int type;
- float size;
- char text[256] = {0};
-};
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _HOTSPOT_HPP_
+#define _HOTSPOT_HPP_
+
+#include "Math/Quaternions.hpp"
+
+#include <vector>
+
+class Hotspot
+{
+public:
+ static std::vector<Hotspot> hotspots;
+ static int current;
+ static int killhotspot;
+
+ Hotspot();
+ Hotspot(XYZ position, int type, float size);
+
+ XYZ position;
+ int type;
+ float size;
+ char text[256] = {0};
+};
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-/**> HEADER FILES <**/
-#include "MacCompatibility.h"
-
-#ifdef WIN32
-#include <windows.h>
-#endif
+#include "MacCompatibility.hpp"
#include <errno.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
+#ifdef WIN32
+#include <windows.h>
+#endif
+
#if PLATFORM_UNIX
+#include <assert.h>
#include <unistd.h>
-#include <sys/time.h>
#include <sys/stat.h>
-#include <assert.h>
+#include <sys/time.h>
+
typedef long long __int64;
typedef __int64 LARGE_INTEGER;
static int QueryPerformanceFrequency(LARGE_INTEGER *liptr)
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _MACCOMPATIBLITY_H_
-#define _MACCOMPATIBLITY_H_
-
-#include <stdio.h>
-#include <float.h>
-#include <math.h>
-
-// stuff to make Mac code compatable with Windows/Linux/etc
-
-#if defined(WIN32) && !defined(strcasecmp)
-#define strcasecmp(a,b) stricmp(a,b)
-#endif
-
-#ifdef _MSC_VER
-// disable warnings about double to float conversions
-#pragma warning(disable:4305)
-#pragma warning(disable:4244)
-
-// disable warnings about boolean to int conversions
-#pragma warning(disable:4800)
-
-// disable warning about unreferenced local variables
-#pragma warning(disable:4101)
-#endif
-
-#ifndef __forceinline
-# ifdef __GNUC__
-# define __forceinline inline __attribute__((always_inline))
-# endif
-#endif
-
-struct Point {
- short v;
- short h;
-};
-
-typedef signed char SInt8;
-typedef unsigned int UInt32;
-
-
-#include "Math/Random.h"
-
-typedef struct AbsoluteTime {
- unsigned long hi;
- unsigned long lo;
-} AbsoluteTime;
-
-AbsoluteTime UpTime(); // NOTE: returns time since app started, not system start
-
-typedef long Duration;
-
-enum {
- durationMicrosecond = -1,
- durationMillisecond = 1,
- durationSecond = 1000,
- durationMinute = 1000 * 60,
- durationHour = 1000 * 60 * 60,
- durationDay = 1000 * 60 * 60 * 24,
- durationForever = 0x7FFFFFFF,
- durationImmediate = 0,
-};
-
-Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b);
-
-#ifdef _MSC_VER
-inline bool isnormal( double x)
-{
- int ret = _fpclass( x);
- return (ret == _FPCLASS_NN || ret == _FPCLASS_PN);
-}
-#else
-#include <stdint.h>
-#endif
-
-#endif
-
-
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _MACCOMPATIBLITY_HPP_
+#define _MACCOMPATIBLITY_HPP_
+
+#include "Math/Random.hpp"
+
+#include <float.h>
+#include <math.h>
+#include <stdio.h>
+
+// stuff to make Mac code compatable with Windows/Linux/etc
+
+#if defined(WIN32) && !defined(strcasecmp)
+#define strcasecmp(a,b) stricmp(a,b)
+#endif
+
+#ifdef _MSC_VER
+// disable warnings about double to float conversions
+#pragma warning(disable:4305)
+#pragma warning(disable:4244)
+
+// disable warnings about boolean to int conversions
+#pragma warning(disable:4800)
+
+// disable warning about unreferenced local variables
+#pragma warning(disable:4101)
+#endif
+
+#ifndef __forceinline
+# ifdef __GNUC__
+# define __forceinline inline __attribute__((always_inline))
+# endif
+#endif
+
+struct Point {
+ short v;
+ short h;
+};
+
+typedef signed char SInt8;
+typedef unsigned int UInt32;
+
+
+
+typedef struct AbsoluteTime {
+ unsigned long hi;
+ unsigned long lo;
+} AbsoluteTime;
+
+AbsoluteTime UpTime(); // NOTE: returns time since app started, not system start
+
+typedef long Duration;
+
+enum {
+ durationMicrosecond = -1,
+ durationMillisecond = 1,
+ durationSecond = 1000,
+ durationMinute = 1000 * 60,
+ durationHour = 1000 * 60 * 60,
+ durationDay = 1000 * 60 * 60 * 24,
+ durationForever = 0x7FFFFFFF,
+ durationImmediate = 0,
+};
+
+Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b);
+
+#ifdef _MSC_VER
+inline bool isnormal( double x)
+{
+ int ret = _fpclass( x);
+ return (ret == _FPCLASS_NN || ret == _FPCLASS_PN);
+}
+#else
+#include <stdint.h>
+#endif
+
+#endif
+
+
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Math/Frustum.h"
-#include <math.h>
+#include "Math/Frustum.hpp"
-#include "Graphic/gamegl.h"
+#include "Graphic/gamegl.hpp"
+#include <math.h>
void FRUSTUM::
GetFrustum()
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef FRUSTUM_H
-#define FRUSTUM_H
-
-class FRUSTUM
-{
-public:
- float frustum[6][4];
- void GetFrustum();
- int CubeInFrustum(float, float, float, float);
- int CubeInFrustum(float, float, float, float, float);
- int SphereInFrustum(float, float, float, float);
-};
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _FRUSTUM_HPP_
+#define _FRUSTUM_HPP_
+
+class FRUSTUM
+{
+public:
+ float frustum[6][4];
+ void GetFrustum();
+ int CubeInFrustum(float, float, float, float);
+ int CubeInFrustum(float, float, float, float, float);
+ int SphereInFrustum(float, float, float, float);
+};
+
+#endif
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _PHYSICSMATH_H_
-#define _PHYSICSMATH_H_
-
-//#include <Carbon.h>
-
-#include "MacCompatibility.h"
-
-//------------------------------------------------------------------------//
-// Misc. Constants
-//------------------------------------------------------------------------//
-
-float const pi = 3.14159265f;
-float const g = -32.174f; // acceleration due to gravity, ft/s^2
-float const rho = 0.0023769f; // desity of air at sea level, slugs/ft^3
-float const tol = 0.0000000001f; // float type tolerance
-
-
-//------------------------------------------------------------------------//
-// Misc. Functions
-//------------------------------------------------------------------------//
-inline float DegreesToRadians(float deg);
-inline float RadiansToDegrees(float rad);
-
-inline float DegreesToRadians(float deg)
-{
- return deg * pi / 180.0f;
-}
-
-inline float RadiansToDegrees(float rad)
-{
- return rad * 180.0f / pi;
-}
-
-//------------------------------------------------------------------------//
-// Vector Class and vector functions
-//------------------------------------------------------------------------//
-class Vector
-{
-public:
- float x;
- float y;
- float z;
-
- Vector(void);
- Vector(float xi, float yi, float zi);
-
- float Magnitude(void);
- void Normalize(void);
- void Reverse(void);
-
- Vector& operator+=(Vector u); // vector addition
- Vector& operator-=(Vector u); // vector subtraction
- Vector& operator*=(float s); // scalar multiply
- Vector& operator/=(float s); // scalar divide
-
- Vector operator-(void);
-
-};
-
-inline Vector operator+(Vector u, Vector v);
-inline Vector operator-(Vector u, Vector v);
-inline Vector operator^(Vector u, Vector v);
-inline float operator*(Vector u, Vector v);
-inline Vector operator*(float s, Vector u);
-inline Vector operator*(Vector u, float s);
-inline Vector operator/(Vector u, float s);
-inline float TripleScalarProduct(Vector u, Vector v, Vector w);
-/*
-float fast_sqrt2 (register float arg);
-float fast_sqrt2 (register float arg)
-{
-// Can replace with slower return std::sqrt(arg);
-register float result;
-
-if (arg == 0.0) return 0.0;
-
-asm {
-frsqrte result,arg // Calculate Square root
-}
-
-// Newton Rhapson iterations.
-result = result + 0.5 * result * (1.0 - arg * result * result);
-result = result + 0.5 * result * (1.0 - arg * result * result);
-
-return result * arg;
-}
-*/
-inline Vector::Vector(void)
-{
- x = 0;
- y = 0;
- z = 0;
-}
-
-inline Vector::Vector(float xi, float yi, float zi)
-{
- x = xi;
- y = yi;
- z = zi;
-}
-
-inline float Vector::Magnitude(void)
-{
- return (float) sqrt(x * x + y * y + z * z);
-}
-
-inline void Vector::Normalize(void)
-{
- float m = (float) sqrt(x * x + y * y + z * z);
- if (m <= tol)
- m = 1;
- x /= m;
- y /= m;
- z /= m;
-
- if (fabs(x) < tol)
- x = 0.0f;
- if (fabs(y) < tol)
- y = 0.0f;
- if (fabs(z) < tol)
- z = 0.0f;
-}
-
-inline void Vector::Reverse(void)
-{
- x = -x;
- y = -y;
- z = -z;
-}
-
-inline Vector& Vector::operator+=(Vector u)
-{
- x += u.x;
- y += u.y;
- z += u.z;
- return *this;
-}
-
-inline Vector& Vector::operator-=(Vector u)
-{
- x -= u.x;
- y -= u.y;
- z -= u.z;
- return *this;
-}
-
-inline Vector& Vector::operator*=(float s)
-{
- x *= s;
- y *= s;
- z *= s;
- return *this;
-}
-
-inline Vector& Vector::operator/=(float s)
-{
- x /= s;
- y /= s;
- z /= s;
- return *this;
-}
-
-inline Vector Vector::operator-(void)
-{
- return Vector(-x, -y, -z);
-}
-
-
-inline Vector operator+(Vector u, Vector v)
-{
- return Vector(u.x + v.x, u.y + v.y, u.z + v.z);
-}
-
-inline Vector operator-(Vector u, Vector v)
-{
- return Vector(u.x - v.x, u.y - v.y, u.z - v.z);
-}
-
-// Vector cross product (u cross v)
-inline Vector operator^(Vector u, Vector v)
-{
- return Vector( u.y * v.z - u.z * v.y,
- -u.x * v.z + u.z * v.x,
- u.x * v.y - u.y * v.x );
-}
-
-// Vector dot product
-inline float operator*(Vector u, Vector v)
-{
- return (u.x * v.x + u.y * v.y + u.z * v.z);
-}
-
-inline Vector operator*(float s, Vector u)
-{
- return Vector(u.x * s, u.y * s, u.z * s);
-}
-
-inline Vector operator*(Vector u, float s)
-{
- return Vector(u.x * s, u.y * s, u.z * s);
-}
-
-inline Vector operator/(Vector u, float s)
-{
- return Vector(u.x / s, u.y / s, u.z / s);
-}
-
-// triple scalar product (u dot (v cross w))
-inline float TripleScalarProduct(Vector u, Vector v, Vector w)
-{
- return float( (u.x * (v.y * w.z - v.z * w.y)) +
- (u.y * (-v.x * w.z + v.z * w.x)) +
- (u.z * (v.x * w.y - v.y * w.x)) );
- //return u*(v^w);
-
-}
-
-
-
-//------------------------------------------------------------------------//
-// Matrix Class and matrix functions
-//------------------------------------------------------------------------//
-
-class Matrix3x3
-{
-public:
- // elements eij: i -> row, j -> column
- float e11, e12, e13, e21, e22, e23, e31, e32, e33;
-
- Matrix3x3(void);
- Matrix3x3( float r1c1, float r1c2, float r1c3,
- float r2c1, float r2c2, float r2c3,
- float r3c1, float r3c2, float r3c3 );
-
- float det(void);
- Matrix3x3 Transpose(void);
- Matrix3x3 Inverse(void);
-
- Matrix3x3& operator+=(Matrix3x3 m);
- Matrix3x3& operator-=(Matrix3x3 m);
- Matrix3x3& operator*=(float s);
- Matrix3x3& operator/=(float s);
-};
-
-inline Matrix3x3 operator+(Matrix3x3 m1, Matrix3x3 m2);
-inline Matrix3x3 operator-(Matrix3x3 m1, Matrix3x3 m2);
-inline Matrix3x3 operator/(Matrix3x3 m, float s);
-inline Matrix3x3 operator*(Matrix3x3 m1, Matrix3x3 m2);
-inline Matrix3x3 operator*(Matrix3x3 m, float s);
-inline Matrix3x3 operator*(float s, Matrix3x3 m);
-inline Vector operator*(Matrix3x3 m, Vector u);
-inline Vector operator*(Vector u, Matrix3x3 m);
-
-
-
-
-
-inline Matrix3x3::Matrix3x3(void)
-{
- e11 = 0;
- e12 = 0;
- e13 = 0;
- e21 = 0;
- e22 = 0;
- e23 = 0;
- e31 = 0;
- e32 = 0;
- e33 = 0;
-}
-
-inline Matrix3x3::Matrix3x3( float r1c1, float r1c2, float r1c3,
- float r2c1, float r2c2, float r2c3,
- float r3c1, float r3c2, float r3c3 )
-{
- e11 = r1c1;
- e12 = r1c2;
- e13 = r1c3;
- e21 = r2c1;
- e22 = r2c2;
- e23 = r2c3;
- e31 = r3c1;
- e32 = r3c2;
- e33 = r3c3;
-}
-
-inline float Matrix3x3::det(void)
-{
- return e11 * e22 * e33 -
- e11 * e32 * e23 +
- e21 * e32 * e13 -
- e21 * e12 * e33 +
- e31 * e12 * e23 -
- e31 * e22 * e13;
-}
-
-inline Matrix3x3 Matrix3x3::Transpose(void)
-{
- return Matrix3x3(e11, e21, e31, e12, e22, e32, e13, e23, e33);
-}
-
-inline Matrix3x3 Matrix3x3::Inverse(void)
-{
- float d = e11 * e22 * e33 -
- e11 * e32 * e23 +
- e21 * e32 * e13 -
- e21 * e12 * e33 +
- e31 * e12 * e23 -
- e31 * e22 * e13;
-
- if (d == 0)
- d = 1;
-
- return Matrix3x3( (e22 * e33 - e23 * e32) / d,
- -(e12 * e33 - e13 * e32) / d,
- (e12 * e23 - e13 * e22) / d,
- -(e21 * e33 - e23 * e31) / d,
- (e11 * e33 - e13 * e31) / d,
- -(e11 * e23 - e13 * e21) / d,
- (e21 * e32 - e22 * e31) / d,
- -(e11 * e32 - e12 * e31) / d,
- (e11 * e22 - e12 * e21) / d );
-}
-
-inline Matrix3x3& Matrix3x3::operator+=(Matrix3x3 m)
-{
- e11 += m.e11;
- e12 += m.e12;
- e13 += m.e13;
- e21 += m.e21;
- e22 += m.e22;
- e23 += m.e23;
- e31 += m.e31;
- e32 += m.e32;
- e33 += m.e33;
- return *this;
-}
-
-inline Matrix3x3& Matrix3x3::operator-=(Matrix3x3 m)
-{
- e11 -= m.e11;
- e12 -= m.e12;
- e13 -= m.e13;
- e21 -= m.e21;
- e22 -= m.e22;
- e23 -= m.e23;
- e31 -= m.e31;
- e32 -= m.e32;
- e33 -= m.e33;
- return *this;
-}
-
-inline Matrix3x3& Matrix3x3::operator*=(float s)
-{
- e11 *= s;
- e12 *= s;
- e13 *= s;
- e21 *= s;
- e22 *= s;
- e23 *= s;
- e31 *= s;
- e32 *= s;
- e33 *= s;
- return *this;
-}
-
-inline Matrix3x3& Matrix3x3::operator/=(float s)
-{
- e11 /= s;
- e12 /= s;
- e13 /= s;
- e21 /= s;
- e22 /= s;
- e23 /= s;
- e31 /= s;
- e32 /= s;
- e33 /= s;
- return *this;
-}
-
-inline Matrix3x3 operator+(Matrix3x3 m1, Matrix3x3 m2)
-{
- return Matrix3x3( m1.e11 + m2.e11,
- m1.e12 + m2.e12,
- m1.e13 + m2.e13,
- m1.e21 + m2.e21,
- m1.e22 + m2.e22,
- m1.e23 + m2.e23,
- m1.e31 + m2.e31,
- m1.e32 + m2.e32,
- m1.e33 + m2.e33);
-}
-
-inline Matrix3x3 operator-(Matrix3x3 m1, Matrix3x3 m2)
-{
- return Matrix3x3( m1.e11 - m2.e11,
- m1.e12 - m2.e12,
- m1.e13 - m2.e13,
- m1.e21 - m2.e21,
- m1.e22 - m2.e22,
- m1.e23 - m2.e23,
- m1.e31 - m2.e31,
- m1.e32 - m2.e32,
- m1.e33 - m2.e33);
-}
-
-inline Matrix3x3 operator/(Matrix3x3 m, float s)
-{
- return Matrix3x3( m.e11 / s,
- m.e12 / s,
- m.e13 / s,
- m.e21 / s,
- m.e22 / s,
- m.e23 / s,
- m.e31 / s,
- m.e32 / s,
- m.e33 / s);
-}
-
-inline Matrix3x3 operator*(Matrix3x3 m1, Matrix3x3 m2)
-{
- return Matrix3x3( m1.e11 * m2.e11 + m1.e12 * m2.e21 + m1.e13 * m2.e31,
- m1.e11 * m2.e12 + m1.e12 * m2.e22 + m1.e13 * m2.e32,
- m1.e11 * m2.e13 + m1.e12 * m2.e23 + m1.e13 * m2.e33,
- m1.e21 * m2.e11 + m1.e22 * m2.e21 + m1.e23 * m2.e31,
- m1.e21 * m2.e12 + m1.e22 * m2.e22 + m1.e23 * m2.e32,
- m1.e21 * m2.e13 + m1.e22 * m2.e23 + m1.e23 * m2.e33,
- m1.e31 * m2.e11 + m1.e32 * m2.e21 + m1.e33 * m2.e31,
- m1.e31 * m2.e12 + m1.e32 * m2.e22 + m1.e33 * m2.e32,
- m1.e31 * m2.e13 + m1.e32 * m2.e23 + m1.e33 * m2.e33 );
-}
-
-inline Matrix3x3 operator*(Matrix3x3 m, float s)
-{
- return Matrix3x3( m.e11 * s,
- m.e12 * s,
- m.e13 * s,
- m.e21 * s,
- m.e22 * s,
- m.e23 * s,
- m.e31 * s,
- m.e32 * s,
- m.e33 * s);
-}
-
-inline Matrix3x3 operator*(float s, Matrix3x3 m)
-{
- return Matrix3x3( m.e11 * s,
- m.e12 * s,
- m.e13 * s,
- m.e21 * s,
- m.e22 * s,
- m.e23 * s,
- m.e31 * s,
- m.e32 * s,
- m.e33 * s);
-}
-
-inline Vector operator*(Matrix3x3 m, Vector u)
-{
- return Vector( m.e11 * u.x + m.e12 * u.y + m.e13 * u.z,
- m.e21 * u.x + m.e22 * u.y + m.e23 * u.z,
- m.e31 * u.x + m.e32 * u.y + m.e33 * u.z);
-}
-
-inline Vector operator*(Vector u, Matrix3x3 m)
-{
- return Vector( u.x * m.e11 + u.y * m.e21 + u.z * m.e31,
- u.x * m.e12 + u.y * m.e22 + u.z * m.e32,
- u.x * m.e13 + u.y * m.e23 + u.z * m.e33);
-}
-
-//------------------------------------------------------------------------//
-// Quaternion Class and Quaternion functions
-//------------------------------------------------------------------------//
-
-class Quaternion
-{
-public:
- float n; // number (scalar) part
- Vector v; // vector part: v.x, v.y, v.z
-
- Quaternion(void);
- Quaternion(float e0, float e1, float e2, float e3);
-
- float Magnitude(void);
- Vector GetVector(void);
- float GetScalar(void);
- Quaternion operator+=(Quaternion q);
- Quaternion operator-=(Quaternion q);
- Quaternion operator*=(float s);
- Quaternion operator/=(float s);
- Quaternion operator~(void) const {
- return Quaternion(n, -v.x, -v.y, -v.z);
- }
-};
-
-inline Quaternion operator+(Quaternion q1, Quaternion q2);
-inline Quaternion operator-(Quaternion q1, Quaternion q2);
-inline Quaternion operator*(Quaternion q1, Quaternion q2);
-inline Quaternion operator*(Quaternion q, float s);
-inline Quaternion operator*(float s, Quaternion q);
-inline Quaternion operator*(Quaternion q, Vector v);
-inline Quaternion operator*(Vector v, Quaternion q);
-inline Quaternion operator/(Quaternion q, float s);
-inline float QGetAngle(Quaternion q);
-inline Vector QGetAxis(Quaternion q);
-inline Quaternion QRotate(Quaternion q1, Quaternion q2);
-inline Vector QVRotate(Quaternion q, Vector v);
-inline Quaternion MakeQFromEulerAngles(float x, float y, float z);
-inline Vector MakeEulerAnglesFromQ(Quaternion q);
-
-
-inline Quaternion::Quaternion(void)
-{
- n = 0;
- v.x = 0;
- v.y = 0;
- v.z = 0;
-}
-
-inline Quaternion::Quaternion(float e0, float e1, float e2, float e3)
-{
- n = e0;
- v.x = e1;
- v.y = e2;
- v.z = e3;
-}
-
-inline float Quaternion::Magnitude(void)
-{
- return (float) sqrt(n * n + v.x * v.x + v.y * v.y + v.z * v.z);
-}
-
-inline Vector Quaternion::GetVector(void)
-{
- return Vector(v.x, v.y, v.z);
-}
-
-inline float Quaternion::GetScalar(void)
-{
- return n;
-}
-
-inline Quaternion Quaternion::operator+=(Quaternion q)
-{
- n += q.n;
- v.x += q.v.x;
- v.y += q.v.y;
- v.z += q.v.z;
- return *this;
-}
-
-inline Quaternion Quaternion::operator-=(Quaternion q)
-{
- n -= q.n;
- v.x -= q.v.x;
- v.y -= q.v.y;
- v.z -= q.v.z;
- return *this;
-}
-
-inline Quaternion Quaternion::operator*=(float s)
-{
- n *= s;
- v.x *= s;
- v.y *= s;
- v.z *= s;
- return *this;
-}
-
-inline Quaternion Quaternion::operator/=(float s)
-{
- n /= s;
- v.x /= s;
- v.y /= s;
- v.z /= s;
- return *this;
-}
-
-/*inline Quaternion Quaternion::operator~()
-{
-return Quaternion(n, -v.x, -v.y, -v.z);
-}*/
-
-inline Quaternion operator+(Quaternion q1, Quaternion q2)
-{
- return Quaternion( q1.n + q2.n,
- q1.v.x + q2.v.x,
- q1.v.y + q2.v.y,
- q1.v.z + q2.v.z);
-}
-
-inline Quaternion operator-(Quaternion q1, Quaternion q2)
-{
- return Quaternion( q1.n - q2.n,
- q1.v.x - q2.v.x,
- q1.v.y - q2.v.y,
- q1.v.z - q2.v.z);
-}
-
-inline Quaternion operator*(Quaternion q1, Quaternion q2)
-{
- return Quaternion( q1.n * q2.n - q1.v.x * q2.v.x - q1.v.y * q2.v.y - q1.v.z * q2.v.z,
- q1.n * q2.v.x + q1.v.x * q2.n + q1.v.y * q2.v.z - q1.v.z * q2.v.y,
- q1.n * q2.v.y + q1.v.y * q2.n + q1.v.z * q2.v.x - q1.v.x * q2.v.z,
- q1.n * q2.v.z + q1.v.z * q2.n + q1.v.x * q2.v.y - q1.v.y * q2.v.x);
-}
-
-inline Quaternion operator*(Quaternion q, float s)
-{
- return Quaternion(q.n * s, q.v.x * s, q.v.y * s, q.v.z * s);
-}
-
-inline Quaternion operator*(float s, Quaternion q)
-{
- return Quaternion(q.n * s, q.v.x * s, q.v.y * s, q.v.z * s);
-}
-
-inline Quaternion operator*(Quaternion q, Vector v)
-{
- return Quaternion( -(q.v.x * v.x + q.v.y * v.y + q.v.z * v.z),
- q.n * v.x + q.v.y * v.z - q.v.z * v.y,
- q.n * v.y + q.v.z * v.x - q.v.x * v.z,
- q.n * v.z + q.v.x * v.y - q.v.y * v.x);
-}
-
-inline Quaternion operator*(Vector v, Quaternion q)
-{
- return Quaternion( -(q.v.x * v.x + q.v.y * v.y + q.v.z * v.z),
- q.n * v.x + q.v.z * v.y - q.v.y * v.z,
- q.n * v.y + q.v.x * v.z - q.v.z * v.x,
- q.n * v.z + q.v.y * v.x - q.v.x * v.y);
-}
-
-inline Quaternion operator/(Quaternion q, float s)
-{
- return Quaternion(q.n / s, q.v.x / s, q.v.y / s, q.v.z / s);
-}
-
-inline float QGetAngle(Quaternion q)
-{
- return (float) (2 * acosf(q.n));
-}
-
-inline Vector QGetAxis(Quaternion q)
-{
- Vector v;
- float m;
-
- v = q.GetVector();
- m = v.Magnitude();
-
- if (m <= tol)
- return Vector();
- else
- return v / m;
-}
-
-inline Quaternion QRotate(Quaternion q1, Quaternion q2)
-{
- return q1 * q2 * (~q1);
-}
-
-inline Vector QVRotate(Quaternion q, Vector v)
-{
- Quaternion t;
-
-
- t = q * v * (~q);
-
- return t.GetVector();
-}
-
-inline Quaternion MakeQFromEulerAngles(float x, float y, float z)
-{
- Quaternion q;
- double roll = DegreesToRadians(x);
- double pitch = DegreesToRadians(y);
- double yaw = DegreesToRadians(z);
-
- double cyaw, cpitch, croll, syaw, spitch, sroll;
- double cyawcpitch, syawspitch, cyawspitch, syawcpitch;
-
- cyaw = cos(0.5f * yaw);
- cpitch = cos(0.5f * pitch);
- croll = cos(0.5f * roll);
- syaw = sin(0.5f * yaw);
- spitch = sin(0.5f * pitch);
- sroll = sin(0.5f * roll);
-
- cyawcpitch = cyaw * cpitch;
- syawspitch = syaw * spitch;
- cyawspitch = cyaw * spitch;
- syawcpitch = syaw * cpitch;
-
- q.n = (float) (cyawcpitch * croll + syawspitch * sroll);
- q.v.x = (float) (cyawcpitch * sroll - syawspitch * croll);
- q.v.y = (float) (cyawspitch * croll + syawcpitch * sroll);
- q.v.z = (float) (syawcpitch * croll - cyawspitch * sroll);
-
- return q;
-}
-
-inline Vector MakeEulerAnglesFromQ(Quaternion q)
-{
- double r11, r21, r31, r32, r33;
- double q00, q11, q22, q33;
- double tmp;
- Vector u;
-
- q00 = q.n * q.n;
- q11 = q.v.x * q.v.x;
- q22 = q.v.y * q.v.y;
- q33 = q.v.z * q.v.z;
-
- r11 = q00 + q11 - q22 - q33;
- r21 = 2 * (q.v.x * q.v.y + q.n * q.v.z);
- r31 = 2 * (q.v.x * q.v.z - q.n * q.v.y);
- r32 = 2 * (q.v.y * q.v.z + q.n * q.v.x);
- r33 = q00 - q11 - q22 + q33;
-
- tmp = fabs(r31);
- if (tmp > 0.999999) {
- double r12 = 2 * (q.v.x * q.v.y - q.n * q.v.z);
- double r13 = 2 * (q.v.x * q.v.z + q.n * q.v.y);
-
- u.x = RadiansToDegrees(0.0f); //roll
- u.y = RadiansToDegrees((float) (-(pi / 2) * r31 / tmp)); // pitch
- u.z = RadiansToDegrees((float) atan2(-r12, -r31 * r13)); // yaw
- return u;
- }
-
- u.x = RadiansToDegrees((float) atan2(r32, r33)); // roll
- u.y = RadiansToDegrees((float) asinf(-r31)); // pitch
- u.z = RadiansToDegrees((float) atan2(r21, r11)); // yaw
- return u;
-
-
-}
-
-
-
-
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _PHYSICSMATH_HPP_
+#define _PHYSICSMATH_HPP_
+
+#include "MacCompatibility.hpp"
+
+//------------------------------------------------------------------------//
+// Misc. Constants
+//------------------------------------------------------------------------//
+
+float const pi = 3.14159265f;
+float const g = -32.174f; // acceleration due to gravity, ft/s^2
+float const rho = 0.0023769f; // desity of air at sea level, slugs/ft^3
+float const tol = 0.0000000001f; // float type tolerance
+
+
+//------------------------------------------------------------------------//
+// Misc. Functions
+//------------------------------------------------------------------------//
+inline float DegreesToRadians(float deg);
+inline float RadiansToDegrees(float rad);
+
+inline float DegreesToRadians(float deg)
+{
+ return deg * pi / 180.0f;
+}
+
+inline float RadiansToDegrees(float rad)
+{
+ return rad * 180.0f / pi;
+}
+
+//------------------------------------------------------------------------//
+// Vector Class and vector functions
+//------------------------------------------------------------------------//
+class Vector
+{
+public:
+ float x;
+ float y;
+ float z;
+
+ Vector(void);
+ Vector(float xi, float yi, float zi);
+
+ float Magnitude(void);
+ void Normalize(void);
+ void Reverse(void);
+
+ Vector& operator+=(Vector u); // vector addition
+ Vector& operator-=(Vector u); // vector subtraction
+ Vector& operator*=(float s); // scalar multiply
+ Vector& operator/=(float s); // scalar divide
+
+ Vector operator-(void);
+
+};
+
+inline Vector operator+(Vector u, Vector v);
+inline Vector operator-(Vector u, Vector v);
+inline Vector operator^(Vector u, Vector v);
+inline float operator*(Vector u, Vector v);
+inline Vector operator*(float s, Vector u);
+inline Vector operator*(Vector u, float s);
+inline Vector operator/(Vector u, float s);
+inline float TripleScalarProduct(Vector u, Vector v, Vector w);
+/*
+float fast_sqrt2 (register float arg);
+float fast_sqrt2 (register float arg)
+{
+// Can replace with slower return std::sqrt(arg);
+register float result;
+
+if (arg == 0.0) return 0.0;
+
+asm {
+frsqrte result,arg // Calculate Square root
+}
+
+// Newton Rhapson iterations.
+result = result + 0.5 * result * (1.0 - arg * result * result);
+result = result + 0.5 * result * (1.0 - arg * result * result);
+
+return result * arg;
+}
+*/
+inline Vector::Vector(void)
+{
+ x = 0;
+ y = 0;
+ z = 0;
+}
+
+inline Vector::Vector(float xi, float yi, float zi)
+{
+ x = xi;
+ y = yi;
+ z = zi;
+}
+
+inline float Vector::Magnitude(void)
+{
+ return (float) sqrt(x * x + y * y + z * z);
+}
+
+inline void Vector::Normalize(void)
+{
+ float m = (float) sqrt(x * x + y * y + z * z);
+ if (m <= tol)
+ m = 1;
+ x /= m;
+ y /= m;
+ z /= m;
+
+ if (fabs(x) < tol)
+ x = 0.0f;
+ if (fabs(y) < tol)
+ y = 0.0f;
+ if (fabs(z) < tol)
+ z = 0.0f;
+}
+
+inline void Vector::Reverse(void)
+{
+ x = -x;
+ y = -y;
+ z = -z;
+}
+
+inline Vector& Vector::operator+=(Vector u)
+{
+ x += u.x;
+ y += u.y;
+ z += u.z;
+ return *this;
+}
+
+inline Vector& Vector::operator-=(Vector u)
+{
+ x -= u.x;
+ y -= u.y;
+ z -= u.z;
+ return *this;
+}
+
+inline Vector& Vector::operator*=(float s)
+{
+ x *= s;
+ y *= s;
+ z *= s;
+ return *this;
+}
+
+inline Vector& Vector::operator/=(float s)
+{
+ x /= s;
+ y /= s;
+ z /= s;
+ return *this;
+}
+
+inline Vector Vector::operator-(void)
+{
+ return Vector(-x, -y, -z);
+}
+
+
+inline Vector operator+(Vector u, Vector v)
+{
+ return Vector(u.x + v.x, u.y + v.y, u.z + v.z);
+}
+
+inline Vector operator-(Vector u, Vector v)
+{
+ return Vector(u.x - v.x, u.y - v.y, u.z - v.z);
+}
+
+// Vector cross product (u cross v)
+inline Vector operator^(Vector u, Vector v)
+{
+ return Vector( u.y * v.z - u.z * v.y,
+ -u.x * v.z + u.z * v.x,
+ u.x * v.y - u.y * v.x );
+}
+
+// Vector dot product
+inline float operator*(Vector u, Vector v)
+{
+ return (u.x * v.x + u.y * v.y + u.z * v.z);
+}
+
+inline Vector operator*(float s, Vector u)
+{
+ return Vector(u.x * s, u.y * s, u.z * s);
+}
+
+inline Vector operator*(Vector u, float s)
+{
+ return Vector(u.x * s, u.y * s, u.z * s);
+}
+
+inline Vector operator/(Vector u, float s)
+{
+ return Vector(u.x / s, u.y / s, u.z / s);
+}
+
+// triple scalar product (u dot (v cross w))
+inline float TripleScalarProduct(Vector u, Vector v, Vector w)
+{
+ return float( (u.x * (v.y * w.z - v.z * w.y)) +
+ (u.y * (-v.x * w.z + v.z * w.x)) +
+ (u.z * (v.x * w.y - v.y * w.x)) );
+ //return u*(v^w);
+
+}
+
+
+
+//------------------------------------------------------------------------//
+// Matrix Class and matrix functions
+//------------------------------------------------------------------------//
+
+class Matrix3x3
+{
+public:
+ // elements eij: i -> row, j -> column
+ float e11, e12, e13, e21, e22, e23, e31, e32, e33;
+
+ Matrix3x3(void);
+ Matrix3x3( float r1c1, float r1c2, float r1c3,
+ float r2c1, float r2c2, float r2c3,
+ float r3c1, float r3c2, float r3c3 );
+
+ float det(void);
+ Matrix3x3 Transpose(void);
+ Matrix3x3 Inverse(void);
+
+ Matrix3x3& operator+=(Matrix3x3 m);
+ Matrix3x3& operator-=(Matrix3x3 m);
+ Matrix3x3& operator*=(float s);
+ Matrix3x3& operator/=(float s);
+};
+
+inline Matrix3x3 operator+(Matrix3x3 m1, Matrix3x3 m2);
+inline Matrix3x3 operator-(Matrix3x3 m1, Matrix3x3 m2);
+inline Matrix3x3 operator/(Matrix3x3 m, float s);
+inline Matrix3x3 operator*(Matrix3x3 m1, Matrix3x3 m2);
+inline Matrix3x3 operator*(Matrix3x3 m, float s);
+inline Matrix3x3 operator*(float s, Matrix3x3 m);
+inline Vector operator*(Matrix3x3 m, Vector u);
+inline Vector operator*(Vector u, Matrix3x3 m);
+
+
+
+
+
+inline Matrix3x3::Matrix3x3(void)
+{
+ e11 = 0;
+ e12 = 0;
+ e13 = 0;
+ e21 = 0;
+ e22 = 0;
+ e23 = 0;
+ e31 = 0;
+ e32 = 0;
+ e33 = 0;
+}
+
+inline Matrix3x3::Matrix3x3( float r1c1, float r1c2, float r1c3,
+ float r2c1, float r2c2, float r2c3,
+ float r3c1, float r3c2, float r3c3 )
+{
+ e11 = r1c1;
+ e12 = r1c2;
+ e13 = r1c3;
+ e21 = r2c1;
+ e22 = r2c2;
+ e23 = r2c3;
+ e31 = r3c1;
+ e32 = r3c2;
+ e33 = r3c3;
+}
+
+inline float Matrix3x3::det(void)
+{
+ return e11 * e22 * e33 -
+ e11 * e32 * e23 +
+ e21 * e32 * e13 -
+ e21 * e12 * e33 +
+ e31 * e12 * e23 -
+ e31 * e22 * e13;
+}
+
+inline Matrix3x3 Matrix3x3::Transpose(void)
+{
+ return Matrix3x3(e11, e21, e31, e12, e22, e32, e13, e23, e33);
+}
+
+inline Matrix3x3 Matrix3x3::Inverse(void)
+{
+ float d = e11 * e22 * e33 -
+ e11 * e32 * e23 +
+ e21 * e32 * e13 -
+ e21 * e12 * e33 +
+ e31 * e12 * e23 -
+ e31 * e22 * e13;
+
+ if (d == 0)
+ d = 1;
+
+ return Matrix3x3( (e22 * e33 - e23 * e32) / d,
+ -(e12 * e33 - e13 * e32) / d,
+ (e12 * e23 - e13 * e22) / d,
+ -(e21 * e33 - e23 * e31) / d,
+ (e11 * e33 - e13 * e31) / d,
+ -(e11 * e23 - e13 * e21) / d,
+ (e21 * e32 - e22 * e31) / d,
+ -(e11 * e32 - e12 * e31) / d,
+ (e11 * e22 - e12 * e21) / d );
+}
+
+inline Matrix3x3& Matrix3x3::operator+=(Matrix3x3 m)
+{
+ e11 += m.e11;
+ e12 += m.e12;
+ e13 += m.e13;
+ e21 += m.e21;
+ e22 += m.e22;
+ e23 += m.e23;
+ e31 += m.e31;
+ e32 += m.e32;
+ e33 += m.e33;
+ return *this;
+}
+
+inline Matrix3x3& Matrix3x3::operator-=(Matrix3x3 m)
+{
+ e11 -= m.e11;
+ e12 -= m.e12;
+ e13 -= m.e13;
+ e21 -= m.e21;
+ e22 -= m.e22;
+ e23 -= m.e23;
+ e31 -= m.e31;
+ e32 -= m.e32;
+ e33 -= m.e33;
+ return *this;
+}
+
+inline Matrix3x3& Matrix3x3::operator*=(float s)
+{
+ e11 *= s;
+ e12 *= s;
+ e13 *= s;
+ e21 *= s;
+ e22 *= s;
+ e23 *= s;
+ e31 *= s;
+ e32 *= s;
+ e33 *= s;
+ return *this;
+}
+
+inline Matrix3x3& Matrix3x3::operator/=(float s)
+{
+ e11 /= s;
+ e12 /= s;
+ e13 /= s;
+ e21 /= s;
+ e22 /= s;
+ e23 /= s;
+ e31 /= s;
+ e32 /= s;
+ e33 /= s;
+ return *this;
+}
+
+inline Matrix3x3 operator+(Matrix3x3 m1, Matrix3x3 m2)
+{
+ return Matrix3x3( m1.e11 + m2.e11,
+ m1.e12 + m2.e12,
+ m1.e13 + m2.e13,
+ m1.e21 + m2.e21,
+ m1.e22 + m2.e22,
+ m1.e23 + m2.e23,
+ m1.e31 + m2.e31,
+ m1.e32 + m2.e32,
+ m1.e33 + m2.e33);
+}
+
+inline Matrix3x3 operator-(Matrix3x3 m1, Matrix3x3 m2)
+{
+ return Matrix3x3( m1.e11 - m2.e11,
+ m1.e12 - m2.e12,
+ m1.e13 - m2.e13,
+ m1.e21 - m2.e21,
+ m1.e22 - m2.e22,
+ m1.e23 - m2.e23,
+ m1.e31 - m2.e31,
+ m1.e32 - m2.e32,
+ m1.e33 - m2.e33);
+}
+
+inline Matrix3x3 operator/(Matrix3x3 m, float s)
+{
+ return Matrix3x3( m.e11 / s,
+ m.e12 / s,
+ m.e13 / s,
+ m.e21 / s,
+ m.e22 / s,
+ m.e23 / s,
+ m.e31 / s,
+ m.e32 / s,
+ m.e33 / s);
+}
+
+inline Matrix3x3 operator*(Matrix3x3 m1, Matrix3x3 m2)
+{
+ return Matrix3x3( m1.e11 * m2.e11 + m1.e12 * m2.e21 + m1.e13 * m2.e31,
+ m1.e11 * m2.e12 + m1.e12 * m2.e22 + m1.e13 * m2.e32,
+ m1.e11 * m2.e13 + m1.e12 * m2.e23 + m1.e13 * m2.e33,
+ m1.e21 * m2.e11 + m1.e22 * m2.e21 + m1.e23 * m2.e31,
+ m1.e21 * m2.e12 + m1.e22 * m2.e22 + m1.e23 * m2.e32,
+ m1.e21 * m2.e13 + m1.e22 * m2.e23 + m1.e23 * m2.e33,
+ m1.e31 * m2.e11 + m1.e32 * m2.e21 + m1.e33 * m2.e31,
+ m1.e31 * m2.e12 + m1.e32 * m2.e22 + m1.e33 * m2.e32,
+ m1.e31 * m2.e13 + m1.e32 * m2.e23 + m1.e33 * m2.e33 );
+}
+
+inline Matrix3x3 operator*(Matrix3x3 m, float s)
+{
+ return Matrix3x3( m.e11 * s,
+ m.e12 * s,
+ m.e13 * s,
+ m.e21 * s,
+ m.e22 * s,
+ m.e23 * s,
+ m.e31 * s,
+ m.e32 * s,
+ m.e33 * s);
+}
+
+inline Matrix3x3 operator*(float s, Matrix3x3 m)
+{
+ return Matrix3x3( m.e11 * s,
+ m.e12 * s,
+ m.e13 * s,
+ m.e21 * s,
+ m.e22 * s,
+ m.e23 * s,
+ m.e31 * s,
+ m.e32 * s,
+ m.e33 * s);
+}
+
+inline Vector operator*(Matrix3x3 m, Vector u)
+{
+ return Vector( m.e11 * u.x + m.e12 * u.y + m.e13 * u.z,
+ m.e21 * u.x + m.e22 * u.y + m.e23 * u.z,
+ m.e31 * u.x + m.e32 * u.y + m.e33 * u.z);
+}
+
+inline Vector operator*(Vector u, Matrix3x3 m)
+{
+ return Vector( u.x * m.e11 + u.y * m.e21 + u.z * m.e31,
+ u.x * m.e12 + u.y * m.e22 + u.z * m.e32,
+ u.x * m.e13 + u.y * m.e23 + u.z * m.e33);
+}
+
+//------------------------------------------------------------------------//
+// Quaternion Class and Quaternion functions
+//------------------------------------------------------------------------//
+
+class Quaternion
+{
+public:
+ float n; // number (scalar) part
+ Vector v; // vector part: v.x, v.y, v.z
+
+ Quaternion(void);
+ Quaternion(float e0, float e1, float e2, float e3);
+
+ float Magnitude(void);
+ Vector GetVector(void);
+ float GetScalar(void);
+ Quaternion operator+=(Quaternion q);
+ Quaternion operator-=(Quaternion q);
+ Quaternion operator*=(float s);
+ Quaternion operator/=(float s);
+ Quaternion operator~(void) const {
+ return Quaternion(n, -v.x, -v.y, -v.z);
+ }
+};
+
+inline Quaternion operator+(Quaternion q1, Quaternion q2);
+inline Quaternion operator-(Quaternion q1, Quaternion q2);
+inline Quaternion operator*(Quaternion q1, Quaternion q2);
+inline Quaternion operator*(Quaternion q, float s);
+inline Quaternion operator*(float s, Quaternion q);
+inline Quaternion operator*(Quaternion q, Vector v);
+inline Quaternion operator*(Vector v, Quaternion q);
+inline Quaternion operator/(Quaternion q, float s);
+inline float QGetAngle(Quaternion q);
+inline Vector QGetAxis(Quaternion q);
+inline Quaternion QRotate(Quaternion q1, Quaternion q2);
+inline Vector QVRotate(Quaternion q, Vector v);
+inline Quaternion MakeQFromEulerAngles(float x, float y, float z);
+inline Vector MakeEulerAnglesFromQ(Quaternion q);
+
+
+inline Quaternion::Quaternion(void)
+{
+ n = 0;
+ v.x = 0;
+ v.y = 0;
+ v.z = 0;
+}
+
+inline Quaternion::Quaternion(float e0, float e1, float e2, float e3)
+{
+ n = e0;
+ v.x = e1;
+ v.y = e2;
+ v.z = e3;
+}
+
+inline float Quaternion::Magnitude(void)
+{
+ return (float) sqrt(n * n + v.x * v.x + v.y * v.y + v.z * v.z);
+}
+
+inline Vector Quaternion::GetVector(void)
+{
+ return Vector(v.x, v.y, v.z);
+}
+
+inline float Quaternion::GetScalar(void)
+{
+ return n;
+}
+
+inline Quaternion Quaternion::operator+=(Quaternion q)
+{
+ n += q.n;
+ v.x += q.v.x;
+ v.y += q.v.y;
+ v.z += q.v.z;
+ return *this;
+}
+
+inline Quaternion Quaternion::operator-=(Quaternion q)
+{
+ n -= q.n;
+ v.x -= q.v.x;
+ v.y -= q.v.y;
+ v.z -= q.v.z;
+ return *this;
+}
+
+inline Quaternion Quaternion::operator*=(float s)
+{
+ n *= s;
+ v.x *= s;
+ v.y *= s;
+ v.z *= s;
+ return *this;
+}
+
+inline Quaternion Quaternion::operator/=(float s)
+{
+ n /= s;
+ v.x /= s;
+ v.y /= s;
+ v.z /= s;
+ return *this;
+}
+
+/*inline Quaternion Quaternion::operator~()
+{
+return Quaternion(n, -v.x, -v.y, -v.z);
+}*/
+
+inline Quaternion operator+(Quaternion q1, Quaternion q2)
+{
+ return Quaternion( q1.n + q2.n,
+ q1.v.x + q2.v.x,
+ q1.v.y + q2.v.y,
+ q1.v.z + q2.v.z);
+}
+
+inline Quaternion operator-(Quaternion q1, Quaternion q2)
+{
+ return Quaternion( q1.n - q2.n,
+ q1.v.x - q2.v.x,
+ q1.v.y - q2.v.y,
+ q1.v.z - q2.v.z);
+}
+
+inline Quaternion operator*(Quaternion q1, Quaternion q2)
+{
+ return Quaternion( q1.n * q2.n - q1.v.x * q2.v.x - q1.v.y * q2.v.y - q1.v.z * q2.v.z,
+ q1.n * q2.v.x + q1.v.x * q2.n + q1.v.y * q2.v.z - q1.v.z * q2.v.y,
+ q1.n * q2.v.y + q1.v.y * q2.n + q1.v.z * q2.v.x - q1.v.x * q2.v.z,
+ q1.n * q2.v.z + q1.v.z * q2.n + q1.v.x * q2.v.y - q1.v.y * q2.v.x);
+}
+
+inline Quaternion operator*(Quaternion q, float s)
+{
+ return Quaternion(q.n * s, q.v.x * s, q.v.y * s, q.v.z * s);
+}
+
+inline Quaternion operator*(float s, Quaternion q)
+{
+ return Quaternion(q.n * s, q.v.x * s, q.v.y * s, q.v.z * s);
+}
+
+inline Quaternion operator*(Quaternion q, Vector v)
+{
+ return Quaternion( -(q.v.x * v.x + q.v.y * v.y + q.v.z * v.z),
+ q.n * v.x + q.v.y * v.z - q.v.z * v.y,
+ q.n * v.y + q.v.z * v.x - q.v.x * v.z,
+ q.n * v.z + q.v.x * v.y - q.v.y * v.x);
+}
+
+inline Quaternion operator*(Vector v, Quaternion q)
+{
+ return Quaternion( -(q.v.x * v.x + q.v.y * v.y + q.v.z * v.z),
+ q.n * v.x + q.v.z * v.y - q.v.y * v.z,
+ q.n * v.y + q.v.x * v.z - q.v.z * v.x,
+ q.n * v.z + q.v.y * v.x - q.v.x * v.y);
+}
+
+inline Quaternion operator/(Quaternion q, float s)
+{
+ return Quaternion(q.n / s, q.v.x / s, q.v.y / s, q.v.z / s);
+}
+
+inline float QGetAngle(Quaternion q)
+{
+ return (float) (2 * acosf(q.n));
+}
+
+inline Vector QGetAxis(Quaternion q)
+{
+ Vector v;
+ float m;
+
+ v = q.GetVector();
+ m = v.Magnitude();
+
+ if (m <= tol)
+ return Vector();
+ else
+ return v / m;
+}
+
+inline Quaternion QRotate(Quaternion q1, Quaternion q2)
+{
+ return q1 * q2 * (~q1);
+}
+
+inline Vector QVRotate(Quaternion q, Vector v)
+{
+ Quaternion t;
+
+
+ t = q * v * (~q);
+
+ return t.GetVector();
+}
+
+inline Quaternion MakeQFromEulerAngles(float x, float y, float z)
+{
+ Quaternion q;
+ double roll = DegreesToRadians(x);
+ double pitch = DegreesToRadians(y);
+ double yaw = DegreesToRadians(z);
+
+ double cyaw, cpitch, croll, syaw, spitch, sroll;
+ double cyawcpitch, syawspitch, cyawspitch, syawcpitch;
+
+ cyaw = cos(0.5f * yaw);
+ cpitch = cos(0.5f * pitch);
+ croll = cos(0.5f * roll);
+ syaw = sin(0.5f * yaw);
+ spitch = sin(0.5f * pitch);
+ sroll = sin(0.5f * roll);
+
+ cyawcpitch = cyaw * cpitch;
+ syawspitch = syaw * spitch;
+ cyawspitch = cyaw * spitch;
+ syawcpitch = syaw * cpitch;
+
+ q.n = (float) (cyawcpitch * croll + syawspitch * sroll);
+ q.v.x = (float) (cyawcpitch * sroll - syawspitch * croll);
+ q.v.y = (float) (cyawspitch * croll + syawcpitch * sroll);
+ q.v.z = (float) (syawcpitch * croll - cyawspitch * sroll);
+
+ return q;
+}
+
+inline Vector MakeEulerAnglesFromQ(Quaternion q)
+{
+ double r11, r21, r31, r32, r33;
+ double q00, q11, q22, q33;
+ double tmp;
+ Vector u;
+
+ q00 = q.n * q.n;
+ q11 = q.v.x * q.v.x;
+ q22 = q.v.y * q.v.y;
+ q33 = q.v.z * q.v.z;
+
+ r11 = q00 + q11 - q22 - q33;
+ r21 = 2 * (q.v.x * q.v.y + q.n * q.v.z);
+ r31 = 2 * (q.v.x * q.v.z - q.n * q.v.y);
+ r32 = 2 * (q.v.y * q.v.z + q.n * q.v.x);
+ r33 = q00 - q11 - q22 + q33;
+
+ tmp = fabs(r31);
+ if (tmp > 0.999999) {
+ double r12 = 2 * (q.v.x * q.v.y - q.n * q.v.z);
+ double r13 = 2 * (q.v.x * q.v.z + q.n * q.v.y);
+
+ u.x = RadiansToDegrees(0.0f); //roll
+ u.y = RadiansToDegrees((float) (-(pi / 2) * r31 / tmp)); // pitch
+ u.z = RadiansToDegrees((float) atan2(-r12, -r31 * r13)); // yaw
+ return u;
+ }
+
+ u.x = RadiansToDegrees((float) atan2(r32, r33)); // roll
+ u.y = RadiansToDegrees((float) asinf(-r31)); // pitch
+ u.z = RadiansToDegrees((float) atan2(r21, r11)); // yaw
+ return u;
+
+
+}
+
+
+
+
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Math/Quaternions.h"
+#include "Math/Quaternions.hpp"
// Functions
quaternion Quat_Mult(quaternion q1, quaternion q2)
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-
-#ifndef _QUATERNIONS_H_
-#define _QUATERNIONS_H_
-
-#include "math.h"
-#include "PhysicsMath.h"
-#include "Graphic/gamegl.h"
-
-/**> Quaternion Structures <**/
-#define PI 3.14159265355555897932384626
-#define RADIANS 0
-#define DEGREES 1
-#define deg2rad .0174532925
-
-//using namespace std;
-typedef float Matrix_t [4][4];
-struct euler {
- float x, y, z;
-};
-struct angle_axis {
- float x, y, z, angle;
-};
-struct quaternion {
- float x, y, z, w;
-};
-
-class XYZ
-{
-public:
- float x;
- float y;
- float z;
- XYZ() : x(0.0f), y(0.0f), z(0.0f) {}
- inline XYZ operator+(XYZ add);
- inline XYZ operator-(XYZ add);
- inline XYZ operator*(float add);
- inline XYZ operator*(XYZ add);
- inline XYZ operator/(float add);
- inline void operator+=(XYZ add);
- inline void operator-=(XYZ add);
- inline void operator*=(float add);
- inline void operator*=(XYZ add);
- inline void operator/=(float add);
- inline void operator=(float add);
- inline void vec(Vector add);
- inline bool operator==(XYZ add);
-};
-
-/*********************> Quaternion Function definition <********/
-quaternion To_Quat(int Degree_Flag, euler Euler);
-quaternion To_Quat(angle_axis Ang_Ax);
-quaternion To_Quat(Matrix_t m);
-angle_axis Quat_2_AA(quaternion Quat);
-void Quat_2_Matrix(quaternion Quat, Matrix_t m);
-quaternion Normalize(quaternion Quat);
-quaternion Quat_Mult(quaternion q1, quaternion q2);
-quaternion QNormalize(quaternion Quat);
-XYZ Quat2Vector(quaternion Quat);
-
-inline void CrossProduct(XYZ *P, XYZ *Q, XYZ *V);
-inline void CrossProduct(XYZ P, XYZ Q, XYZ *V);
-inline void Normalise(XYZ *vectory);
-inline float normaldotproduct(XYZ point1, XYZ point2);
-inline float fast_sqrt (register float arg);
-bool PointInTriangle(XYZ *p, XYZ normal, XYZ *p1, XYZ *p2, XYZ *p3);
-bool LineFacet(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ *p);
-float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ *p);
-float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ n, XYZ *p);
-float LineFacetd(XYZ *p1, XYZ *p2, XYZ *pa, XYZ *pb, XYZ *pc, XYZ *n, XYZ *p);
-float LineFacetd(XYZ *p1, XYZ *p2, XYZ *pa, XYZ *pb, XYZ *pc, XYZ *p);
-bool PointInTriangle(Vector *p, Vector normal, float p11, float p12, float p13, float p21, float p22, float p23, float p31, float p32, float p33);
-bool LineFacet(Vector p1, Vector p2, Vector pa, Vector pb, Vector pc, Vector *p);
-inline void ReflectVector(XYZ *vel, const XYZ *n);
-inline void ReflectVector(XYZ *vel, const XYZ &n);
-inline XYZ DoRotation(XYZ thePoint, float xang, float yang, float zang);
-inline XYZ DoRotationRadian(XYZ thePoint, float xang, float yang, float zang);
-inline float findDistance(XYZ *point1, XYZ *point2);
-inline float findLength(XYZ *point1);
-inline float findLengthfast(XYZ *point1);
-inline float distsq(XYZ *point1, XYZ *point2);
-inline float distsq(XYZ point1, XYZ point2);
-inline float distsqflat(XYZ *point1, XYZ *point2);
-inline float dotproduct(const XYZ *point1, const XYZ *point2);
-bool sphere_line_intersection (
- float x1, float y1 , float z1,
- float x2, float y2 , float z2,
- float x3, float y3 , float z3, float r );
-bool sphere_line_intersection (
- XYZ *p1, XYZ *p2, XYZ *p3, float *r );
-inline bool DistancePointLine( XYZ *Point, XYZ *LineStart, XYZ *LineEnd, float *Distance, XYZ *Intersection );
-
-
-inline void Normalise(XYZ *vectory)
-{
- static float d;
- d = fast_sqrt(vectory->x * vectory->x + vectory->y * vectory->y + vectory->z * vectory->z);
- if (d == 0) {
- return;
- }
- vectory->x /= d;
- vectory->y /= d;
- vectory->z /= d;
-}
-
-inline XYZ XYZ::operator+(XYZ add)
-{
- static XYZ ne;
- ne = add;
- ne.x += x;
- ne.y += y;
- ne.z += z;
- return ne;
-}
-
-inline XYZ XYZ::operator-(XYZ add)
-{
- static XYZ ne;
- ne = add;
- ne.x = x - ne.x;
- ne.y = y - ne.y;
- ne.z = z - ne.z;
- return ne;
-}
-
-inline XYZ XYZ::operator*(float add)
-{
- static XYZ ne;
- ne.x = x * add;
- ne.y = y * add;
- ne.z = z * add;
- return ne;
-}
-
-inline XYZ XYZ::operator*(XYZ add)
-{
- static XYZ ne;
- ne.x = x * add.x;
- ne.y = y * add.y;
- ne.z = z * add.z;
- return ne;
-}
-
-inline XYZ XYZ::operator/(float add)
-{
- static XYZ ne;
- ne.x = x / add;
- ne.y = y / add;
- ne.z = z / add;
- return ne;
-}
-
-inline void XYZ::operator+=(XYZ add)
-{
- x += add.x;
- y += add.y;
- z += add.z;
-}
-
-inline void XYZ::operator-=(XYZ add)
-{
- x = x - add.x;
- y = y - add.y;
- z = z - add.z;
-}
-
-inline void XYZ::operator*=(float add)
-{
- x = x * add;
- y = y * add;
- z = z * add;
-}
-
-inline void XYZ::operator*=(XYZ add)
-{
- x = x * add.x;
- y = y * add.y;
- z = z * add.z;
-}
-
-inline void XYZ::operator/=(float add)
-{
- x = x / add;
- y = y / add;
- z = z / add;
-}
-
-inline void XYZ::operator=(float add)
-{
- x = add;
- y = add;
- z = add;
-}
-
-inline void XYZ::vec(Vector add)
-{
- x = add.x;
- y = add.y;
- z = add.z;
-}
-
-inline bool XYZ::operator==(XYZ add)
-{
- if (x == add.x && y == add.y && z == add.z)
- return 1;
- return 0;
-}
-
-inline void CrossProduct(XYZ *P, XYZ *Q, XYZ *V)
-{
- V->x = P->y * Q->z - P->z * Q->y;
- V->y = P->z * Q->x - P->x * Q->z;
- V->z = P->x * Q->y - P->y * Q->x;
-}
-
-inline void CrossProduct(XYZ P, XYZ Q, XYZ *V)
-{
- V->x = P.y * Q.z - P.z * Q.y;
- V->y = P.z * Q.x - P.x * Q.z;
- V->z = P.x * Q.y - P.y * Q.x;
-}
-
-inline float fast_sqrt (register float arg)
-{
- return sqrtf(arg);
-}
-
-inline float normaldotproduct(XYZ point1, XYZ point2)
-{
- static GLfloat returnvalue;
- Normalise(&point1);
- Normalise(&point2);
- returnvalue = (point1.x * point2.x + point1.y * point2.y + point1.z * point2.z);
- return returnvalue;
-}
-
-inline void ReflectVector(XYZ *vel, const XYZ *n)
-{
- ReflectVector(vel, *n);
-}
-
-inline void ReflectVector(XYZ *vel, const XYZ &n)
-{
- static XYZ vn;
- static XYZ vt;
- static float dotprod;
-
- dotprod = dotproduct(&n, vel);
- vn.x = n.x * dotprod;
- vn.y = n.y * dotprod;
- vn.z = n.z * dotprod;
-
- vt.x = vel->x - vn.x;
- vt.y = vel->y - vn.y;
- vt.z = vel->z - vn.z;
-
- vel->x = vt.x - vn.x;
- vel->y = vt.y - vn.y;
- vel->z = vt.z - vn.z;
-}
-
-inline float dotproduct(const XYZ *point1, const XYZ *point2)
-{
- static GLfloat returnvalue;
- returnvalue = (point1->x * point2->x + point1->y * point2->y + point1->z * point2->z);
- return returnvalue;
-}
-
-inline float findDistance(XYZ *point1, XYZ *point2)
-{
- return(fast_sqrt((point1->x - point2->x) * (point1->x - point2->x) + (point1->y - point2->y) * (point1->y - point2->y) + (point1->z - point2->z) * (point1->z - point2->z)));
-}
-
-inline float findLength(XYZ *point1)
-{
- return(fast_sqrt((point1->x) * (point1->x) + (point1->y) * (point1->y) + (point1->z) * (point1->z)));
-}
-
-
-inline float findLengthfast(XYZ *point1)
-{
- return((point1->x) * (point1->x) + (point1->y) * (point1->y) + (point1->z) * (point1->z));
-}
-
-inline float distsq(XYZ *point1, XYZ *point2)
-{
- return((point1->x - point2->x) * (point1->x - point2->x) + (point1->y - point2->y) * (point1->y - point2->y) + (point1->z - point2->z) * (point1->z - point2->z));
-}
-
-inline float distsq(XYZ point1, XYZ point2)
-{
- return((point1.x - point2.x) * (point1.x - point2.x) + (point1.y - point2.y) * (point1.y - point2.y) + (point1.z - point2.z) * (point1.z - point2.z));
-}
-
-inline float distsqflat(XYZ *point1, XYZ *point2)
-{
- return((point1->x - point2->x) * (point1->x - point2->x) + (point1->z - point2->z) * (point1->z - point2->z));
-}
-
-inline XYZ DoRotation(XYZ thePoint, float xang, float yang, float zang)
-{
- static XYZ newpoint;
- if (xang) {
- xang *= 6.283185f;
- xang /= 360;
- }
- if (yang) {
- yang *= 6.283185f;
- yang /= 360;
- }
- if (zang) {
- zang *= 6.283185f;
- zang /= 360;
- }
-
-
- if (yang) {
- newpoint.z = thePoint.z * cosf(yang) - thePoint.x * sinf(yang);
- newpoint.x = thePoint.z * sinf(yang) + thePoint.x * cosf(yang);
- thePoint.z = newpoint.z;
- thePoint.x = newpoint.x;
- }
-
- if (zang) {
- newpoint.x = thePoint.x * cosf(zang) - thePoint.y * sinf(zang);
- newpoint.y = thePoint.y * cosf(zang) + thePoint.x * sinf(zang);
- thePoint.x = newpoint.x;
- thePoint.y = newpoint.y;
- }
-
- if (xang) {
- newpoint.y = thePoint.y * cosf(xang) - thePoint.z * sinf(xang);
- newpoint.z = thePoint.y * sinf(xang) + thePoint.z * cosf(xang);
- thePoint.z = newpoint.z;
- thePoint.y = newpoint.y;
- }
-
- return thePoint;
-}
-
-inline float square( float f )
-{
- return (f * f) ;
-}
-
-inline bool sphere_line_intersection (
- float x1, float y1 , float z1,
- float x2, float y2 , float z2,
- float x3, float y3 , float z3, float r )
-{
-
- // x1,y1,z1 P1 coordinates (point of line)
- // x2,y2,z2 P2 coordinates (point of line)
- // x3,y3,z3, r P3 coordinates and radius (sphere)
- // x,y,z intersection coordinates
- //
- // This function returns a pointer array which first index indicates
- // the number of intersection point, followed by coordinate pairs.
-
- //~ static float x , y , z;
- static float a, b, c, /*mu,*/ i ;
-
- if (x1 > x3 + r && x2 > x3 + r) return(0);
- if (x1 < x3 - r && x2 < x3 - r) return(0);
- if (y1 > y3 + r && y2 > y3 + r) return(0);
- if (y1 < y3 - r && y2 < y3 - r) return(0);
- if (z1 > z3 + r && z2 > z3 + r) return(0);
- if (z1 < z3 - r && z2 < z3 - r) return(0);
- a = square(x2 - x1) + square(y2 - y1) + square(z2 - z1);
- b = 2 * ( (x2 - x1) * (x1 - x3)
- + (y2 - y1) * (y1 - y3)
- + (z2 - z1) * (z1 - z3) ) ;
- c = square(x3) + square(y3) +
- square(z3) + square(x1) +
- square(y1) + square(z1) -
- 2 * ( x3 * x1 + y3 * y1 + z3 * z1 ) - square(r) ;
- i = b * b - 4 * a * c ;
-
- if ( i < 0.0 ) {
- // no intersection
- return(0);
- }
- return(1);
-}
-
-inline bool sphere_line_intersection (
- XYZ *p1, XYZ *p2, XYZ *p3, float *r )
-{
-
- // x1,p1->y,p1->z P1 coordinates (point of line)
- // p2->x,p2->y,p2->z P2 coordinates (point of line)
- // p3->x,p3->y,p3->z, r P3 coordinates and radius (sphere)
- // x,y,z intersection coordinates
- //
- // This function returns a pointer array which first index indicates
- // the number of intersection point, followed by coordinate pairs.
-
- //~ static float x , y , z;
- static float a, b, c, /*mu,*/ i ;
-
- if (p1->x > p3->x + *r && p2->x > p3->x + *r) return(0);
- if (p1->x < p3->x - *r && p2->x < p3->x - *r) return(0);
- if (p1->y > p3->y + *r && p2->y > p3->y + *r) return(0);
- if (p1->y < p3->y - *r && p2->y < p3->y - *r) return(0);
- if (p1->z > p3->z + *r && p2->z > p3->z + *r) return(0);
- if (p1->z < p3->z - *r && p2->z < p3->z - *r) return(0);
- a = square(p2->x - p1->x) + square(p2->y - p1->y) + square(p2->z - p1->z);
- b = 2 * ( (p2->x - p1->x) * (p1->x - p3->x)
- + (p2->y - p1->y) * (p1->y - p3->y)
- + (p2->z - p1->z) * (p1->z - p3->z) ) ;
- c = square(p3->x) + square(p3->y) +
- square(p3->z) + square(p1->x) +
- square(p1->y) + square(p1->z) -
- 2 * ( p3->x * p1->x + p3->y * p1->y + p3->z * p1->z ) - square(*r) ;
- i = b * b - 4 * a * c ;
-
- if ( i < 0.0 ) {
- // no intersection
- return(0);
- }
- return(1);
-}
-
-inline XYZ DoRotationRadian(XYZ thePoint, float xang, float yang, float zang)
-{
- static XYZ newpoint;
- static XYZ oldpoint;
-
- oldpoint = thePoint;
-
- if (yang != 0) {
- newpoint.z = oldpoint.z * cosf(yang) - oldpoint.x * sinf(yang);
- newpoint.x = oldpoint.z * sinf(yang) + oldpoint.x * cosf(yang);
- oldpoint.z = newpoint.z;
- oldpoint.x = newpoint.x;
- }
-
- if (zang != 0) {
- newpoint.x = oldpoint.x * cosf(zang) - oldpoint.y * sinf(zang);
- newpoint.y = oldpoint.y * cosf(zang) + oldpoint.x * sinf(zang);
- oldpoint.x = newpoint.x;
- oldpoint.y = newpoint.y;
- }
-
- if (xang != 0) {
- newpoint.y = oldpoint.y * cosf(xang) - oldpoint.z * sinf(xang);
- newpoint.z = oldpoint.y * sinf(xang) + oldpoint.z * cosf(xang);
- oldpoint.z = newpoint.z;
- oldpoint.y = newpoint.y;
- }
-
- return oldpoint;
-
-}
-
-inline bool DistancePointLine( XYZ *Point, XYZ *LineStart, XYZ *LineEnd, float *Distance, XYZ *Intersection )
-{
- float LineMag;
- float U;
-
- LineMag = findDistance( LineEnd, LineStart );
-
- U = ( ( ( Point->x - LineStart->x ) * ( LineEnd->x - LineStart->x ) ) +
- ( ( Point->y - LineStart->y ) * ( LineEnd->y - LineStart->y ) ) +
- ( ( Point->z - LineStart->z ) * ( LineEnd->z - LineStart->z ) ) ) /
- ( LineMag * LineMag );
-
- if ( U < 0.0f || U > 1.0f )
- return 0; // closest point does not fall within the line segment
-
- Intersection->x = LineStart->x + U * ( LineEnd->x - LineStart->x );
- Intersection->y = LineStart->y + U * ( LineEnd->y - LineStart->y );
- Intersection->z = LineStart->z + U * ( LineEnd->z - LineStart->z );
-
- *Distance = findDistance( Point, Intersection );
-
- return 1;
-}
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _QUATERNIONS_HPP_
+#define _QUATERNIONS_HPP_
+
+#include "PhysicsMath.hpp"
+#include "Graphic/gamegl.hpp"
+
+#include <math.h>
+
+/**> Quaternion Structures <**/
+#define PI 3.14159265355555897932384626
+#define RADIANS 0
+#define DEGREES 1
+#define deg2rad .0174532925
+
+//using namespace std;
+typedef float Matrix_t [4][4];
+struct euler {
+ float x, y, z;
+};
+struct angle_axis {
+ float x, y, z, angle;
+};
+struct quaternion {
+ float x, y, z, w;
+};
+
+class XYZ
+{
+public:
+ float x;
+ float y;
+ float z;
+ XYZ() : x(0.0f), y(0.0f), z(0.0f) {}
+ inline XYZ operator+(XYZ add);
+ inline XYZ operator-(XYZ add);
+ inline XYZ operator*(float add);
+ inline XYZ operator*(XYZ add);
+ inline XYZ operator/(float add);
+ inline void operator+=(XYZ add);
+ inline void operator-=(XYZ add);
+ inline void operator*=(float add);
+ inline void operator*=(XYZ add);
+ inline void operator/=(float add);
+ inline void operator=(float add);
+ inline void vec(Vector add);
+ inline bool operator==(XYZ add);
+};
+
+/*********************> Quaternion Function definition <********/
+quaternion To_Quat(int Degree_Flag, euler Euler);
+quaternion To_Quat(angle_axis Ang_Ax);
+quaternion To_Quat(Matrix_t m);
+angle_axis Quat_2_AA(quaternion Quat);
+void Quat_2_Matrix(quaternion Quat, Matrix_t m);
+quaternion Normalize(quaternion Quat);
+quaternion Quat_Mult(quaternion q1, quaternion q2);
+quaternion QNormalize(quaternion Quat);
+XYZ Quat2Vector(quaternion Quat);
+
+inline void CrossProduct(XYZ *P, XYZ *Q, XYZ *V);
+inline void CrossProduct(XYZ P, XYZ Q, XYZ *V);
+inline void Normalise(XYZ *vectory);
+inline float normaldotproduct(XYZ point1, XYZ point2);
+inline float fast_sqrt (register float arg);
+bool PointInTriangle(XYZ *p, XYZ normal, XYZ *p1, XYZ *p2, XYZ *p3);
+bool LineFacet(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ *p);
+float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ *p);
+float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ n, XYZ *p);
+float LineFacetd(XYZ *p1, XYZ *p2, XYZ *pa, XYZ *pb, XYZ *pc, XYZ *n, XYZ *p);
+float LineFacetd(XYZ *p1, XYZ *p2, XYZ *pa, XYZ *pb, XYZ *pc, XYZ *p);
+bool PointInTriangle(Vector *p, Vector normal, float p11, float p12, float p13, float p21, float p22, float p23, float p31, float p32, float p33);
+bool LineFacet(Vector p1, Vector p2, Vector pa, Vector pb, Vector pc, Vector *p);
+inline void ReflectVector(XYZ *vel, const XYZ *n);
+inline void ReflectVector(XYZ *vel, const XYZ &n);
+inline XYZ DoRotation(XYZ thePoint, float xang, float yang, float zang);
+inline XYZ DoRotationRadian(XYZ thePoint, float xang, float yang, float zang);
+inline float findDistance(XYZ *point1, XYZ *point2);
+inline float findLength(XYZ *point1);
+inline float findLengthfast(XYZ *point1);
+inline float distsq(XYZ *point1, XYZ *point2);
+inline float distsq(XYZ point1, XYZ point2);
+inline float distsqflat(XYZ *point1, XYZ *point2);
+inline float dotproduct(const XYZ *point1, const XYZ *point2);
+bool sphere_line_intersection (
+ float x1, float y1 , float z1,
+ float x2, float y2 , float z2,
+ float x3, float y3 , float z3, float r );
+bool sphere_line_intersection (
+ XYZ *p1, XYZ *p2, XYZ *p3, float *r );
+inline bool DistancePointLine( XYZ *Point, XYZ *LineStart, XYZ *LineEnd, float *Distance, XYZ *Intersection );
+
+
+inline void Normalise(XYZ *vectory)
+{
+ static float d;
+ d = fast_sqrt(vectory->x * vectory->x + vectory->y * vectory->y + vectory->z * vectory->z);
+ if (d == 0) {
+ return;
+ }
+ vectory->x /= d;
+ vectory->y /= d;
+ vectory->z /= d;
+}
+
+inline XYZ XYZ::operator+(XYZ add)
+{
+ static XYZ ne;
+ ne = add;
+ ne.x += x;
+ ne.y += y;
+ ne.z += z;
+ return ne;
+}
+
+inline XYZ XYZ::operator-(XYZ add)
+{
+ static XYZ ne;
+ ne = add;
+ ne.x = x - ne.x;
+ ne.y = y - ne.y;
+ ne.z = z - ne.z;
+ return ne;
+}
+
+inline XYZ XYZ::operator*(float add)
+{
+ static XYZ ne;
+ ne.x = x * add;
+ ne.y = y * add;
+ ne.z = z * add;
+ return ne;
+}
+
+inline XYZ XYZ::operator*(XYZ add)
+{
+ static XYZ ne;
+ ne.x = x * add.x;
+ ne.y = y * add.y;
+ ne.z = z * add.z;
+ return ne;
+}
+
+inline XYZ XYZ::operator/(float add)
+{
+ static XYZ ne;
+ ne.x = x / add;
+ ne.y = y / add;
+ ne.z = z / add;
+ return ne;
+}
+
+inline void XYZ::operator+=(XYZ add)
+{
+ x += add.x;
+ y += add.y;
+ z += add.z;
+}
+
+inline void XYZ::operator-=(XYZ add)
+{
+ x = x - add.x;
+ y = y - add.y;
+ z = z - add.z;
+}
+
+inline void XYZ::operator*=(float add)
+{
+ x = x * add;
+ y = y * add;
+ z = z * add;
+}
+
+inline void XYZ::operator*=(XYZ add)
+{
+ x = x * add.x;
+ y = y * add.y;
+ z = z * add.z;
+}
+
+inline void XYZ::operator/=(float add)
+{
+ x = x / add;
+ y = y / add;
+ z = z / add;
+}
+
+inline void XYZ::operator=(float add)
+{
+ x = add;
+ y = add;
+ z = add;
+}
+
+inline void XYZ::vec(Vector add)
+{
+ x = add.x;
+ y = add.y;
+ z = add.z;
+}
+
+inline bool XYZ::operator==(XYZ add)
+{
+ if (x == add.x && y == add.y && z == add.z)
+ return 1;
+ return 0;
+}
+
+inline void CrossProduct(XYZ *P, XYZ *Q, XYZ *V)
+{
+ V->x = P->y * Q->z - P->z * Q->y;
+ V->y = P->z * Q->x - P->x * Q->z;
+ V->z = P->x * Q->y - P->y * Q->x;
+}
+
+inline void CrossProduct(XYZ P, XYZ Q, XYZ *V)
+{
+ V->x = P.y * Q.z - P.z * Q.y;
+ V->y = P.z * Q.x - P.x * Q.z;
+ V->z = P.x * Q.y - P.y * Q.x;
+}
+
+inline float fast_sqrt (register float arg)
+{
+ return sqrtf(arg);
+}
+
+inline float normaldotproduct(XYZ point1, XYZ point2)
+{
+ static GLfloat returnvalue;
+ Normalise(&point1);
+ Normalise(&point2);
+ returnvalue = (point1.x * point2.x + point1.y * point2.y + point1.z * point2.z);
+ return returnvalue;
+}
+
+inline void ReflectVector(XYZ *vel, const XYZ *n)
+{
+ ReflectVector(vel, *n);
+}
+
+inline void ReflectVector(XYZ *vel, const XYZ &n)
+{
+ static XYZ vn;
+ static XYZ vt;
+ static float dotprod;
+
+ dotprod = dotproduct(&n, vel);
+ vn.x = n.x * dotprod;
+ vn.y = n.y * dotprod;
+ vn.z = n.z * dotprod;
+
+ vt.x = vel->x - vn.x;
+ vt.y = vel->y - vn.y;
+ vt.z = vel->z - vn.z;
+
+ vel->x = vt.x - vn.x;
+ vel->y = vt.y - vn.y;
+ vel->z = vt.z - vn.z;
+}
+
+inline float dotproduct(const XYZ *point1, const XYZ *point2)
+{
+ static GLfloat returnvalue;
+ returnvalue = (point1->x * point2->x + point1->y * point2->y + point1->z * point2->z);
+ return returnvalue;
+}
+
+inline float findDistance(XYZ *point1, XYZ *point2)
+{
+ return(fast_sqrt((point1->x - point2->x) * (point1->x - point2->x) + (point1->y - point2->y) * (point1->y - point2->y) + (point1->z - point2->z) * (point1->z - point2->z)));
+}
+
+inline float findLength(XYZ *point1)
+{
+ return(fast_sqrt((point1->x) * (point1->x) + (point1->y) * (point1->y) + (point1->z) * (point1->z)));
+}
+
+
+inline float findLengthfast(XYZ *point1)
+{
+ return((point1->x) * (point1->x) + (point1->y) * (point1->y) + (point1->z) * (point1->z));
+}
+
+inline float distsq(XYZ *point1, XYZ *point2)
+{
+ return((point1->x - point2->x) * (point1->x - point2->x) + (point1->y - point2->y) * (point1->y - point2->y) + (point1->z - point2->z) * (point1->z - point2->z));
+}
+
+inline float distsq(XYZ point1, XYZ point2)
+{
+ return((point1.x - point2.x) * (point1.x - point2.x) + (point1.y - point2.y) * (point1.y - point2.y) + (point1.z - point2.z) * (point1.z - point2.z));
+}
+
+inline float distsqflat(XYZ *point1, XYZ *point2)
+{
+ return((point1->x - point2->x) * (point1->x - point2->x) + (point1->z - point2->z) * (point1->z - point2->z));
+}
+
+inline XYZ DoRotation(XYZ thePoint, float xang, float yang, float zang)
+{
+ static XYZ newpoint;
+ if (xang) {
+ xang *= 6.283185f;
+ xang /= 360;
+ }
+ if (yang) {
+ yang *= 6.283185f;
+ yang /= 360;
+ }
+ if (zang) {
+ zang *= 6.283185f;
+ zang /= 360;
+ }
+
+
+ if (yang) {
+ newpoint.z = thePoint.z * cosf(yang) - thePoint.x * sinf(yang);
+ newpoint.x = thePoint.z * sinf(yang) + thePoint.x * cosf(yang);
+ thePoint.z = newpoint.z;
+ thePoint.x = newpoint.x;
+ }
+
+ if (zang) {
+ newpoint.x = thePoint.x * cosf(zang) - thePoint.y * sinf(zang);
+ newpoint.y = thePoint.y * cosf(zang) + thePoint.x * sinf(zang);
+ thePoint.x = newpoint.x;
+ thePoint.y = newpoint.y;
+ }
+
+ if (xang) {
+ newpoint.y = thePoint.y * cosf(xang) - thePoint.z * sinf(xang);
+ newpoint.z = thePoint.y * sinf(xang) + thePoint.z * cosf(xang);
+ thePoint.z = newpoint.z;
+ thePoint.y = newpoint.y;
+ }
+
+ return thePoint;
+}
+
+inline float square( float f )
+{
+ return (f * f) ;
+}
+
+inline bool sphere_line_intersection (
+ float x1, float y1 , float z1,
+ float x2, float y2 , float z2,
+ float x3, float y3 , float z3, float r )
+{
+
+ // x1,y1,z1 P1 coordinates (point of line)
+ // x2,y2,z2 P2 coordinates (point of line)
+ // x3,y3,z3, r P3 coordinates and radius (sphere)
+ // x,y,z intersection coordinates
+ //
+ // This function returns a pointer array which first index indicates
+ // the number of intersection point, followed by coordinate pairs.
+
+ //~ static float x , y , z;
+ static float a, b, c, /*mu,*/ i ;
+
+ if (x1 > x3 + r && x2 > x3 + r) return(0);
+ if (x1 < x3 - r && x2 < x3 - r) return(0);
+ if (y1 > y3 + r && y2 > y3 + r) return(0);
+ if (y1 < y3 - r && y2 < y3 - r) return(0);
+ if (z1 > z3 + r && z2 > z3 + r) return(0);
+ if (z1 < z3 - r && z2 < z3 - r) return(0);
+ a = square(x2 - x1) + square(y2 - y1) + square(z2 - z1);
+ b = 2 * ( (x2 - x1) * (x1 - x3)
+ + (y2 - y1) * (y1 - y3)
+ + (z2 - z1) * (z1 - z3) ) ;
+ c = square(x3) + square(y3) +
+ square(z3) + square(x1) +
+ square(y1) + square(z1) -
+ 2 * ( x3 * x1 + y3 * y1 + z3 * z1 ) - square(r) ;
+ i = b * b - 4 * a * c ;
+
+ if ( i < 0.0 ) {
+ // no intersection
+ return(0);
+ }
+ return(1);
+}
+
+inline bool sphere_line_intersection (
+ XYZ *p1, XYZ *p2, XYZ *p3, float *r )
+{
+
+ // x1,p1->y,p1->z P1 coordinates (point of line)
+ // p2->x,p2->y,p2->z P2 coordinates (point of line)
+ // p3->x,p3->y,p3->z, r P3 coordinates and radius (sphere)
+ // x,y,z intersection coordinates
+ //
+ // This function returns a pointer array which first index indicates
+ // the number of intersection point, followed by coordinate pairs.
+
+ //~ static float x , y , z;
+ static float a, b, c, /*mu,*/ i ;
+
+ if (p1->x > p3->x + *r && p2->x > p3->x + *r) return(0);
+ if (p1->x < p3->x - *r && p2->x < p3->x - *r) return(0);
+ if (p1->y > p3->y + *r && p2->y > p3->y + *r) return(0);
+ if (p1->y < p3->y - *r && p2->y < p3->y - *r) return(0);
+ if (p1->z > p3->z + *r && p2->z > p3->z + *r) return(0);
+ if (p1->z < p3->z - *r && p2->z < p3->z - *r) return(0);
+ a = square(p2->x - p1->x) + square(p2->y - p1->y) + square(p2->z - p1->z);
+ b = 2 * ( (p2->x - p1->x) * (p1->x - p3->x)
+ + (p2->y - p1->y) * (p1->y - p3->y)
+ + (p2->z - p1->z) * (p1->z - p3->z) ) ;
+ c = square(p3->x) + square(p3->y) +
+ square(p3->z) + square(p1->x) +
+ square(p1->y) + square(p1->z) -
+ 2 * ( p3->x * p1->x + p3->y * p1->y + p3->z * p1->z ) - square(*r) ;
+ i = b * b - 4 * a * c ;
+
+ if ( i < 0.0 ) {
+ // no intersection
+ return(0);
+ }
+ return(1);
+}
+
+inline XYZ DoRotationRadian(XYZ thePoint, float xang, float yang, float zang)
+{
+ static XYZ newpoint;
+ static XYZ oldpoint;
+
+ oldpoint = thePoint;
+
+ if (yang != 0) {
+ newpoint.z = oldpoint.z * cosf(yang) - oldpoint.x * sinf(yang);
+ newpoint.x = oldpoint.z * sinf(yang) + oldpoint.x * cosf(yang);
+ oldpoint.z = newpoint.z;
+ oldpoint.x = newpoint.x;
+ }
+
+ if (zang != 0) {
+ newpoint.x = oldpoint.x * cosf(zang) - oldpoint.y * sinf(zang);
+ newpoint.y = oldpoint.y * cosf(zang) + oldpoint.x * sinf(zang);
+ oldpoint.x = newpoint.x;
+ oldpoint.y = newpoint.y;
+ }
+
+ if (xang != 0) {
+ newpoint.y = oldpoint.y * cosf(xang) - oldpoint.z * sinf(xang);
+ newpoint.z = oldpoint.y * sinf(xang) + oldpoint.z * cosf(xang);
+ oldpoint.z = newpoint.z;
+ oldpoint.y = newpoint.y;
+ }
+
+ return oldpoint;
+
+}
+
+inline bool DistancePointLine( XYZ *Point, XYZ *LineStart, XYZ *LineEnd, float *Distance, XYZ *Intersection )
+{
+ float LineMag;
+ float U;
+
+ LineMag = findDistance( LineEnd, LineStart );
+
+ U = ( ( ( Point->x - LineStart->x ) * ( LineEnd->x - LineStart->x ) ) +
+ ( ( Point->y - LineStart->y ) * ( LineEnd->y - LineStart->y ) ) +
+ ( ( Point->z - LineStart->z ) * ( LineEnd->z - LineStart->z ) ) ) /
+ ( LineMag * LineMag );
+
+ if ( U < 0.0f || U > 1.0f )
+ return 0; // closest point does not fall within the line segment
+
+ Intersection->x = LineStart->x + U * ( LineEnd->x - LineStart->x );
+ Intersection->y = LineStart->y + U * ( LineEnd->y - LineStart->y );
+ Intersection->z = LineStart->z + U * ( LineEnd->z - LineStart->z );
+
+ *Distance = findDistance( Point, Intersection );
+
+ return 1;
+}
+
+#endif
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _RANDOM_H_
-#define _RANDOM_H_
-
-#include <stdlib.h>
-
-static inline short Random()
-{
- return rand();
-}
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _RANDOM_HPP_
+#define _RANDOM_HPP_
+
+#include <stdlib.h>
+
+static inline short Random()
+{
+ return rand();
+}
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <vector>
-#include <string>
-#include <set>
+#include "Menu/Menu.hpp"
-#include "Graphic/gamegl.h"
-#include "Level/Campaign.h"
-#include "Menu/Menu.h"
-#include "User/Settings.h"
-#include "Utils/Input.h"
+#include "Audio/openal_wrapper.hpp"
+#include "Graphic/gamegl.hpp"
+#include "Level/Campaign.hpp"
+#include "User/Settings.hpp"
+#include "Utils/Input.hpp"
// Should not be needed, Menu should call methods from other classes to launch maps and challenges and so on
-#include "Level/Awards.h"
-#include "Audio/openal_wrapper.h"
+#include "Level/Awards.hpp"
+
+#include <set>
+#include <string>
+#include <vector>
using namespace Game;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _MENU_H_
-#define _MENU_H_
-
-#include "Game.h"
-
-struct MenuItem {
- enum MenuItemType {NONE, LABEL, BUTTON, IMAGE, IMAGEBUTTON, MAPMARKER, MAPLINE, MAPLABEL} type;
- int id;
- string text;
- Texture texture;
- int x, y, w, h;
- float r, g, b;
- float effectfade;
-
- float linestartsize;
- float lineendsize;
-
- MenuItem(MenuItemType _type, int _id, const string& _text, Texture _texture,
- int _x, int _y, int _w, int _h, float _r, float _g, float _b,
- float _linestartsize = 1, float _lineendsize = 1);
-};
-
-class Menu
-{
-public:
- static void clearMenu();
- static void addLabel(int id, const string& text, int x, int y, float r = 1, float g = 0, float b = 0);
- static void addButton(int id, const string& text, int x, int y, float r = 1, float g = 0, float b = 0);
- static void addImage(int id, Texture texture, int x, int y, int w, int h, float r = 1, float g = 1, float b = 1);
- static void addButtonImage(int id, Texture texture, int x, int y, int w, int h, float r = 1, float g = 1, float b = 1);
- static void addMapLine(int x, int y, int w, int h, float startsize, float endsize, float r, float g, float b);
- static void addMapMarker(int id, Texture texture, int x, int y, int w, int h, float r, float g, float b);
- static void addMapLabel(int id, const string& text, int x, int y, float r = 1, float g = 0, float b = 0);
- static void setText(int id, const string& text);
- static void setText(int id, const string& text, int x, int y, int w, int h);
- static int getSelected(int mousex, int mousey);
- static void drawItems();
-
- static void Load();
- static void Tick();
- static void updateSettingsMenu();
- static void updateStereoConfigMenu();
- static void updateControlsMenu();
- static void setKeySelected();
-
-private:
- static void handleFadeEffect();
-
- static std::vector<MenuItem> items;
-};
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _MENU_HPP_
+#define _MENU_HPP_
+
+#include "Game.hpp"
+
+struct MenuItem {
+ enum MenuItemType {NONE, LABEL, BUTTON, IMAGE, IMAGEBUTTON, MAPMARKER, MAPLINE, MAPLABEL} type;
+ int id;
+ string text;
+ Texture texture;
+ int x, y, w, h;
+ float r, g, b;
+ float effectfade;
+
+ float linestartsize;
+ float lineendsize;
+
+ MenuItem(MenuItemType _type, int _id, const string& _text, Texture _texture,
+ int _x, int _y, int _w, int _h, float _r, float _g, float _b,
+ float _linestartsize = 1, float _lineendsize = 1);
+};
+
+class Menu
+{
+public:
+ static void clearMenu();
+ static void addLabel(int id, const string& text, int x, int y, float r = 1, float g = 0, float b = 0);
+ static void addButton(int id, const string& text, int x, int y, float r = 1, float g = 0, float b = 0);
+ static void addImage(int id, Texture texture, int x, int y, int w, int h, float r = 1, float g = 1, float b = 1);
+ static void addButtonImage(int id, Texture texture, int x, int y, int w, int h, float r = 1, float g = 1, float b = 1);
+ static void addMapLine(int x, int y, int w, int h, float startsize, float endsize, float r, float g, float b);
+ static void addMapMarker(int id, Texture texture, int x, int y, int w, int h, float r, float g, float b);
+ static void addMapLabel(int id, const string& text, int x, int y, float r = 1, float g = 0, float b = 0);
+ static void setText(int id, const string& text);
+ static void setText(int id, const string& text, int x, int y, int w, int h);
+ static int getSelected(int mousex, int mousey);
+ static void drawItems();
+
+ static void Load();
+ static void Tick();
+ static void updateSettingsMenu();
+ static void updateStereoConfigMenu();
+ static void updateControlsMenu();
+ static void setKeySelected();
+
+private:
+ static void handleFadeEffect();
+
+ static std::vector<MenuItem> items;
+};
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Objects/Objects.h"
+#include "Objects/Objects.hpp"
extern XYZ viewer;
extern float viewdistance;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _OBJECTS_H_
-#define _OBJECTS_H_
-
-#include "Environment/Lights.h"
-#include "Environment/Terrain.h"
-#include "Graphic/gamegl.h"
-#include "Graphic/Models.h"
-#include "Graphic/Sprite.h"
-#include "Graphic/Texture.h"
-#include "Math/Frustum.h"
-#include "Math/Quaternions.h"
-#include "Math/Quaternions.h"
-#include "Utils/ImageIO.h"
-
-#include <vector>
-//
-// Model Structures
-//
-
-#define max_objects 300
-
-#define boxtype 0
-#define weirdtype 1
-#define spiketype 2
-#define treetrunktype 3
-#define treeleavestype 4
-#define bushtype 5
-#define rocktype 6
-#define walltype 7
-#define chimneytype 8
-#define platformtype 9
-#define tunneltype 11
-#define cooltype 12
-#define firetype 13
-
-
-class Objects
-{
-public:
- XYZ center;
- float radius;
- XYZ position[max_objects];
- int type[max_objects];
- float yaw[max_objects];
- float pitch[max_objects];
- float rotx[max_objects];
- float rotxvel[max_objects];
- float roty[max_objects];
- float rotyvel[max_objects];
- int numobjects;
- bool possible[max_objects];
- Model model[max_objects];
- Model displaymodel[max_objects];
- float friction[max_objects];
- float scale[max_objects];
- float messedwith[max_objects];
- float checked[max_objects];
- Texture boxtextureptr;
- Texture treetextureptr;
- Texture bushtextureptr;
- Texture rocktextureptr;
- float shadowed[max_objects];
- float occluded[max_objects];
- bool checkcollide(XYZ startpoint, XYZ endpoint, int which);
- bool onfire[max_objects];
- float flamedelay[max_objects];
-
- void SphereCheckPossible(XYZ *p1, float radius);
- void DeleteObject(int which);
- void MakeObject(int atype, XYZ where, float ayaw, float ascale);
- void MakeObject(int atype, XYZ where, float ayaw, float apitch, float ascale);
- void Draw();
- void DoShadows();
- void DoStuff();
-
- Objects();
- ~Objects();
-};
-
-#endif
-
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _OBJECTS_HPP_
+#define _OBJECTS_HPP_
+
+#include "Environment/Lights.hpp"
+#include "Environment/Terrain.hpp"
+#include "Graphic/gamegl.hpp"
+#include "Graphic/Models.hpp"
+#include "Graphic/Sprite.hpp"
+#include "Graphic/Texture.hpp"
+#include "Math/Frustum.hpp"
+#include "Math/Quaternions.hpp"
+#include "Utils/ImageIO.hpp"
+
+#include <vector>
+//
+// Model Structures
+//
+
+#define max_objects 300
+
+#define boxtype 0
+#define weirdtype 1
+#define spiketype 2
+#define treetrunktype 3
+#define treeleavestype 4
+#define bushtype 5
+#define rocktype 6
+#define walltype 7
+#define chimneytype 8
+#define platformtype 9
+#define tunneltype 11
+#define cooltype 12
+#define firetype 13
+
+
+class Objects
+{
+public:
+ XYZ center;
+ float radius;
+ XYZ position[max_objects];
+ int type[max_objects];
+ float yaw[max_objects];
+ float pitch[max_objects];
+ float rotx[max_objects];
+ float rotxvel[max_objects];
+ float roty[max_objects];
+ float rotyvel[max_objects];
+ int numobjects;
+ bool possible[max_objects];
+ Model model[max_objects];
+ Model displaymodel[max_objects];
+ float friction[max_objects];
+ float scale[max_objects];
+ float messedwith[max_objects];
+ float checked[max_objects];
+ Texture boxtextureptr;
+ Texture treetextureptr;
+ Texture bushtextureptr;
+ Texture rocktextureptr;
+ float shadowed[max_objects];
+ float occluded[max_objects];
+ bool checkcollide(XYZ startpoint, XYZ endpoint, int which);
+ bool onfire[max_objects];
+ float flamedelay[max_objects];
+
+ void SphereCheckPossible(XYZ *p1, float radius);
+ void DeleteObject(int which);
+ void MakeObject(int atype, XYZ where, float ayaw, float ascale);
+ void MakeObject(int atype, XYZ where, float ayaw, float apitch, float ascale);
+ void Draw();
+ void DoShadows();
+ void DoStuff();
+
+ Objects();
+ ~Objects();
+};
+
+#endif
+
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-/**> HEADER FILES <**/
-#include "Animation/Animation.h"
-#include "Audio/openal_wrapper.h"
-#include "Audio/Sounds.h"
-#include "Level/Awards.h"
-#include "Level/Dialog.h"
-#include "Objects/Person.h"
-#include "Utils/Folders.h"
-
-#include "Game.h"
+#include "Objects/Person.hpp"
+
+#include "Animation/Animation.hpp"
+#include "Audio/openal_wrapper.hpp"
+#include "Audio/Sounds.hpp"
+#include "Game.hpp"
+#include "Level/Awards.hpp"
+#include "Level/Dialog.hpp"
+#include "Utils/Folders.hpp"
extern float multiplier;
extern Terrain terrain;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _PERSON_H_
-#define _PERSON_H_
-
-/**> HEADER FILES <**/
-#include "Animation/Animation.h"
-#include "Animation/Skeleton.h"
-#include "Environment/Terrain.h"
-#include "Graphic/gamegl.h"
-#include "Graphic/Models.h"
-#include "Graphic/Sprite.h"
-#include "Math/Quaternions.h"
-#include "Objects/Weapons.h"
-
-#include <memory>
-#include <cmath>
-
-#define passivetype 0
-#define guardtype 1
-#define searchtype 2
-#define attacktype 3
-#define attacktypecutoff 4
-#define playercontrolled 5
-#define gethelptype 6
-#define getweapontype 7
-#define pathfindtype 8
-
-#define rabbittype 0
-#define wolftype 1
-
-struct InvalidPersonException : public exception {
- const char * what () const throw () {
- return "Invalid weapon number";
- }
-};
-
-class Person : public enable_shared_from_this<Person>
-{
-public:
- static std::vector<std::shared_ptr<Person>> players;
-
- int whichpatchx;
- int whichpatchz;
-
- // animCurrent and animTarget are used to interpolate between different animations
- // (and for a bunch of other things).
- // animations interpolate with one another at various speeds.
- // animTarget seems to determine the combat state?
- int animCurrent;
- int animTarget;
-
- // frameCurrent and frameTarget are used to interpolate between the frames of an animation
- // (e.g. the crouched animation has only two frames, lerped back and forth slowly).
- // animations advance at various speeds.
- int frameCurrent;
- int frameTarget;
-
- int oldanimCurrent;
- int oldanimTarget;
- int oldframeCurrent;
- int oldframeTarget;
-
- int howactive;
-
- float parriedrecently;
-
- bool superruntoggle;
-
- int lastattack, lastattack2, lastattack3;
-
- XYZ currentoffset, targetoffset, offset;
- float target;
- float transspeed;
-
- XYZ realoldcoords;
- XYZ oldcoords;
- XYZ coords;
- XYZ velocity;
-
- XYZ proportionhead;
- XYZ proportionlegs;
- XYZ proportionarms;
- XYZ proportionbody;
-
- float unconscioustime;
-
- bool immobile;
-
- float velspeed;
- float targetyaw;
- float targetrot;
- float rot;
- float oldrot;
- float lookyaw;
- float lookpitch;
- float yaw;
- float pitch;
- float lowyaw;
- float tilt;
- float targettilt;
- float tilt2;
- float targettilt2;
- bool rabbitkickenabled;
-
- float bloodloss;
- float bleeddelay;
- float skiddelay;
- float skiddingdelay;
- float deathbleeding;
- float tempdeltav;
-
- float damagetolerance;
- float damage;
- float permanentdamage;
- float superpermanentdamage;
- float lastcollide;
- /* Seems to be 0 = alive, 1 = unconscious, 2 = dead */
- int dead;
-
- float jumppower;
- bool onground;
-
- int wentforweapon;
-
- bool calcrot;
-
- XYZ facing;
-
- float bleeding;
- float bleedx, bleedy;
- int direction;
- float texupdatedelay;
-
- float headyaw, headpitch;
- float targetheadyaw, targetheadpitch;
-
- bool onterrain;
- bool pause;
-
- float grabdelay;
-
- std::shared_ptr<Person> victim;
- bool hasvictim;
-
- float updatedelay;
- float normalsupdatedelay;
-
- bool jumpstart;
-
- bool forwardkeydown;
- bool forwardstogglekeydown;
- bool rightkeydown;
- bool leftkeydown;
- bool backkeydown;
- bool jumpkeydown;
- bool jumptogglekeydown;
- bool crouchkeydown;
- bool crouchtogglekeydown;
- bool drawkeydown;
- bool drawtogglekeydown;
- bool throwkeydown;
- bool throwtogglekeydown;
- bool attackkeydown;
- bool feint;
- bool lastfeint;
- bool headless;
-
- float crouchkeydowntime;
- float jumpkeydowntime;
- bool freefall;
-
-
- float turnspeed;
-
- int aitype;
- float aiupdatedelay;
- float losupdatedelay;
- int ally;
- float collide;
- float collided;
- float avoidcollided;
- bool loaded;
- bool whichdirection;
- float whichdirectiondelay;
- bool avoidsomething;
- XYZ avoidwhere;
- float blooddimamount;
-
- float staggerdelay;
- float blinkdelay;
- float twitchdelay;
- float twitchdelay2;
- float twitchdelay3;
- float lefthandmorphness;
- float righthandmorphness;
- float headmorphness;
- float chestmorphness;
- float tailmorphness;
- float targetlefthandmorphness;
- float targetrighthandmorphness;
- float targetheadmorphness;
- float targetchestmorphness;
- float targettailmorphness;
- int lefthandmorphstart, lefthandmorphend;
- int righthandmorphstart, righthandmorphend;
- int headmorphstart, headmorphend;
- int chestmorphstart, chestmorphend;
- int tailmorphstart, tailmorphend;
-
- float weaponmissdelay;
- float highreversaldelay;
- float lowreversaldelay;
-
- int creature;
-
- unsigned id;
-
- Skeleton skeleton;
-
- float speed;
- float scale;
- float power;
- float speedmult;
-
- float protectionhead;
- float protectionhigh;
- float protectionlow;
- float armorhead;
- float armorhigh;
- float armorlow;
- bool metalhead;
- bool metalhigh;
- bool metallow;
-
- int numclothes;
- char clothes[10][256];
- float clothestintr[10];
- float clothestintg[10];
- float clothestintb[10];
-
- bool landhard;
- bool bled;
- bool spurt;
- bool onfire;
- float onfiredelay;
- float burnt;
-
- float flamedelay;
-
- int playerdetail;
-
- int num_weapons;
- int weaponids[4];
- /* Key of weaponids which is the weapon in hand, if any. -1 otherwise.
- * Always 0 or -1 as activeweapon is moved to position 0 when taken */
- int weaponactive;
- int weaponstuck;
- /* 0 or 1 to say if weapon is stuck in the front or the back */
- int weaponstuckwhere;
-
- int numwaypoints;
- XYZ waypoints[90];
- int waypointtype[90];
- float pausetime;
-
- XYZ headtarget;
- float interestdelay;
-
- XYZ finalfinaltarget;
- XYZ finaltarget;
- int finalpathfindpoint;
- int targetpathfindpoint;
- int lastpathfindpoint;
- int lastpathfindpoint2;
- int lastpathfindpoint3;
- int lastpathfindpoint4;
-
- int waypoint;
-
- XYZ lastseen;
- float lastseentime;
- float lastchecktime;
- float stunned;
- float surprised;
- float runninghowlong;
- int occluded;
- int lastoccluded;
- int laststanding;
- int escapednum;
-
- float speechdelay;
- float neckspurtdelay;
- float neckspurtparticledelay;
- float neckspurtamount;
-
- int whichskin;
- bool rabbitkickragdoll;
-
- Animation tempanimation;
-
- bool jumpclimb;
-
- Person();
- Person(FILE*, int, unsigned);
-
- void skeletonLoad(bool clothes = false);
-
- // convenience functions
- inline Joint& joint(int bodypart) { return skeleton.joints[skeleton.jointlabels[bodypart]]; }
- inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; }
- inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; }
- inline AnimationFrame& currentFrame() { return Animation::animations.at(animCurrent).frames.at(frameCurrent); }
- inline AnimationFrame& targetFrame() { return Animation::animations.at(animTarget).frames.at(frameTarget); }
-
-
- void CheckKick();
- void CatchFire();
- void DoBlood(float howmuch, int which);
- void DoBloodBig(float howmuch, int which);
- bool DoBloodBigWhere(float howmuch, int which, XYZ where);
-
- bool wasIdle() { return animation_bits[animCurrent] & ab_idle; }
- bool isIdle() { return animation_bits[animTarget] & ab_idle; }
- int getIdle();
-
- bool isSitting() { return animation_bits[animTarget] & ab_sit; }
-
- bool isSleeping() { return animation_bits[animTarget] & ab_sleep; }
-
- bool wasCrouch() { return animation_bits[animCurrent] & ab_crouch; }
- bool isCrouch() { return animation_bits[animTarget] & ab_crouch; }
- int getCrouch();
-
- bool wasStop() { return animation_bits[animCurrent] & ab_stop; }
- bool isStop() { return animation_bits[animTarget] & ab_stop; }
- int getStop();
-
- bool wasSneak();
- bool isSneak();
- int getSneak();
-
- bool wasRun() { return animation_bits[animCurrent] & ab_run; }
- bool isRun() { return animation_bits[animTarget] & ab_run; }
- int getRun();
-
- bool wasLanding() { return animation_bits[animCurrent] & ab_land; }
- bool isLanding() { return animation_bits[animTarget] & ab_land; }
- int getLanding();
-
- bool wasLandhard() { return animation_bits[animCurrent] & ab_landhard; }
- bool isLandhard() { return animation_bits[animTarget] & ab_landhard; }
- int getLandhard();
-
- bool wasFlip() { return animation_bits[animCurrent] & ab_flip; }
- bool isFlip() { return animation_bits[animTarget] & ab_flip; }
-
- bool isWallJump() { return animation_bits[animTarget] & ab_walljump; }
- void Reverse();
- void DoDamage(float howmuch);
- void DoHead();
- void DoMipmaps() {
- skeleton.drawmodel.textureptr.bind();
- glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, skeleton.skinsize, skeleton.skinsize, 0, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0]);
- }
-
- int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model);
- int DrawSkeleton();
- void Puff(int whichlabel);
- void FootLand(bodypart whichfoot, float opacity);
- void DoStuff();
- void setAnimation(int);
- void DoAnimations();
- void RagDoll(bool checkcollision);
-
- void takeWeapon (int weaponId);
-
- bool addClothes(const int& clothesId);
- void addClothes();
-};
-
-const int maxplayers = 10;
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _PERSON_HPP_
+#define _PERSON_HPP_
+
+#include "Animation/Animation.hpp"
+#include "Animation/Skeleton.hpp"
+#include "Environment/Terrain.hpp"
+#include "Graphic/gamegl.hpp"
+#include "Graphic/Models.hpp"
+#include "Graphic/Sprite.hpp"
+#include "Math/Quaternions.hpp"
+#include "Objects/Weapons.hpp"
+
+#include <cmath>
+#include <memory>
+
+#define passivetype 0
+#define guardtype 1
+#define searchtype 2
+#define attacktype 3
+#define attacktypecutoff 4
+#define playercontrolled 5
+#define gethelptype 6
+#define getweapontype 7
+#define pathfindtype 8
+
+#define rabbittype 0
+#define wolftype 1
+
+struct InvalidPersonException : public exception {
+ const char * what () const throw () {
+ return "Invalid weapon number";
+ }
+};
+
+class Person : public enable_shared_from_this<Person>
+{
+public:
+ static std::vector<std::shared_ptr<Person>> players;
+
+ int whichpatchx;
+ int whichpatchz;
+
+ // animCurrent and animTarget are used to interpolate between different animations
+ // (and for a bunch of other things).
+ // animations interpolate with one another at various speeds.
+ // animTarget seems to determine the combat state?
+ int animCurrent;
+ int animTarget;
+
+ // frameCurrent and frameTarget are used to interpolate between the frames of an animation
+ // (e.g. the crouched animation has only two frames, lerped back and forth slowly).
+ // animations advance at various speeds.
+ int frameCurrent;
+ int frameTarget;
+
+ int oldanimCurrent;
+ int oldanimTarget;
+ int oldframeCurrent;
+ int oldframeTarget;
+
+ int howactive;
+
+ float parriedrecently;
+
+ bool superruntoggle;
+
+ int lastattack, lastattack2, lastattack3;
+
+ XYZ currentoffset, targetoffset, offset;
+ float target;
+ float transspeed;
+
+ XYZ realoldcoords;
+ XYZ oldcoords;
+ XYZ coords;
+ XYZ velocity;
+
+ XYZ proportionhead;
+ XYZ proportionlegs;
+ XYZ proportionarms;
+ XYZ proportionbody;
+
+ float unconscioustime;
+
+ bool immobile;
+
+ float velspeed;
+ float targetyaw;
+ float targetrot;
+ float rot;
+ float oldrot;
+ float lookyaw;
+ float lookpitch;
+ float yaw;
+ float pitch;
+ float lowyaw;
+ float tilt;
+ float targettilt;
+ float tilt2;
+ float targettilt2;
+ bool rabbitkickenabled;
+
+ float bloodloss;
+ float bleeddelay;
+ float skiddelay;
+ float skiddingdelay;
+ float deathbleeding;
+ float tempdeltav;
+
+ float damagetolerance;
+ float damage;
+ float permanentdamage;
+ float superpermanentdamage;
+ float lastcollide;
+ /* Seems to be 0 = alive, 1 = unconscious, 2 = dead */
+ int dead;
+
+ float jumppower;
+ bool onground;
+
+ int wentforweapon;
+
+ bool calcrot;
+
+ XYZ facing;
+
+ float bleeding;
+ float bleedx, bleedy;
+ int direction;
+ float texupdatedelay;
+
+ float headyaw, headpitch;
+ float targetheadyaw, targetheadpitch;
+
+ bool onterrain;
+ bool pause;
+
+ float grabdelay;
+
+ std::shared_ptr<Person> victim;
+ bool hasvictim;
+
+ float updatedelay;
+ float normalsupdatedelay;
+
+ bool jumpstart;
+
+ bool forwardkeydown;
+ bool forwardstogglekeydown;
+ bool rightkeydown;
+ bool leftkeydown;
+ bool backkeydown;
+ bool jumpkeydown;
+ bool jumptogglekeydown;
+ bool crouchkeydown;
+ bool crouchtogglekeydown;
+ bool drawkeydown;
+ bool drawtogglekeydown;
+ bool throwkeydown;
+ bool throwtogglekeydown;
+ bool attackkeydown;
+ bool feint;
+ bool lastfeint;
+ bool headless;
+
+ float crouchkeydowntime;
+ float jumpkeydowntime;
+ bool freefall;
+
+
+ float turnspeed;
+
+ int aitype;
+ float aiupdatedelay;
+ float losupdatedelay;
+ int ally;
+ float collide;
+ float collided;
+ float avoidcollided;
+ bool loaded;
+ bool whichdirection;
+ float whichdirectiondelay;
+ bool avoidsomething;
+ XYZ avoidwhere;
+ float blooddimamount;
+
+ float staggerdelay;
+ float blinkdelay;
+ float twitchdelay;
+ float twitchdelay2;
+ float twitchdelay3;
+ float lefthandmorphness;
+ float righthandmorphness;
+ float headmorphness;
+ float chestmorphness;
+ float tailmorphness;
+ float targetlefthandmorphness;
+ float targetrighthandmorphness;
+ float targetheadmorphness;
+ float targetchestmorphness;
+ float targettailmorphness;
+ int lefthandmorphstart, lefthandmorphend;
+ int righthandmorphstart, righthandmorphend;
+ int headmorphstart, headmorphend;
+ int chestmorphstart, chestmorphend;
+ int tailmorphstart, tailmorphend;
+
+ float weaponmissdelay;
+ float highreversaldelay;
+ float lowreversaldelay;
+
+ int creature;
+
+ unsigned id;
+
+ Skeleton skeleton;
+
+ float speed;
+ float scale;
+ float power;
+ float speedmult;
+
+ float protectionhead;
+ float protectionhigh;
+ float protectionlow;
+ float armorhead;
+ float armorhigh;
+ float armorlow;
+ bool metalhead;
+ bool metalhigh;
+ bool metallow;
+
+ int numclothes;
+ char clothes[10][256];
+ float clothestintr[10];
+ float clothestintg[10];
+ float clothestintb[10];
+
+ bool landhard;
+ bool bled;
+ bool spurt;
+ bool onfire;
+ float onfiredelay;
+ float burnt;
+
+ float flamedelay;
+
+ int playerdetail;
+
+ int num_weapons;
+ int weaponids[4];
+ /* Key of weaponids which is the weapon in hand, if any. -1 otherwise.
+ * Always 0 or -1 as activeweapon is moved to position 0 when taken */
+ int weaponactive;
+ int weaponstuck;
+ /* 0 or 1 to say if weapon is stuck in the front or the back */
+ int weaponstuckwhere;
+
+ int numwaypoints;
+ XYZ waypoints[90];
+ int waypointtype[90];
+ float pausetime;
+
+ XYZ headtarget;
+ float interestdelay;
+
+ XYZ finalfinaltarget;
+ XYZ finaltarget;
+ int finalpathfindpoint;
+ int targetpathfindpoint;
+ int lastpathfindpoint;
+ int lastpathfindpoint2;
+ int lastpathfindpoint3;
+ int lastpathfindpoint4;
+
+ int waypoint;
+
+ XYZ lastseen;
+ float lastseentime;
+ float lastchecktime;
+ float stunned;
+ float surprised;
+ float runninghowlong;
+ int occluded;
+ int lastoccluded;
+ int laststanding;
+ int escapednum;
+
+ float speechdelay;
+ float neckspurtdelay;
+ float neckspurtparticledelay;
+ float neckspurtamount;
+
+ int whichskin;
+ bool rabbitkickragdoll;
+
+ Animation tempanimation;
+
+ bool jumpclimb;
+
+ Person();
+ Person(FILE*, int, unsigned);
+
+ void skeletonLoad(bool clothes = false);
+
+ // convenience functions
+ inline Joint& joint(int bodypart) { return skeleton.joints[skeleton.jointlabels[bodypart]]; }
+ inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; }
+ inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; }
+ inline AnimationFrame& currentFrame() { return Animation::animations.at(animCurrent).frames.at(frameCurrent); }
+ inline AnimationFrame& targetFrame() { return Animation::animations.at(animTarget).frames.at(frameTarget); }
+
+
+ void CheckKick();
+ void CatchFire();
+ void DoBlood(float howmuch, int which);
+ void DoBloodBig(float howmuch, int which);
+ bool DoBloodBigWhere(float howmuch, int which, XYZ where);
+
+ bool wasIdle() { return animation_bits[animCurrent] & ab_idle; }
+ bool isIdle() { return animation_bits[animTarget] & ab_idle; }
+ int getIdle();
+
+ bool isSitting() { return animation_bits[animTarget] & ab_sit; }
+
+ bool isSleeping() { return animation_bits[animTarget] & ab_sleep; }
+
+ bool wasCrouch() { return animation_bits[animCurrent] & ab_crouch; }
+ bool isCrouch() { return animation_bits[animTarget] & ab_crouch; }
+ int getCrouch();
+
+ bool wasStop() { return animation_bits[animCurrent] & ab_stop; }
+ bool isStop() { return animation_bits[animTarget] & ab_stop; }
+ int getStop();
+
+ bool wasSneak();
+ bool isSneak();
+ int getSneak();
+
+ bool wasRun() { return animation_bits[animCurrent] & ab_run; }
+ bool isRun() { return animation_bits[animTarget] & ab_run; }
+ int getRun();
+
+ bool wasLanding() { return animation_bits[animCurrent] & ab_land; }
+ bool isLanding() { return animation_bits[animTarget] & ab_land; }
+ int getLanding();
+
+ bool wasLandhard() { return animation_bits[animCurrent] & ab_landhard; }
+ bool isLandhard() { return animation_bits[animTarget] & ab_landhard; }
+ int getLandhard();
+
+ bool wasFlip() { return animation_bits[animCurrent] & ab_flip; }
+ bool isFlip() { return animation_bits[animTarget] & ab_flip; }
+
+ bool isWallJump() { return animation_bits[animTarget] & ab_walljump; }
+ void Reverse();
+ void DoDamage(float howmuch);
+ void DoHead();
+ void DoMipmaps() {
+ skeleton.drawmodel.textureptr.bind();
+ glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, skeleton.skinsize, skeleton.skinsize, 0, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0]);
+ }
+
+ int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model);
+ int DrawSkeleton();
+ void Puff(int whichlabel);
+ void FootLand(bodypart whichfoot, float opacity);
+ void DoStuff();
+ void setAnimation(int);
+ void DoAnimations();
+ void RagDoll(bool checkcollision);
+
+ void takeWeapon (int weaponId);
+
+ bool addClothes(const int& clothesId);
+ void addClothes();
+};
+
+const int maxplayers = 10;
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-/**> HEADER FILES <**/
-#include "Animation/Animation.h"
-#include "Audio/openal_wrapper.h"
-#include "Audio/Sounds.h"
-#include "Level/Awards.h"
-#include "Objects/Weapons.h"
-
-#include "Game.h"
+#include "Objects/Weapons.hpp"
+
+#include "Animation/Animation.hpp"
+#include "Audio/openal_wrapper.hpp"
+#include "Audio/Sounds.hpp"
+#include "Game.hpp"
+#include "Level/Awards.hpp"
extern float multiplier;
extern Terrain terrain;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _WEAPONS_H_
-#define _WEAPONS_H_
-
-/**> HEADER FILES <**/
-#include "Animation/Skeleton.h"
-#include "Environment/Terrain.h"
-#include "Graphic/gamegl.h"
-#include "Graphic/Models.h"
-#include "Graphic/Sprite.h"
-#include "Graphic/Texture.h"
-#include "Math/Quaternions.h"
-#include "Objects/Person.h"
-
-#include <cmath>
-
-#define max_weapons 30
-#define max_weaponinstances 20
-
-#define knife 1
-#define sword 2
-#define staff 3
-
-class Weapon
-{
-public:
- Weapon(int type, int owner);
-
- static Model throwingknifemodel;
- static Texture knifetextureptr;
- static Texture lightbloodknifetextureptr;
- static Texture bloodknifetextureptr;
-
- static Model swordmodel;
- static Texture swordtextureptr;
- static Texture lightbloodswordtextureptr;
- static Texture bloodswordtextureptr;
-
- static Model staffmodel;
- static Texture stafftextureptr;
-
- void Draw();
- void DoStuff(int);
-
- int getType() {
- return type;
- }
- void setType(int);
-
- void drop(XYZ velocity, XYZ tipvelocity, bool sethitsomething = true);
- void thrown(XYZ velocity, bool sethitsomething = true);
-
- int owner;
- XYZ position;
- XYZ tippoint;
- XYZ velocity;
- XYZ tipvelocity;
- bool missed;
- bool hitsomething;
- float freetime;
- bool firstfree;
- bool physics;
-
- float damage;
- int bloody;
- float blooddrip;
- float blooddripdelay;
-
- float rotation1;
- float rotation2;
- float rotation3;
- float bigrotation;
- float bigtilt;
- float bigtilt2;
- float smallrotation;
- float smallrotation2;
-private:
- int type;
-
- XYZ oldtippoint;
- XYZ oldposition;
- int oldowner;
- bool onfire;
- float flamedelay;
- float mass;
- float tipmass;
- float length;
- float drawhowmany;
-
- XYZ lastdrawnposition;
- XYZ lastdrawntippoint;
- float lastdrawnrotation1;
- float lastdrawnrotation2;
- float lastdrawnrotation3;
- float lastdrawnbigrotation;
- float lastdrawnbigtilt;
- float lastdrawnbigtilt2;
- float lastdrawnsmallrotation;
- float lastdrawnsmallrotation2;
- int lastdrawnanim;
-};
-
-class Weapons : public std::vector<Weapon>
-{
-public:
- Weapons();
- ~Weapons();
-
- int Draw();
- void DoStuff();
-};
-
-extern Weapons weapons;
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _WEAPONS_HPP_
+#define _WEAPONS_HPP_
+
+#include "Animation/Skeleton.hpp"
+#include "Environment/Terrain.hpp"
+#include "Graphic/gamegl.hpp"
+#include "Graphic/Models.hpp"
+#include "Graphic/Sprite.hpp"
+#include "Graphic/Texture.hpp"
+#include "Math/Quaternions.hpp"
+#include "Objects/Person.hpp"
+
+#include <cmath>
+
+#define max_weapons 30
+#define max_weaponinstances 20
+
+#define knife 1
+#define sword 2
+#define staff 3
+
+class Weapon
+{
+public:
+ Weapon(int type, int owner);
+
+ static Model throwingknifemodel;
+ static Texture knifetextureptr;
+ static Texture lightbloodknifetextureptr;
+ static Texture bloodknifetextureptr;
+
+ static Model swordmodel;
+ static Texture swordtextureptr;
+ static Texture lightbloodswordtextureptr;
+ static Texture bloodswordtextureptr;
+
+ static Model staffmodel;
+ static Texture stafftextureptr;
+
+ void Draw();
+ void DoStuff(int);
+
+ int getType() {
+ return type;
+ }
+ void setType(int);
+
+ void drop(XYZ velocity, XYZ tipvelocity, bool sethitsomething = true);
+ void thrown(XYZ velocity, bool sethitsomething = true);
+
+ int owner;
+ XYZ position;
+ XYZ tippoint;
+ XYZ velocity;
+ XYZ tipvelocity;
+ bool missed;
+ bool hitsomething;
+ float freetime;
+ bool firstfree;
+ bool physics;
+
+ float damage;
+ int bloody;
+ float blooddrip;
+ float blooddripdelay;
+
+ float rotation1;
+ float rotation2;
+ float rotation3;
+ float bigrotation;
+ float bigtilt;
+ float bigtilt2;
+ float smallrotation;
+ float smallrotation2;
+private:
+ int type;
+
+ XYZ oldtippoint;
+ XYZ oldposition;
+ int oldowner;
+ bool onfire;
+ float flamedelay;
+ float mass;
+ float tipmass;
+ float length;
+ float drawhowmany;
+
+ XYZ lastdrawnposition;
+ XYZ lastdrawntippoint;
+ float lastdrawnrotation1;
+ float lastdrawnrotation2;
+ float lastdrawnrotation3;
+ float lastdrawnbigrotation;
+ float lastdrawnbigtilt;
+ float lastdrawnbigtilt2;
+ float lastdrawnsmallrotation;
+ float lastdrawnsmallrotation2;
+ int lastdrawnanim;
+};
+
+class Weapons : public std::vector<Weapon>
+{
+public:
+ Weapons();
+ ~Weapons();
+
+ int Draw();
+ void DoStuff();
+};
+
+extern Weapons weapons;
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "User/Account.h"
+#include "User/Account.hpp"
+
+#include "MacCompatibility.hpp"
#include "Utils/binio.h"
-#include "MacCompatibility.h"
+
#include <fstream>
-#include "string.h"
#include <iostream>
+#include <string.h>
using namespace std;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _Account_H_
-#define _Account_H_
-
-#include <vector>
-#include <string>
-#include <map>
-#include <fstream>
-
-struct CampaignProgress {
- float highscore;
- float fasttime;
- float score;
- float time;
- std::vector<int> choices;
- CampaignProgress() {
- highscore = 0;
- fasttime = 0;
- score = 0;
- time = 0;
- }
-};
-
-class Account
-{
-public:
- static void destroyActive();
- static void setActive(int i);
- static void add(const std::string& name);
- static Account& get(int i);
- static void loadFile(std::string filename);
- static void saveFile(std::string filename);
- static int getNbAccounts();
-
- static bool hasActive();
- static Account& active();
-
- Account(const std::string& name = "");
- Account(FILE* tfile);
-
- void endGame();
- void winCampaignLevel(int choice, float score, float time);
- void winLevel(int level, float score, float time);
-
- // getter and setters
- int getDifficulty();
- void setDifficulty(int i) {
- difficulty = i;
- };
- const std::string& getName() {
- return name;
- };
- float getCampaignScore() {
- return campaignProgress[currentCampaign].score;
- };
- int getCampaignChoicesMade() {
- return campaignProgress[currentCampaign].choices.size();
- };
- int getCampaignChoice(int i) {
- return campaignProgress[currentCampaign].choices[i];
- };
- void setCampaignScore(int s) {
- campaignProgress[currentCampaign].score = s;
- if (s > campaignProgress[currentCampaign].highscore)
- campaignProgress[currentCampaign].highscore = s;
- };
- void setCampaignFinalTime(float t) {
- campaignProgress[currentCampaign].time = t;
- if ((t < campaignProgress[currentCampaign].fasttime) || ((campaignProgress[currentCampaign].fasttime == 0) && (t != 0)))
- campaignProgress[currentCampaign].fasttime = t;
- };
- float getCampaignFasttime() {
- return campaignProgress[currentCampaign].fasttime;
- };
- void resetFasttime() {
- campaignProgress[currentCampaign].fasttime = 0;
- };
- float getCampaignHighScore() {
- return campaignProgress[currentCampaign].highscore;
- };
- float getHighScore(int i) {
- return highscore[i];
- };
- float getFastTime(int i) {
- return fasttime[i];
- };
- int getProgress() {
- return progress;
- };
- std::string getCurrentCampaign() {
- return currentCampaign;
- };
- void setCurrentCampaign(const std::string& name);
-
-private:
- //statics
- static std::vector<Account> accounts;
- static int i_active;
-
- void save(FILE* tfile);
-
- int difficulty;
- int progress; // progress in challenge levels
- float points;
- float highscore[50];
- float fasttime[50];
- bool unlocked[60];
- std::string name;
-
- std::string currentCampaign;
- std::map<std::string, CampaignProgress> campaignProgress;
-};
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _ACCOUNT_HPP_
+#define _ACCOUNT_HPP_
+
+#include <fstream>
+#include <map>
+#include <string>
+#include <vector>
+
+struct CampaignProgress {
+ float highscore;
+ float fasttime;
+ float score;
+ float time;
+ std::vector<int> choices;
+ CampaignProgress() {
+ highscore = 0;
+ fasttime = 0;
+ score = 0;
+ time = 0;
+ }
+};
+
+class Account
+{
+public:
+ static void destroyActive();
+ static void setActive(int i);
+ static void add(const std::string& name);
+ static Account& get(int i);
+ static void loadFile(std::string filename);
+ static void saveFile(std::string filename);
+ static int getNbAccounts();
+
+ static bool hasActive();
+ static Account& active();
+
+ Account(const std::string& name = "");
+ Account(FILE* tfile);
+
+ void endGame();
+ void winCampaignLevel(int choice, float score, float time);
+ void winLevel(int level, float score, float time);
+
+ // getter and setters
+ int getDifficulty();
+ void setDifficulty(int i) {
+ difficulty = i;
+ };
+ const std::string& getName() {
+ return name;
+ };
+ float getCampaignScore() {
+ return campaignProgress[currentCampaign].score;
+ };
+ int getCampaignChoicesMade() {
+ return campaignProgress[currentCampaign].choices.size();
+ };
+ int getCampaignChoice(int i) {
+ return campaignProgress[currentCampaign].choices[i];
+ };
+ void setCampaignScore(int s) {
+ campaignProgress[currentCampaign].score = s;
+ if (s > campaignProgress[currentCampaign].highscore)
+ campaignProgress[currentCampaign].highscore = s;
+ };
+ void setCampaignFinalTime(float t) {
+ campaignProgress[currentCampaign].time = t;
+ if ((t < campaignProgress[currentCampaign].fasttime) || ((campaignProgress[currentCampaign].fasttime == 0) && (t != 0)))
+ campaignProgress[currentCampaign].fasttime = t;
+ };
+ float getCampaignFasttime() {
+ return campaignProgress[currentCampaign].fasttime;
+ };
+ void resetFasttime() {
+ campaignProgress[currentCampaign].fasttime = 0;
+ };
+ float getCampaignHighScore() {
+ return campaignProgress[currentCampaign].highscore;
+ };
+ float getHighScore(int i) {
+ return highscore[i];
+ };
+ float getFastTime(int i) {
+ return fasttime[i];
+ };
+ int getProgress() {
+ return progress;
+ };
+ std::string getCurrentCampaign() {
+ return currentCampaign;
+ };
+ void setCurrentCampaign(const std::string& name);
+
+private:
+ //statics
+ static std::vector<Account> accounts;
+ static int i_active;
+
+ void save(FILE* tfile);
+
+ int difficulty;
+ int progress; // progress in challenge levels
+ float points;
+ float highscore[50];
+ float fasttime[50];
+ bool unlocked[60];
+ std::string name;
+
+ std::string currentCampaign;
+ std::map<std::string, CampaignProgress> campaignProgress;
+};
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Game.h"
-#include "User/Settings.h"
-#include "Utils/Folders.h"
-#include "Utils/Input.h"
+#include "User/Settings.hpp"
+
+#include "Game.hpp"
+#include "Utils/Folders.hpp"
+#include "Utils/Input.hpp"
using namespace Game;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef SETTINGS_H_
-#define SETTINGS_H_
-
-#include "Game.h"
-
-extern float usermousesensitivity;
-extern bool ismotionblur;
-extern bool floatjump;
-extern bool mousejump;
-extern bool ambientsound;
-extern int bloodtoggle;
-extern bool autoslomo;
-extern bool foliage;
-extern bool musictoggle;
-extern bool trilinear;
-extern bool decals;
-extern bool invertmouse;
-extern float gamespeed;
-extern float oldgamespeed;
-extern bool damageeffects;
-extern bool texttoggle;
-extern bool devtools;
-extern bool showpoints;
-extern bool showdamagebar;
-extern bool alwaysblur;
-extern bool immediate;
-extern bool velocityblur;
-extern float volume;
-extern int detail;
-extern int kContextWidth;
-extern int kContextHeight;
-extern float screenwidth, screenheight;
-extern bool fullscreen;
-
-void DefaultSettings();
-void SaveSettings();
-bool LoadSettings();
-
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _SETTINGS_HPP_
+#define _SETTINGS_HPP_
+
+#include "Game.hpp"
+
+extern float usermousesensitivity;
+extern bool ismotionblur;
+extern bool floatjump;
+extern bool mousejump;
+extern bool ambientsound;
+extern int bloodtoggle;
+extern bool autoslomo;
+extern bool foliage;
+extern bool musictoggle;
+extern bool trilinear;
+extern bool decals;
+extern bool invertmouse;
+extern float gamespeed;
+extern float oldgamespeed;
+extern bool damageeffects;
+extern bool texttoggle;
+extern bool devtools;
+extern bool showpoints;
+extern bool showdamagebar;
+extern bool alwaysblur;
+extern bool immediate;
+extern bool velocityblur;
+extern float volume;
+extern int detail;
+extern int kContextWidth;
+extern int kContextHeight;
+extern float screenwidth, screenheight;
+extern bool fullscreen;
+
+void DefaultSettings();
+void SaveSettings();
+bool LoadSettings();
+
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Folders.h"
+#include "Folders.hpp"
+
#include <cstring>
#include <unistd.h>
+
#if PLATFORM_UNIX
+#include <pwd.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <pwd.h>
#endif
+
#if _WIN32
-#include <windows.h>
#include <shlobj.h> // to get paths related functions
+#include <windows.h>
#endif
const std::string Folders::dataDir = DATA_DIR;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _FOLDERS_H_
-#define _FOLDERS_H_
-
-#include <string>
-
-#ifndef DATA_DIR
-#define DATA_DIR "Data"
-#endif
-
-struct FileNotFoundException: public std::exception
-{
- std::string errorText;
- FileNotFoundException (const std::string& filename) {
- errorText = filename + " could not be found";
- }
-
- const char * what () const throw () {
- return errorText.c_str();
- }
-};
-
-class Folders
-{
- static const std::string dataDir;
-
-public:
- /* Returns path to the screenshot directory. Creates it if needed. */
- static std::string getScreenshotDir();
-
- /* Returns full path for a game resource */
- static std::string getResourcePath(std::string filepath);
-
- /* Returns full path for user data */
- static std::string getUserDataPath();
-
- /* Returns full path for config file */
- static std::string getConfigFilePath();
-
- static FILE* openMandatoryFile(std::string filename, const char* mode);
-
-private:
- static const char* getHomeDirectory();
- static std::string getGenericDirectory(const char* ENVVAR, const std::string fallback);
- static bool makeDirectory(std::string path);
-};
-
-#endif /* _FOLDERS_H_ */
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _FOLDERS_HPP_
+#define _FOLDERS_HPP_
+
+#include <string>
+
+#ifndef DATA_DIR
+#define DATA_DIR "Data"
+#endif
+
+struct FileNotFoundException: public std::exception
+{
+ std::string errorText;
+ FileNotFoundException (const std::string& filename) {
+ errorText = filename + " could not be found";
+ }
+
+ const char * what () const throw () {
+ return errorText.c_str();
+ }
+};
+
+class Folders
+{
+ static const std::string dataDir;
+
+public:
+ /* Returns path to the screenshot directory. Creates it if needed. */
+ static std::string getScreenshotDir();
+
+ /* Returns full path for a game resource */
+ static std::string getResourcePath(std::string filepath);
+
+ /* Returns full path for user data */
+ static std::string getUserDataPath();
+
+ /* Returns full path for config file */
+ static std::string getConfigFilePath();
+
+ static FILE* openMandatoryFile(std::string filename, const char* mode);
+
+private:
+ static const char* getHomeDirectory();
+ static std::string getGenericDirectory(const char* ENVVAR, const std::string fallback);
+ static bool makeDirectory(std::string path);
+};
+
+#endif /* _FOLDERS_H_ */
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-/**> HEADER FILES <**/
+#include "Utils/ImageIO.hpp"
+
+#include "Game.hpp"
+#include "Utils/Folders.hpp"
-#include <stdio.h>
#include <jpeglib.h>
#include <png.h>
+#include <stdio.h>
#include <zlib.h>
-#include "Game.h"
-#include "Utils/ImageIO.h"
-#include "Utils/Folders.h"
-
extern bool visibleloading;
/* These two are needed for screenshot */
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _IMAGE_IO_H_
-#define _IMAGE_IO_H_
-
-#ifdef _MSC_VER
-#pragma once
-#endif
-
-
-/**> HEADER FILES <**/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef WIN32
-#define WIN32_LEAN_AND_MEAN
-#define Polygon WinPolygon
-#include <windows.h>
-#undef Polygon
-#include "GL/gl.h"
-#else
-#include "Graphic/gamegl.h"
-#endif
-
-/**> DATA STRUCTURES <**/
-class ImageRec {
-public:
- GLubyte *data; // Image Data (Up To 32 Bits)
- GLuint bpp; // Image Color Depth In Bits Per Pixel.
- GLuint sizeX;
- GLuint sizeY;
- ImageRec();
- ~ImageRec();
-private:
- /* Make sure this class cannot be copied to avoid memory problems */
- ImageRec(ImageRec const &);
- ImageRec& operator=(ImageRec const &);
-};
-
-bool load_image(const char * fname, ImageRec & tex);
-bool save_screenshot(const char * fname);
-
-#endif
-
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _IMAGE_IO_HPP_
+#define _IMAGE_IO_HPP_
+
+#ifdef _MSC_VER
+#pragma once
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
+#define Polygon WinPolygon
+#include <windows.h>
+#undef Polygon
+#include <GL/gl.h>
+#else
+#include "Graphic/gamegl.hpp"
+#endif
+
+/**> DATA STRUCTURES <**/
+class ImageRec {
+public:
+ GLubyte *data; // Image Data (Up To 32 Bits)
+ GLuint bpp; // Image Color Depth In Bits Per Pixel.
+ GLuint sizeX;
+ GLuint sizeY;
+ ImageRec();
+ ~ImageRec();
+private:
+ /* Make sure this class cannot be copied to avoid memory problems */
+ ImageRec(ImageRec const &);
+ ImageRec& operator=(ImageRec const &);
+};
+
+bool load_image(const char * fname, ImageRec & tex);
+bool save_screenshot(const char * fname);
+
+#endif
+
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-/**> HEADER FILES <**/
-#include "Utils/Input.h"
+#include "Utils/Input.hpp"
bool keyDown[SDL_NUM_SCANCODES + 6];
bool keyPressed[SDL_NUM_SCANCODES + 6];
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _Input_H_
-#define _Input_H_
-
-/**> HEADER FILES <**/
-#include "SDL.h"
-#include "Game.h"
-
-/**> CONSTANT DECLARATIONS <**/
-#define MOUSEBUTTON1 (SDL_NUM_SCANCODES + SDL_BUTTON_LEFT)
-#define MOUSEBUTTON2 (SDL_NUM_SCANCODES + SDL_BUTTON_RIGHT)
-#define MOUSEBUTTON3 (SDL_NUM_SCANCODES + SDL_BUTTON_MIDDLE)
-
-/**> FUNCTION PROTOTYPES <**/
-class Input
-{
-public:
- static void Tick();
- static bool isKeyDown(int k);
- static bool isKeyPressed(int k);
- static const char* keyToChar(unsigned short which);
- static unsigned short CharToKey(const char* which);
- static bool MouseClicked();
-};
-
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _INPUT_HPP_
+#define _INPUT_HPP_
+
+#include "Game.hpp"
+
+#include <SDL.h>
+
+/**> CONSTANT DECLARATIONS <**/
+#define MOUSEBUTTON1 (SDL_NUM_SCANCODES + SDL_BUTTON_LEFT)
+#define MOUSEBUTTON2 (SDL_NUM_SCANCODES + SDL_BUTTON_RIGHT)
+#define MOUSEBUTTON3 (SDL_NUM_SCANCODES + SDL_BUTTON_MIDDLE)
+
+/**> FUNCTION PROTOTYPES <**/
+class Input
+{
+public:
+ static void Tick();
+ static bool isKeyDown(int k);
+ static bool isKeyPressed(int k);
+ static const char* keyToChar(unsigned short which);
+ static unsigned short CharToKey(const char* which);
+ static bool MouseClicked();
+};
+
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdlib.h>
-
#include "binio.h"
#include "private.h"
+#include <stdlib.h>
+
struct BinIOPackContext {
uint8_t *buffer;
va_list args;
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <string.h>
-
#include "private.h"
+#include <string.h>
+
void BinIOConvert1(int from_byte_order, int to_byte_order,
const uint8_t *src, uint8_t *dst,
unsigned int count)
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdlib.h>
-
#include "binio.h"
#include "private.h"
+#include <stdlib.h>
+
struct BinIOUnpackContext {
const uint8_t *data;
va_list args;
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-/**> HEADER FILES <**/
-#include "WinDefs.h"
-#include <windows.h>
+#include "WinDefs.hpp"
+
#include <errno.h>
-#include <time.h>
#include <stdio.h>
+#include <time.h>
+#include <windows.h>
class AppTime
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _WINDEFS_H_
-#define _WINDEFS_H_
-#ifdef WIN32
-
-
-#include <stdio.h>
-#include <math.h>
-
-// stuff to make Mac code compatable with Windows
-
-
-// disable warnings about double to float conversions
-#pragma warning(disable:4305)
-#pragma warning(disable:4244)
-
-// disable warnings about boolean to int conversions
-#pragma warning(disable:4800)
-
-// disable warning about unreferenced local variables
-#pragma warning(disable:4101)
-
-struct Point {
- short v;
- short h;
-};
-
-typedef signed char SInt8;
-typedef unsigned int UInt32;
-
-
-#include "Math/Random.h"
-
-
-typedef struct AbsoluteTime {
- unsigned long hi;
- unsigned long lo;
-} AbsoluteTime;
-
-AbsoluteTime UpTime(); // NOTE: returns time since app started, not system start
-
-typedef long Duration;
-
-enum {
- durationMicrosecond = -1,
- durationMillisecond = 1,
- durationSecond = 1000,
- durationMinute = 1000 * 60,
- durationHour = 1000 * 60 * 60,
- durationDay = 1000 * 60 * 60 * 24,
- durationForever = 0x7FFFFFFF,
- durationImmediate = 0,
-};
-
-Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b);
-
-#ifndef __MINGW32__
-inline float abs(float f)
-{
- if (f < 0)
- return -f;
- return f;
-}
-
-inline double abs(double f)
-{
- if (f < 0)
- return -f;
- return f;
-}
-#endif // __MINGW32__
-
-
-#endif
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _WINDEFS_HPP_
+#define _WINDEFS_HPP_
+#ifdef WIN32
+
+#include <math.h>
+#include <stdio.h>
+
+#include "Math/Random.hpp"
+
+// stuff to make Mac code compatable with Windows
+
+// disable warnings about double to float conversions
+#pragma warning(disable:4305)
+#pragma warning(disable:4244)
+
+// disable warnings about boolean to int conversions
+#pragma warning(disable:4800)
+
+// disable warning about unreferenced local variables
+#pragma warning(disable:4101)
+
+struct Point {
+ short v;
+ short h;
+};
+
+typedef signed char SInt8;
+typedef unsigned int UInt32;
+
+
+typedef struct AbsoluteTime {
+ unsigned long hi;
+ unsigned long lo;
+} AbsoluteTime;
+
+AbsoluteTime UpTime(); // NOTE: returns time since app started, not system start
+
+typedef long Duration;
+
+enum {
+ durationMicrosecond = -1,
+ durationMillisecond = 1,
+ durationSecond = 1000,
+ durationMinute = 1000 * 60,
+ durationHour = 1000 * 60 * 60,
+ durationDay = 1000 * 60 * 60 * 24,
+ durationForever = 0x7FFFFFFF,
+ durationImmediate = 0,
+};
+
+Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b);
+
+#ifndef __MINGW32__
+inline float abs(float f)
+{
+ if (f < 0)
+ return -f;
+ return f;
+}
+
+inline double abs(double f)
+{
+ if (f < 0)
+ return -f;
+ return f;
+}
+#endif // __MINGW32__
+
+
+#endif
+#endif
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "Game.hpp"
+
+#include "Audio/openal_wrapper.hpp"
+#include "Graphic/gamegl.hpp"
+#include "MacCompatibility.hpp"
+#include "User/Settings.hpp"
+
+#include <fstream>
+#include <iostream>
#include <math.h>
+#include <set>
#include <stdio.h>
#include <string.h>
-#include <fstream>
-#include <iostream>
#include <zlib.h>
-#include <set>
-#include "MacCompatibility.h"
-#include "Graphic/gamegl.h"
-#include "User/Settings.h"
-
-#include "Game.h"
using namespace Game;
-#include "Audio/openal_wrapper.h"
-
#ifdef WIN32
-#include <windows.h>
#include <shellapi.h>
-#include "win-res/resource.h"
+#include <windows.h>
+#include "win-res/resource.hpp"
#endif
extern float multiplier;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-Lugaru 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
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by Lugaru.rc
-//
-#define IDI_LUGARU 104
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 105
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru 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
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by Lugaru.rc
+//
+#define IDI_LUGARU 104
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 105
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif