Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Character.h
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2005-2012 Pierre-Michel Ricordel
4 Copyright 2007-2012 Thomas Fischer
5 Copyright 2017-2018 Petr Ohlidal
6
7 For more information, see http://www.rigsofrods.org/
8
9 Rigs of Rods is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License version 3, as
11 published by the Free Software Foundation.
12
13 Rigs of Rods is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#pragma once
23
24#include "ForwardDeclarations.h"
25#include "SurveyMapEntity.h"
26
27#include <OgreMeshManager.h>
28#include <OgreTimer.h>
29#include <string>
30
31namespace RoR {
32
35
38
40{
41public:
42
43 Character(int source = -1, unsigned int streamid = 0, std::string playerName = "", int color_number = 0, bool is_remote = true);
44 ~Character();
45
46 int getSourceID() const { return m_source_id; }
47 bool isRemote() const { return m_is_remote; }
48 int GetColorNum() const { return m_color_number; }
49 bool GetIsRemote() const { return m_is_remote; }
50 std::string const& GetNetUsername() { return m_net_username; }
51 std::string const & GetAnimName() const { return m_anim_name; }
52 float GetAnimTime() const { return m_anim_time; }
53 Ogre::Radian getRotation() const { return m_character_rotation; }
55 void setColour(int color) { this->m_color_number = color; }
56 Ogre::Vector3 getPosition();
57 void setPosition(Ogre::Vector3 position);
58 void setRotation(Ogre::Radian rotation);
59 void move(Ogre::Vector3 offset);
60 void update(float dt);
62 void receiveStreamData(unsigned int& type, int& source, unsigned int& streamid, char* buffer);
63 void SetActorCoupling(bool enabled, ActorPtr actor);
65
66private:
67
68 void ReportError(const char* detail);
69 void SendStreamData();
70 void SendStreamSetup();
71 void SetAnimState(std::string mode, float time = 0);
72
77 Ogre::Vector3 m_character_position;
78 Ogre::Vector3 m_prev_position;
84 std::string m_anim_name;
88 std::string m_instance_name;
89 std::string m_net_username;
90 Ogre::Timer m_net_timer;
93};
94
97
99{
100 struct SimBuffer
101 {
102 Ogre::Vector3 simbuf_character_pos;
103 Ogre::Radian simbuf_character_rot;
108 std::string simbuf_anim_name;
109 float simbuf_anim_time; // Intentionally left empty = forces initial update.
110 };
111
113
116
117 Ogre::SceneNode* xc_scenenode;
121 std::string xc_instance_name; // TODO: Store MaterialPtr-s directly ~only_a_ptr, 05/2018
123};
124
125} // namespace RoR
126
Global forward declarations.
void setColour(int color)
Definition Character.h:55
GfxCharacter * SetupGfx()
void setPosition(Ogre::Vector3 position)
Definition Character.cpp:85
ActorPtr m_actor_coupling
The vehicle or machine which the character occupies.
Definition Character.h:73
Ogre::Vector3 getPosition()
Definition Character.cpp:92
void setRotation(Ogre::Radian rotation)
Definition Character.cpp:98
float m_driving_anim_length
Definition Character.h:87
void SendStreamData()
float m_character_v_speed
Definition Character.h:76
void update(float dt)
unsigned long m_net_last_update_time
Definition Character.h:91
Ogre::Vector3 m_prev_position
Definition Character.h:78
void receiveStreamData(unsigned int &type, int &source, unsigned int &streamid, char *buffer)
std::string const & GetAnimName() const
Definition Character.h:51
std::string m_anim_name
Definition Character.h:84
bool GetIsRemote() const
Definition Character.h:49
void SendStreamSetup()
float m_anim_time
Definition Character.h:85
std::string const & GetNetUsername()
Definition Character.h:50
void SetActorCoupling(bool enabled, ActorPtr actor)
float m_net_last_anim_time
Definition Character.h:86
ActorPtr GetActorCoupling()
GfxCharacter * m_gfx_character
Definition Character.h:92
int GetColorNum() const
Definition Character.h:48
Ogre::Radian m_character_rotation
Definition Character.h:74
int getSourceID() const
Definition Character.h:46
Ogre::Vector3 m_character_position
Definition Character.h:77
void move(Ogre::Vector3 offset)
void SetAnimState(std::string mode, float time=0)
std::string m_net_username
Definition Character.h:89
void updateCharacterRotation()
Definition Character.cpp:80
Ogre::Timer m_net_timer
Definition Character.h:90
Ogre::Radian getRotation() const
Definition Character.h:53
float GetAnimTime() const
Definition Character.h:52
bool isRemote() const
Definition Character.h:47
std::string m_instance_name
Definition Character.h:88
float m_character_h_speed
Definition Character.h:75
void ReportError(const char *detail)
< Buffered simulation state for async gfx scene update
Definition Character.h:101
Ogre::Radian simbuf_character_rot
When on foot.
Definition Character.h:103
Ogre::Vector3 simbuf_character_pos
Definition Character.h:102
Character * xc_character
Definition Character.h:120
Ogre::SceneNode * xc_scenenode
Definition Character.h:117
std::string xc_instance_name
Definition Character.h:121
SurveyMapEntity xc_surveymap_entity
Definition Character.h:122
void UpdateCharacterInScene()
SimBuffer xc_simbuf_prev
Definition Character.h:119
SimBuffer xc_simbuf
Definition Character.h:118
void BufferSimulationData()