id
int64 0
877k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
66
| repo_stars
int64 94
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 11
values | repo_extraction_date
stringclasses 197
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,537,207
|
spatial_index.h
|
haowenz_sigmap/src/spatial_index.h
|
#ifndef SPATIALINDEX_H_
#define SPATIALINDEX_H_
#include <string>
#include <vector>
#include "nanoflann.hpp"
#include "sequence_batch.h"
#include "sigmap_adaptor.h"
#include "signal_batch.h"
namespace sigmap {
enum Direction {
Negative = 0,
Positive = 1,
};
struct SignalAnchor {
uint32_t target_position;
uint32_t query_position;
float distance;
bool operator<(const SignalAnchor &a) const {
return std::tie(target_position, query_position, distance) <
std::tie(a.target_position, a.query_position, a.distance);
}
};
struct SignalAnchorChain {
float score;
uint32_t reference_sequence_index;
uint32_t start_position;
uint32_t end_position;
uint32_t num_anchors;
uint8_t mapq;
Direction direction;
// bool is_primary_chain;
std::vector<SignalAnchor> anchors;
bool operator>(const SignalAnchorChain &b) const {
return std::tie(score, num_anchors, direction, reference_sequence_index,
start_position, end_position) >
std::tie(b.score, b.num_anchors, b.direction,
b.reference_sequence_index, b.start_position,
b.end_position);
}
};
class SpatialIndex {
public:
SpatialIndex(int min_num_seeds_required_for_mapping,
const std::vector<int> &max_seed_frequencies,
const std::string &index_file_path_prefix)
: min_num_seeds_required_for_mapping_(min_num_seeds_required_for_mapping),
max_seed_frequencies_(max_seed_frequencies),
index_file_path_prefix_(index_file_path_prefix) { // for read mapping
spatial_index_ = nullptr;
}
SpatialIndex(int dimension, int max_leaf, int num_threads,
const std::string &index_file_path_prefix)
: dimension_(dimension),
max_leaf_(max_leaf),
num_threads_(num_threads),
index_file_path_prefix_(
index_file_path_prefix) { // for index construction
spatial_index_ = nullptr;
}
~SpatialIndex() {
if (spatial_index_ != nullptr) {
delete spatial_index_;
}
}
void GeneratePointCloudOnOneDirection(
Direction direction, uint32_t signal_index,
const std::vector<std::vector<bool> > &is_masked,
const float *signal_values, size_t signal_length, int step_size,
std::vector<Point> &point_cloud);
// void GetSignalIndexAndPosition(size_t point_index, size_t num_signals,
// const std::vector<std::vector<float> > &signals, size_t &signal_index,
// size_t &signal_position);
void Construct(size_t num_signals,
const std::vector<std::vector<bool> > &positive_is_masked,
const std::vector<std::vector<bool> > &negative_is_masked,
const std::vector<std::vector<float> > &positive_signals,
const std::vector<std::vector<float> > &negative_signals);
void Save();
void Load();
void GenerateChains(const std::vector<float> &query_signal,
const std::vector<float> &query_signal_stdvs,
uint32_t query_start_offset,
int query_point_cloud_step_size, float search_radius,
size_t num_target_signals,
std::vector<SignalAnchorChain> &chains);
void TracebackChains(
int min_num_anchors, Direction direction, size_t chain_end_anchor_index,
uint32_t chain_target_signal_index,
const std::vector<float> &chaining_scores,
const std::vector<size_t> &chaining_predecessors,
const std::vector<std::vector<SignalAnchor> > &anchors_on_diff_signals,
std::vector<bool> &anchor_is_used,
std::vector<SignalAnchorChain> &chains);
void GeneratePrimaryChains(std::vector<SignalAnchorChain> &chains);
void ComputeMAPQ(std::vector<SignalAnchorChain> &chains);
protected:
int dimension_;
int max_leaf_ = 10;
// int window_size_;
int min_num_seeds_required_for_mapping_;
std::vector<int> max_seed_frequencies_;
int num_threads_;
std::string index_file_path_prefix_; // For now, I have to use two files *.pt
// for dim, max leaf, points and *.si
// for spatial index.
SigmapAdaptor<float> *spatial_index_;
std::vector<Point> point_cloud_; // TODO(Haowen): remove this duplicate later
};
} // namespace sigmap
#endif // SPATIALINDEX_H_
| 4,358
|
C++
|
.h
| 110
| 32.763636
| 80
| 0.660533
|
haowenz/sigmap
| 31
| 8
| 4
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,208
|
utils.h
|
haowenz_sigmap/src/utils.h
|
#ifndef UTILS_H_
#define UTILS_H_
#include <assert.h>
#include <dirent.h>
#include <float.h>
#include <hdf5.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include "cwt.h"
//#define DEBUG
#define LEGACY_FAST5_RAW_ROOT "/Raw/Reads/"
namespace sigmap {
struct FAST5File {
hid_t hdf5_file;
bool is_multi_fast5;
};
inline static bool IsDirectory(const std::string &dir_path) {
auto dir = opendir(dir_path.c_str());
if (not dir) {
return false;
}
closedir(dir);
return true;
}
inline static std::vector<std::string> ListDirectory(
const std::string &dir_path) {
std::vector<std::string> res;
DIR *dir;
struct dirent *ent;
dir = opendir(dir_path.c_str());
if (not dir) {
return res;
}
while ((ent = readdir(dir)) != nullptr) {
res.push_back(ent->d_name);
}
closedir(dir);
return res;
}
inline static double GetRealTime() {
struct timeval tp;
struct timezone tzp;
gettimeofday(&tp, &tzp);
return tp.tv_sec + tp.tv_usec * 1e-6;
}
inline static double GetCPUTime() {
struct rusage r;
getrusage(RUSAGE_SELF, &r);
return r.ru_utime.tv_sec + r.ru_stime.tv_sec +
1e-6 * (r.ru_utime.tv_usec + r.ru_stime.tv_usec);
}
inline static void ExitWithMessage(const std::string &message) {
std::cerr << message << std::endl;
exit(-1);
}
// For sequence manipulation
static constexpr uint8_t char_to_uint8_table_[256] = {
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 1, 4, 4, 4, 2,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 0, 4, 1, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4};
static constexpr char uint8_to_char_table_[8] = {'A', 'C', 'G', 'T',
'N', 'N', 'N', 'N'};
inline static uint8_t CharToUint8(const char c) {
return char_to_uint8_table_[(uint8_t)c];
}
inline static char Uint8ToChar(const uint8_t i) {
return uint8_to_char_table_[i];
}
inline static uint64_t GenerateSeedFromSequence(const char *sequence,
size_t sequence_length,
uint32_t start_position,
uint32_t seed_length) {
uint64_t mask = (((uint64_t)1) << (2 * seed_length)) - 1;
uint64_t seed = 0;
for (uint32_t i = 0; i < seed_length; ++i) {
if (start_position + i < sequence_length) {
uint8_t current_base = CharToUint8(sequence[i + start_position]);
if (current_base < 4) { // not an ambiguous base
seed = ((seed << 2) | current_base) & mask; // forward k-mer
} else {
seed = (seed << 2) & mask; // N->A
}
} else {
seed = (seed << 2) & mask; // Pad A
}
}
return seed;
}
// For FAST5 manipulation
inline static FAST5File OpenFAST5(const std::string &fast5_file_path) {
FAST5File fast5_file;
fast5_file.hdf5_file =
H5Fopen(fast5_file_path.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
if (fast5_file.hdf5_file < 0) {
fprintf(stderr, "could not open fast5 file: %s\n", fast5_file_path.c_str());
}
// Check for attribute that indicates whether it is single or multi-fast5
// see: https://community.nanoporetech.com/posts/multi-fast5-format
const std::string indicator_p1 = "/UniqueGlobalKey/";
const std::string indicator_p2 = indicator_p1 + "tracking_id/";
bool has_indicator =
H5Lexists(fast5_file.hdf5_file, indicator_p1.c_str(), H5P_DEFAULT) &&
H5Lexists(fast5_file.hdf5_file, indicator_p2.c_str(), H5P_DEFAULT);
fast5_file.is_multi_fast5 = !has_indicator;
return fast5_file;
}
inline static void CloseFAST5(FAST5File &fast5_file) {
H5Fclose(fast5_file.hdf5_file);
}
inline static float GetFloatAttributeInGroup(hid_t group_id,
const char *attribute_name) {
// The group_id should be checked somewhere else!
float attribute_value = NAN;
hid_t attribute_id = H5Aopen(group_id, attribute_name, H5P_DEFAULT);
if (attribute_id < 0) {
fprintf(stderr, "Failed to open attribute '%s' for reading.",
attribute_name);
return attribute_value;
}
herr_t err = H5Aread(attribute_id, H5T_NATIVE_FLOAT, &attribute_value);
if (err < 0) {
fprintf(stderr, "error reading attribute %s\n", attribute_name);
exit(EXIT_FAILURE);
}
H5Aclose(attribute_id);
return attribute_value;
}
inline static void GetStringAttributeInGroup(hid_t group_id,
const char *attribute_name,
char **string_attribute) {
// The group_id should be checked somewhere else!
hid_t attribute_id = H5Aopen(group_id, attribute_name, H5P_DEFAULT);
hid_t attribute_type_id;
hid_t native_type_id;
htri_t is_variable_string;
if (attribute_id < 0) {
fprintf(stderr, "Failed to open attribute '%s' for reading.",
attribute_name);
*string_attribute = NULL;
goto close_attr;
}
// Get data type and check it is a fixed-length string
attribute_type_id = H5Aget_type(attribute_id);
if (attribute_type_id < 0) {
fprintf(stderr, "failed to get attribute type %s\n", attribute_name);
*string_attribute = NULL;
goto close_type;
}
if (H5Tget_class(attribute_type_id) != H5T_STRING) {
fprintf(stderr, "attribute %s is not a string\n", attribute_name);
*string_attribute = NULL;
goto close_type;
}
native_type_id = H5Tget_native_type(attribute_type_id, H5T_DIR_ASCEND);
if (native_type_id < 0) {
fprintf(stderr, "failed to get native type for %s\n", attribute_name);
*string_attribute = NULL;
goto close_native_type;
}
is_variable_string = H5Tis_variable_str(attribute_type_id);
if (is_variable_string > 0) {
// variable length string
// char* buffer;
// herr_t err = H5Aread(attribute_id, native_type_id, &string_attribute);
herr_t err = H5Aread(attribute_id, native_type_id, string_attribute);
if (err < 0) {
fprintf(stderr, "error reading attribute %s\n", attribute_name);
exit(EXIT_FAILURE);
}
// out = buffer;
// free(buffer);
// buffer = NULL;
} else if (is_variable_string == 0) {
// fixed length string
// Get the storage size and allocate
size_t storage_size = H5Aget_storage_size(attribute_id);
;
// char* buffer;
// buffer = (char*)calloc(storage_size + 1, sizeof(char));
*string_attribute = (char *)calloc(storage_size + 1, sizeof(char));
// finally read the attribute
herr_t err = H5Aread(attribute_id, attribute_type_id, *string_attribute);
if (err < 0) {
fprintf(stderr, "error reading attribute %s\n", attribute_name);
exit(EXIT_FAILURE);
}
// clean up
// free(buffer);
} else {
fprintf(stderr,
"error when determing whether it is a variable string for "
"attribute %s\n",
attribute_name);
exit(EXIT_FAILURE);
}
// H5Aread(attribute_id, H5T_NATIVE_FLOAT, &attribute_value);
// H5Aclose(attribute_id);
close_native_type:
H5Tclose(native_type_id);
close_type:
H5Tclose(attribute_type_id);
close_attr:
H5Aclose(attribute_id);
// close_group:
// H5Gclose(group);
}
// For signal processing
static inline void GetSignalMinAndMax(const float *signal_values,
size_t signal_length, float &min,
float &max) {
min = signal_values[0];
max = signal_values[0];
for (size_t position = 0; position < signal_length; ++position) {
if (signal_values[position] < min) {
min = signal_values[position];
}
if (signal_values[position] > max) {
max = signal_values[position];
}
}
}
static inline size_t GetSignalsTotalLength(
const std::vector<std::vector<float> > &signals) {
size_t length = 0;
for (size_t i = 0; i < signals.size(); ++i) {
length += signals[i].size();
}
return length;
}
static inline void SaveVectorToFile(const float *signal_values,
size_t signal_length,
const std::string &file_path) {
FILE *output_file = fopen(file_path.c_str(), "w");
assert(output_file != NULL);
for (size_t signal_position = 0; signal_position < signal_length - 1;
++signal_position) {
fprintf(output_file, "%f\t", signal_values[signal_position]);
}
fprintf(output_file, "%f\n", signal_values[signal_length - 1]);
fclose(output_file);
}
static inline void SaveVectorToFile(const size_t *positions,
size_t signal_length,
const std::string &file_path) {
FILE *output_file = fopen(file_path.c_str(), "w");
assert(output_file != NULL);
for (size_t signal_position = 0; signal_position < signal_length - 1;
++signal_position) {
fprintf(output_file, "%lu\t", positions[signal_position]);
}
fprintf(output_file, "%lu\n", positions[signal_length - 1]);
fclose(output_file);
}
} // namespace sigmap
#endif // UTILS_H_
| 9,734
|
C++
|
.h
| 268
| 30.738806
| 80
| 0.606057
|
haowenz/sigmap
| 31
| 8
| 4
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,209
|
signal_batch.h
|
haowenz_sigmap/src/signal_batch.h
|
#ifndef SIGNALBATCH_H_
#define SIGNALBATCH_H_
#include <string>
#include <vector>
#include <slow5/slow5.h>
#include "hdf5_tools.hpp"
#include "pore_model.h"
#include "sequence_batch.h"
#include "utils.h"
namespace sigmap {
struct Signal {
// read group name
std::string id;
// channel_id
float digitisation;
float range;
float offset;
// signal
std::vector<float> signal_values;
std::vector<float> negative_signal_values;
size_t GetSignalLength() const { return signal_values.size(); }
};
class SignalBatch {
public:
SignalBatch() {}
~SignalBatch() {}
void InitializeLoading(const std::string &signal_directory);
void FinalizeLoading();
size_t LoadAllReadSignals();
void AddSignal(const hdf5_tools::File &file, const std::string &raw_path,
const std::string &ch_path);
void AddSignal(slow5_rec_t *rec);
void AddSignalsFromFAST5(const std::string &fast5_file_path);
void AddSignalsFromSLOW5(const std::string &slow5_file_path);
void NormalizeSignalAt(size_t signal_index);
void ConvertSequencesToSignals(const SequenceBatch &sequence_batch,
const PoreModel &pore_model,
size_t num_sequences);
const Signal &GetSignalAt(size_t signal_index) const {
return signals_[signal_index];
}
const char *GetSignalNameAt(size_t signal_index) const {
return signals_[signal_index].id.data();
}
size_t GetSignalLengthAt(size_t signal_index) const {
return signals_[signal_index].signal_values.size();
}
protected:
std::string signal_directory_;
std::vector<Signal> signals_;
};
} // namespace sigmap
#endif // SIGNALBATCH_H_
| 1,673
|
C++
|
.h
| 53
| 27.528302
| 75
| 0.710657
|
haowenz/sigmap
| 31
| 8
| 4
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,210
|
output_tools.h
|
haowenz_sigmap/src/output_tools.h
|
#ifndef OUTPUTTOOLS_H_
#define OUTPUTTOOLS_H_
#include <assert.h>
#include <cstring>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#include "sequence_batch.h"
namespace sigmap {
struct PAFMapping {
uint32_t read_id;
std::string read_name;
uint32_t read_length;
uint32_t read_start_position;
uint32_t read_end_position;
uint32_t fragment_start_position;
uint32_t fragment_length;
uint8_t mapq : 6, direction : 1, is_unique : 1;
std::string tags;
bool operator<(const PAFMapping &m) const {
return std::tie(fragment_start_position, fragment_length, mapq, direction,
is_unique, read_id, read_start_position,
read_end_position) <
std::tie(m.fragment_start_position, m.fragment_length, m.mapq,
m.direction, m.is_unique, m.read_id, m.read_start_position,
m.read_end_position);
}
bool operator==(const PAFMapping &m) const {
return std::tie(fragment_start_position) ==
std::tie(m.fragment_start_position);
}
};
struct MappingWithBarcode {
uint32_t read_id;
uint32_t cell_barcode;
uint32_t fragment_start_position;
uint16_t fragment_length;
uint8_t mapq : 6, direction : 1, is_unique : 1;
bool operator<(const MappingWithBarcode &m) const {
return std::tie(fragment_start_position, fragment_length, cell_barcode,
mapq, direction, is_unique, read_id) <
std::tie(m.fragment_start_position, m.fragment_length,
m.cell_barcode, m.mapq, m.direction, m.is_unique,
m.read_id);
}
bool operator==(const MappingWithBarcode &m) const {
return std::tie(cell_barcode, fragment_start_position) ==
std::tie(m.cell_barcode, m.fragment_start_position);
}
};
struct MappingWithoutBarcode {
uint32_t read_id;
uint32_t fragment_start_position;
uint16_t fragment_length;
uint8_t mapq : 6, direction : 1, is_unique : 1;
bool operator<(const MappingWithoutBarcode &m) const {
return std::tie(fragment_start_position, fragment_length, mapq, direction,
is_unique, read_id) <
std::tie(m.fragment_start_position, m.fragment_length, m.mapq,
m.direction, m.is_unique, m.read_id);
}
bool operator==(const MappingWithoutBarcode &m) const {
return std::tie(fragment_start_position) ==
std::tie(m.fragment_start_position);
}
};
template <typename MappingRecord>
struct TempMappingFileHandle {
std::string file_path;
FILE *file;
bool all_loaded;
uint32_t num_mappings;
uint32_t block_size;
uint32_t current_rid;
uint32_t current_mapping_index;
uint32_t num_mappings_on_current_rid;
uint32_t num_loaded_mappings_on_current_rid;
std::vector<MappingRecord>
mappings; // this vector only keep mappings on the same ref seq
inline void InitializeTempMappingLoading(uint32_t num_reference_sequences) {
file = fopen(file_path.c_str(), "rb");
assert(file != NULL);
all_loaded = false;
current_rid = 0;
fread(&num_mappings_on_current_rid, sizeof(size_t), 1, file);
mappings.resize(block_size);
num_loaded_mappings_on_current_rid = 0;
std::cerr << "Block size: " << block_size << ", initialize temp file "
<< file_path << "\n";
}
inline void FinalizeTempMappingLoading() { fclose(file); }
inline void LoadTempMappingBlock(uint32_t num_reference_sequences) {
num_mappings = 0;
while (num_mappings == 0) {
// Only keep mappings on one ref seq, which means # mappings in buffer can
// be less than block size Two cases: current ref seq has remainings or
// not
if (num_loaded_mappings_on_current_rid < num_mappings_on_current_rid) {
// Check if # remains larger than block size
uint32_t num_mappings_to_load_on_current_rid =
num_mappings_on_current_rid - num_loaded_mappings_on_current_rid;
if (num_mappings_to_load_on_current_rid > block_size) {
num_mappings_to_load_on_current_rid = block_size;
}
// std::cerr << num_mappings_to_load_on_current_rid << " " <<
// num_loaded_mappings_on_current_rid << " " <<
// num_mappings_on_current_rid << "\n"; std::cerr << mappings.size() <<
// "\n";
fread(mappings.data(), sizeof(MappingRecord),
num_mappings_to_load_on_current_rid, file);
// std::cerr << "Load mappings\n";
num_loaded_mappings_on_current_rid +=
num_mappings_to_load_on_current_rid;
num_mappings = num_mappings_to_load_on_current_rid;
} else {
// Move to next rid
++current_rid;
if (current_rid < num_reference_sequences) {
// std::cerr << "Load size\n";
fread(&num_mappings_on_current_rid, sizeof(size_t), 1, file);
// std::cerr << "Load size " << num_mappings_on_current_rid << "\n";
num_loaded_mappings_on_current_rid = 0;
} else {
all_loaded = true;
break;
}
}
}
current_mapping_index = 0;
}
inline void Next(uint32_t num_reference_sequences) {
++current_mapping_index;
if (current_mapping_index >= num_mappings) {
LoadTempMappingBlock(num_reference_sequences);
}
}
};
template <typename MappingRecord>
class OutputTools {
public:
OutputTools() {}
virtual ~OutputTools() {}
inline void OutputTempMapping(
const std::string &temp_mapping_output_file_path,
uint32_t num_reference_sequences,
const std::vector<std::vector<MappingRecord> > &mappings) {
FILE *temp_mapping_output_file =
fopen(temp_mapping_output_file_path.c_str(), "wb");
assert(temp_mapping_output_file != NULL);
for (size_t ri = 0; ri < num_reference_sequences; ++ri) {
// make sure mappings[ri] exists even if its size is 0
size_t num_mappings = mappings[ri].size();
fwrite(&num_mappings, sizeof(size_t), 1, temp_mapping_output_file);
if (mappings[ri].size() > 0) {
fwrite(mappings[ri].data(), sizeof(MappingRecord), mappings[ri].size(),
temp_mapping_output_file);
}
}
fclose(temp_mapping_output_file);
}
inline void LoadBinaryTempMapping(
const std::string &temp_mapping_file_path,
uint32_t num_reference_sequences,
std::vector<std::vector<MappingRecord> > &mappings) {
FILE *temp_mapping_file = fopen(temp_mapping_file_path.c_str(), "rb");
assert(temp_mapping_file != NULL);
for (size_t ri = 0; ri < num_reference_sequences; ++ri) {
size_t num_mappings = 0;
fread(&num_mappings, sizeof(size_t), 1, temp_mapping_file);
if (num_mappings > 0) {
mappings.emplace_back(std::vector<MappingRecord>(num_mappings));
fread(&(mappings[ri].data()), sizeof(MappingRecord), num_mappings,
temp_mapping_file);
} else {
mappings.emplace_back(std::vector<MappingRecord>());
}
}
fclose(temp_mapping_file);
}
inline void InitializeMappingOutput(
const std::string &mapping_output_file_path) {
mapping_output_file_path_ = mapping_output_file_path;
mapping_output_file_ = fopen(mapping_output_file_path_.c_str(), "w");
assert(mapping_output_file_ != NULL);
}
inline void FinalizeMappingOutput() { fclose(mapping_output_file_); }
inline void AppendMappingOutput(const std::string &line) {
fprintf(mapping_output_file_, "%s", line.data());
}
inline void AppendUnmappedRead(uint32_t rid, const SequenceBatch &reference,
const PAFMapping &mapping) {
// const char *reference_sequence_name = reference.GetSequenceNameAt(rid);
// uint32_t reference_sequence_length = reference.GetSequenceLengthAt(rid);
// uint32_t mapping_end_position = mapping.fragment_start_position +
// mapping.fragment_length;
this->AppendMappingOutput(
mapping.read_name + "\t" + std::to_string(mapping.read_length) +
"\t*\t*\t*\t*\t*\t*\t*\t*\t*\t" + std::to_string(mapping.mapq) + "\t" +
mapping.tags + "\n");
}
virtual void AppendMapping(uint32_t rid, const SequenceBatch &reference,
const MappingRecord &mapping) = 0;
inline std::string GeneratePAFLine(
const SequenceBatch &query_batch, uint32_t query_index,
const int query_start, const int query_end, const char relative_strand,
const SequenceBatch &target_batch, uint32_t target_index,
const int target_start, const int target_end, const int num_matches,
const int alignment_length, const int mapping_quality) {
return std::string(query_batch.GetSequenceNameAt(query_index)) + "\t" +
std::to_string(query_batch.GetSequenceLengthAt(query_index)) + "\t" +
std::to_string(query_start) + "\t" + std::to_string(query_end) +
"\t" + relative_strand + "\t" +
std::string(target_batch.GetSequenceNameAt(target_index)) + "\t" +
std::to_string(target_batch.GetSequenceLengthAt(target_index)) +
"\t" + std::to_string(target_start) + "\t" +
std::to_string(target_end) + "\t" + std::to_string(num_matches) +
"\t" + std::to_string(alignment_length) + "\t" +
std::to_string(mapping_quality) + "\n";
}
inline uint32_t GetNumMappings() const { return num_mappings_; }
inline std::string Seed2Sequence(uint64_t seed, uint32_t seed_length) const {
std::string sequence;
sequence.reserve(seed_length);
uint64_t mask = 3;
for (uint32_t i = 0; i < seed_length; ++i) {
sequence.push_back(SequenceBatch::Uint8ToChar(
(seed >> ((seed_length - 1 - i) * 2)) & mask));
}
return sequence;
}
// inline void InitializeMatrixOutput(const std::string &matrix_output_prefix)
// {
// matrix_output_prefix_ = matrix_output_prefix;
// matrix_output_file_ = fopen((matrix_output_prefix_ +
// "_matrix.mtx").c_str(), "w"); assert(matrix_output_file_ != NULL);
// peak_output_file_ = fopen((matrix_output_prefix_ + "_peaks.bed").c_str(),
// "w"); assert(peak_output_file_ != NULL); barcode_output_file_ =
// fopen((matrix_output_prefix_ + "_barcode.tsv").c_str(), "w");
// assert(barcode_output_file_ != NULL);
//}
// void OutputPeaks(uint32_t bin_size, uint32_t num_sequences, const
// SequenceBatch &reference) {
// for (uint32_t rid = 0; rid < num_sequences; ++rid) {
// uint32_t sequence_length = reference.GetSequenceLengthAt(rid);
// const char *sequence_name = reference.GetSequenceNameAt(rid);
// for (uint32_t position = 0; position < sequence_length; position +=
// bin_size) {
// fprintf(peak_output_file_, "%s\t%u\t%u\n", sequence_name, position +
// 1, position + bin_size);
// }
// }
//}
// void OutputPeaks(uint32_t peak_start_position, uint16_t peak_length,
// uint32_t rid, const SequenceBatch &reference) {
// const char *sequence_name = reference.GetSequenceNameAt(rid);
// fprintf(peak_output_file_, "%s\t%u\t%u\n", sequence_name,
// peak_start_position + 1, peak_start_position + peak_length);
//}
// void AppendBarcodeOutput(uint32_t barcode_key) {
// fprintf(barcode_output_file_, "%s-1\n", Seed2Sequence(barcode_key,
// cell_barcode_length_).data());
//}
// void WriteMatrixOutputHead(uint64_t num_peaks, uint64_t num_barcodes,
// uint64_t num_lines) {
// fprintf(matrix_output_file_, "%lu\t%lu\t%lu\n", num_peaks, num_barcodes,
// num_lines);
//}
// void AppendMatrixOutput(uint32_t peak_index, uint32_t barcode_index,
// uint32_t num_mappings) {
// fprintf(matrix_output_file_, "%u\t%u\t%u\n", peak_index, barcode_index,
// num_mappings);
//}
inline void FinalizeMatrixOutput() {
fclose(matrix_output_file_);
fclose(peak_output_file_);
fclose(barcode_output_file_);
}
protected:
std::string mapping_output_file_path_;
FILE *mapping_output_file_;
uint32_t num_mappings_;
uint32_t cell_barcode_length_ = 16;
std::string matrix_output_prefix_;
FILE *peak_output_file_;
FILE *barcode_output_file_;
FILE *matrix_output_file_;
};
// template <typename MappingRecord>
// class BEDOutputTools : public OutputTools<MappingRecord> {
// inline void AppendMapping(uint32_t rid, const SequenceBatch &reference,
// const MappingRecord &mapping) {
// std::string strand = (mapping.direction & 1) == 1 ? "+" : "-";
// const char *reference_sequence_name = reference.GetSequenceNameAt(rid);
// uint32_t mapping_end_position = mapping.fragment_start_position +
// mapping.fragment_length;
// this->AppendMappingOutput(std::string(reference_sequence_name) + "\t" +
// std::to_string(mapping.fragment_start_position) + "\t" +
// std::to_string(mapping_end_position) + "\tN\t1000\t" + strand + "\n");
// }
//};
//
// template <>
// class BEDOutputTools<MappingWithBarcode> : public
// OutputTools<MappingWithBarcode> {
// inline void AppendMapping(uint32_t rid, const SequenceBatch &reference,
// const MappingWithBarcode &mapping) {
// std::string strand = (mapping.direction & 1) == 1 ? "+" : "-";
// const char *reference_sequence_name = reference.GetSequenceNameAt(rid);
// uint32_t mapping_end_position = mapping.fragment_start_position +
// mapping.fragment_length;
// this->AppendMappingOutput(std::string(reference_sequence_name) + "\t" +
// std::to_string(mapping.fragment_start_position) + "\t" +
// std::to_string(mapping_end_position) + "\t" +
// Seed2Sequence(mapping.cell_barcode, cell_barcode_length_) +"\n");
// }
//};
template <typename MappingRecord>
class PAFOutputTools : public OutputTools<MappingRecord> {};
template <>
class PAFOutputTools<PAFMapping> : public OutputTools<PAFMapping> {
inline void AppendMapping(uint32_t rid, const SequenceBatch &reference,
const PAFMapping &mapping) {
const char *reference_sequence_name = reference.GetSequenceNameAt(rid);
uint32_t reference_sequence_length = reference.GetSequenceLengthAt(rid);
std::string strand = (mapping.direction & 1) == 1 ? "+" : "-";
uint32_t mapping_end_position =
mapping.fragment_start_position + mapping.fragment_length;
this->AppendMappingOutput(
mapping.read_name + "\t" + std::to_string(mapping.read_length) + "\t" +
std::to_string(mapping.read_start_position) + "\t" +
std::to_string(mapping.read_end_position) + "\t" + strand + "\t" +
std::string(reference_sequence_name) + "\t" +
std::to_string(reference_sequence_length) + "\t" +
std::to_string(mapping.fragment_start_position) + "\t" +
std::to_string(mapping_end_position) + "\t" +
std::to_string(mapping.read_length) + "\t" +
std::to_string(mapping.fragment_length) + "\t" +
std::to_string(mapping.mapq) + "\t" + mapping.tags + "\n");
}
};
template <>
class PAFOutputTools<MappingWithBarcode>
: public OutputTools<MappingWithBarcode> {
inline void AppendMapping(uint32_t rid, const SequenceBatch &reference,
const MappingWithBarcode &mapping) {
const char *reference_sequence_name = reference.GetSequenceNameAt(rid);
uint32_t reference_sequence_length = reference.GetSequenceLengthAt(rid);
std::string strand = (mapping.direction & 1) == 1 ? "+" : "-";
uint32_t mapping_end_position =
mapping.fragment_start_position + mapping.fragment_length;
this->AppendMappingOutput(
std::to_string(mapping.read_id) + "\t" +
std::to_string(mapping.fragment_length) + "\t" + std::to_string(0) +
"\t" + std::to_string(mapping.fragment_length) + "\t" + strand + "\t" +
std::string(reference_sequence_name) + "\t" +
std::to_string(reference_sequence_length) + "\t" +
std::to_string(mapping.fragment_start_position) + "\t" +
std::to_string(mapping_end_position) + "\t" +
std::to_string(mapping.fragment_length) + "\t" +
std::to_string(mapping.fragment_length) + "\t" +
std::to_string(mapping.mapq) + "\n");
}
};
template <>
class PAFOutputTools<MappingWithoutBarcode>
: public OutputTools<MappingWithoutBarcode> {
inline void AppendMapping(uint32_t rid, const SequenceBatch &reference,
const MappingWithoutBarcode &mapping) {
const char *reference_sequence_name = reference.GetSequenceNameAt(rid);
uint32_t reference_sequence_length = reference.GetSequenceLengthAt(rid);
std::string strand = (mapping.direction & 1) == 1 ? "+" : "-";
uint32_t mapping_end_position =
mapping.fragment_start_position + mapping.fragment_length;
this->AppendMappingOutput(
std::to_string(mapping.read_id) + "\t" +
std::to_string(mapping.fragment_length) + "\t" + std::to_string(0) +
"\t" + std::to_string(mapping.fragment_length) + "\t" + strand + "\t" +
std::string(reference_sequence_name) + "\t" +
std::to_string(reference_sequence_length) + "\t" +
std::to_string(mapping.fragment_start_position) + "\t" +
std::to_string(mapping_end_position) + "\t" +
std::to_string(mapping.fragment_length) + "\t" +
std::to_string(mapping.fragment_length) + "\t" +
std::to_string(mapping.mapq) + "\n");
}
};
} // namespace sigmap
#endif // OUTPUTTOOLS_H_
| 17,307
|
C++
|
.h
| 389
| 38.768638
| 80
| 0.653689
|
haowenz/sigmap
| 31
| 8
| 4
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,211
|
cwt.h
|
haowenz_sigmap/src/cwt.h
|
#ifndef CWT_H_
#define CWT_H_
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
namespace sigmap {
// FFT
#ifndef fft_type
#define fft_type float
#endif
#define PI2 6.28318530717958647692528676655900577
typedef struct fft_set *fft_object;
typedef struct fft_t {
fft_type re;
fft_type im;
} fft_data;
struct fft_set {
int N;
int sgn;
int factors[64];
int lf;
int lt;
fft_data twiddle[1];
};
fft_object fft_init(int N, int sgn);
void fft_exec(fft_object obj, fft_data *inp, fft_data *oup);
void free_fft(fft_object object);
// CWT
#ifndef cplx_type
#define cplx_type float
#endif
#ifndef cwt_type
#define cwt_type float
#endif
typedef struct cplx_t {
cplx_type re;
cplx_type im;
} cplx_data;
typedef struct cwt_set *cwt_object;
struct cwt_set {
char wave[10]; // Wavelet - morl/morlet,paul,dog/dgauss
int siglength; // Length of Input Data
int J; // Total Number of Scales
cwt_type s0; // Smallest scale. It depends on the sampling rate. s0 <= 2 * dt
// for most wavelets
cwt_type dt; // Sampling Rate
cwt_type dj; // Separation between scales. eg., scale = s0 * 2 ^ ( [0:N-1]
// *dj ) or scale = s0 *[0:N-1] * dj
char type[10]; // Scale Type - Power or Linear
int pow; // Base of Power in case type = pow. Typical value is pow = 2
int sflag;
int pflag;
int npad;
int mother;
cwt_type m; // Wavelet parameter param
cwt_type smean; // Input Signal mean
cplx_data *output;
cwt_type *scale;
cwt_type *period;
cwt_type *coi;
cwt_type params[0];
};
cwt_object cwt_init(const char *wave, cwt_type param, int siglength,
cwt_type dt, int J);
void setCWTScales(cwt_object wt, cwt_type s0, cwt_type dj, const char *type,
int power);
// void setCWTScaleVector(cwt_object wt, const double *scale, int J, double s0,
// double dj); void setCWTPadding(cwt_object wt, int pad);
void cwavelet(const cwt_type *y, int N, cwt_type dt, int mother, cwt_type param,
cwt_type s0, cwt_type dj, int jtot, int npad, cwt_type *wave,
cwt_type *scale, cwt_type *period, cwt_type *coi);
void cwt(cwt_object wt, const cwt_type *inp);
void cwt_free(cwt_object object);
void cwt_summary(cwt_object wt);
// void icwt(cwt_object wt, double *cwtop);
// int getCWTScaleLength(int N);
} // namespace sigmap
#endif // CWT_H_
| 2,407
|
C++
|
.h
| 79
| 27.303797
| 80
| 0.67661
|
haowenz/sigmap
| 31
| 8
| 4
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,214
|
event.h
|
haowenz_sigmap/src/event.h
|
#ifndef EVENT_H_
#define EVENT_H_
#include <assert.h>
#include <float.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <cmath>
#include <vector>
#include "utils.h"
namespace sigmap {
struct Event {
uint64_t start;
size_t length;
float mean;
float stdv;
};
struct DetectorArgs {
size_t window_length1;
size_t window_length2;
float threshold1;
float threshold2;
float peak_height;
};
static DetectorArgs const event_detection_defaults = {
.window_length1 = 3,
.window_length2 = 6,
.threshold1 = 4.30265f, // 4.60409f,//1.4f,
.threshold2 = 2.57058f, // 3.16927f,//9.0f,
.peak_height = 1.0f // 0.2f
};
static DetectorArgs const event_detection_rna = {.window_length1 = 7,
.window_length2 = 14,
.threshold1 = 2.5f,
.threshold2 = 9.0f,
.peak_height = 1.0f};
struct Detector {
int DEF_PEAK_POS;
float DEF_PEAK_VAL;
float *signal_values;
size_t signal_length;
float threshold;
size_t window_length;
size_t masked_to;
int peak_pos;
float peak_value;
bool valid_peak;
};
static inline void ComputePrefixSumAndPrefixSumSquares(
const float *data, size_t data_length, std::vector<float> &prefix_sum,
std::vector<float> &prefix_sum_square) {
assert(data_length > 0);
prefix_sum.emplace_back(0.0f);
prefix_sum_square.emplace_back(0.0f);
for (size_t i = 0; i < data_length; ++i) {
prefix_sum.emplace_back(prefix_sum[i] + data[i]);
prefix_sum_square.emplace_back(prefix_sum_square[i] + data[i] * data[i]);
}
}
static inline void ComputeTStat(const float *prefix_sum,
const float *prefix_sum_square,
size_t signal_length, size_t window_length,
std::vector<float> &tstat) {
const float eta = FLT_MIN;
// Quick return:
// t-test not defined for number of points less than 2
// need at least as many points as twice the window length
if (signal_length < 2 * window_length || window_length < 2) {
for (size_t i = 0; i < signal_length; ++i) {
tstat.emplace_back(0.0f);
}
return;
}
// fudge boundaries
for (size_t i = 0; i < window_length; ++i) {
tstat.emplace_back(0.0f);
}
// get to work on the rest
for (size_t i = window_length; i <= signal_length - window_length; ++i) {
float sum1 = prefix_sum[i];
float sumsq1 = prefix_sum_square[i];
if (i > window_length) {
sum1 -= prefix_sum[i - window_length];
sumsq1 -= prefix_sum_square[i - window_length];
}
float sum2 = prefix_sum[i + window_length] - prefix_sum[i];
float sumsq2 = prefix_sum_square[i + window_length] - prefix_sum_square[i];
float mean1 = sum1 / window_length;
float mean2 = sum2 / window_length;
float combined_var = sumsq1 / window_length - mean1 * mean1 +
sumsq2 / window_length - mean2 * mean2;
// Prevent problem due to very small variances
combined_var = fmaxf(combined_var, eta);
// t-stat
// Formula is a simplified version of Student's t-statistic for the
// special case where there are two samples of equal size with
// differing variance
const float delta_mean = mean2 - mean1;
tstat.emplace_back(fabs(delta_mean) / sqrt(combined_var / window_length));
}
// fudge boundaries
for (size_t i = 0; i < window_length; ++i) {
tstat.emplace_back(0.0f);
}
}
static inline void GeneratePeaksUsingMultiWindows(Detector *short_detector,
Detector *long_detector,
const float peak_height,
std::vector<size_t> &peaks) {
assert(short_detector->signal_length == long_detector->signal_length);
size_t ndetector = 2;
Detector *detectors[ndetector]; // = {short_detector, long_detector};
detectors[0] = short_detector;
detectors[1] = long_detector;
peaks.reserve(short_detector->signal_length);
for (size_t i = 0; i < short_detector->signal_length; i++) {
for (size_t k = 0; k < ndetector; k++) {
Detector *detector = detectors[k];
// Carry on if we've been masked out
if (detector->masked_to >= i) {
continue;
}
float current_value = detector->signal_values[i];
if (detector->peak_pos == detector->DEF_PEAK_POS) {
// CASE 1: We've not yet recorded a maximum
if (current_value < detector->peak_value) {
// Either record a deeper minimum...
detector->peak_value = current_value;
} else if (current_value - detector->peak_value >
peak_height) { // TODO(Haowen): this might cause overflow,
// need to fix this
// ...or we've seen a qualifying maximum
detector->peak_value = current_value;
detector->peak_pos = i;
// otherwise, wait to rise high enough to be considered a peak
}
} else {
// CASE 2: In an existing peak, waiting to see if it is good
if (current_value > detector->peak_value) {
// Update the peak
detector->peak_value = current_value;
detector->peak_pos = i;
}
// Dominate other tstat signals if we're going to fire at some point
if (detector == short_detector) {
if (detector->peak_value > detector->threshold) {
long_detector->masked_to =
detector->peak_pos + detector->window_length;
long_detector->peak_pos = long_detector->DEF_PEAK_POS;
long_detector->peak_value = long_detector->DEF_PEAK_VAL;
long_detector->valid_peak = false;
}
}
// Have we convinced ourselves we've seen a peak
if (detector->peak_value - current_value > peak_height &&
detector->peak_value > detector->threshold) {
detector->valid_peak = true;
}
// Finally, check the distance if this is a good peak
if (detector->valid_peak &&
(i - detector->peak_pos) > detector->window_length / 2) {
// Emit the boundary and reset
peaks.emplace_back(detector->peak_pos);
detector->peak_pos = detector->DEF_PEAK_POS;
detector->peak_value = current_value;
detector->valid_peak = false;
}
}
}
}
}
static inline Event CreateEvent(size_t start, size_t end,
const float *prefix_sum,
const float *prefix_sum_square,
size_t signal_length) {
assert(start < signal_length);
assert(end <= signal_length);
Event event;
event.start = start;
event.length = end - start;
event.mean = (prefix_sum[end] - prefix_sum[start]) / event.length;
float deltasqr = prefix_sum_square[end] - prefix_sum_square[start];
float var = deltasqr / event.length - event.mean * event.mean;
event.stdv = sqrtf(fmaxf(var, 0.0f));
return event;
}
static inline void CreateEvents(const size_t *peaks, uint32_t peak_size,
const float *prefix_sum,
const float *prefix_sum_square,
size_t signal_length,
std::vector<Event> &events) {
// Count number of events found
size_t num_events = 1;
for (size_t i = 1; i < peak_size; ++i) {
if (peaks[i] > 0 && peaks[i] < signal_length) {
num_events++;
}
}
// First event -- starts at zero
events.emplace_back(
CreateEvent(0, peaks[0], prefix_sum, prefix_sum_square, signal_length));
// Other events -- peak[i-1] -> peak[i]
for (size_t pi = 1; pi < num_events - 1; pi++) {
events.emplace_back(CreateEvent(peaks[pi - 1], peaks[pi], prefix_sum,
prefix_sum_square, signal_length));
}
// Last event -- ends at signal_length
events.emplace_back(CreateEvent(peaks[num_events - 2], signal_length,
prefix_sum, prefix_sum_square,
signal_length));
}
static inline void DetectEvents(
const float *signal_values, size_t signal_length,
const DetectorArgs &edparam, std::vector<float> &prefix_sum,
std::vector<float> &prefix_sum_square, std::vector<float> &tstat1,
std::vector<float> &tstat2, std::vector<size_t> &peaks,
std::vector<Event> &events) {
prefix_sum.reserve(signal_length + 1);
prefix_sum_square.reserve(signal_length + 1);
ComputePrefixSumAndPrefixSumSquares(signal_values, signal_length, prefix_sum,
prefix_sum_square);
ComputeTStat(prefix_sum.data(), prefix_sum_square.data(), signal_length,
edparam.window_length1, tstat1);
ComputeTStat(prefix_sum.data(), prefix_sum_square.data(), signal_length,
edparam.window_length2, tstat2);
Detector short_detector = {.DEF_PEAK_POS = -1,
.DEF_PEAK_VAL = FLT_MAX,
.signal_values = tstat1.data(),
.signal_length = signal_length,
.threshold = edparam.threshold1,
.window_length = edparam.window_length1,
.masked_to = 0,
.peak_pos = -1,
.peak_value = FLT_MAX,
.valid_peak = false};
Detector long_detector = {.DEF_PEAK_POS = -1,
.DEF_PEAK_VAL = FLT_MAX,
.signal_values = tstat2.data(),
.signal_length = signal_length,
.threshold = edparam.threshold2,
.window_length = edparam.window_length2,
.masked_to = 0,
.peak_pos = -1,
.peak_value = FLT_MAX,
.valid_peak = false};
GeneratePeaksUsingMultiWindows(&short_detector, &long_detector,
edparam.peak_height, peaks);
CreateEvents(peaks.data(), peaks.size(), prefix_sum.data(),
prefix_sum_square.data(), signal_length, events);
#ifdef DEBUG
std::cerr << "Detected " << events.size() << " events.\n";
#endif
}
} // namespace sigmap
#endif // EVENT_H_
| 10,566
|
C++
|
.h
| 255
| 31.47451
| 79
| 0.572941
|
haowenz/sigmap
| 31
| 8
| 4
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,216
|
sequence_batch.h
|
haowenz_sigmap/src/sequence_batch.h
|
#ifndef SEQUENCEBATCH_H_
#define SEQUENCEBATCH_H_
#include <unistd.h>
#include <zlib.h>
#include <iostream>
#include <string>
#include <vector>
#include "kseq.h"
#include "utils.h"
namespace sigmap {
class SequenceBatch {
public:
KSEQ_INIT(gzFile, gzread);
SequenceBatch() {}
SequenceBatch(uint32_t max_num_sequences)
: max_num_sequences_(max_num_sequences) {
// Construct once and use update methods when loading each batch
sequence_batch_.reserve(max_num_sequences_);
for (uint32_t i = 0; i < max_num_sequences_; ++i) {
sequence_batch_.emplace_back((kseq_t *)calloc(1, sizeof(kseq_t)));
}
negative_sequence_batch_.assign(max_num_sequences_, "");
}
~SequenceBatch() {
if (sequence_batch_.size() > 0) {
for (uint32_t i = 0; i < sequence_batch_.size(); ++i) {
free(sequence_batch_[i]);
}
}
}
inline uint32_t GetMaxBatchSize() const { return max_num_sequences_; }
inline uint64_t GetNumBases() const { return num_bases_; }
inline std::vector<kseq_t *> &GetSequenceBatch() { return sequence_batch_; }
inline std::vector<std::string> &GetNegativeSequenceBatch() {
return negative_sequence_batch_;
}
inline const char *GetSequenceAt(uint32_t sequence_index) const {
return sequence_batch_[sequence_index]->seq.s;
}
inline uint32_t GetSequenceLengthAt(uint32_t sequence_index) const {
return sequence_batch_[sequence_index]->seq.l;
}
inline const char *GetSequenceNameAt(uint32_t sequence_index) const {
return sequence_batch_[sequence_index]->name.s;
}
inline uint32_t GetSequenceNameLengthAt(uint32_t sequence_index) const {
return sequence_batch_[sequence_index]->name.l;
}
inline uint32_t GetSequenceIdAt(uint32_t sequence_index) const {
return sequence_batch_[sequence_index]->id;
}
inline const std::string &GetNegativeSequenceAt(
uint32_t sequence_index) const {
return negative_sequence_batch_[sequence_index];
}
// inline char GetReverseComplementBaseOfSequenceAt(uint32_t sequence_index,
// uint32_t position) {
// kseq_t *sequence = sequence_batch_[sequence_index];
// return Uint8ToChar(((uint8_t)3) ^
// (CharToUint8((sequence->seq.s)[sequence->seq.l - position - 1])));
// }
inline void PrepareNegativeSequenceAt(uint32_t sequence_index) {
kseq_t *sequence = sequence_batch_[sequence_index];
uint32_t sequence_length = sequence->seq.l;
std::string &negative_sequence = negative_sequence_batch_[sequence_index];
negative_sequence.clear();
negative_sequence.reserve(sequence_length);
for (uint32_t i = 0; i < sequence_length; ++i) {
negative_sequence.push_back(Uint8ToChar(
((uint8_t)3) ^
(CharToUint8((sequence->seq.s)[sequence_length - i - 1]))));
}
}
inline void TrimSequenceAt(uint32_t sequence_index, int length_after_trim) {
kseq_t *sequence = sequence_batch_[sequence_index];
negative_sequence_batch_[sequence_index].erase(
negative_sequence_batch_[sequence_index].begin(),
negative_sequence_batch_[sequence_index].begin() + sequence->seq.l -
length_after_trim);
sequence->seq.l = length_after_trim;
}
inline void SwapSequenceBatch(SequenceBatch &batch) {
sequence_batch_.swap(batch.GetSequenceBatch());
negative_sequence_batch_.swap(batch.GetNegativeSequenceBatch());
}
void InitializeLoading(const std::string &sequence_file_path);
void FinalizeLoading();
// Return the number of reads loaded into the batch
// and return 0 if there is no more reads
uint32_t LoadBatch();
bool LoadOneSequenceAndSaveAt(uint32_t sequence_index);
uint32_t LoadAllSequences();
inline static uint8_t CharToUint8(const char c) {
return char_to_uint8_table_[(uint8_t)c];
}
inline static char Uint8ToChar(const uint8_t i) {
return uint8_to_char_table_[i];
}
inline uint64_t GenerateSeedFromSequenceAt(uint32_t sequence_index,
uint32_t start_position,
uint32_t seed_length) const {
const char *sequence = GetSequenceAt(sequence_index);
uint32_t sequence_length = GetSequenceLengthAt(sequence_index);
uint64_t mask = (((uint64_t)1) << (2 * seed_length)) - 1;
uint64_t seed = 0;
for (uint32_t i = 0; i < seed_length; ++i) {
if (start_position + i < sequence_length) {
uint8_t current_base =
SequenceBatch::CharToUint8(sequence[i + start_position]);
if (current_base < 4) { // not an ambiguous base
seed = ((seed << 2) | current_base) & mask; // forward k-mer
} else {
seed = (seed << 2) & mask; // N->A
}
} else {
seed = (seed << 2) & mask; // Pad A
}
}
return seed;
}
protected:
uint32_t num_loaded_sequences_ = 0;
uint32_t max_num_sequences_;
uint64_t num_bases_;
std::string sequence_file_path_;
gzFile sequence_file_;
kseq_t *sequence_kseq_;
std::vector<kseq_t *> sequence_batch_;
std::vector<std::string> negative_sequence_batch_;
};
} // namespace sigmap
#endif // SEQUENCEBATCH_H_
| 5,150
|
C++
|
.h
| 132
| 33.969697
| 79
| 0.671257
|
haowenz/sigmap
| 31
| 8
| 4
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,217
|
pore_model.h
|
haowenz_sigmap/src/pore_model.h
|
#ifndef POREMODEL_H_
#define POREMODEL_H_
#include <string>
#include <vector>
#include "utils.h"
namespace sigmap {
struct PoreModelParameters {
uint16_t kmer;
float level_mean;
float level_stdv;
float sd_mean;
float sd_stdv;
// float weight; // No need to store weight
};
class PoreModel {
public:
PoreModel() {}
~PoreModel() {}
void Load(const std::string &pore_model_file_path);
void Print();
std::vector<float> GetLevelMeansAt(const char *sequence,
uint32_t start_position,
uint32_t end_position) const;
int GetKmerSize() const { return kmer_size_; }
protected:
int kmer_size_;
std::vector<PoreModelParameters> pore_models_;
};
} // namespace sigmap
#endif // POREMODEL_H_
| 789
|
C++
|
.h
| 30
| 21.633333
| 66
| 0.661355
|
haowenz/sigmap
| 31
| 8
| 4
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,218
|
sigmap.h
|
haowenz_sigmap/src/sigmap.h
|
#ifndef SIGMAP_H_
#define SIGMAP_H_
#include <memory>
#include <string>
#include "event.h"
#include "output_tools.h"
#include "signal_batch.h"
#include "utils.h"
namespace sigmap {
class SigmapDriver {
public:
SigmapDriver() {}
~SigmapDriver() {}
void ParseArgsAndRun(int argc, char *argv[]);
};
class Sigmap {
public:
Sigmap() {}
~Sigmap() {}
// for index construction
Sigmap(int dimension, int max_leaf, const std::string &reference_file_path,
const std::string &pore_model_file_path,
const std::string &output_file_path)
: dimension_(dimension),
max_leaf_(max_leaf),
reference_file_path_(reference_file_path),
pore_model_file_path_(pore_model_file_path),
output_file_path_(output_file_path) {}
void ConstructIndex();
// for mapping
Sigmap(int num_threads, const std::string &reference_file_path,
const std::string &pore_model_file_path,
const std::string &signal_directory,
const std::string &reference_index_file_path,
const std::string &output_file_path)
: num_threads_(num_threads),
reference_file_path_(reference_file_path),
pore_model_file_path_(pore_model_file_path),
signal_directory_(signal_directory),
reference_index_file_path_(reference_index_file_path),
output_file_path_(output_file_path) {}
Sigmap(float search_radius, int read_seeding_step_size, int num_threads,
int max_num_chunks, int stop_mapping_min_num_anchors,
int output_mapping_min_num_anchors, float stop_mapping_ratio,
float output_mapping_ratio, float stop_mapping_mean_ratio,
float output_mapping_mean_ratio,
const std::string &reference_file_path,
const std::string &pore_model_file_path,
const std::string &signal_directory,
const std::string &reference_index_file_path,
const std::string &output_file_path)
: search_radius_(search_radius),
read_seeding_step_size_(read_seeding_step_size),
num_threads_(num_threads),
max_num_chunks_(max_num_chunks),
stop_mapping_min_num_anchors_(stop_mapping_min_num_anchors),
output_mapping_min_num_anchors_(output_mapping_min_num_anchors),
stop_mapping_ratio_(stop_mapping_ratio),
output_mapping_ratio_(output_mapping_ratio),
stop_mapping_mean_ratio_(stop_mapping_mean_ratio),
output_mapping_mean_ratio_(output_mapping_mean_ratio),
reference_file_path_(reference_file_path),
pore_model_file_path_(pore_model_file_path),
signal_directory_(signal_directory),
reference_index_file_path_(reference_index_file_path),
output_file_path_(output_file_path) {}
void Map();
void StreamingMap();
void DTWAlign();
void CWTAlign();
// Support functions
void GenerateEvents(size_t start, size_t end, const Signal &signal,
std::vector<float> &feature_signal,
std::vector<float> &feature_signal_stdvs);
void GenerateFeatureSignalUsingCWT(const Signal &signal, float scale0,
std::vector<float> &feature_signal,
std::vector<size_t> &feature_positions);
float GenerateMADNormalizedSignal(const float *signal_values,
size_t signal_length,
std::vector<float> &normalized_signal);
float GenerateZscoreNormalizedSignal(const float *signal_values,
size_t signal_length,
std::vector<float> &normalized_signal);
void GenerateCWTSignal(const float *signal_values, size_t signal_length,
float scale0, std::vector<float> &cwt_signal);
void GeneratePeaks(const float *signal_values, size_t signal_length,
float selective, std::vector<float> &peaks,
std::vector<size_t> &peak_positions);
float sDTW(const Signal &target_signal, const Signal &query_signal);
float sDTW(const float *target_signal_values, size_t target_length,
const float *query_signal_values, size_t query_length,
ssize_t &mapping_end_position);
// void EmplaceBackMappingRecord(uint32_t read_id, const char *read_name,
// uint32_t read_length, uint32_t barcode, uint32_t fragment_start_position,
// uint32_t fragment_length, uint8_t mapq, uint8_t direction, uint8_t
// is_unique, std::vector<PAFMapping> *mappings_on_diff_ref_seqs);
void OutputMappingsInVector(
uint8_t mapq_threshold, uint32_t num_reference_sequences,
const SequenceBatch &reference,
const std::vector<std::vector<PAFMapping> > &mappings);
uint32_t MoveMappingsInBuffersToMappingContainer(
uint32_t num_reference_sequences,
std::vector<std::vector<std::vector<PAFMapping> > >
*mappings_on_diff_ref_seqs_for_diff_threads_for_saving);
void GenerateMaskedPositions(
int kmer_size, float frequency, uint32_t num_reference_sequences,
const SequenceBatch &sequence_batch,
std::vector<std::vector<bool> > &positive_is_masked,
std::vector<std::vector<bool> > &negative_is_masked);
// Output debug files
void FAST5ToText();
void EventsToText();
protected:
int dimension_;
int max_leaf_;
float search_radius_;
int read_seeding_step_size_;
int num_threads_;
int max_num_chunks_;
int stop_mapping_min_num_anchors_;
int output_mapping_min_num_anchors_;
float stop_mapping_ratio_;
float output_mapping_ratio_;
float stop_mapping_mean_ratio_;
float output_mapping_mean_ratio_;
std::string reference_file_path_;
std::string pore_model_file_path_;
std::string signal_directory_;
std::string reference_index_file_path_;
std::string output_file_path_;
std::unique_ptr<OutputTools<PAFMapping> > output_tools_;
std::vector<std::vector<PAFMapping> > mappings_on_diff_ref_seqs_;
};
} // namespace sigmap
#endif // SIGMAP_H_
| 6,001
|
C++
|
.h
| 135
| 36.955556
| 78
| 0.671843
|
haowenz/sigmap
| 31
| 8
| 4
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,220
|
khash.h
|
haowenz_sigmap/src/khash.h
|
/* The MIT License
Copyright (c) 2008, 2009, 2011 by Attractive Chaos <attractor@live.co.uk>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/*
An example:
#include "khash.h"
KHASH_MAP_INIT_INT(32, char)
int main() {
int ret, is_missing;
khiter_t k;
khash_t(32) *h = kh_init(32);
k = kh_put(32, h, 5, &ret);
kh_value(h, k) = 10;
k = kh_get(32, h, 10);
is_missing = (k == kh_end(h));
k = kh_get(32, h, 5);
kh_del(32, h, k);
for (k = kh_begin(h); k != kh_end(h); ++k)
if (kh_exist(h, k)) kh_value(h, k) = 1;
kh_destroy(32, h);
return 0;
}
*/
/*
2013-05-02 (0.2.8):
* Use quadratic probing. When the capacity is power of 2, stepping function
i*(i+1)/2 guarantees to traverse each bucket. It is better than double
hashing on cache performance and is more robust than linear probing.
In theory, double hashing should be more robust than quadratic probing.
However, my implementation is probably not for large hash tables, because
the second hash function is closely tied to the first hash function,
which reduce the effectiveness of double hashing.
Reference: http://research.cs.vt.edu/AVresearch/hashing/quadratic.php
2011-12-29 (0.2.7):
* Minor code clean up; no actual effect.
2011-09-16 (0.2.6):
* The capacity is a power of 2. This seems to dramatically improve the
speed for simple keys. Thank Zilong Tan for the suggestion. Reference:
- http://code.google.com/p/ulib/
- http://nothings.org/computer/judy/
* Allow to optionally use linear probing which usually has better
performance for random input. Double hashing is still the default as it
is more robust to certain non-random input.
* Added Wang's integer hash function (not used by default). This hash
function is more robust to certain non-random input.
2011-02-14 (0.2.5):
* Allow to declare global functions.
2009-09-26 (0.2.4):
* Improve portability
2008-09-19 (0.2.3):
* Corrected the example
* Improved interfaces
2008-09-11 (0.2.2):
* Improved speed a little in kh_put()
2008-09-10 (0.2.1):
* Added kh_clear()
* Fixed a compiling error
2008-09-02 (0.2.0):
* Changed to token concatenation which increases flexibility.
2008-08-31 (0.1.2):
* Fixed a bug in kh_get(), which has not been tested previously.
2008-08-31 (0.1.1):
* Added destructor
*/
#ifndef __AC_KHASH_H
#define __AC_KHASH_H
/*!
@header
Generic hash table library.
*/
#define AC_VERSION_KHASH_H "0.2.8"
#include <stdlib.h>
#include <string.h>
#include <limits.h>
/* compiler specific configuration */
#if UINT_MAX == 0xffffffffu
typedef unsigned int khint32_t;
#elif ULONG_MAX == 0xffffffffu
typedef unsigned long khint32_t;
#endif
#if ULONG_MAX == ULLONG_MAX
typedef unsigned long khint64_t;
#else
typedef unsigned long long khint64_t;
#endif
#ifndef kh_inline
#ifdef _MSC_VER
#define kh_inline __inline
#else
#define kh_inline inline
#endif
#endif /* kh_inline */
#ifndef klib_unused
#if (defined __clang__ && __clang_major__ >= 3) || (defined __GNUC__ && __GNUC__ >= 3)
#define klib_unused __attribute__ ((__unused__))
#else
#define klib_unused
#endif
#endif /* klib_unused */
typedef khint32_t khint_t;
typedef khint_t khiter_t;
#define __ac_isempty(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&2)
#define __ac_isdel(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&1)
#define __ac_iseither(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&3)
#define __ac_set_isdel_false(flag, i) (flag[i>>4]&=~(1ul<<((i&0xfU)<<1)))
#define __ac_set_isempty_false(flag, i) (flag[i>>4]&=~(2ul<<((i&0xfU)<<1)))
#define __ac_set_isboth_false(flag, i) (flag[i>>4]&=~(3ul<<((i&0xfU)<<1)))
#define __ac_set_isdel_true(flag, i) (flag[i>>4]|=1ul<<((i&0xfU)<<1))
#define __ac_fsize(m) ((m) < 16? 1 : (m)>>4)
#ifndef kroundup32
#define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
#endif
#ifndef kcalloc
#define kcalloc(N,Z) calloc(N,Z)
#endif
#ifndef kmalloc
#define kmalloc(Z) malloc(Z)
#endif
#ifndef krealloc
#define krealloc(P,Z) realloc(P,Z)
#endif
#ifndef kfree
#define kfree(P) free(P)
#endif
static const double __ac_HASH_UPPER = 0.77;
#define __KHASH_TYPE(name, khkey_t, khval_t) \
typedef struct kh_##name##_s { \
khint_t n_buckets, size, n_occupied, upper_bound; \
khint32_t *flags; \
khkey_t *keys; \
khval_t *vals; \
} kh_##name##_t;
#define __KHASH_PROTOTYPES(name, khkey_t, khval_t) \
extern kh_##name##_t *kh_init_##name(void); \
extern void kh_destroy_##name(kh_##name##_t *h); \
extern void kh_clear_##name(kh_##name##_t *h); \
extern khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \
extern int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \
extern khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \
extern void kh_del_##name(kh_##name##_t *h, khint_t x); \
extern void kh_load_##name(kh_##name##_t *h, FILE* fp); \
extern void kh_save_##name(kh_##name##_t *h, FILE* fp);
#define __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
SCOPE kh_##name##_t *kh_init_##name(void) { \
return (kh_##name##_t*)kcalloc(1, sizeof(kh_##name##_t)); \
} \
SCOPE void kh_destroy_##name(kh_##name##_t *h) \
{ \
if (h) { \
kfree((void *)h->keys); kfree(h->flags); \
kfree((void *)h->vals); \
kfree(h); \
} \
} \
SCOPE void kh_clear_##name(kh_##name##_t *h) \
{ \
if (h && h->flags) { \
memset(h->flags, 0xaa, __ac_fsize(h->n_buckets) * sizeof(khint32_t)); \
h->size = h->n_occupied = 0; \
} \
} \
SCOPE khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \
{ \
if (h->n_buckets) { \
khint_t k, i, last, mask, step = 0; \
mask = h->n_buckets - 1; \
k = __hash_func(key); i = k & mask; \
last = i; \
while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \
i = (i + (++step)) & mask; \
if (i == last) return h->n_buckets; \
} \
return __ac_iseither(h->flags, i)? h->n_buckets : i; \
} else return 0; \
} \
SCOPE int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \
{ /* This function uses 0.25*n_buckets bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. */ \
khint32_t *new_flags = 0; \
khint_t j = 1; \
{ \
kroundup32(new_n_buckets); \
if (new_n_buckets < 4) new_n_buckets = 4; \
if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0; /* requested size is too small */ \
else { /* hash table size to be changed (shrink or expand); rehash */ \
new_flags = (khint32_t*)kmalloc(__ac_fsize(new_n_buckets) * sizeof(khint32_t)); \
if (!new_flags) return -1; \
memset(new_flags, 0xaa, __ac_fsize(new_n_buckets) * sizeof(khint32_t)); \
if (h->n_buckets < new_n_buckets) { /* expand */ \
khkey_t *new_keys = (khkey_t*)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
if (!new_keys) { kfree(new_flags); return -1; } \
h->keys = new_keys; \
if (kh_is_map) { \
khval_t *new_vals = (khval_t*)krealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
if (!new_vals) { kfree(new_flags); return -1; } \
h->vals = new_vals; \
} \
} /* otherwise shrink */ \
} \
} \
if (j) { /* rehashing is needed */ \
for (j = 0; j != h->n_buckets; ++j) { \
if (__ac_iseither(h->flags, j) == 0) { \
khkey_t key = h->keys[j]; \
khval_t val; \
khint_t new_mask; \
new_mask = new_n_buckets - 1; \
if (kh_is_map) val = h->vals[j]; \
__ac_set_isdel_true(h->flags, j); \
while (1) { /* kick-out process; sort of like in Cuckoo hashing */ \
khint_t k, i, step = 0; \
k = __hash_func(key); \
i = k & new_mask; \
while (!__ac_isempty(new_flags, i)) i = (i + (++step)) & new_mask; \
__ac_set_isempty_false(new_flags, i); \
if (i < h->n_buckets && __ac_iseither(h->flags, i) == 0) { /* kick out the existing element */ \
{ khkey_t tmp = h->keys[i]; h->keys[i] = key; key = tmp; } \
if (kh_is_map) { khval_t tmp = h->vals[i]; h->vals[i] = val; val = tmp; } \
__ac_set_isdel_true(h->flags, i); /* mark it as deleted in the old hash table */ \
} else { /* write the element and jump out of the loop */ \
h->keys[i] = key; \
if (kh_is_map) h->vals[i] = val; \
break; \
} \
} \
} \
} \
if (h->n_buckets > new_n_buckets) { /* shrink the hash table */ \
h->keys = (khkey_t*)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
if (kh_is_map) h->vals = (khval_t*)krealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
} \
kfree(h->flags); /* free the working space */ \
h->flags = new_flags; \
h->n_buckets = new_n_buckets; \
h->n_occupied = h->size; \
h->upper_bound = (khint_t)(h->n_buckets * __ac_HASH_UPPER + 0.5); \
} \
return 0; \
} \
SCOPE khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret) \
{ \
khint_t x; \
if (h->n_occupied >= h->upper_bound) { /* update the hash table */ \
if (h->n_buckets > (h->size<<1)) { \
if (kh_resize_##name(h, h->n_buckets - 1) < 0) { /* clear "deleted" elements */ \
*ret = -1; return h->n_buckets; \
} \
} else if (kh_resize_##name(h, h->n_buckets + 1) < 0) { /* expand the hash table */ \
*ret = -1; return h->n_buckets; \
} \
} /* TODO: to implement automatically shrinking; resize() already support shrinking */ \
{ \
khint_t k, i, site, last, mask = h->n_buckets - 1, step = 0; \
x = site = h->n_buckets; k = __hash_func(key); i = k & mask; \
if (__ac_isempty(h->flags, i)) x = i; /* for speed up */ \
else { \
last = i; \
while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \
if (__ac_isdel(h->flags, i)) site = i; \
i = (i + (++step)) & mask; \
if (i == last) { x = site; break; } \
} \
if (x == h->n_buckets) { \
if (__ac_isempty(h->flags, i) && site != h->n_buckets) x = site; \
else x = i; \
} \
} \
} \
if (__ac_isempty(h->flags, x)) { /* not present at all */ \
h->keys[x] = key; \
__ac_set_isboth_false(h->flags, x); \
++h->size; ++h->n_occupied; \
*ret = 1; \
} else if (__ac_isdel(h->flags, x)) { /* deleted */ \
h->keys[x] = key; \
__ac_set_isboth_false(h->flags, x); \
++h->size; \
*ret = 2; \
} else *ret = 0; /* Don't touch h->keys[x] if present and not deleted */ \
return x; \
} \
SCOPE void kh_del_##name(kh_##name##_t *h, khint_t x) \
{ \
if (x != h->n_buckets && !__ac_iseither(h->flags, x)) { \
__ac_set_isdel_true(h->flags, x); \
--h->size; \
} \
} \
SCOPE void kh_load_##name(kh_##name##_t *h, FILE* fp)\
{\
fread(&(h->n_buckets), sizeof(khint_t), 1, fp);\
fread(&(h->size), sizeof(khint_t), 1, fp);\
fread(&(h->n_occupied), sizeof(khint_t), 1, fp);\
fread(&(h->upper_bound), sizeof(khint_t), 1, fp);\
if (h->n_buckets)\
{\
h->flags = (khint32_t*)kmalloc(__ac_fsize(h->n_buckets) * sizeof(khint32_t));\
fread(h->flags, sizeof(khint32_t), __ac_fsize(h->n_buckets), fp);\
h->keys = (khkey_t*)kmalloc(sizeof(khkey_t)*h->n_buckets);\
fread(h->keys, sizeof(khkey_t), h->n_buckets, fp);\
h->vals = (khval_t*)kmalloc(sizeof(khval_t)*h->n_buckets);\
fread(h->vals, sizeof(khval_t), h->n_buckets, fp);\
}\
}\
SCOPE void kh_write_##name(kh_##name##_t *h, FILE* fp)\
{\
fwrite(&(h->n_buckets), sizeof(khint_t), 1, fp);\
fwrite(&(h->size), sizeof(khint_t), 1, fp);\
fwrite(&(h->n_occupied), sizeof(khint_t), 1, fp);\
fwrite(&(h->upper_bound), sizeof(khint_t), 1, fp);\
if (h->n_buckets)\
{\
fwrite(h->flags, sizeof(khint32_t), __ac_fsize(h->n_buckets), fp);\
fwrite(h->keys, sizeof(khkey_t), h->n_buckets, fp);\
fwrite(h->vals, sizeof(khval_t), h->n_buckets, fp);\
}\
}
#define KHASH_DECLARE(name, khkey_t, khval_t) \
__KHASH_TYPE(name, khkey_t, khval_t) \
__KHASH_PROTOTYPES(name, khkey_t, khval_t)
#define KHASH_INIT2(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
__KHASH_TYPE(name, khkey_t, khval_t) \
__KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
#define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
KHASH_INIT2(name, static kh_inline klib_unused, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
/* --- BEGIN OF HASH FUNCTIONS --- */
/*! @function
@abstract Integer hash function
@param key The integer [khint32_t]
@return The hash value [khint_t]
*/
#define kh_int_hash_func(key) (khint32_t)(key)
/*! @function
@abstract Integer comparison function
*/
#define kh_int_hash_equal(a, b) ((a) == (b))
/*! @function
@abstract 64-bit integer hash function
@param key The integer [khint64_t]
@return The hash value [khint_t]
*/
#define kh_int64_hash_func(key) (khint32_t)((key)>>33^(key)^(key)<<11)
/*! @function
@abstract 64-bit integer comparison function
*/
#define kh_int64_hash_equal(a, b) ((a) == (b))
/*! @function
@abstract const char* hash function
@param s Pointer to a null terminated string
@return The hash value
*/
static kh_inline khint_t __ac_X31_hash_string(const char *s)
{
khint_t h = (khint_t)*s;
if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)*s;
return h;
}
/*! @function
@abstract Another interface to const char* hash function
@param key Pointer to a null terminated string [const char*]
@return The hash value [khint_t]
*/
#define kh_str_hash_func(key) __ac_X31_hash_string(key)
/*! @function
@abstract Const char* comparison function
*/
#define kh_str_hash_equal(a, b) (strcmp(a, b) == 0)
static kh_inline khint_t __ac_Wang_hash(khint_t key)
{
key += ~(key << 15);
key ^= (key >> 10);
key += (key << 3);
key ^= (key >> 6);
key += ~(key << 11);
key ^= (key >> 16);
return key;
}
#define kh_int_hash_func2(key) __ac_Wang_hash((khint_t)key)
/* --- END OF HASH FUNCTIONS --- */
/* Other convenient macros... */
/*!
@abstract Type of the hash table.
@param name Name of the hash table [symbol]
*/
#define khash_t(name) kh_##name##_t
/*! @function
@abstract Initiate a hash table.
@param name Name of the hash table [symbol]
@return Pointer to the hash table [khash_t(name)*]
*/
#define kh_init(name) kh_init_##name()
/*! @function
@abstract Destroy a hash table.
@param name Name of the hash table [symbol]
@param h Pointer to the hash table [khash_t(name)*]
*/
#define kh_destroy(name, h) kh_destroy_##name(h)
/*! @function
@abstract Reset a hash table without deallocating memory.
@param name Name of the hash table [symbol]
@param h Pointer to the hash table [khash_t(name)*]
*/
#define kh_clear(name, h) kh_clear_##name(h)
/*! @function
@abstract Resize a hash table.
@param name Name of the hash table [symbol]
@param h Pointer to the hash table [khash_t(name)*]
@param s New size [khint_t]
*/
#define kh_resize(name, h, s) kh_resize_##name(h, s)
/*! @function
@abstract Insert a key to the hash table.
@param name Name of the hash table [symbol]
@param h Pointer to the hash table [khash_t(name)*]
@param k Key [type of keys]
@param r Extra return code: -1 if the operation failed;
0 if the key is present in the hash table;
1 if the bucket is empty (never used); 2 if the element in
the bucket has been deleted [int*]
@return Iterator to the inserted element [khint_t]
*/
#define kh_put(name, h, k, r) kh_put_##name(h, k, r)
/*! @function
@abstract Retrieve a key from the hash table.
@param name Name of the hash table [symbol]
@param h Pointer to the hash table [khash_t(name)*]
@param k Key [type of keys]
@return Iterator to the found element, or kh_end(h) if the element is absent [khint_t]
*/
#define kh_get(name, h, k) kh_get_##name(h, k)
/*! @function
@abstract Remove a key from the hash table.
@param name Name of the hash table [symbol]
@param h Pointer to the hash table [khash_t(name)*]
@param k Iterator to the element to be deleted [khint_t]
*/
#define kh_del(name, h, k) kh_del_##name(h, k)
/*! @function
@abstract Test whether a bucket contains data.
@param h Pointer to the hash table [khash_t(name)*]
@param x Iterator to the bucket [khint_t]
@return 1 if containing data; 0 otherwise [int]
*/
#define kh_exist(h, x) (!__ac_iseither((h)->flags, (x)))
/*! @function
@abstract Get key given an iterator
@param h Pointer to the hash table [khash_t(name)*]
@param x Iterator to the bucket [khint_t]
@return Key [type of keys]
*/
#define kh_key(h, x) ((h)->keys[x])
/*! @function
@abstract Get value given an iterator
@param h Pointer to the hash table [khash_t(name)*]
@param x Iterator to the bucket [khint_t]
@return Value [type of values]
@discussion For hash sets, calling this results in segfault.
*/
#define kh_val(h, x) ((h)->vals[x])
/*! @function
@abstract Alias of kh_val()
*/
#define kh_value(h, x) ((h)->vals[x])
/*! @function
@abstract Get the start iterator
@param h Pointer to the hash table [khash_t(name)*]
@return The start iterator [khint_t]
*/
#define kh_begin(h) (khint_t)(0)
/*! @function
@abstract Get the end iterator
@param h Pointer to the hash table [khash_t(name)*]
@return The end iterator [khint_t]
*/
#define kh_end(h) ((h)->n_buckets)
/*! @function
@abstract Get the number of elements in the hash table
@param h Pointer to the hash table [khash_t(name)*]
@return Number of elements in the hash table [khint_t]
*/
#define kh_size(h) ((h)->size)
/*! @function
@abstract Get the number of buckets in the hash table
@param h Pointer to the hash table [khash_t(name)*]
@return Number of buckets in the hash table [khint_t]
*/
#define kh_n_buckets(h) ((h)->n_buckets)
/*! @function
@abstract Iterate over the entries in the hash table
@param h Pointer to the hash table [khash_t(name)*]
@param kvar Variable to which key will be assigned
@param vvar Variable to which value will be assigned
@param code Block of code to execute
*/
#define kh_foreach(h, kvar, vvar, code) { khint_t __i; \
for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \
if (!kh_exist(h,__i)) continue; \
(kvar) = kh_key(h,__i); \
(vvar) = kh_val(h,__i); \
code; \
} }
/*! @function
@abstract Iterate over the values in the hash table
@param h Pointer to the hash table [khash_t(name)*]
@param vvar Variable to which value will be assigned
@param code Block of code to execute
*/
#define kh_foreach_value(h, vvar, code) { khint_t __i; \
for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \
if (!kh_exist(h,__i)) continue; \
(vvar) = kh_val(h,__i); \
code; \
} }
#define kh_load(name, h, fp) kh_load_##name(h, fp)
#define kh_save(name, h, fp) kh_write_##name(h, fp)
/* More convenient interfaces */
/*! @function
@abstract Instantiate a hash set containing integer keys
@param name Name of the hash table [symbol]
*/
#define KHASH_SET_INIT_INT(name) \
KHASH_INIT(name, khint32_t, char, 0, kh_int_hash_func, kh_int_hash_equal)
/*! @function
@abstract Instantiate a hash map containing integer keys
@param name Name of the hash table [symbol]
@param khval_t Type of values [type]
*/
#define KHASH_MAP_INIT_INT(name, khval_t) \
KHASH_INIT(name, khint32_t, khval_t, 1, kh_int_hash_func, kh_int_hash_equal)
/*! @function
@abstract Instantiate a hash set containing 64-bit integer keys
@param name Name of the hash table [symbol]
*/
#define KHASH_SET_INIT_INT64(name) \
KHASH_INIT(name, khint64_t, char, 0, kh_int64_hash_func, kh_int64_hash_equal)
/*! @function
@abstract Instantiate a hash map containing 64-bit integer keys
@param name Name of the hash table [symbol]
@param khval_t Type of values [type]
*/
#define KHASH_MAP_INIT_INT64(name, khval_t) \
KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
typedef const char *kh_cstr_t;
/*! @function
@abstract Instantiate a hash map containing const char* keys
@param name Name of the hash table [symbol]
*/
#define KHASH_SET_INIT_STR(name) \
KHASH_INIT(name, kh_cstr_t, char, 0, kh_str_hash_func, kh_str_hash_equal)
/*! @function
@abstract Instantiate a hash map containing const char* keys
@param name Name of the hash table [symbol]
@param khval_t Type of values [type]
*/
#define KHASH_MAP_INIT_STR(name, khval_t) \
KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal)
#endif /* __AC_KHASH_H */
| 23,001
|
C++
|
.h
| 573
| 37.066318
| 115
| 0.592659
|
haowenz/sigmap
| 31
| 8
| 4
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,221
|
fast_dtw.h
|
haowenz_sigmap/src/fast_dtw.h
|
#ifndef FAST_DTW_H_
#define FAST_DTW_H_
#include<iostream>
#include<fstream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<string>
#include "signal_batch.h"
#include "utils.h"
namespace sigmap {
struct Coordinate{
size_t target_coord;
size_t query_coord;
Coordinate(size_t new_target_coord,size_t new_query_coord):
target_coord(new_target_coord),query_coord(new_query_coord){}
bool operator < (const Coordinate &other) const { return ((target_coord < other.target_coord)||((target_coord == other.target_coord)&(query_coord < other.query_coord))); }
};
// std::ostream& operator<<(std::ostream& os, const Coordinate& c){
// os << c.target_coord << "," << c.query_coord;
// return os;
// }
void reduce_by_half(const float *signal, size_t length, float *signal_reduced, size_t &reduced_length);
void expand_window(std::vector<Coordinate> &path,size_t target_length,size_t query_length,int radius,std::vector<std::vector<Coordinate>> &window);
void generate_path(std::vector<std::vector<int>> &path_matrix,std::vector<std::vector<Coordinate>> &window,std::map<Coordinate,std::pair<size_t,size_t>> &coord_to_window_index_map,std::vector<std::pair<Coordinate,int>> &path,ssize_t end_target_position);
float DTW(const float *target_signal, size_t target_length, const float *query_signal, size_t query_length, std::vector<std::vector<Coordinate>> &window,std::vector<std::pair<Coordinate,int>> &path,ssize_t &end_target_position);
float _fastDTW(const float *target_signal, size_t target_length, const float *query_signal, size_t query_length, int radius,std::vector<std::pair<Coordinate,int>> &path,std::vector<std::vector<Coordinate>> &window, ssize_t &end_target_position);
std::string print_alignment(std::vector<std::pair<Coordinate,int>> &path);
float fastDTW(const float *target_signal, size_t target_length, const float *query_signal, size_t query_length,int radius,ssize_t &end_target_position,std::string &cigar);
} // namespace sigmap
#endif // FAST_DTW_H_
| 2,058
|
C++
|
.h
| 32
| 61.4375
| 255
| 0.730655
|
haowenz/sigmap
| 31
| 8
| 4
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,222
|
SCD30.cpp
|
openair-collective_openair-violet/Code/Open-Air_Violet_PlatformIO/lib/Open-Air_Violet/src/SCD30.cpp
|
#include "SCD30.hpp"
AirSensor::AirSensor()
{
// constructor
}
AirSensor::~AirSensor()
{
// destructor
}
void AirSensor::setupSensor()
{
Wire.begin();
Serial.begin(BAUD_RATE);
Serial.println("SCD30 Example");
airSensor.begin(); // This will cause readings to occur every two seconds
// airSensor.setMeasurementInterval(2); //Change number of seconds between measurements: 2 to 1800 (30 minutes)
// My desk is ~1600m above sealevel
airSensor.setAltitudeCompensation(1); // Set altitude of the sensor in m
// Pressure in Boulder, CO is 24.65inHg or 834.74mBar
airSensor.setAmbientPressure(1037); // Current ambient pressure in mBar: 700 to 1200
}
void AirSensor::loopSensor()
{
if (airSensor.dataAvailable())
{
Serial.write(1);
// Serial.print("co2(ppm):");
Serial.print(airSensor.getCO2());
// Serial.print(" temp(C):");
// Serial.print(airSensor.getTemperature(), 1);
//
// Serial.print(" humidity(%):");
// Serial.print(airSensor.getHumidity(), 1);
Serial.println();
}
else
{
Serial.write(0);
// Serial.print(".");
}
my_delay(1); // delay for 1 second
}
AirSensor airSensor;
| 1,259
|
C++
|
.cpp
| 43
| 24.372093
| 115
| 0.640365
|
openair-collective/openair-violet
| 31
| 3
| 1
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,223
|
defines.cpp
|
openair-collective_openair-violet/Code/Open-Air_Violet_PlatformIO/lib/Open-Air_Violet/src/defines.cpp
|
/*
* Global variables with default values
* and global functions will go here
*/
// waste time without blocking using a for-loop
void my_delay(volatile long delay_time)
{
delay_time = delay_time * 1e+6L;
for (volatile long count = delay_time; count > 0L; count--)
;
}
| 287
|
C++
|
.cpp
| 11
| 23.363636
| 63
| 0.695652
|
openair-collective/openair-violet
| 31
| 3
| 1
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,224
|
main.cpp
|
openair-collective_openair-violet/Code/Open-Air_Violet_PlatformIO/src/main.cpp
|
#include <SCD30.hpp>
void setup() {
airsensor.setupSensor();
// put your setup code here, to run once:
}
void loop() {
airsensor.loopSensor();
// put your main code here, to run repeatedly:
}
| 201
|
C++
|
.cpp
| 9
| 20.333333
| 48
| 0.701571
|
openair-collective/openair-violet
| 31
| 3
| 1
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,225
|
defines.hpp
|
openair-collective_openair-violet/Code/Open-Air_Violet_PlatformIO/lib/Open-Air_Violet/src/defines.hpp
|
/*
* Global header files
* and global function/variable declarations will go here
*/
#pragma once
#ifndef DEFINES_HPP
#define DEFINES_HPP
#include <Arduino.h>
#if (ESP32)
#define BAUD_RATE 115200
#endif
// Globally available functions
void my_delay(volatile long delay_time);
#endif //EOF DEFINES_HPP
| 306
|
C++
|
.h
| 14
| 20.5
| 56
| 0.789655
|
openair-collective/openair-violet
| 31
| 3
| 1
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,226
|
SCD30.hpp
|
openair-collective_openair-violet/Code/Open-Air_Violet_PlatformIO/lib/Open-Air_Violet/src/SCD30.hpp
|
/*
Initial testing of the SD30 CO2 sensor for openair-violet
Attempts to send the C02 ppm every second accross a serial
port so it is availble to visualized for by the associated process sketch.
Requires the SD30 Ardunio Lib.
Based off the sample detailed below:
Reading CO2, humidity and temperature from the SCD30
By: Nathan Seidle
SparkFun Electronics
Date: May 22nd, 2018
License: MIT. See license file for more information but you can
basically do whatever you want with this code.
Feel like supporting open source hardware?
Buy a board from SparkFun! https://www.sparkfun.com/products/14751
This example demonstrates the various settings available on the SCD30.
Hardware Connections:
Attach the Qwiic Shield to your Arduino/Photon/ESP32 or other
Plug the sensor onto the shield
Serial.print it out at 9600 baud to serial monitor.
Note: All settings (interval, altitude, etc) are saved to non-volatile memory and are
loaded by the SCD30 at power on. There's no damage in sending that at each power on.
Note: 100kHz I2C is fine, but according to the datasheet 400kHz I2C is not supported by the SCD30
*/
#pragma once
#ifndef SCD30_HPP
#define SCD30_HPP
#include "defines.hpp"
#include <Wire.h> // Change to TinyI2C for more performance
#include <SparkFun_SCD30_Arduino_Library.h>
class AirSensor : public SCD30
{
public:
AirSensor();
virtual ~AirSensor();
void setupSensor();
void loopSensor();
private:
// private stuff goes here
};
extern AirSensor airsensor;
#endif
| 1,548
|
C++
|
.h
| 41
| 34.926829
| 99
| 0.779786
|
openair-collective/openair-violet
| 31
| 3
| 1
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,228
|
bufferpool.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/bufferpool.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// BufferPool is a memory pool to reduce memory allocation time consumption for functionality like custom camera interoperability, which needs to allocate memory buffers of a fixed size repeatedly.
/// </summary>
@interface easyar_BufferPool : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// block_size is the byte size of each `Buffer`_ .
/// capacity is the maximum count of `Buffer`_ .
/// </summary>
+ (easyar_BufferPool *) create:(int)block_size capacity:(int)capacity;
/// <summary>
/// The byte size of each `Buffer`_ .
/// </summary>
- (int)block_size;
/// <summary>
/// The maximum count of `Buffer`_ .
/// </summary>
- (int)capacity;
/// <summary>
/// Current acquired count of `Buffer`_ .
/// </summary>
- (int)size;
/// <summary>
/// Tries to acquire a memory block. If current acquired count of `Buffer`_ does not reach maximum, a new `Buffer`_ is fetched or allocated, or else null is returned.
/// </summary>
- (easyar_Buffer *)tryAcquire;
@end
| 1,717
|
C++
|
.h
| 37
| 45.189189
| 198
| 0.623804
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,230
|
videoplayer.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/videoplayer.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_VIDEOPLAYER_H__
#define __EASYAR_VIDEOPLAYER_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
void easyar_VideoPlayer__ctor(/* OUT */ easyar_VideoPlayer * * Return);
/// <summary>
/// Checks if the component is available. It returns true only on Windows, Android or iOS. It's not available on Mac.
/// </summary>
bool easyar_VideoPlayer_isAvailable(void);
/// <summary>
/// Sets the video type. The type will default to normal video if not set manually. It should be called before open.
/// </summary>
void easyar_VideoPlayer_setVideoType(easyar_VideoPlayer * This, easyar_VideoType videoType);
/// <summary>
/// Passes the texture to display video into player. It should be set before open.
/// </summary>
void easyar_VideoPlayer_setRenderTexture(easyar_VideoPlayer * This, easyar_TextureId * texture);
/// <summary>
/// Opens a video from path.
/// path can be a local video file (path/to/video.mp4) or url (http://www.../.../video.mp4). storageType indicates the type of path. See `StorageType`_ for more description.
/// This method is an asynchronous method. Open may take some time to finish. If you want to know the open result or the play status while playing, you have to handle callback. The callback will be called from a different thread. You can check if the open finished successfully and start play after a successful open.
/// </summary>
void easyar_VideoPlayer_open(easyar_VideoPlayer * This, easyar_String * path, easyar_StorageType storageType, easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromVideoStatus callback);
/// <summary>
/// Closes the video.
/// </summary>
void easyar_VideoPlayer_close(easyar_VideoPlayer * This);
/// <summary>
/// Starts or continues to play video.
/// </summary>
bool easyar_VideoPlayer_play(easyar_VideoPlayer * This);
/// <summary>
/// Stops the video playback.
/// </summary>
void easyar_VideoPlayer_stop(easyar_VideoPlayer * This);
/// <summary>
/// Pauses the video playback.
/// </summary>
void easyar_VideoPlayer_pause(easyar_VideoPlayer * This);
/// <summary>
/// Checks whether video texture is ready for render. Use this to check if texture passed into the player has been touched.
/// </summary>
bool easyar_VideoPlayer_isRenderTextureAvailable(easyar_VideoPlayer * This);
/// <summary>
/// Updates texture data. This should be called in the renderer thread when isRenderTextureAvailable returns true.
/// </summary>
void easyar_VideoPlayer_updateFrame(easyar_VideoPlayer * This);
/// <summary>
/// Returns the video duration. Use after a successful open.
/// </summary>
int easyar_VideoPlayer_duration(easyar_VideoPlayer * This);
/// <summary>
/// Returns the current position of video. Use after a successful open.
/// </summary>
int easyar_VideoPlayer_currentPosition(easyar_VideoPlayer * This);
/// <summary>
/// Seeks to play to position . Use after a successful open.
/// </summary>
bool easyar_VideoPlayer_seek(easyar_VideoPlayer * This, int position);
/// <summary>
/// Returns the video size. Use after a successful open.
/// </summary>
easyar_Vec2I easyar_VideoPlayer_size(easyar_VideoPlayer * This);
/// <summary>
/// Returns current volume. Use after a successful open.
/// </summary>
float easyar_VideoPlayer_volume(easyar_VideoPlayer * This);
/// <summary>
/// Sets volume of the video. Use after a successful open.
/// </summary>
bool easyar_VideoPlayer_setVolume(easyar_VideoPlayer * This, float volume);
void easyar_VideoPlayer__dtor(easyar_VideoPlayer * This);
void easyar_VideoPlayer__retain(const easyar_VideoPlayer * This, /* OUT */ easyar_VideoPlayer * * Return);
const char * easyar_VideoPlayer__typeName(const easyar_VideoPlayer * This);
#ifdef __cplusplus
}
#endif
#endif
| 4,387
|
C++
|
.h
| 88
| 48.75
| 317
| 0.716783
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
1,537,232
|
engine.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/engine.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_ENGINE_H__
#define __EASYAR_ENGINE_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Gets the version schema hash, which can be used to ensure type declarations consistent with runtime library.
/// </summary>
int easyar_Engine_schemaHash(void);
bool easyar_Engine_initialize(easyar_String * key);
/// <summary>
/// Handles the app onPause, pauses internal tasks.
/// </summary>
void easyar_Engine_onPause(void);
/// <summary>
/// Handles the app onResume, resumes internal tasks.
/// </summary>
void easyar_Engine_onResume(void);
/// <summary>
/// Gets error message on initialization failure.
/// </summary>
void easyar_Engine_errorMessage(/* OUT */ easyar_String * * Return);
/// <summary>
/// Gets the version number of EasyARSense.
/// </summary>
void easyar_Engine_versionString(/* OUT */ easyar_String * * Return);
/// <summary>
/// Gets the product name of EasyARSense. (Including variant, operating system and CPU architecture.)
/// </summary>
void easyar_Engine_name(/* OUT */ easyar_String * * Return);
#ifdef __cplusplus
}
#endif
#endif
| 1,759
|
C++
|
.h
| 43
| 39.697674
| 127
| 0.634446
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,233
|
objecttarget.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/objecttarget.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
#import "easyar/target.oc.h"
/// <summary>
/// ObjectTargetParameters represents the parameters to create a `ObjectTarget`_ .
/// </summary>
@interface easyar_ObjectTargetParameters : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_ObjectTargetParameters *) create;
/// <summary>
/// Gets `Buffer`_ dictionary.
/// </summary>
- (easyar_BufferDictionary *)bufferDictionary;
/// <summary>
/// Sets `Buffer`_ dictionary. obj, mtl and jpg/png files shall be loaded into the dictionay, and be able to be located by relative or absolute paths.
/// </summary>
- (void)setBufferDictionary:(easyar_BufferDictionary *)bufferDictionary;
/// <summary>
/// Gets obj file path.
/// </summary>
- (NSString *)objPath;
/// <summary>
/// Sets obj file path.
/// </summary>
- (void)setObjPath:(NSString *)objPath;
/// <summary>
/// Gets target name. It can be used to distinguish targets.
/// </summary>
- (NSString *)name;
/// <summary>
/// Sets target name.
/// </summary>
- (void)setName:(NSString *)name;
/// <summary>
/// Gets the target uid. You can set this uid in the json config as a method to distinguish from targets.
/// </summary>
- (NSString *)uid;
/// <summary>
/// Sets target uid.
/// </summary>
- (void)setUid:(NSString *)uid;
/// <summary>
/// Gets meta data.
/// </summary>
- (NSString *)meta;
/// <summary>
/// Sets meta data。
/// </summary>
- (void)setMeta:(NSString *)meta;
/// <summary>
/// Gets the scale of model. The value is the physical scale divided by model coordinate system scale. The default value is 1. (Supposing the unit of model coordinate system is 1 meter.)
/// </summary>
- (float)scale;
/// <summary>
/// Sets the scale of model. The value is the physical scale divided by model coordinate system scale. The default value is 1. (Supposing the unit of model coordinate system is 1 meter.)
/// It is needed to set the model scale in rendering engine separately.
/// </summary>
- (void)setScale:(float)size;
@end
/// <summary>
/// ObjectTarget represents 3d object targets that can be tracked by `ObjectTracker`_ .
/// The size of ObjectTarget is determined by the `obj` file. You can change it by changing the object `scale`, which is default to 1.
/// A ObjectTarget should be setup using setup before any value is valid. And ObjectTarget can be tracked by `ObjectTracker`_ after a successful load into the `ObjectTracker`_ using `ObjectTracker.loadTarget`_ .
/// </summary>
@interface easyar_ObjectTarget : easyar_Target
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_ObjectTarget *) create;
/// <summary>
/// Creates a target from parameters.
/// </summary>
+ (easyar_ObjectTarget *)createFromParameters:(easyar_ObjectTargetParameters *)parameters;
/// <summary>
/// Creats a target from obj, mtl and jpg/png files.
/// </summary>
+ (easyar_ObjectTarget *)createFromObjectFile:(NSString *)path storageType:(easyar_StorageType)storageType name:(NSString *)name uid:(NSString *)uid meta:(NSString *)meta scale:(float)scale;
/// <summary>
/// Setup all targets listed in the json file or json string from path with storageType. This method only parses the json file or string.
/// If path is json file path, storageType should be `App` or `Assets` or `Absolute` indicating the path type. Paths inside json files should be absolute path or relative path to the json file.
/// See `StorageType`_ for more descriptions.
/// </summary>
+ (NSArray<easyar_ObjectTarget *> *)setupAll:(NSString *)path storageType:(easyar_StorageType)storageType;
/// <summary>
/// The scale of model. The value is the physical scale divided by model coordinate system scale. The default value is 1. (Supposing the unit of model coordinate system is 1 meter.)
/// </summary>
- (float)scale;
/// <summary>
/// The bounding box of object, it contains the 8 points of the box.
/// Vertices's indices are defined and stored following the rule:
/// ::
///
/// 4-----7
/// /| /|
/// 5-----6 | z
/// | | | | |
/// | 0---|-3 o---y
/// |/ |/ /
/// 1-----2 x
/// </summary>
- (NSArray<easyar_Vec3F *> *)boundingBox;
/// <summary>
/// Sets model target scale, this will overwrite the value set in the json file or the default value. The value is the physical scale divided by model coordinate system scale. The default value is 1. (Supposing the unit of model coordinate system is 1 meter.)
/// It is needed to set the model scale in rendering engine separately.
/// It also should been done before loading ObjectTarget into `ObjectTracker`_ using `ObjectTracker.loadTarget`_.
/// </summary>
- (bool)setScale:(float)scale;
/// <summary>
/// Returns the target id. A target id is a integer number generated at runtime. This id is non-zero and increasing globally.
/// </summary>
- (int)runtimeID;
/// <summary>
/// Returns the target uid. A target uid is useful in cloud based algorithms. If no cloud is used, you can set this uid in the json config as a alternative method to distinguish from targets.
/// </summary>
- (NSString *)uid;
/// <summary>
/// Returns the target name. Name is used to distinguish targets in a json file.
/// </summary>
- (NSString *)name;
/// <summary>
/// Set name. It will erase previously set data or data from cloud.
/// </summary>
- (void)setName:(NSString *)name;
/// <summary>
/// Returns the meta data set by setMetaData. Or, in a cloud returned target, returns the meta data set in the cloud server.
/// </summary>
- (NSString *)meta;
/// <summary>
/// Set meta data. It will erase previously set data or data from cloud.
/// </summary>
- (void)setMeta:(NSString *)data;
@end
| 6,332
|
C++
|
.h
| 139
| 44.453237
| 259
| 0.690727
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,234
|
dataflow.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/dataflow.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_DATAFLOW_H__
#define __EASYAR_DATAFLOW_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Input data.
/// </summary>
void easyar_SignalSink_handle(easyar_SignalSink * This);
void easyar_SignalSink__dtor(easyar_SignalSink * This);
void easyar_SignalSink__retain(const easyar_SignalSink * This, /* OUT */ easyar_SignalSink * * Return);
const char * easyar_SignalSink__typeName(const easyar_SignalSink * This);
/// <summary>
/// Sets data handler.
/// </summary>
void easyar_SignalSource_setHandler(easyar_SignalSource * This, easyar_OptionalOfFunctorOfVoid handler);
/// <summary>
/// Connects to input port.
/// </summary>
void easyar_SignalSource_connect(easyar_SignalSource * This, easyar_SignalSink * sink);
/// <summary>
/// Disconnects.
/// </summary>
void easyar_SignalSource_disconnect(easyar_SignalSource * This);
void easyar_SignalSource__dtor(easyar_SignalSource * This);
void easyar_SignalSource__retain(const easyar_SignalSource * This, /* OUT */ easyar_SignalSource * * Return);
const char * easyar_SignalSource__typeName(const easyar_SignalSource * This);
/// <summary>
/// Input data.
/// </summary>
void easyar_InputFrameSink_handle(easyar_InputFrameSink * This, easyar_InputFrame * inputData);
void easyar_InputFrameSink__dtor(easyar_InputFrameSink * This);
void easyar_InputFrameSink__retain(const easyar_InputFrameSink * This, /* OUT */ easyar_InputFrameSink * * Return);
const char * easyar_InputFrameSink__typeName(const easyar_InputFrameSink * This);
/// <summary>
/// Sets data handler.
/// </summary>
void easyar_InputFrameSource_setHandler(easyar_InputFrameSource * This, easyar_OptionalOfFunctorOfVoidFromInputFrame handler);
/// <summary>
/// Connects to input port.
/// </summary>
void easyar_InputFrameSource_connect(easyar_InputFrameSource * This, easyar_InputFrameSink * sink);
/// <summary>
/// Disconnects.
/// </summary>
void easyar_InputFrameSource_disconnect(easyar_InputFrameSource * This);
void easyar_InputFrameSource__dtor(easyar_InputFrameSource * This);
void easyar_InputFrameSource__retain(const easyar_InputFrameSource * This, /* OUT */ easyar_InputFrameSource * * Return);
const char * easyar_InputFrameSource__typeName(const easyar_InputFrameSource * This);
/// <summary>
/// Input data.
/// </summary>
void easyar_OutputFrameSink_handle(easyar_OutputFrameSink * This, easyar_OutputFrame * inputData);
void easyar_OutputFrameSink__dtor(easyar_OutputFrameSink * This);
void easyar_OutputFrameSink__retain(const easyar_OutputFrameSink * This, /* OUT */ easyar_OutputFrameSink * * Return);
const char * easyar_OutputFrameSink__typeName(const easyar_OutputFrameSink * This);
/// <summary>
/// Sets data handler.
/// </summary>
void easyar_OutputFrameSource_setHandler(easyar_OutputFrameSource * This, easyar_OptionalOfFunctorOfVoidFromOutputFrame handler);
/// <summary>
/// Connects to input port.
/// </summary>
void easyar_OutputFrameSource_connect(easyar_OutputFrameSource * This, easyar_OutputFrameSink * sink);
/// <summary>
/// Disconnects.
/// </summary>
void easyar_OutputFrameSource_disconnect(easyar_OutputFrameSource * This);
void easyar_OutputFrameSource__dtor(easyar_OutputFrameSource * This);
void easyar_OutputFrameSource__retain(const easyar_OutputFrameSource * This, /* OUT */ easyar_OutputFrameSource * * Return);
const char * easyar_OutputFrameSource__typeName(const easyar_OutputFrameSource * This);
/// <summary>
/// Input data.
/// </summary>
void easyar_FeedbackFrameSink_handle(easyar_FeedbackFrameSink * This, easyar_FeedbackFrame * inputData);
void easyar_FeedbackFrameSink__dtor(easyar_FeedbackFrameSink * This);
void easyar_FeedbackFrameSink__retain(const easyar_FeedbackFrameSink * This, /* OUT */ easyar_FeedbackFrameSink * * Return);
const char * easyar_FeedbackFrameSink__typeName(const easyar_FeedbackFrameSink * This);
/// <summary>
/// Sets data handler.
/// </summary>
void easyar_FeedbackFrameSource_setHandler(easyar_FeedbackFrameSource * This, easyar_OptionalOfFunctorOfVoidFromFeedbackFrame handler);
/// <summary>
/// Connects to input port.
/// </summary>
void easyar_FeedbackFrameSource_connect(easyar_FeedbackFrameSource * This, easyar_FeedbackFrameSink * sink);
/// <summary>
/// Disconnects.
/// </summary>
void easyar_FeedbackFrameSource_disconnect(easyar_FeedbackFrameSource * This);
void easyar_FeedbackFrameSource__dtor(easyar_FeedbackFrameSource * This);
void easyar_FeedbackFrameSource__retain(const easyar_FeedbackFrameSource * This, /* OUT */ easyar_FeedbackFrameSource * * Return);
const char * easyar_FeedbackFrameSource__typeName(const easyar_FeedbackFrameSource * This);
/// <summary>
/// Input port.
/// </summary>
void easyar_InputFrameFork_input(easyar_InputFrameFork * This, /* OUT */ easyar_InputFrameSink * * Return);
/// <summary>
/// Output port.
/// </summary>
void easyar_InputFrameFork_output(easyar_InputFrameFork * This, int index, /* OUT */ easyar_InputFrameSource * * Return);
/// <summary>
/// Output count.
/// </summary>
int easyar_InputFrameFork_outputCount(easyar_InputFrameFork * This);
/// <summary>
/// Creates an instance.
/// </summary>
void easyar_InputFrameFork_create(int outputCount, /* OUT */ easyar_InputFrameFork * * Return);
void easyar_InputFrameFork__dtor(easyar_InputFrameFork * This);
void easyar_InputFrameFork__retain(const easyar_InputFrameFork * This, /* OUT */ easyar_InputFrameFork * * Return);
const char * easyar_InputFrameFork__typeName(const easyar_InputFrameFork * This);
/// <summary>
/// Input port.
/// </summary>
void easyar_OutputFrameFork_input(easyar_OutputFrameFork * This, /* OUT */ easyar_OutputFrameSink * * Return);
/// <summary>
/// Output port.
/// </summary>
void easyar_OutputFrameFork_output(easyar_OutputFrameFork * This, int index, /* OUT */ easyar_OutputFrameSource * * Return);
/// <summary>
/// Output count.
/// </summary>
int easyar_OutputFrameFork_outputCount(easyar_OutputFrameFork * This);
/// <summary>
/// Creates an instance.
/// </summary>
void easyar_OutputFrameFork_create(int outputCount, /* OUT */ easyar_OutputFrameFork * * Return);
void easyar_OutputFrameFork__dtor(easyar_OutputFrameFork * This);
void easyar_OutputFrameFork__retain(const easyar_OutputFrameFork * This, /* OUT */ easyar_OutputFrameFork * * Return);
const char * easyar_OutputFrameFork__typeName(const easyar_OutputFrameFork * This);
/// <summary>
/// Input port.
/// </summary>
void easyar_OutputFrameJoin_input(easyar_OutputFrameJoin * This, int index, /* OUT */ easyar_OutputFrameSink * * Return);
/// <summary>
/// Output port.
/// </summary>
void easyar_OutputFrameJoin_output(easyar_OutputFrameJoin * This, /* OUT */ easyar_OutputFrameSource * * Return);
/// <summary>
/// Input count.
/// </summary>
int easyar_OutputFrameJoin_inputCount(easyar_OutputFrameJoin * This);
/// <summary>
/// Creates an instance. The default joiner will be used, which takes input frame from the first input and first result or null of each input. The first result of every input will be placed at the corresponding input index of results of the final output frame.
/// </summary>
void easyar_OutputFrameJoin_create(int inputCount, /* OUT */ easyar_OutputFrameJoin * * Return);
/// <summary>
/// Creates an instance. A custom joiner is specified.
/// </summary>
void easyar_OutputFrameJoin_createWithJoiner(int inputCount, easyar_FunctorOfOutputFrameFromListOfOutputFrame joiner, /* OUT */ easyar_OutputFrameJoin * * Return);
void easyar_OutputFrameJoin__dtor(easyar_OutputFrameJoin * This);
void easyar_OutputFrameJoin__retain(const easyar_OutputFrameJoin * This, /* OUT */ easyar_OutputFrameJoin * * Return);
const char * easyar_OutputFrameJoin__typeName(const easyar_OutputFrameJoin * This);
/// <summary>
/// Input port.
/// </summary>
void easyar_FeedbackFrameFork_input(easyar_FeedbackFrameFork * This, /* OUT */ easyar_FeedbackFrameSink * * Return);
/// <summary>
/// Output port.
/// </summary>
void easyar_FeedbackFrameFork_output(easyar_FeedbackFrameFork * This, int index, /* OUT */ easyar_FeedbackFrameSource * * Return);
/// <summary>
/// Output count.
/// </summary>
int easyar_FeedbackFrameFork_outputCount(easyar_FeedbackFrameFork * This);
/// <summary>
/// Creates an instance.
/// </summary>
void easyar_FeedbackFrameFork_create(int outputCount, /* OUT */ easyar_FeedbackFrameFork * * Return);
void easyar_FeedbackFrameFork__dtor(easyar_FeedbackFrameFork * This);
void easyar_FeedbackFrameFork__retain(const easyar_FeedbackFrameFork * This, /* OUT */ easyar_FeedbackFrameFork * * Return);
const char * easyar_FeedbackFrameFork__typeName(const easyar_FeedbackFrameFork * This);
/// <summary>
/// Input port.
/// </summary>
void easyar_InputFrameThrottler_input(easyar_InputFrameThrottler * This, /* OUT */ easyar_InputFrameSink * * Return);
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
int easyar_InputFrameThrottler_bufferRequirement(easyar_InputFrameThrottler * This);
/// <summary>
/// Output port.
/// </summary>
void easyar_InputFrameThrottler_output(easyar_InputFrameThrottler * This, /* OUT */ easyar_InputFrameSource * * Return);
/// <summary>
/// Input port for clearance signal.
/// </summary>
void easyar_InputFrameThrottler_signalInput(easyar_InputFrameThrottler * This, /* OUT */ easyar_SignalSink * * Return);
/// <summary>
/// Creates an instance.
/// </summary>
void easyar_InputFrameThrottler_create(/* OUT */ easyar_InputFrameThrottler * * Return);
void easyar_InputFrameThrottler__dtor(easyar_InputFrameThrottler * This);
void easyar_InputFrameThrottler__retain(const easyar_InputFrameThrottler * This, /* OUT */ easyar_InputFrameThrottler * * Return);
const char * easyar_InputFrameThrottler__typeName(const easyar_InputFrameThrottler * This);
/// <summary>
/// Input port.
/// </summary>
void easyar_OutputFrameBuffer_input(easyar_OutputFrameBuffer * This, /* OUT */ easyar_OutputFrameSink * * Return);
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
int easyar_OutputFrameBuffer_bufferRequirement(easyar_OutputFrameBuffer * This);
/// <summary>
/// Output port for frame arrival. It can be connected to `InputFrameThrottler.signalInput`_ .
/// </summary>
void easyar_OutputFrameBuffer_signalOutput(easyar_OutputFrameBuffer * This, /* OUT */ easyar_SignalSource * * Return);
/// <summary>
/// Fetches the most recent `OutputFrame`_ .
/// </summary>
void easyar_OutputFrameBuffer_peek(easyar_OutputFrameBuffer * This, /* OUT */ easyar_OptionalOfOutputFrame * Return);
/// <summary>
/// Creates an instance.
/// </summary>
void easyar_OutputFrameBuffer_create(/* OUT */ easyar_OutputFrameBuffer * * Return);
/// <summary>
/// Pauses output of `OutputFrame`_ . After execution, all results of `OutputFrameBuffer.peek`_ will be empty. `OutputFrameBuffer.signalOutput`_ is not affected.
/// </summary>
void easyar_OutputFrameBuffer_pause(easyar_OutputFrameBuffer * This);
/// <summary>
/// Resumes output of `OutputFrame`_ .
/// </summary>
void easyar_OutputFrameBuffer_resume(easyar_OutputFrameBuffer * This);
void easyar_OutputFrameBuffer__dtor(easyar_OutputFrameBuffer * This);
void easyar_OutputFrameBuffer__retain(const easyar_OutputFrameBuffer * This, /* OUT */ easyar_OutputFrameBuffer * * Return);
const char * easyar_OutputFrameBuffer__typeName(const easyar_OutputFrameBuffer * This);
/// <summary>
/// Input port.
/// </summary>
void easyar_InputFrameToOutputFrameAdapter_input(easyar_InputFrameToOutputFrameAdapter * This, /* OUT */ easyar_InputFrameSink * * Return);
/// <summary>
/// Output port.
/// </summary>
void easyar_InputFrameToOutputFrameAdapter_output(easyar_InputFrameToOutputFrameAdapter * This, /* OUT */ easyar_OutputFrameSource * * Return);
/// <summary>
/// Creates an instance.
/// </summary>
void easyar_InputFrameToOutputFrameAdapter_create(/* OUT */ easyar_InputFrameToOutputFrameAdapter * * Return);
void easyar_InputFrameToOutputFrameAdapter__dtor(easyar_InputFrameToOutputFrameAdapter * This);
void easyar_InputFrameToOutputFrameAdapter__retain(const easyar_InputFrameToOutputFrameAdapter * This, /* OUT */ easyar_InputFrameToOutputFrameAdapter * * Return);
const char * easyar_InputFrameToOutputFrameAdapter__typeName(const easyar_InputFrameToOutputFrameAdapter * This);
/// <summary>
/// Input port.
/// </summary>
void easyar_InputFrameToFeedbackFrameAdapter_input(easyar_InputFrameToFeedbackFrameAdapter * This, /* OUT */ easyar_InputFrameSink * * Return);
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
int easyar_InputFrameToFeedbackFrameAdapter_bufferRequirement(easyar_InputFrameToFeedbackFrameAdapter * This);
/// <summary>
/// Side input port for historic output frame input.
/// </summary>
void easyar_InputFrameToFeedbackFrameAdapter_sideInput(easyar_InputFrameToFeedbackFrameAdapter * This, /* OUT */ easyar_OutputFrameSink * * Return);
/// <summary>
/// Output port.
/// </summary>
void easyar_InputFrameToFeedbackFrameAdapter_output(easyar_InputFrameToFeedbackFrameAdapter * This, /* OUT */ easyar_FeedbackFrameSource * * Return);
/// <summary>
/// Creates an instance.
/// </summary>
void easyar_InputFrameToFeedbackFrameAdapter_create(/* OUT */ easyar_InputFrameToFeedbackFrameAdapter * * Return);
void easyar_InputFrameToFeedbackFrameAdapter__dtor(easyar_InputFrameToFeedbackFrameAdapter * This);
void easyar_InputFrameToFeedbackFrameAdapter__retain(const easyar_InputFrameToFeedbackFrameAdapter * This, /* OUT */ easyar_InputFrameToFeedbackFrameAdapter * * Return);
const char * easyar_InputFrameToFeedbackFrameAdapter__typeName(const easyar_InputFrameToFeedbackFrameAdapter * This);
void easyar_ListOfOutputFrame__ctor(easyar_OutputFrame * const * begin, easyar_OutputFrame * const * end, /* OUT */ easyar_ListOfOutputFrame * * Return);
void easyar_ListOfOutputFrame__dtor(easyar_ListOfOutputFrame * This);
void easyar_ListOfOutputFrame_copy(const easyar_ListOfOutputFrame * This, /* OUT */ easyar_ListOfOutputFrame * * Return);
int easyar_ListOfOutputFrame_size(const easyar_ListOfOutputFrame * This);
easyar_OutputFrame * easyar_ListOfOutputFrame_at(const easyar_ListOfOutputFrame * This, int index);
#ifdef __cplusplus
}
#endif
#endif
| 14,780
|
C++
|
.h
| 283
| 51.137809
| 260
| 0.760641
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,235
|
jniutility.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/jniutility.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// JNI utility class.
/// It is used in Unity to wrap Java byte array and ByteBuffer.
/// It is not supported on iOS.
/// </summary>
@interface easyar_JniUtility : NSObject
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Wraps Java's byte[]。
/// </summary>
+ (easyar_Buffer *)wrapByteArray:(void *)bytes readOnly:(bool)readOnly deleter:(void (^)())deleter;
/// <summary>
/// Wraps Java's java.nio.ByteBuffer, which must be a direct buffer.
/// </summary>
+ (easyar_Buffer *)wrapBuffer:(void *)directBuffer deleter:(void (^)())deleter;
@end
| 1,292
|
C++
|
.h
| 26
| 48.307692
| 127
| 0.589172
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,243
|
densespatialmap.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/densespatialmap.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_DENSESPATIALMAP_H__
#define __EASYAR_DENSESPATIALMAP_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Returns True when the device supports dense reconstruction, otherwise returns False.
/// </summary>
bool easyar_DenseSpatialMap_isAvailable(void);
/// <summary>
/// Input port for input frame. For DenseSpatialMap to work, the inputFrame must include image and it's camera parameters and spatial information (cameraTransform and trackingStatus). See also `InputFrameSink`_ .
/// </summary>
void easyar_DenseSpatialMap_inputFrameSink(easyar_DenseSpatialMap * This, /* OUT */ easyar_InputFrameSink * * Return);
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
int easyar_DenseSpatialMap_bufferRequirement(easyar_DenseSpatialMap * This);
/// <summary>
/// Create `DenseSpatialMap`_ object.
/// </summary>
void easyar_DenseSpatialMap_create(/* OUT */ easyar_DenseSpatialMap * * Return);
/// <summary>
/// Start or continue runninng `DenseSpatialMap`_ algorithm.
/// </summary>
bool easyar_DenseSpatialMap_start(easyar_DenseSpatialMap * This);
/// <summary>
/// Pause the reconstruction algorithm. Call `start` to resume reconstruction.
/// </summary>
void easyar_DenseSpatialMap_stop(easyar_DenseSpatialMap * This);
/// <summary>
/// Close `DenseSpatialMap`_ algorithm.
/// </summary>
void easyar_DenseSpatialMap_close(easyar_DenseSpatialMap * This);
/// <summary>
/// Get the mesh management object of type `SceneMesh`_ . The contents will automatically update after calling the `DenseSpatialMap.updateSceneMesh`_ function.
/// </summary>
void easyar_DenseSpatialMap_getMesh(easyar_DenseSpatialMap * This, /* OUT */ easyar_SceneMesh * * Return);
/// <summary>
/// Get the lastest updated mesh and save it to the `SceneMesh`_ object obtained by `DenseSpatialMap.getMesh`_ .
/// The parameter `updateMeshAll` indicates whether to perform a `full update` or an `incremental update`. When `updateMeshAll` is True, `full update` is performed. All meshes are saved to `SceneMesh`_ . When `updateMeshAll` is False, `incremental update` is performed, and only the most recently updated mesh is saved to `SceneMesh`_ .
/// `Full update` will take extra time and memory space, causing performance degradation.
/// </summary>
bool easyar_DenseSpatialMap_updateSceneMesh(easyar_DenseSpatialMap * This, bool updateMeshAll);
void easyar_DenseSpatialMap__dtor(easyar_DenseSpatialMap * This);
void easyar_DenseSpatialMap__retain(const easyar_DenseSpatialMap * This, /* OUT */ easyar_DenseSpatialMap * * Return);
const char * easyar_DenseSpatialMap__typeName(const easyar_DenseSpatialMap * This);
#ifdef __cplusplus
}
#endif
#endif
| 3,356
|
C++
|
.h
| 59
| 55.728814
| 336
| 0.712287
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,246
|
callbackscheduler.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/callbackscheduler.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// Callback scheduler.
/// There are two subclasses: `DelayedCallbackScheduler`_ and `ImmediateCallbackScheduler`_ .
/// `DelayedCallbackScheduler`_ is used to delay callback to be invoked manually, and it can be used in single-threaded environments (such as various UI environments).
/// `ImmediateCallbackScheduler`_ is used to mark callback to be invoked when event is dispatched, and it can be used in multi-threaded environments (such as server or service daemon).
/// </summary>
@interface easyar_CallbackScheduler : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
@end
/// <summary>
/// Delayed callback scheduler.
/// It is used to delay callback to be invoked manually, and it can be used in single-threaded environments (such as various UI environments).
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_DelayedCallbackScheduler : easyar_CallbackScheduler
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_DelayedCallbackScheduler *) create;
/// <summary>
/// Executes a callback. If there is no callback to execute, false is returned.
/// </summary>
- (bool)runOne;
@end
/// <summary>
/// Immediate callback scheduler.
/// It is used to mark callback to be invoked when event is dispatched, and it can be used in multi-threaded environments (such as server or service daemon).
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_ImmediateCallbackScheduler : easyar_CallbackScheduler
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Gets a default immediate callback scheduler.
/// </summary>
+ (easyar_ImmediateCallbackScheduler *)getDefault;
@end
| 2,437
|
C++
|
.h
| 46
| 51.652174
| 184
| 0.694865
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,247
|
vector.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/vector.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// record
/// 4 dimensional vector of float.
/// </summary>
@interface easyar_Vec4F : NSObject
/// <summary>
/// The raw data of vector.
/// </summary>
@property (nonatomic) NSArray<NSNumber *> * data;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)create:(NSArray<NSNumber *> *)data;
@end
/// <summary>
/// record
/// 3 dimensional vector of float.
/// </summary>
@interface easyar_Vec3F : NSObject
/// <summary>
/// The raw data of vector.
/// </summary>
@property (nonatomic) NSArray<NSNumber *> * data;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)create:(NSArray<NSNumber *> *)data;
@end
/// <summary>
/// record
/// 2 dimensional vector of float.
/// </summary>
@interface easyar_Vec2F : NSObject
/// <summary>
/// The raw data of vector.
/// </summary>
@property (nonatomic) NSArray<NSNumber *> * data;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)create:(NSArray<NSNumber *> *)data;
@end
/// <summary>
/// record
/// 4 dimensional vector of int.
/// </summary>
@interface easyar_Vec4I : NSObject
/// <summary>
/// The raw data of vector.
/// </summary>
@property (nonatomic) NSArray<NSNumber *> * data;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)create:(NSArray<NSNumber *> *)data;
@end
/// <summary>
/// record
/// 2 dimensional vector of int.
/// </summary>
@interface easyar_Vec2I : NSObject
/// <summary>
/// The raw data of vector.
/// </summary>
@property (nonatomic) NSArray<NSNumber *> * data;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)create:(NSArray<NSNumber *> *)data;
@end
| 2,436
|
C++
|
.h
| 74
| 31.527027
| 127
| 0.647664
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
1,537,248
|
texture.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/texture.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// TextureId encapsulates a texture object in rendering API.
/// For OpenGL/OpenGLES, getInt and fromInt shall be used. For Direct3D, getPointer and fromPointer shall be used.
/// </summary>
@interface easyar_TextureId : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Gets ID of an OpenGL/OpenGLES texture object.
/// </summary>
- (int)getInt;
/// <summary>
/// Gets pointer of a Direct3D texture object.
/// </summary>
- (void *)getPointer;
/// <summary>
/// Creates from ID of an OpenGL/OpenGLES texture object.
/// </summary>
+ (easyar_TextureId *)fromInt:(int)_value;
/// <summary>
/// Creates from pointer of a Direct3D texture object.
/// </summary>
+ (easyar_TextureId *)fromPointer:(void *)ptr;
@end
| 1,466
|
C++
|
.h
| 33
| 43.181818
| 127
| 0.614035
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,249
|
sparsespatialmapmanager.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/sparsespatialmapmanager.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// SparseSpatialMap manager class, for managing sharing.
/// </summary>
@interface easyar_SparseSpatialMapManager : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Check whether SparseSpatialMapManager is is available. It returns true when the operating system is Mac, iOS or Android.
/// </summary>
+ (bool)isAvailable;
/// <summary>
/// Creates an instance.
/// </summary>
+ (easyar_SparseSpatialMapManager *)create;
/// <summary>
/// Creates a map from `SparseSpatialMap`_ and upload it to EasyAR cloud servers. After completion, a serverMapId will be returned for loading map from EasyAR cloud servers.
/// </summary>
- (void)host:(easyar_SparseSpatialMap *)mapBuilder apiKey:(NSString *)apiKey apiSecret:(NSString *)apiSecret sparseSpatialMapAppId:(NSString *)sparseSpatialMapAppId name:(NSString *)name preview:(easyar_Image *)preview callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler onCompleted:(void (^)(bool isSuccessful, NSString * serverMapId, NSString * error))onCompleted;
/// <summary>
/// Loads a map from EasyAR cloud servers by serverMapId. To unload the map, call `SparseSpatialMap.unloadMap`_ with serverMapId.
/// </summary>
- (void)load:(easyar_SparseSpatialMap *)mapTracker serverMapId:(NSString *)serverMapId apiKey:(NSString *)apiKey apiSecret:(NSString *)apiSecret sparseSpatialMapAppId:(NSString *)sparseSpatialMapAppId callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler onCompleted:(void (^)(bool isSuccessful, NSString * error))onCompleted;
/// <summary>
/// Clears allocated cache space.
/// </summary>
- (void)clear;
@end
| 2,337
|
C++
|
.h
| 36
| 63.694444
| 378
| 0.694723
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,251
|
target.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/target.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
#import "easyar/frame.oc.h"
/// <summary>
/// Target is the base class for all targets that can be tracked by `ImageTracker`_ or other algorithms inside EasyAR.
/// </summary>
@interface easyar_Target : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Returns the target id. A target id is a integer number generated at runtime. This id is non-zero and increasing globally.
/// </summary>
- (int)runtimeID;
/// <summary>
/// Returns the target uid. A target uid is useful in cloud based algorithms. If no cloud is used, you can set this uid in the json config as a alternative method to distinguish from targets.
/// </summary>
- (NSString *)uid;
/// <summary>
/// Returns the target name. Name is used to distinguish targets in a json file.
/// </summary>
- (NSString *)name;
/// <summary>
/// Set name. It will erase previously set data or data from cloud.
/// </summary>
- (void)setName:(NSString *)name;
/// <summary>
/// Returns the meta data set by setMetaData. Or, in a cloud returned target, returns the meta data set in the cloud server.
/// </summary>
- (NSString *)meta;
/// <summary>
/// Set meta data. It will erase previously set data or data from cloud.
/// </summary>
- (void)setMeta:(NSString *)data;
@end
/// <summary>
/// TargetInstance is the tracked target by trackers.
/// An TargetInstance contains a raw `Target`_ that is tracked and current status and pose of the `Target`_ .
/// </summary>
@interface easyar_TargetInstance : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_TargetInstance *) create;
/// <summary>
/// Returns current status of the tracked target. Usually you can check if the status equals `TargetStatus.Tracked` to determine current status of the target.
/// </summary>
- (easyar_TargetStatus)status;
/// <summary>
/// Gets the raw target. It will return the same `Target`_ you loaded into a tracker if it was previously loaded into the tracker.
/// </summary>
- (easyar_Target *)target;
/// <summary>
/// Returns current pose of the tracked target. Camera coordinate system and target coordinate system are all right-handed. For the camera coordinate system, the origin is the optical center, x-right, y-up, and z in the direction of light going into camera. (The right and up, on mobile devices, is the right and up when the device is in the natural orientation.) The data arrangement is row-major, not like OpenGL's column-major.
/// </summary>
- (easyar_Matrix44F *)pose;
@end
/// <summary>
/// TargetTrackerResult is the base class of `ImageTrackerResult`_ and `ObjectTrackerResult`_ .
/// </summary>
@interface easyar_TargetTrackerResult : easyar_FrameFilterResult
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Returns the list of `TargetInstance`_ contained in the result.
/// </summary>
- (NSArray<easyar_TargetInstance *> *)targetInstances;
/// <summary>
/// Sets the list of `TargetInstance`_ contained in the result.
/// </summary>
- (void)setTargetInstances:(NSArray<easyar_TargetInstance *> *)instances;
@end
| 3,813
|
C++
|
.h
| 77
| 48.311688
| 434
| 0.697043
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,252
|
surfacetracker.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/surfacetracker.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_SURFACETRACKER_H__
#define __EASYAR_SURFACETRACKER_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Camera transform against world coordinate system. Camera coordinate system and world coordinate system are all right-handed. For the camera coordinate system, the origin is the optical center, x-right, y-up, and z in the direction of light going into camera. (The right and up, on mobile devices, is the right and up when the device is in the natural orientation.) For the world coordinate system, y is up (to the opposite of gravity). The data arrangement is row-major, not like OpenGL's column-major.
/// </summary>
easyar_Matrix44F easyar_SurfaceTrackerResult_transform(const easyar_SurfaceTrackerResult * This);
void easyar_SurfaceTrackerResult__dtor(easyar_SurfaceTrackerResult * This);
void easyar_SurfaceTrackerResult__retain(const easyar_SurfaceTrackerResult * This, /* OUT */ easyar_SurfaceTrackerResult * * Return);
const char * easyar_SurfaceTrackerResult__typeName(const easyar_SurfaceTrackerResult * This);
void easyar_castSurfaceTrackerResultToFrameFilterResult(const easyar_SurfaceTrackerResult * This, /* OUT */ easyar_FrameFilterResult * * Return);
void easyar_tryCastFrameFilterResultToSurfaceTrackerResult(const easyar_FrameFilterResult * This, /* OUT */ easyar_SurfaceTrackerResult * * Return);
/// <summary>
/// Returns true only on Android or iOS when accelerometer and gyroscope are available.
/// </summary>
bool easyar_SurfaceTracker_isAvailable(void);
/// <summary>
/// `InputFrame`_ input port. InputFrame must have raw image, timestamp, and camera parameters.
/// </summary>
void easyar_SurfaceTracker_inputFrameSink(easyar_SurfaceTracker * This, /* OUT */ easyar_InputFrameSink * * Return);
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
int easyar_SurfaceTracker_bufferRequirement(easyar_SurfaceTracker * This);
/// <summary>
/// `OutputFrame`_ output port.
/// </summary>
void easyar_SurfaceTracker_outputFrameSource(easyar_SurfaceTracker * This, /* OUT */ easyar_OutputFrameSource * * Return);
/// <summary>
/// Creates an instance.
/// </summary>
void easyar_SurfaceTracker_create(/* OUT */ easyar_SurfaceTracker * * Return);
/// <summary>
/// Starts the track algorithm.
/// </summary>
bool easyar_SurfaceTracker_start(easyar_SurfaceTracker * This);
/// <summary>
/// Stops the track algorithm. Call start to start the track again.
/// </summary>
void easyar_SurfaceTracker_stop(easyar_SurfaceTracker * This);
/// <summary>
/// Close. The component shall not be used after calling close.
/// </summary>
void easyar_SurfaceTracker_close(easyar_SurfaceTracker * This);
/// <summary>
/// Sets the tracking target to a point on camera image. For the camera image coordinate system ([0, 1]^2), x-right, y-down, and origin is at left-top corner. `CameraParameters.imageCoordinatesFromScreenCoordinates`_ can be used to convert points from screen coordinate system to camera image coordinate system.
/// </summary>
void easyar_SurfaceTracker_alignTargetToCameraImagePoint(easyar_SurfaceTracker * This, easyar_Vec2F cameraImagePoint);
void easyar_SurfaceTracker__dtor(easyar_SurfaceTracker * This);
void easyar_SurfaceTracker__retain(const easyar_SurfaceTracker * This, /* OUT */ easyar_SurfaceTracker * * Return);
const char * easyar_SurfaceTracker__typeName(const easyar_SurfaceTracker * This);
#ifdef __cplusplus
}
#endif
#endif
| 4,104
|
C++
|
.h
| 66
| 61.030303
| 510
| 0.731877
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,253
|
imagetracker.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/imagetracker.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
#import "easyar/target.oc.h"
/// <summary>
/// Result of `ImageTracker`_ .
/// </summary>
@interface easyar_ImageTrackerResult : easyar_TargetTrackerResult
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Returns the list of `TargetInstance`_ contained in the result.
/// </summary>
- (NSArray<easyar_TargetInstance *> *)targetInstances;
/// <summary>
/// Sets the list of `TargetInstance`_ contained in the result.
/// </summary>
- (void)setTargetInstances:(NSArray<easyar_TargetInstance *> *)instances;
@end
/// <summary>
/// ImageTracker implements image target detection and tracking.
/// ImageTracker occupies (1 + SimultaneousNum) buffers of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// After creation, you can call start/stop to enable/disable the track process. start and stop are very lightweight calls.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// ImageTracker inputs `FeedbackFrame`_ from feedbackFrameSink. `FeedbackFrameSource`_ shall be connected to feedbackFrameSink for use. Refer to `Overview <Overview.html>`_ .
/// Before a `Target`_ can be tracked by ImageTracker, you have to load it using loadTarget/unloadTarget. You can get load/unload results from callbacks passed into the interfaces.
/// </summary>
@interface easyar_ImageTracker : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Returns true.
/// </summary>
+ (bool)isAvailable;
/// <summary>
/// `FeedbackFrame`_ input port. The InputFrame member of FeedbackFrame must have raw image, timestamp, and camera parameters.
/// </summary>
- (easyar_FeedbackFrameSink *)feedbackFrameSink;
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
- (int)bufferRequirement;
/// <summary>
/// `OutputFrame`_ output port.
/// </summary>
- (easyar_OutputFrameSource *)outputFrameSource;
/// <summary>
/// Creates an instance. The default track mode is `ImageTrackerMode.PreferQuality`_ .
/// </summary>
+ (easyar_ImageTracker *)create;
/// <summary>
/// Creates an instance with a specified track mode. On lower-end phones, `ImageTrackerMode.PreferPerformance`_ can be used to keep a better performance with a little quality loss.
/// </summary>
+ (easyar_ImageTracker *)createWithMode:(easyar_ImageTrackerMode)trackMode;
/// <summary>
/// Starts the track algorithm.
/// </summary>
- (bool)start;
/// <summary>
/// Stops the track algorithm. Call start to start the track again.
/// </summary>
- (void)stop;
/// <summary>
/// Close. The component shall not be used after calling close.
/// </summary>
- (void)close;
/// <summary>
/// Load a `Target`_ into the tracker. A Target can only be tracked by tracker after a successful load.
/// This method is an asynchronous method. A load operation may take some time to finish and detection of a new/lost target may take more time during the load. The track time after detection will not be affected. If you want to know the load result, you have to handle the callback data. The callback will be called from the thread specified by `CallbackScheduler`_ . It will not block the track thread or any other operations except other load/unload.
/// </summary>
- (void)loadTarget:(easyar_Target *)target callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler callback:(void (^)(easyar_Target * target, bool status))callback;
/// <summary>
/// Unload a `Target`_ from the tracker.
/// This method is an asynchronous method. An unload operation may take some time to finish and detection of a new/lost target may take more time during the unload. If you want to know the unload result, you have to handle the callback data. The callback will be called from the thread specified by `CallbackScheduler`_ . It will not block the track thread or any other operations except other load/unload.
/// </summary>
- (void)unloadTarget:(easyar_Target *)target callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler callback:(void (^)(easyar_Target * target, bool status))callback;
/// <summary>
/// Returns current loaded targets in the tracker. If an asynchronous load/unload is in progress, the returned value will not reflect the result until all load/unload finish.
/// </summary>
- (NSArray<easyar_Target *> *)targets;
/// <summary>
/// Sets the max number of targets which will be the simultaneously tracked by the tracker. The default value is 1.
/// </summary>
- (bool)setSimultaneousNum:(int)num;
/// <summary>
/// Gets the max number of targets which will be the simultaneously tracked by the tracker. The default value is 1.
/// </summary>
- (int)simultaneousNum;
@end
| 5,539
|
C++
|
.h
| 95
| 57.178947
| 452
| 0.725331
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,256
|
frame.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/frame.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// Input frame.
/// It includes image, camera parameters, timestamp, camera transform matrix against world coordinate system, and tracking status,
/// among which, camera parameters, timestamp, camera transform matrix and tracking status are all optional, but specific algorithms may have special requirements on the input.
/// </summary>
@interface easyar_InputFrame : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Index, an automatic incremental value, which is different for every input frame.
/// </summary>
- (int)index;
/// <summary>
/// Gets image.
/// </summary>
- (easyar_Image *)image;
/// <summary>
/// Checks if there are camera parameters.
/// </summary>
- (bool)hasCameraParameters;
/// <summary>
/// Gets camera parameters.
/// </summary>
- (easyar_CameraParameters *)cameraParameters;
/// <summary>
/// Checks if there is temporal information (timestamp).
/// </summary>
- (bool)hasTemporalInformation;
/// <summary>
/// Timestamp.
/// </summary>
- (double)timestamp;
/// <summary>
/// Checks if there is spatial information (cameraTransform and trackingStatus).
/// </summary>
- (bool)hasSpatialInformation;
/// <summary>
/// Camera transform matrix against world coordinate system. Camera coordinate system and world coordinate system are all right-handed. For the camera coordinate system, the origin is the optical center, x-right, y-up, and z in the direction of light going into camera. (The right and up, on mobile devices, is the right and up when the device is in the natural orientation.) The data arrangement is row-major, not like OpenGL's column-major.
/// </summary>
- (easyar_Matrix44F *)cameraTransform;
/// <summary>
/// Gets device motion tracking status: `MotionTrackingStatus`_ .
/// </summary>
- (easyar_MotionTrackingStatus)trackingStatus;
/// <summary>
/// Creates an instance.
/// </summary>
+ (easyar_InputFrame *)create:(easyar_Image *)image cameraParameters:(easyar_CameraParameters *)cameraParameters timestamp:(double)timestamp cameraTransform:(easyar_Matrix44F *)cameraTransform trackingStatus:(easyar_MotionTrackingStatus)trackingStatus;
/// <summary>
/// Creates an instance with image, camera parameters, and timestamp.
/// </summary>
+ (easyar_InputFrame *)createWithImageAndCameraParametersAndTemporal:(easyar_Image *)image cameraParameters:(easyar_CameraParameters *)cameraParameters timestamp:(double)timestamp;
/// <summary>
/// Creates an instance with image and camera parameters.
/// </summary>
+ (easyar_InputFrame *)createWithImageAndCameraParameters:(easyar_Image *)image cameraParameters:(easyar_CameraParameters *)cameraParameters;
/// <summary>
/// Creates an instance with image.
/// </summary>
+ (easyar_InputFrame *)createWithImage:(easyar_Image *)image;
@end
/// <summary>
/// FrameFilterResult is the base class for result classes of all synchronous algorithm components.
/// </summary>
@interface easyar_FrameFilterResult : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
@end
/// <summary>
/// Output frame.
/// It includes input frame and results of synchronous components.
/// </summary>
@interface easyar_OutputFrame : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_OutputFrame *) create:(easyar_InputFrame *)inputFrame results:(NSArray<easyar_FrameFilterResult *> *)results;
/// <summary>
/// Index, an automatic incremental value, which is different for every output frame.
/// </summary>
- (int)index;
/// <summary>
/// Corresponding input frame.
/// </summary>
- (easyar_InputFrame *)inputFrame;
/// <summary>
/// Results of synchronous components.
/// </summary>
- (NSArray<easyar_FrameFilterResult *> *)results;
@end
/// <summary>
/// Feedback frame.
/// It includes an input frame and a historic output frame for use in feedback synchronous components such as `ImageTracker`_ .
/// </summary>
@interface easyar_FeedbackFrame : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_FeedbackFrame *) create:(easyar_InputFrame *)inputFrame previousOutputFrame:(easyar_OutputFrame *)previousOutputFrame;
/// <summary>
/// Input frame.
/// </summary>
- (easyar_InputFrame *)inputFrame;
/// <summary>
/// Historic output frame.
/// </summary>
- (easyar_OutputFrame *)previousOutputFrame;
@end
| 5,076
|
C++
|
.h
| 115
| 42.973913
| 446
| 0.724808
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,257
|
sparsespatialmap.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/sparsespatialmap.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
#import "easyar/frame.oc.h"
/// <summary>
/// Describes the result of mapping and localization. Updated at the same frame rate with OutputFrame.
/// </summary>
@interface easyar_SparseSpatialMapResult : easyar_FrameFilterResult
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Obtain motion tracking status.
/// </summary>
- (easyar_MotionTrackingStatus)getMotionTrackingStatus;
/// <summary>
/// Returns pose of the origin of VIO system in camera coordinate system.
/// </summary>
- (easyar_Matrix44F *)getVioPose;
/// <summary>
/// Returns the pose of origin of the map in camera coordinate system, when localization is successful.
/// Otherwise, returns pose of the origin of VIO system in camera coordinate system.
/// </summary>
- (easyar_Matrix44F *)getMapPose;
/// <summary>
/// Returns true if the system can reliablly locate the pose of the device with regard to the map.
/// Once relocalization succeeds, relative pose can be updated by motion tracking module.
/// As long as the motion tracking module returns normal tracking status, the localization status is also true.
/// </summary>
- (bool)getLocalizationStatus;
/// <summary>
/// Returns current localized map ID.
/// </summary>
- (NSString *)getLocalizationMapID;
@end
@interface easyar_PlaneData : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Constructor
/// </summary>
+ (easyar_PlaneData *) create;
/// <summary>
/// Returns the type of this plane.
/// </summary>
- (easyar_PlaneType)getType;
/// <summary>
/// Returns the pose of the center of the detected plane.The pose's transformed +Y axis will be point normal out of the plane, with the +X and +Z axes orienting the extents of the bounding rectangle.
/// </summary>
- (easyar_Matrix44F *)getPose;
/// <summary>
/// Returns the length of this plane's bounding rectangle measured along the local X-axis of the coordinate space centered on the plane.
/// </summary>
- (float)getExtentX;
/// <summary>
/// Returns the length of this plane's bounding rectangle measured along the local Z-axis of the coordinate frame centered on the plane.
/// </summary>
- (float)getExtentZ;
@end
/// <summary>
/// Configuration used to set the localization mode.
/// </summary>
@interface easyar_SparseSpatialMapConfig : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Constructor
/// </summary>
+ (easyar_SparseSpatialMapConfig *) create;
/// <summary>
/// Sets localization configurations. See also `LocalizationMode`_.
/// </summary>
- (void)setLocalizationMode:(easyar_LocalizationMode)_value;
/// <summary>
/// Returns localization configurations. See also `LocalizationMode`_.
/// </summary>
- (easyar_LocalizationMode)getLocalizationMode;
@end
/// <summary>
/// Provides core components for SparseSpatialMap, can be used for sparse spatial map building as well as localization using existing map. Also provides utilities for point cloud and plane access.
/// SparseSpatialMap occupies 2 buffers of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// </summary>
@interface easyar_SparseSpatialMap : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Check whether SparseSpatialMap is is available, always return true.
/// </summary>
+ (bool)isAvailable;
/// <summary>
/// Input port for input frame. For SparseSpatialMap to work, the inputFrame must include camera parameters, timestamp and spatial information. See also `InputFrameSink`_
/// </summary>
- (easyar_InputFrameSink *)inputFrameSink;
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
- (int)bufferRequirement;
/// <summary>
/// Output port for output frame. See also `OutputFrameSource`_
/// </summary>
- (easyar_OutputFrameSource *)outputFrameSource;
/// <summary>
/// Construct SparseSpatialMap.
/// </summary>
+ (easyar_SparseSpatialMap *)create;
/// <summary>
/// Start SparseSpatialMap system.
/// </summary>
- (bool)start;
/// <summary>
/// Stop SparseSpatialMap from running。Can resume running by calling start().
/// </summary>
- (void)stop;
/// <summary>
/// Close SparseSpatialMap. SparseSpatialMap can no longer be used.
/// </summary>
- (void)close;
/// <summary>
/// Returns the buffer of point cloud coordinate. Each 3D point is represented by three consecutive values, representing X, Y, Z position coordinates in the world coordinate space, each of which takes 4 bytes.
/// </summary>
- (easyar_Buffer *)getPointCloudBuffer;
/// <summary>
/// Returns detected planes in SparseSpatialMap.
/// </summary>
- (NSArray<easyar_PlaneData *> *)getMapPlanes;
/// <summary>
/// Perform hit test against the point cloud. The results are returned sorted by their distance to the camera in ascending order.
/// </summary>
- (NSArray<easyar_Vec3F *> *)hitTestAgainstPointCloud:(easyar_Vec2F *)cameraImagePoint;
/// <summary>
/// Performs ray cast from the user's device in the direction of given screen point.
/// Intersections with detected planes are returned. 3D positions on physical planes are sorted by distance from the device in ascending order.
/// For the camera image coordinate system ([0, 1]^2), x-right, y-down, and origin is at left-top corner. `CameraParameters.imageCoordinatesFromScreenCoordinates`_ can be used to convert points from screen coordinate system to camera image coordinate system.
/// The output point cloud coordinate is in the world coordinate system.
/// </summary>
- (NSArray<easyar_Vec3F *> *)hitTestAgainstPlanes:(easyar_Vec2F *)cameraImagePoint;
/// <summary>
/// Get the map data version of the current SparseSpatialMap.
/// </summary>
+ (NSString *)getMapVersion;
/// <summary>
/// UnloadMap specified SparseSpatialMap data via callback function.The return value of callback indicates whether unload map succeeds (true) or fails (false).
/// </summary>
- (void)unloadMap:(NSString *)mapID callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler resultCallBack:(void (^)(bool))resultCallBack;
/// <summary>
/// Set configurations for SparseSpatialMap. See also `SparseSpatialMapConfig`_.
/// </summary>
- (void)setConfig:(easyar_SparseSpatialMapConfig *)config;
/// <summary>
/// Returns configurations for SparseSpatialMap. See also `SparseSpatialMapConfig`_.
/// </summary>
- (easyar_SparseSpatialMapConfig *)getConfig;
/// <summary>
/// Start localization in loaded maps. Should set `LocalizationMode`_ first.
/// </summary>
- (bool)startLocalization;
/// <summary>
/// Stop localization in loaded maps.
/// </summary>
- (void)stopLocalization;
@end
| 7,479
|
C++
|
.h
| 166
| 43.921687
| 258
| 0.733644
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,258
|
sparsespatialmapmanager.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/sparsespatialmapmanager.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_SPARSESPATIALMAPMANAGER_H__
#define __EASYAR_SPARSESPATIALMAPMANAGER_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Check whether SparseSpatialMapManager is is available. It returns true when the operating system is Mac, iOS or Android.
/// </summary>
bool easyar_SparseSpatialMapManager_isAvailable(void);
/// <summary>
/// Creates an instance.
/// </summary>
void easyar_SparseSpatialMapManager_create(/* OUT */ easyar_SparseSpatialMapManager * * Return);
/// <summary>
/// Creates a map from `SparseSpatialMap`_ and upload it to EasyAR cloud servers. After completion, a serverMapId will be returned for loading map from EasyAR cloud servers.
/// </summary>
void easyar_SparseSpatialMapManager_host(easyar_SparseSpatialMapManager * This, easyar_SparseSpatialMap * mapBuilder, easyar_String * apiKey, easyar_String * apiSecret, easyar_String * sparseSpatialMapAppId, easyar_String * name, easyar_OptionalOfImage preview, easyar_CallbackScheduler * callbackScheduler, easyar_FunctorOfVoidFromBoolAndStringAndString onCompleted);
/// <summary>
/// Loads a map from EasyAR cloud servers by serverMapId. To unload the map, call `SparseSpatialMap.unloadMap`_ with serverMapId.
/// </summary>
void easyar_SparseSpatialMapManager_load(easyar_SparseSpatialMapManager * This, easyar_SparseSpatialMap * mapTracker, easyar_String * serverMapId, easyar_String * apiKey, easyar_String * apiSecret, easyar_String * sparseSpatialMapAppId, easyar_CallbackScheduler * callbackScheduler, easyar_FunctorOfVoidFromBoolAndString onCompleted);
/// <summary>
/// Clears allocated cache space.
/// </summary>
void easyar_SparseSpatialMapManager_clear(easyar_SparseSpatialMapManager * This);
void easyar_SparseSpatialMapManager__dtor(easyar_SparseSpatialMapManager * This);
void easyar_SparseSpatialMapManager__retain(const easyar_SparseSpatialMapManager * This, /* OUT */ easyar_SparseSpatialMapManager * * Return);
const char * easyar_SparseSpatialMapManager__typeName(const easyar_SparseSpatialMapManager * This);
#ifdef __cplusplus
}
#endif
#endif
| 2,743
|
C++
|
.h
| 41
| 65.682927
| 368
| 0.728184
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,259
|
scenemesh.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/scenemesh.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_SCENEMESH_H__
#define __EASYAR_SCENEMESH_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Get the number of vertices in `meshAll`.
/// </summary>
int easyar_SceneMesh_getNumOfVertexAll(easyar_SceneMesh * This);
/// <summary>
/// Get the number of indices in `meshAll`. Since every 3 indices form a triangle, the returned value should be a multiple of 3.
/// </summary>
int easyar_SceneMesh_getNumOfIndexAll(easyar_SceneMesh * This);
/// <summary>
/// Get the position component of the vertices in `meshAll` (in the world coordinate system). The position of a vertex is described by three coordinates (x, y, z) in meters. The position data are stored tightly in `Buffer`_ by `x1, y1, z1, x2, y2, z2, ...` Each component is of `float` type.
/// </summary>
void easyar_SceneMesh_getVerticesAll(easyar_SceneMesh * This, /* OUT */ easyar_Buffer * * Return);
/// <summary>
/// Get the normal component of vertices in `meshAll`. The normal of a vertex is described by three components (nx, ny, nz). The normal is normalized, that is, the length is 1. Normal data are stored tightly in `Buffer`_ by `nx1, ny1, nz1, nx2, ny2, nz2,....` Each component is of `float` type.
/// </summary>
void easyar_SceneMesh_getNormalsAll(easyar_SceneMesh * This, /* OUT */ easyar_Buffer * * Return);
/// <summary>
/// Get the index data in `meshAll`. Each triangle is composed of three indices (ix, iy, iz). Indices are stored tightly in `Buffer`_ by `ix1, iy1, iz1, ix2, iy2, iz2,...` Each component is of `int32` type.
/// </summary>
void easyar_SceneMesh_getIndicesAll(easyar_SceneMesh * This, /* OUT */ easyar_Buffer * * Return);
/// <summary>
/// Get the number of vertices in `meshUpdated`.
/// </summary>
int easyar_SceneMesh_getNumOfVertexIncremental(easyar_SceneMesh * This);
/// <summary>
/// Get the number of indices in `meshUpdated`. Since every 3 indices form a triangle, the returned value should be a multiple of 3.
/// </summary>
int easyar_SceneMesh_getNumOfIndexIncremental(easyar_SceneMesh * This);
/// <summary>
/// Get the position component of the vertices in `meshUpdated` (in the world coordinate system). The position of a vertex is described by three coordinates (x, y, z) in meters. The position data are stored tightly in `Buffer`_ by `x1, y1, z1, x2, y2, z2, ...` Each component is of `float` type.
/// </summary>
void easyar_SceneMesh_getVerticesIncremental(easyar_SceneMesh * This, /* OUT */ easyar_Buffer * * Return);
/// <summary>
/// Get the normal component of vertices in `meshUpdated`. The normal of a vertex is described by three components (nx, ny, nz). The normal is normalized, that is, the length is 1. Normal data are stored tightly in `Buffer`_ by `nx1, ny1, nz1, nx2, ny2, nz2,....` Each component is of `float` type.
/// </summary>
void easyar_SceneMesh_getNormalsIncremental(easyar_SceneMesh * This, /* OUT */ easyar_Buffer * * Return);
/// <summary>
/// Get the index data in `meshUpdated`. Each triangle is composed of three indices (ix, iy, iz). Indices are stored tightly in `Buffer`_ by `ix1, iy1, iz1, ix2, iy2, iz2,...` Each component is of `int32` type.
/// </summary>
void easyar_SceneMesh_getIndicesIncremental(easyar_SceneMesh * This, /* OUT */ easyar_Buffer * * Return);
/// <summary>
/// Gets the description object of `mesh block` in `meshUpdate`. The return value is an array of `BlockInfo`_ elements, each of which is a detailed description of a `mesh block`.
/// </summary>
void easyar_SceneMesh_getBlocksInfoIncremental(easyar_SceneMesh * This, /* OUT */ easyar_ListOfBlockInfo * * Return);
/// <summary>
/// Get the edge length of a `mesh block` in meters.
/// </summary>
float easyar_SceneMesh_getBlockDimensionInMeters(easyar_SceneMesh * This);
void easyar_SceneMesh__dtor(easyar_SceneMesh * This);
void easyar_SceneMesh__retain(const easyar_SceneMesh * This, /* OUT */ easyar_SceneMesh * * Return);
const char * easyar_SceneMesh__typeName(const easyar_SceneMesh * This);
void easyar_ListOfBlockInfo__ctor(easyar_BlockInfo const * begin, easyar_BlockInfo const * end, /* OUT */ easyar_ListOfBlockInfo * * Return);
void easyar_ListOfBlockInfo__dtor(easyar_ListOfBlockInfo * This);
void easyar_ListOfBlockInfo_copy(const easyar_ListOfBlockInfo * This, /* OUT */ easyar_ListOfBlockInfo * * Return);
int easyar_ListOfBlockInfo_size(const easyar_ListOfBlockInfo * This);
easyar_BlockInfo easyar_ListOfBlockInfo_at(const easyar_ListOfBlockInfo * This, int index);
#ifdef __cplusplus
}
#endif
#endif
| 5,150
|
C++
|
.h
| 74
| 68.459459
| 298
| 0.702527
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,260
|
jniutility.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/jniutility.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_JNIUTILITY_H__
#define __EASYAR_JNIUTILITY_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Wraps Java's byte[]。
/// </summary>
void easyar_JniUtility_wrapByteArray(void * bytes, bool readOnly, easyar_FunctorOfVoid deleter, /* OUT */ easyar_Buffer * * Return);
/// <summary>
/// Wraps Java's java.nio.ByteBuffer, which must be a direct buffer.
/// </summary>
void easyar_JniUtility_wrapBuffer(void * directBuffer, easyar_FunctorOfVoid deleter, /* OUT */ easyar_Buffer * * Return);
#ifdef __cplusplus
}
#endif
#endif
| 1,238
|
C++
|
.h
| 26
| 46.192308
| 132
| 0.592007
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,261
|
motiontracker.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/motiontracker.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// MotionTrackerCameraDevice implements a camera device with metric-scale six degree-of-freedom motion tracking, which outputs `InputFrame`_ (including image, camera parameters, timestamp, 6DOF pose and tracking status).
/// After creation, start/stop can be invoked to start or stop data flow.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// MotionTrackerCameraDevice outputs `InputFrame`_ from inputFrameSource. inputFrameSource shall be connected to `InputFrameSink`_ for further use. Refer to `Overview <Overview.html>`_ .
/// </summary>
@interface easyar_MotionTrackerCameraDevice : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Create MotionTrackerCameraDevice object.
/// </summary>
+ (easyar_MotionTrackerCameraDevice *) create;
/// <summary>
/// Check if the devices supports motion tracking. Returns True if the device supports Motion Tracking, otherwise returns False.
/// </summary>
+ (bool)isAvailable;
/// <summary>
/// Set `InputFrame`_ buffer capacity.
/// bufferCapacity is the capacity of `InputFrame`_ buffer. If the count of `InputFrame`_ which has been output from the device and have not been released is higher than this number, the device will not output new `InputFrame`_ until previous `InputFrame`_ has been released. This may cause screen stuck. Refer to `Overview <Overview.html>`_ .
/// </summary>
- (void)setBufferCapacity:(int)capacity;
/// <summary>
/// Get `InputFrame`_ buffer capacity. The default is 8.
/// </summary>
- (int)bufferCapacity;
/// <summary>
/// `InputFrame`_ output port.
/// </summary>
- (easyar_InputFrameSource *)inputFrameSource;
/// <summary>
/// Start motion tracking or resume motion tracking after pause.
/// Notice: Calling start after pausing will trigger device relocalization. Tracking will resume when the relocalization process succeeds.
/// </summary>
- (bool)start;
/// <summary>
/// Pause motion tracking. Call `start` to trigger relocation, resume motion tracking if the relocation succeeds.
/// </summary>
- (void)stop;
/// <summary>
/// Close motion tracking. The component shall not be used after calling close.
/// </summary>
- (void)close;
@end
| 2,968
|
C++
|
.h
| 53
| 54.849057
| 349
| 0.697282
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,263
|
cameraparameters.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/cameraparameters.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// Camera parameters, including image size, focal length, principal point, camera type and camera rotation against natural orientation.
/// </summary>
@interface easyar_CameraParameters : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_CameraParameters *) create:(easyar_Vec2I *)size focalLength:(easyar_Vec2F *)focalLength principalPoint:(easyar_Vec2F *)principalPoint cameraDeviceType:(easyar_CameraDeviceType)cameraDeviceType cameraOrientation:(int)cameraOrientation;
/// <summary>
/// Image size.
/// </summary>
- (easyar_Vec2I *)size;
/// <summary>
/// Focal length, the distance from effective optical center to CCD plane, divided by unit pixel density in width and height directions. The unit is pixel.
/// </summary>
- (easyar_Vec2F *)focalLength;
/// <summary>
/// Principal point, coordinates of the intersection point of principal axis on CCD plane against the left-top corner of the image. The unit is pixel.
/// </summary>
- (easyar_Vec2F *)principalPoint;
/// <summary>
/// Camera device type. Default, back or front camera. On desktop devices, there are only default cameras. On mobile devices, there is a differentiation between back and front cameras.
/// </summary>
- (easyar_CameraDeviceType)cameraDeviceType;
/// <summary>
/// Camera rotation against device natural orientation.
/// For Android phones and some Android tablets, this value is 90 degrees.
/// For Android eye-wear and some Android tablets, this value is 0 degrees.
/// For all current iOS devices, this value is 90 degrees.
/// </summary>
- (int)cameraOrientation;
/// <summary>
/// Creates CameraParameters with default camera intrinsics. Default intrinsics are calculated by image size, which is not very precise.
/// </summary>
+ (easyar_CameraParameters *)createWithDefaultIntrinsics:(easyar_Vec2I *)size cameraDeviceType:(easyar_CameraDeviceType)cameraDeviceType cameraOrientation:(int)cameraOrientation;
/// <summary>
/// Calculates the angle required to rotate the camera image clockwise to align it with the screen.
/// screenRotation is the angle of rotation of displaying screen image against device natural orientation in clockwise in degrees.
/// For iOS(UIInterfaceOrientationPortrait as natural orientation):
/// * UIInterfaceOrientationPortrait: rotation = 0
/// * UIInterfaceOrientationLandscapeRight: rotation = 90
/// * UIInterfaceOrientationPortraitUpsideDown: rotation = 180
/// * UIInterfaceOrientationLandscapeLeft: rotation = 270
/// For Android:
/// * Surface.ROTATION_0 = 0
/// * Surface.ROTATION_90 = 90
/// * Surface.ROTATION_180 = 180
/// * Surface.ROTATION_270 = 270
/// </summary>
- (int)imageOrientation:(int)screenRotation;
/// <summary>
/// Calculates whether the image needed to be flipped horizontally. The image is rotated, then flipped in rendering. When cameraDeviceType is front, a flip is automatically applied. Pass manualHorizontalFlip with true to add a manual flip.
/// </summary>
- (bool)imageHorizontalFlip:(bool)manualHorizontalFlip;
/// <summary>
/// Calculates the perspective projection matrix needed by virtual object rendering. The projection transforms points from camera coordinate system to clip coordinate system ([-1, 1]^4). The form of perspective projection matrix is the same as OpenGL, that matrix multiply column vector of homogeneous coordinates of point on the right, ant not like Direct3D, that matrix multiply row vector of homogeneous coordinates of point on the left. But data arrangement is row-major, not like OpenGL's column-major. Clip coordinate system and normalized device coordinate system are defined as the same as OpenGL's default.
/// </summary>
- (easyar_Matrix44F *)projection:(float)nearPlane farPlane:(float)farPlane viewportAspectRatio:(float)viewportAspectRatio screenRotation:(int)screenRotation combiningFlip:(bool)combiningFlip manualHorizontalFlip:(bool)manualHorizontalFlip;
/// <summary>
/// Calculates the orthogonal projection matrix needed by camera background rendering. The projection transforms points from image quad coordinate system ([-1, 1]^2) to clip coordinate system ([-1, 1]^4), with the undefined two dimensions unchanged. The form of orthogonal projection matrix is the same as OpenGL, that matrix multiply column vector of homogeneous coordinates of point on the right, ant not like Direct3D, that matrix multiply row vector of homogeneous coordinates of point on the left. But data arrangement is row-major, not like OpenGL's column-major. Clip coordinate system and normalized device coordinate system are defined as the same as OpenGL's default.
/// </summary>
- (easyar_Matrix44F *)imageProjection:(float)viewportAspectRatio screenRotation:(int)screenRotation combiningFlip:(bool)combiningFlip manualHorizontalFlip:(bool)manualHorizontalFlip;
/// <summary>
/// Transforms points from image coordinate system ([0, 1]^2) to screen coordinate system ([0, 1]^2). Both coordinate system is x-left, y-down, with origin at left-top.
/// </summary>
- (easyar_Vec2F *)screenCoordinatesFromImageCoordinates:(float)viewportAspectRatio screenRotation:(int)screenRotation combiningFlip:(bool)combiningFlip manualHorizontalFlip:(bool)manualHorizontalFlip imageCoordinates:(easyar_Vec2F *)imageCoordinates;
/// <summary>
/// Transforms points from screen coordinate system ([0, 1]^2) to image coordinate system ([0, 1]^2). Both coordinate system is x-left, y-down, with origin at left-top.
/// </summary>
- (easyar_Vec2F *)imageCoordinatesFromScreenCoordinates:(float)viewportAspectRatio screenRotation:(int)screenRotation combiningFlip:(bool)combiningFlip manualHorizontalFlip:(bool)manualHorizontalFlip screenCoordinates:(easyar_Vec2F *)screenCoordinates;
/// <summary>
/// Checks if two groups of parameters are equal.
/// </summary>
- (bool)equalsTo:(easyar_CameraParameters *)other;
@end
| 6,541
|
C++
|
.h
| 83
| 77.710843
| 685
| 0.760465
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,264
|
imagetracker.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/imagetracker.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_IMAGETRACKER_H__
#define __EASYAR_IMAGETRACKER_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Returns the list of `TargetInstance`_ contained in the result.
/// </summary>
void easyar_ImageTrackerResult_targetInstances(const easyar_ImageTrackerResult * This, /* OUT */ easyar_ListOfTargetInstance * * Return);
/// <summary>
/// Sets the list of `TargetInstance`_ contained in the result.
/// </summary>
void easyar_ImageTrackerResult_setTargetInstances(easyar_ImageTrackerResult * This, easyar_ListOfTargetInstance * instances);
void easyar_ImageTrackerResult__dtor(easyar_ImageTrackerResult * This);
void easyar_ImageTrackerResult__retain(const easyar_ImageTrackerResult * This, /* OUT */ easyar_ImageTrackerResult * * Return);
const char * easyar_ImageTrackerResult__typeName(const easyar_ImageTrackerResult * This);
void easyar_castImageTrackerResultToFrameFilterResult(const easyar_ImageTrackerResult * This, /* OUT */ easyar_FrameFilterResult * * Return);
void easyar_tryCastFrameFilterResultToImageTrackerResult(const easyar_FrameFilterResult * This, /* OUT */ easyar_ImageTrackerResult * * Return);
void easyar_castImageTrackerResultToTargetTrackerResult(const easyar_ImageTrackerResult * This, /* OUT */ easyar_TargetTrackerResult * * Return);
void easyar_tryCastTargetTrackerResultToImageTrackerResult(const easyar_TargetTrackerResult * This, /* OUT */ easyar_ImageTrackerResult * * Return);
/// <summary>
/// Returns true.
/// </summary>
bool easyar_ImageTracker_isAvailable(void);
/// <summary>
/// `FeedbackFrame`_ input port. The InputFrame member of FeedbackFrame must have raw image, timestamp, and camera parameters.
/// </summary>
void easyar_ImageTracker_feedbackFrameSink(easyar_ImageTracker * This, /* OUT */ easyar_FeedbackFrameSink * * Return);
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
int easyar_ImageTracker_bufferRequirement(easyar_ImageTracker * This);
/// <summary>
/// `OutputFrame`_ output port.
/// </summary>
void easyar_ImageTracker_outputFrameSource(easyar_ImageTracker * This, /* OUT */ easyar_OutputFrameSource * * Return);
/// <summary>
/// Creates an instance. The default track mode is `ImageTrackerMode.PreferQuality`_ .
/// </summary>
void easyar_ImageTracker_create(/* OUT */ easyar_ImageTracker * * Return);
/// <summary>
/// Creates an instance with a specified track mode. On lower-end phones, `ImageTrackerMode.PreferPerformance`_ can be used to keep a better performance with a little quality loss.
/// </summary>
void easyar_ImageTracker_createWithMode(easyar_ImageTrackerMode trackMode, /* OUT */ easyar_ImageTracker * * Return);
/// <summary>
/// Starts the track algorithm.
/// </summary>
bool easyar_ImageTracker_start(easyar_ImageTracker * This);
/// <summary>
/// Stops the track algorithm. Call start to start the track again.
/// </summary>
void easyar_ImageTracker_stop(easyar_ImageTracker * This);
/// <summary>
/// Close. The component shall not be used after calling close.
/// </summary>
void easyar_ImageTracker_close(easyar_ImageTracker * This);
/// <summary>
/// Load a `Target`_ into the tracker. A Target can only be tracked by tracker after a successful load.
/// This method is an asynchronous method. A load operation may take some time to finish and detection of a new/lost target may take more time during the load. The track time after detection will not be affected. If you want to know the load result, you have to handle the callback data. The callback will be called from the thread specified by `CallbackScheduler`_ . It will not block the track thread or any other operations except other load/unload.
/// </summary>
void easyar_ImageTracker_loadTarget(easyar_ImageTracker * This, easyar_Target * target, easyar_CallbackScheduler * callbackScheduler, easyar_FunctorOfVoidFromTargetAndBool callback);
/// <summary>
/// Unload a `Target`_ from the tracker.
/// This method is an asynchronous method. An unload operation may take some time to finish and detection of a new/lost target may take more time during the unload. If you want to know the unload result, you have to handle the callback data. The callback will be called from the thread specified by `CallbackScheduler`_ . It will not block the track thread or any other operations except other load/unload.
/// </summary>
void easyar_ImageTracker_unloadTarget(easyar_ImageTracker * This, easyar_Target * target, easyar_CallbackScheduler * callbackScheduler, easyar_FunctorOfVoidFromTargetAndBool callback);
/// <summary>
/// Returns current loaded targets in the tracker. If an asynchronous load/unload is in progress, the returned value will not reflect the result until all load/unload finish.
/// </summary>
void easyar_ImageTracker_targets(const easyar_ImageTracker * This, /* OUT */ easyar_ListOfTarget * * Return);
/// <summary>
/// Sets the max number of targets which will be the simultaneously tracked by the tracker. The default value is 1.
/// </summary>
bool easyar_ImageTracker_setSimultaneousNum(easyar_ImageTracker * This, int num);
/// <summary>
/// Gets the max number of targets which will be the simultaneously tracked by the tracker. The default value is 1.
/// </summary>
int easyar_ImageTracker_simultaneousNum(const easyar_ImageTracker * This);
void easyar_ImageTracker__dtor(easyar_ImageTracker * This);
void easyar_ImageTracker__retain(const easyar_ImageTracker * This, /* OUT */ easyar_ImageTracker * * Return);
const char * easyar_ImageTracker__typeName(const easyar_ImageTracker * This);
void easyar_ListOfTargetInstance__ctor(easyar_TargetInstance * const * begin, easyar_TargetInstance * const * end, /* OUT */ easyar_ListOfTargetInstance * * Return);
void easyar_ListOfTargetInstance__dtor(easyar_ListOfTargetInstance * This);
void easyar_ListOfTargetInstance_copy(const easyar_ListOfTargetInstance * This, /* OUT */ easyar_ListOfTargetInstance * * Return);
int easyar_ListOfTargetInstance_size(const easyar_ListOfTargetInstance * This);
easyar_TargetInstance * easyar_ListOfTargetInstance_at(const easyar_ListOfTargetInstance * This, int index);
void easyar_ListOfTarget__ctor(easyar_Target * const * begin, easyar_Target * const * end, /* OUT */ easyar_ListOfTarget * * Return);
void easyar_ListOfTarget__dtor(easyar_ListOfTarget * This);
void easyar_ListOfTarget_copy(const easyar_ListOfTarget * This, /* OUT */ easyar_ListOfTarget * * Return);
int easyar_ListOfTarget_size(const easyar_ListOfTarget * This);
easyar_Target * easyar_ListOfTarget_at(const easyar_ListOfTarget * This, int index);
#ifdef __cplusplus
}
#endif
#endif
| 7,247
|
C++
|
.h
| 104
| 68.567308
| 452
| 0.754172
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,265
|
scenemesh.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/scenemesh.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// record
/// The dense reconstructed model is represented by triangle mesh, or simply denoted as mesh. Because mesh updates frequently, in order to ensure efficiency, the mesh of the whole reconstruction model is divided into many mesh blocks. A mesh block is composed of a cube about 1 meter long, with attributes such as vertices and indices.
///
/// BlockInfo is used to describe the content of a mesh block. (x, y, z) is the index of mesh block, the coordinates of a mesh block's origin in world coordinate system can be obtained by multiplying (x, y, z) by the physical size of mesh block. You may filter the part you want to display in advance by the mesh block's world coordinates for the sake of saving rendering time.
/// </summary>
@interface easyar_BlockInfo : NSObject
/// <summary>
/// x in index (x, y, z) of mesh block.
/// </summary>
@property (nonatomic) int x;
/// <summary>
/// y in index (x, y, z) of mesh block.
/// </summary>
@property (nonatomic) int y;
/// <summary>
/// z in index (x, y, z) of mesh block.
/// </summary>
@property (nonatomic) int z;
/// <summary>
/// Number of vertices in a mesh block.
/// </summary>
@property (nonatomic) int numOfVertex;
/// <summary>
/// startPointOfVertex is the starting position of the vertex data stored in the vertex buffer, indicating from where the stored vertices belong to current mesh block. It is not equal to the number of bytes of the offset from the beginning of vertex buffer. The offset is startPointOfVertex*3*4 bytes.
/// </summary>
@property (nonatomic) int startPointOfVertex;
/// <summary>
/// The number of indices in a mesh block. Each of three consecutive vertices form a triangle.
/// </summary>
@property (nonatomic) int numOfIndex;
/// <summary>
/// Similar to startPointOfVertex. startPointOfIndex is the starting position of the index data stored in the index buffer, indicating from where the stored indices belong to current mesh block. It is not equal to the number of bytes of the offset from the beginning of index buffer. The offset is startPointOfIndex*3*4 bytes.
/// </summary>
@property (nonatomic) int startPointOfIndex;
/// <summary>
/// Version represents how many times the mesh block has updated. The larger the version, the newer the block. If the version of a mesh block increases after calling `DenseSpatialMap.updateSceneMesh`_ , it indicates that the mash block has changed.
/// </summary>
@property (nonatomic) int version;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)create:(int)x y:(int)y z:(int)z numOfVertex:(int)numOfVertex startPointOfVertex:(int)startPointOfVertex numOfIndex:(int)numOfIndex startPointOfIndex:(int)startPointOfIndex version:(int)version;
@end
/// <summary>
/// SceneMesh is used to manage and preserve the results of `DenseSpatialMap`_.
/// There are two kinds of meshes saved in SceneMesh, one is the mesh of the whole reconstructed scene, hereinafter referred to as `meshAll`, the other is the recently updated mesh, hereinafter referred to as `meshUpdated`. `meshAll` is a whole mesh, including all vertex data and index data, etc. `meshUpdated` is composed of several `mesh block` s, each `mesh block` is a cube, which contains the mesh formed by the object surface in the corresponding cube space.
/// `meshAll` is available only when the `DenseSpatialMap.updateSceneMesh`_ method is called specifying that all meshes need to be updated. If `meshAll` has been updated previously and not updated in recent times, the data in `meshAll` is remain the same.
/// </summary>
@interface easyar_SceneMesh : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Get the number of vertices in `meshAll`.
/// </summary>
- (int)getNumOfVertexAll;
/// <summary>
/// Get the number of indices in `meshAll`. Since every 3 indices form a triangle, the returned value should be a multiple of 3.
/// </summary>
- (int)getNumOfIndexAll;
/// <summary>
/// Get the position component of the vertices in `meshAll` (in the world coordinate system). The position of a vertex is described by three coordinates (x, y, z) in meters. The position data are stored tightly in `Buffer`_ by `x1, y1, z1, x2, y2, z2, ...` Each component is of `float` type.
/// </summary>
- (easyar_Buffer *)getVerticesAll;
/// <summary>
/// Get the normal component of vertices in `meshAll`. The normal of a vertex is described by three components (nx, ny, nz). The normal is normalized, that is, the length is 1. Normal data are stored tightly in `Buffer`_ by `nx1, ny1, nz1, nx2, ny2, nz2,....` Each component is of `float` type.
/// </summary>
- (easyar_Buffer *)getNormalsAll;
/// <summary>
/// Get the index data in `meshAll`. Each triangle is composed of three indices (ix, iy, iz). Indices are stored tightly in `Buffer`_ by `ix1, iy1, iz1, ix2, iy2, iz2,...` Each component is of `int32` type.
/// </summary>
- (easyar_Buffer *)getIndicesAll;
/// <summary>
/// Get the number of vertices in `meshUpdated`.
/// </summary>
- (int)getNumOfVertexIncremental;
/// <summary>
/// Get the number of indices in `meshUpdated`. Since every 3 indices form a triangle, the returned value should be a multiple of 3.
/// </summary>
- (int)getNumOfIndexIncremental;
/// <summary>
/// Get the position component of the vertices in `meshUpdated` (in the world coordinate system). The position of a vertex is described by three coordinates (x, y, z) in meters. The position data are stored tightly in `Buffer`_ by `x1, y1, z1, x2, y2, z2, ...` Each component is of `float` type.
/// </summary>
- (easyar_Buffer *)getVerticesIncremental;
/// <summary>
/// Get the normal component of vertices in `meshUpdated`. The normal of a vertex is described by three components (nx, ny, nz). The normal is normalized, that is, the length is 1. Normal data are stored tightly in `Buffer`_ by `nx1, ny1, nz1, nx2, ny2, nz2,....` Each component is of `float` type.
/// </summary>
- (easyar_Buffer *)getNormalsIncremental;
/// <summary>
/// Get the index data in `meshUpdated`. Each triangle is composed of three indices (ix, iy, iz). Indices are stored tightly in `Buffer`_ by `ix1, iy1, iz1, ix2, iy2, iz2,...` Each component is of `int32` type.
/// </summary>
- (easyar_Buffer *)getIndicesIncremental;
/// <summary>
/// Gets the description object of `mesh block` in `meshUpdate`. The return value is an array of `BlockInfo`_ elements, each of which is a detailed description of a `mesh block`.
/// </summary>
- (NSArray<easyar_BlockInfo *> *)getBlocksInfoIncremental;
/// <summary>
/// Get the edge length of a `mesh block` in meters.
/// </summary>
- (float)getBlockDimensionInMeters;
@end
| 7,371
|
C++
|
.h
| 109
| 66.504587
| 465
| 0.71872
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,268
|
log.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/log.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// Log class.
/// It is used to setup a custom log output function.
/// </summary>
@interface easyar_Log : NSObject
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Sets custom log output function.
/// </summary>
+ (void)setLogFunc:(void (^)(easyar_LogLevel level, NSString * message))func;
/// <summary>
/// Clears custom log output function and reverts to default log output function.
/// </summary>
+ (void)resetLogFunc;
@end
| 1,170
|
C++
|
.h
| 25
| 45.48
| 127
| 0.583993
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,270
|
imagehelper.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/imagehelper.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_IMAGEHELPER_H__
#define __EASYAR_IMAGEHELPER_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Decodes a JPEG or PNG file.
/// </summary>
void easyar_ImageHelper_decode(easyar_Buffer * buffer, /* OUT */ easyar_OptionalOfImage * Return);
#ifdef __cplusplus
}
#endif
#endif
| 983
|
C++
|
.h
| 22
| 43.272727
| 127
| 0.558824
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,271
|
callbackscheduler.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/callbackscheduler.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_CALLBACKSCHEDULER_H__
#define __EASYAR_CALLBACKSCHEDULER_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
void easyar_CallbackScheduler__dtor(easyar_CallbackScheduler * This);
void easyar_CallbackScheduler__retain(const easyar_CallbackScheduler * This, /* OUT */ easyar_CallbackScheduler * * Return);
const char * easyar_CallbackScheduler__typeName(const easyar_CallbackScheduler * This);
void easyar_DelayedCallbackScheduler__ctor(/* OUT */ easyar_DelayedCallbackScheduler * * Return);
/// <summary>
/// Executes a callback. If there is no callback to execute, false is returned.
/// </summary>
bool easyar_DelayedCallbackScheduler_runOne(easyar_DelayedCallbackScheduler * This);
void easyar_DelayedCallbackScheduler__dtor(easyar_DelayedCallbackScheduler * This);
void easyar_DelayedCallbackScheduler__retain(const easyar_DelayedCallbackScheduler * This, /* OUT */ easyar_DelayedCallbackScheduler * * Return);
const char * easyar_DelayedCallbackScheduler__typeName(const easyar_DelayedCallbackScheduler * This);
void easyar_castDelayedCallbackSchedulerToCallbackScheduler(const easyar_DelayedCallbackScheduler * This, /* OUT */ easyar_CallbackScheduler * * Return);
void easyar_tryCastCallbackSchedulerToDelayedCallbackScheduler(const easyar_CallbackScheduler * This, /* OUT */ easyar_DelayedCallbackScheduler * * Return);
/// <summary>
/// Gets a default immediate callback scheduler.
/// </summary>
void easyar_ImmediateCallbackScheduler_getDefault(/* OUT */ easyar_ImmediateCallbackScheduler * * Return);
void easyar_ImmediateCallbackScheduler__dtor(easyar_ImmediateCallbackScheduler * This);
void easyar_ImmediateCallbackScheduler__retain(const easyar_ImmediateCallbackScheduler * This, /* OUT */ easyar_ImmediateCallbackScheduler * * Return);
const char * easyar_ImmediateCallbackScheduler__typeName(const easyar_ImmediateCallbackScheduler * This);
void easyar_castImmediateCallbackSchedulerToCallbackScheduler(const easyar_ImmediateCallbackScheduler * This, /* OUT */ easyar_CallbackScheduler * * Return);
void easyar_tryCastCallbackSchedulerToImmediateCallbackScheduler(const easyar_CallbackScheduler * This, /* OUT */ easyar_ImmediateCallbackScheduler * * Return);
#ifdef __cplusplus
}
#endif
#endif
| 2,905
|
C++
|
.h
| 40
| 71.35
| 160
| 0.741766
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,272
|
types.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/types.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import <Foundation/Foundation.h>
@interface easyar_RefBase : NSObject
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
@end
@class easyar_ObjectTargetParameters;
@class easyar_ObjectTarget;
@class easyar_ObjectTrackerResult;
@class easyar_ObjectTracker;
typedef enum easyar_CloudStatus : NSInteger
{
/// <summary>
/// Targets are recognized.
/// </summary>
easyar_CloudStatus_FoundTargets = 0,
/// <summary>
/// No targets are recognized.
/// </summary>
easyar_CloudStatus_TargetsNotFound = 1,
/// <summary>
/// Connection broke and auto reconnecting
/// </summary>
easyar_CloudStatus_Reconnecting = 2,
/// <summary>
/// Protocol error
/// </summary>
easyar_CloudStatus_ProtocolError = 3,
} easyar_CloudStatus;
@class easyar_CloudRecognizer;
@class easyar_DenseSpatialMap;
@class easyar_BlockInfo;
@class easyar_SceneMesh;
@class easyar_SurfaceTrackerResult;
@class easyar_SurfaceTracker;
@class easyar_MotionTrackerCameraDevice;
@class easyar_ImageTargetParameters;
@class easyar_ImageTarget;
typedef enum easyar_ImageTrackerMode : NSInteger
{
/// <summary>
/// Quality is preferred.
/// </summary>
easyar_ImageTrackerMode_PreferQuality = 0,
/// <summary>
/// Performance is preferred.
/// </summary>
easyar_ImageTrackerMode_PreferPerformance = 1,
} easyar_ImageTrackerMode;
@class easyar_ImageTrackerResult;
@class easyar_ImageTracker;
@class easyar_Recorder;
typedef enum easyar_RecordProfile : NSInteger
{
/// <summary>
/// 1080P, low quality
/// </summary>
easyar_RecordProfile_Quality_1080P_Low = 0x00000001,
/// <summary>
/// 1080P, middle quality
/// </summary>
easyar_RecordProfile_Quality_1080P_Middle = 0x00000002,
/// <summary>
/// 1080P, high quality
/// </summary>
easyar_RecordProfile_Quality_1080P_High = 0x00000004,
/// <summary>
/// 720P, low quality
/// </summary>
easyar_RecordProfile_Quality_720P_Low = 0x00000008,
/// <summary>
/// 720P, middle quality
/// </summary>
easyar_RecordProfile_Quality_720P_Middle = 0x00000010,
/// <summary>
/// 720P, high quality
/// </summary>
easyar_RecordProfile_Quality_720P_High = 0x00000020,
/// <summary>
/// 480P, low quality
/// </summary>
easyar_RecordProfile_Quality_480P_Low = 0x00000040,
/// <summary>
/// 480P, middle quality
/// </summary>
easyar_RecordProfile_Quality_480P_Middle = 0x00000080,
/// <summary>
/// 480P, high quality
/// </summary>
easyar_RecordProfile_Quality_480P_High = 0x00000100,
/// <summary>
/// default resolution and quality, same as `Quality_720P_Middle`
/// </summary>
easyar_RecordProfile_Quality_Default = 0x00000010,
} easyar_RecordProfile;
typedef enum easyar_RecordVideoSize : NSInteger
{
/// <summary>
/// 1080P
/// </summary>
easyar_RecordVideoSize_Vid1080p = 0x00000002,
/// <summary>
/// 720P
/// </summary>
easyar_RecordVideoSize_Vid720p = 0x00000010,
/// <summary>
/// 480P
/// </summary>
easyar_RecordVideoSize_Vid480p = 0x00000080,
} easyar_RecordVideoSize;
typedef enum easyar_RecordZoomMode : NSInteger
{
/// <summary>
/// If output aspect ratio does not fit input, content will be clipped to fit output aspect ratio.
/// </summary>
easyar_RecordZoomMode_NoZoomAndClip = 0x00000000,
/// <summary>
/// If output aspect ratio does not fit input, content will not be clipped and there will be black borders in one dimension.
/// </summary>
easyar_RecordZoomMode_ZoomInWithAllContent = 0x00000001,
} easyar_RecordZoomMode;
typedef enum easyar_RecordVideoOrientation : NSInteger
{
/// <summary>
/// video recorded is landscape
/// </summary>
easyar_RecordVideoOrientation_Landscape = 0x00000000,
/// <summary>
/// video recorded is portrait
/// </summary>
easyar_RecordVideoOrientation_Portrait = 0x00000001,
} easyar_RecordVideoOrientation;
typedef enum easyar_RecordStatus : NSInteger
{
/// <summary>
/// recording start
/// </summary>
easyar_RecordStatus_OnStarted = 0x00000002,
/// <summary>
/// recording stopped
/// </summary>
easyar_RecordStatus_OnStopped = 0x00000004,
/// <summary>
/// start fail
/// </summary>
easyar_RecordStatus_FailedToStart = 0x00000202,
/// <summary>
/// file write succeed
/// </summary>
easyar_RecordStatus_FileSucceeded = 0x00000400,
/// <summary>
/// file write fail
/// </summary>
easyar_RecordStatus_FileFailed = 0x00000401,
/// <summary>
/// runtime info with description
/// </summary>
easyar_RecordStatus_LogInfo = 0x00000800,
/// <summary>
/// runtime error with description
/// </summary>
easyar_RecordStatus_LogError = 0x00001000,
} easyar_RecordStatus;
@class easyar_RecorderConfiguration;
@class easyar_SparseSpatialMapResult;
typedef enum easyar_PlaneType : NSInteger
{
/// <summary>
/// Horizontal plane
/// </summary>
easyar_PlaneType_Horizontal = 0,
/// <summary>
/// Vertical plane
/// </summary>
easyar_PlaneType_Vertical = 1,
} easyar_PlaneType;
@class easyar_PlaneData;
typedef enum easyar_LocalizationMode : NSInteger
{
/// <summary>
/// Attempt to perform localization in current SparseSpatialMap until success.
/// </summary>
easyar_LocalizationMode_UntilSuccess = 0,
/// <summary>
/// Perform localization only once
/// </summary>
easyar_LocalizationMode_Once = 1,
/// <summary>
/// Keep performing localization and adjust result on success
/// </summary>
easyar_LocalizationMode_KeepUpdate = 2,
/// <summary>
/// Keep performing localization and adjust localization result only when localization returns different map ID from previous results
/// </summary>
easyar_LocalizationMode_ContinousLocalize = 3,
} easyar_LocalizationMode;
@class easyar_SparseSpatialMapConfig;
@class easyar_SparseSpatialMap;
@class easyar_SparseSpatialMapManager;
@class easyar_ImageHelper;
@class easyar_ARCoreCameraDevice;
@class easyar_ARKitCameraDevice;
@class easyar_CallbackScheduler;
@class easyar_DelayedCallbackScheduler;
@class easyar_ImmediateCallbackScheduler;
typedef enum easyar_CameraDeviceFocusMode : NSInteger
{
/// <summary>
/// Normal auto focus mode. You should call autoFocus to start the focus in this mode.
/// </summary>
easyar_CameraDeviceFocusMode_Normal = 0,
/// <summary>
/// Continuous auto focus mode
/// </summary>
easyar_CameraDeviceFocusMode_Continousauto = 2,
/// <summary>
/// Infinity focus mode
/// </summary>
easyar_CameraDeviceFocusMode_Infinity = 3,
/// <summary>
/// Macro (close-up) focus mode. You should call autoFocus to start the focus in this mode.
/// </summary>
easyar_CameraDeviceFocusMode_Macro = 4,
/// <summary>
/// Medium distance focus mode
/// </summary>
easyar_CameraDeviceFocusMode_Medium = 5,
} easyar_CameraDeviceFocusMode;
typedef enum easyar_AndroidCameraApiType : NSInteger
{
/// <summary>
/// Android Camera1
/// </summary>
easyar_AndroidCameraApiType_Camera1 = 0,
/// <summary>
/// Android Camera2
/// </summary>
easyar_AndroidCameraApiType_Camera2 = 1,
} easyar_AndroidCameraApiType;
typedef enum easyar_CameraDevicePresetProfile : NSInteger
{
/// <summary>
/// The same as AVCaptureSessionPresetPhoto.
/// </summary>
easyar_CameraDevicePresetProfile_Photo = 0,
/// <summary>
/// The same as AVCaptureSessionPresetHigh.
/// </summary>
easyar_CameraDevicePresetProfile_High = 1,
/// <summary>
/// The same as AVCaptureSessionPresetMedium.
/// </summary>
easyar_CameraDevicePresetProfile_Medium = 2,
/// <summary>
/// The same as AVCaptureSessionPresetLow.
/// </summary>
easyar_CameraDevicePresetProfile_Low = 3,
} easyar_CameraDevicePresetProfile;
typedef enum easyar_CameraState : NSInteger
{
/// <summary>
/// Unknown
/// </summary>
easyar_CameraState_Unknown = 0x00000000,
/// <summary>
/// Disconnected
/// </summary>
easyar_CameraState_Disconnected = 0x00000001,
/// <summary>
/// Preempted by another application.
/// </summary>
easyar_CameraState_Preempted = 0x00000002,
} easyar_CameraState;
@class easyar_CameraDevice;
typedef enum easyar_CameraDevicePreference : NSInteger
{
/// <summary>
/// Optimized for `ImageTracker`_ , `ObjectTracker`_ and `CloudRecognizer`_ .
/// </summary>
easyar_CameraDevicePreference_PreferObjectSensing = 0,
/// <summary>
/// Optimized for `SurfaceTracker`_ .
/// </summary>
easyar_CameraDevicePreference_PreferSurfaceTracking = 1,
} easyar_CameraDevicePreference;
@class easyar_CameraDeviceSelector;
@class easyar_SignalSink;
@class easyar_SignalSource;
@class easyar_InputFrameSink;
@class easyar_InputFrameSource;
@class easyar_OutputFrameSink;
@class easyar_OutputFrameSource;
@class easyar_FeedbackFrameSink;
@class easyar_FeedbackFrameSource;
@class easyar_InputFrameFork;
@class easyar_OutputFrameFork;
@class easyar_OutputFrameJoin;
@class easyar_FeedbackFrameFork;
@class easyar_InputFrameThrottler;
@class easyar_OutputFrameBuffer;
@class easyar_InputFrameToOutputFrameAdapter;
@class easyar_InputFrameToFeedbackFrameAdapter;
@class easyar_Engine;
@class easyar_InputFrame;
@class easyar_FrameFilterResult;
@class easyar_OutputFrame;
@class easyar_FeedbackFrame;
typedef enum easyar_PermissionStatus : NSInteger
{
/// <summary>
/// Permission granted
/// </summary>
easyar_PermissionStatus_Granted = 0x00000000,
/// <summary>
/// Permission denied
/// </summary>
easyar_PermissionStatus_Denied = 0x00000001,
/// <summary>
/// A error happened while requesting permission.
/// </summary>
easyar_PermissionStatus_Error = 0x00000002,
} easyar_PermissionStatus;
/// <summary>
/// StorageType represents where the images, jsons, videos or other files are located.
/// StorageType specifies the root path, in all interfaces, you can use relative path relative to the root path.
/// </summary>
typedef enum easyar_StorageType : NSInteger
{
/// <summary>
/// The app path.
/// Android: the application's `persistent data directory <https://developer.android.google.cn/reference/android/content/pm/ApplicationInfo.html#dataDir>`_
/// iOS: the application's sandbox directory
/// Windows: Windows: the application's executable directory
/// Mac: the application’s executable directory (if app is a bundle, this path is inside the bundle)
/// </summary>
easyar_StorageType_App = 0,
/// <summary>
/// The assets path.
/// Android: assets directory (inside apk)
/// iOS: the application's executable directory
/// Windows: EasyAR.dll directory
/// Mac: libEasyAR.dylib directory
/// **Note:** *this path is different if you are using Unity3D. It will point to the StreamingAssets folder.*
/// </summary>
easyar_StorageType_Assets = 1,
/// <summary>
/// The absolute path (json/image path or video path) or url (video only).
/// </summary>
easyar_StorageType_Absolute = 2,
} easyar_StorageType;
@class easyar_Target;
typedef enum easyar_TargetStatus : NSInteger
{
/// <summary>
/// The status is unknown.
/// </summary>
easyar_TargetStatus_Unknown = 0,
/// <summary>
/// The status is undefined.
/// </summary>
easyar_TargetStatus_Undefined = 1,
/// <summary>
/// The target is detected.
/// </summary>
easyar_TargetStatus_Detected = 2,
/// <summary>
/// The target is tracked.
/// </summary>
easyar_TargetStatus_Tracked = 3,
} easyar_TargetStatus;
@class easyar_TargetInstance;
@class easyar_TargetTrackerResult;
@class easyar_TextureId;
typedef enum easyar_VideoStatus : NSInteger
{
/// <summary>
/// Status to indicate something wrong happen in video open or play.
/// </summary>
easyar_VideoStatus_Error = -1,
/// <summary>
/// Status to show video finished open and is ready for play.
/// </summary>
easyar_VideoStatus_Ready = 0,
/// <summary>
/// Status to indicate video finished play and reached the end.
/// </summary>
easyar_VideoStatus_Completed = 1,
} easyar_VideoStatus;
typedef enum easyar_VideoType : NSInteger
{
/// <summary>
/// Normal video.
/// </summary>
easyar_VideoType_Normal = 0,
/// <summary>
/// Transparent video, left half is the RGB channel and right half is alpha channel.
/// </summary>
easyar_VideoType_TransparentSideBySide = 1,
/// <summary>
/// Transparent video, top half is the RGB channel and bottom half is alpha channel.
/// </summary>
easyar_VideoType_TransparentTopAndBottom = 2,
} easyar_VideoType;
@class easyar_VideoPlayer;
@class easyar_Buffer;
@class easyar_BufferDictionary;
@class easyar_BufferPool;
typedef enum easyar_CameraDeviceType : NSInteger
{
/// <summary>
/// Unknown location
/// </summary>
easyar_CameraDeviceType_Unknown = 0,
/// <summary>
/// Rear camera
/// </summary>
easyar_CameraDeviceType_Back = 1,
/// <summary>
/// Front camera
/// </summary>
easyar_CameraDeviceType_Front = 2,
} easyar_CameraDeviceType;
/// <summary>
/// MotionTrackingStatus describes the quality of device motion tracking.
/// </summary>
typedef enum easyar_MotionTrackingStatus : NSInteger
{
/// <summary>
/// Result is not available and should not to be used to render virtual objects or do 3D reconstruction. This value occurs temporarily after initializing, tracking lost or relocalizing.
/// </summary>
easyar_MotionTrackingStatus_NotTracking = 0,
/// <summary>
/// Tracking is available, but the quality of the result is not good enough. This value occurs temporarily due to weak texture or excessive movement. The result can be used to render virtual objects, but should generally not be used to do 3D reconstruction.
/// </summary>
easyar_MotionTrackingStatus_Limited = 1,
/// <summary>
/// Tracking with a good quality. The result can be used to render virtual objects or do 3D reconstruction.
/// </summary>
easyar_MotionTrackingStatus_Tracking = 2,
} easyar_MotionTrackingStatus;
@class easyar_CameraParameters;
/// <summary>
/// PixelFormat represents the format of image pixel data. All formats follow the pixel direction from left to right and from top to bottom.
/// </summary>
typedef enum easyar_PixelFormat : NSInteger
{
/// <summary>
/// Unknown
/// </summary>
easyar_PixelFormat_Unknown = 0,
/// <summary>
/// 256 shades grayscale
/// </summary>
easyar_PixelFormat_Gray = 1,
/// <summary>
/// YUV_NV21
/// </summary>
easyar_PixelFormat_YUV_NV21 = 2,
/// <summary>
/// YUV_NV12
/// </summary>
easyar_PixelFormat_YUV_NV12 = 3,
/// <summary>
/// YUV_I420
/// </summary>
easyar_PixelFormat_YUV_I420 = 4,
/// <summary>
/// YUV_YV12
/// </summary>
easyar_PixelFormat_YUV_YV12 = 5,
/// <summary>
/// RGB888
/// </summary>
easyar_PixelFormat_RGB888 = 6,
/// <summary>
/// BGR888
/// </summary>
easyar_PixelFormat_BGR888 = 7,
/// <summary>
/// RGBA8888
/// </summary>
easyar_PixelFormat_RGBA8888 = 8,
/// <summary>
/// BGRA8888
/// </summary>
easyar_PixelFormat_BGRA8888 = 9,
} easyar_PixelFormat;
@class easyar_Image;
@class easyar_JniUtility;
typedef enum easyar_LogLevel : NSInteger
{
/// <summary>
/// Error
/// </summary>
easyar_LogLevel_Error = 0,
/// <summary>
/// Warning
/// </summary>
easyar_LogLevel_Warning = 1,
/// <summary>
/// Information
/// </summary>
easyar_LogLevel_Info = 2,
} easyar_LogLevel;
@class easyar_Log;
@class easyar_Matrix44F;
@class easyar_Matrix33F;
@class easyar_Vec4F;
@class easyar_Vec3F;
@class easyar_Vec2F;
@class easyar_Vec4I;
@class easyar_Vec2I;
| 16,903
|
C++
|
.h
| 519
| 28.620424
| 261
| 0.687999
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,273
|
image.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/image.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_IMAGE_H__
#define __EASYAR_IMAGE_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
void easyar_Image__ctor(easyar_Buffer * buffer, easyar_PixelFormat format, int width, int height, /* OUT */ easyar_Image * * Return);
/// <summary>
/// Returns buffer inside image. It can be used to access internal data of image. The content of `Buffer`_ shall not be modified, as they may be accessed from other threads.
/// </summary>
void easyar_Image_buffer(const easyar_Image * This, /* OUT */ easyar_Buffer * * Return);
/// <summary>
/// Returns image format.
/// </summary>
easyar_PixelFormat easyar_Image_format(const easyar_Image * This);
/// <summary>
/// Returns image width.
/// </summary>
int easyar_Image_width(const easyar_Image * This);
/// <summary>
/// Returns image height.
/// </summary>
int easyar_Image_height(const easyar_Image * This);
/// <summary>
/// Checks if the image is empty.
/// </summary>
bool easyar_Image_empty(easyar_Image * This);
void easyar_Image__dtor(easyar_Image * This);
void easyar_Image__retain(const easyar_Image * This, /* OUT */ easyar_Image * * Return);
const char * easyar_Image__typeName(const easyar_Image * This);
#ifdef __cplusplus
}
#endif
#endif
| 1,879
|
C++
|
.h
| 42
| 43.52381
| 173
| 0.634026
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,274
|
target.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/target.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_TARGET_H__
#define __EASYAR_TARGET_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Returns the target id. A target id is a integer number generated at runtime. This id is non-zero and increasing globally.
/// </summary>
int easyar_Target_runtimeID(const easyar_Target * This);
/// <summary>
/// Returns the target uid. A target uid is useful in cloud based algorithms. If no cloud is used, you can set this uid in the json config as a alternative method to distinguish from targets.
/// </summary>
void easyar_Target_uid(const easyar_Target * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Returns the target name. Name is used to distinguish targets in a json file.
/// </summary>
void easyar_Target_name(const easyar_Target * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Set name. It will erase previously set data or data from cloud.
/// </summary>
void easyar_Target_setName(easyar_Target * This, easyar_String * name);
/// <summary>
/// Returns the meta data set by setMetaData. Or, in a cloud returned target, returns the meta data set in the cloud server.
/// </summary>
void easyar_Target_meta(const easyar_Target * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Set meta data. It will erase previously set data or data from cloud.
/// </summary>
void easyar_Target_setMeta(easyar_Target * This, easyar_String * data);
void easyar_Target__dtor(easyar_Target * This);
void easyar_Target__retain(const easyar_Target * This, /* OUT */ easyar_Target * * Return);
const char * easyar_Target__typeName(const easyar_Target * This);
void easyar_TargetInstance__ctor(/* OUT */ easyar_TargetInstance * * Return);
/// <summary>
/// Returns current status of the tracked target. Usually you can check if the status equals `TargetStatus.Tracked` to determine current status of the target.
/// </summary>
easyar_TargetStatus easyar_TargetInstance_status(const easyar_TargetInstance * This);
/// <summary>
/// Gets the raw target. It will return the same `Target`_ you loaded into a tracker if it was previously loaded into the tracker.
/// </summary>
void easyar_TargetInstance_target(const easyar_TargetInstance * This, /* OUT */ easyar_OptionalOfTarget * Return);
/// <summary>
/// Returns current pose of the tracked target. Camera coordinate system and target coordinate system are all right-handed. For the camera coordinate system, the origin is the optical center, x-right, y-up, and z in the direction of light going into camera. (The right and up, on mobile devices, is the right and up when the device is in the natural orientation.) The data arrangement is row-major, not like OpenGL's column-major.
/// </summary>
easyar_Matrix44F easyar_TargetInstance_pose(const easyar_TargetInstance * This);
void easyar_TargetInstance__dtor(easyar_TargetInstance * This);
void easyar_TargetInstance__retain(const easyar_TargetInstance * This, /* OUT */ easyar_TargetInstance * * Return);
const char * easyar_TargetInstance__typeName(const easyar_TargetInstance * This);
/// <summary>
/// Returns the list of `TargetInstance`_ contained in the result.
/// </summary>
void easyar_TargetTrackerResult_targetInstances(const easyar_TargetTrackerResult * This, /* OUT */ easyar_ListOfTargetInstance * * Return);
/// <summary>
/// Sets the list of `TargetInstance`_ contained in the result.
/// </summary>
void easyar_TargetTrackerResult_setTargetInstances(easyar_TargetTrackerResult * This, easyar_ListOfTargetInstance * instances);
void easyar_TargetTrackerResult__dtor(easyar_TargetTrackerResult * This);
void easyar_TargetTrackerResult__retain(const easyar_TargetTrackerResult * This, /* OUT */ easyar_TargetTrackerResult * * Return);
const char * easyar_TargetTrackerResult__typeName(const easyar_TargetTrackerResult * This);
void easyar_castTargetTrackerResultToFrameFilterResult(const easyar_TargetTrackerResult * This, /* OUT */ easyar_FrameFilterResult * * Return);
void easyar_tryCastFrameFilterResultToTargetTrackerResult(const easyar_FrameFilterResult * This, /* OUT */ easyar_TargetTrackerResult * * Return);
void easyar_ListOfTargetInstance__ctor(easyar_TargetInstance * const * begin, easyar_TargetInstance * const * end, /* OUT */ easyar_ListOfTargetInstance * * Return);
void easyar_ListOfTargetInstance__dtor(easyar_ListOfTargetInstance * This);
void easyar_ListOfTargetInstance_copy(const easyar_ListOfTargetInstance * This, /* OUT */ easyar_ListOfTargetInstance * * Return);
int easyar_ListOfTargetInstance_size(const easyar_ListOfTargetInstance * This);
easyar_TargetInstance * easyar_ListOfTargetInstance_at(const easyar_ListOfTargetInstance * This, int index);
#ifdef __cplusplus
}
#endif
#endif
| 5,369
|
C++
|
.h
| 79
| 66.810127
| 434
| 0.734559
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,275
|
sparsespatialmap.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/sparsespatialmap.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_SPARSESPATIALMAP_H__
#define __EASYAR_SPARSESPATIALMAP_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Obtain motion tracking status.
/// </summary>
easyar_MotionTrackingStatus easyar_SparseSpatialMapResult_getMotionTrackingStatus(const easyar_SparseSpatialMapResult * This);
/// <summary>
/// Returns pose of the origin of VIO system in camera coordinate system.
/// </summary>
easyar_OptionalOfMatrix44F easyar_SparseSpatialMapResult_getVioPose(const easyar_SparseSpatialMapResult * This);
/// <summary>
/// Returns the pose of origin of the map in camera coordinate system, when localization is successful.
/// Otherwise, returns pose of the origin of VIO system in camera coordinate system.
/// </summary>
easyar_OptionalOfMatrix44F easyar_SparseSpatialMapResult_getMapPose(const easyar_SparseSpatialMapResult * This);
/// <summary>
/// Returns true if the system can reliablly locate the pose of the device with regard to the map.
/// Once relocalization succeeds, relative pose can be updated by motion tracking module.
/// As long as the motion tracking module returns normal tracking status, the localization status is also true.
/// </summary>
bool easyar_SparseSpatialMapResult_getLocalizationStatus(const easyar_SparseSpatialMapResult * This);
/// <summary>
/// Returns current localized map ID.
/// </summary>
void easyar_SparseSpatialMapResult_getLocalizationMapID(const easyar_SparseSpatialMapResult * This, /* OUT */ easyar_String * * Return);
void easyar_SparseSpatialMapResult__dtor(easyar_SparseSpatialMapResult * This);
void easyar_SparseSpatialMapResult__retain(const easyar_SparseSpatialMapResult * This, /* OUT */ easyar_SparseSpatialMapResult * * Return);
const char * easyar_SparseSpatialMapResult__typeName(const easyar_SparseSpatialMapResult * This);
void easyar_castSparseSpatialMapResultToFrameFilterResult(const easyar_SparseSpatialMapResult * This, /* OUT */ easyar_FrameFilterResult * * Return);
void easyar_tryCastFrameFilterResultToSparseSpatialMapResult(const easyar_FrameFilterResult * This, /* OUT */ easyar_SparseSpatialMapResult * * Return);
/// <summary>
/// Constructor
/// </summary>
void easyar_PlaneData__ctor(/* OUT */ easyar_PlaneData * * Return);
/// <summary>
/// Returns the type of this plane.
/// </summary>
easyar_PlaneType easyar_PlaneData_getType(const easyar_PlaneData * This);
/// <summary>
/// Returns the pose of the center of the detected plane.The pose's transformed +Y axis will be point normal out of the plane, with the +X and +Z axes orienting the extents of the bounding rectangle.
/// </summary>
easyar_Matrix44F easyar_PlaneData_getPose(const easyar_PlaneData * This);
/// <summary>
/// Returns the length of this plane's bounding rectangle measured along the local X-axis of the coordinate space centered on the plane.
/// </summary>
float easyar_PlaneData_getExtentX(const easyar_PlaneData * This);
/// <summary>
/// Returns the length of this plane's bounding rectangle measured along the local Z-axis of the coordinate frame centered on the plane.
/// </summary>
float easyar_PlaneData_getExtentZ(const easyar_PlaneData * This);
void easyar_PlaneData__dtor(easyar_PlaneData * This);
void easyar_PlaneData__retain(const easyar_PlaneData * This, /* OUT */ easyar_PlaneData * * Return);
const char * easyar_PlaneData__typeName(const easyar_PlaneData * This);
/// <summary>
/// Constructor
/// </summary>
void easyar_SparseSpatialMapConfig__ctor(/* OUT */ easyar_SparseSpatialMapConfig * * Return);
/// <summary>
/// Sets localization configurations. See also `LocalizationMode`_.
/// </summary>
void easyar_SparseSpatialMapConfig_setLocalizationMode(easyar_SparseSpatialMapConfig * This, easyar_LocalizationMode _value);
/// <summary>
/// Returns localization configurations. See also `LocalizationMode`_.
/// </summary>
easyar_LocalizationMode easyar_SparseSpatialMapConfig_getLocalizationMode(const easyar_SparseSpatialMapConfig * This);
void easyar_SparseSpatialMapConfig__dtor(easyar_SparseSpatialMapConfig * This);
void easyar_SparseSpatialMapConfig__retain(const easyar_SparseSpatialMapConfig * This, /* OUT */ easyar_SparseSpatialMapConfig * * Return);
const char * easyar_SparseSpatialMapConfig__typeName(const easyar_SparseSpatialMapConfig * This);
/// <summary>
/// Check whether SparseSpatialMap is is available, always return true.
/// </summary>
bool easyar_SparseSpatialMap_isAvailable(void);
/// <summary>
/// Input port for input frame. For SparseSpatialMap to work, the inputFrame must include camera parameters, timestamp and spatial information. See also `InputFrameSink`_
/// </summary>
void easyar_SparseSpatialMap_inputFrameSink(easyar_SparseSpatialMap * This, /* OUT */ easyar_InputFrameSink * * Return);
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
int easyar_SparseSpatialMap_bufferRequirement(easyar_SparseSpatialMap * This);
/// <summary>
/// Output port for output frame. See also `OutputFrameSource`_
/// </summary>
void easyar_SparseSpatialMap_outputFrameSource(easyar_SparseSpatialMap * This, /* OUT */ easyar_OutputFrameSource * * Return);
/// <summary>
/// Construct SparseSpatialMap.
/// </summary>
void easyar_SparseSpatialMap_create(/* OUT */ easyar_SparseSpatialMap * * Return);
/// <summary>
/// Start SparseSpatialMap system.
/// </summary>
bool easyar_SparseSpatialMap_start(easyar_SparseSpatialMap * This);
/// <summary>
/// Stop SparseSpatialMap from running。Can resume running by calling start().
/// </summary>
void easyar_SparseSpatialMap_stop(easyar_SparseSpatialMap * This);
/// <summary>
/// Close SparseSpatialMap. SparseSpatialMap can no longer be used.
/// </summary>
void easyar_SparseSpatialMap_close(easyar_SparseSpatialMap * This);
/// <summary>
/// Returns the buffer of point cloud coordinate. Each 3D point is represented by three consecutive values, representing X, Y, Z position coordinates in the world coordinate space, each of which takes 4 bytes.
/// </summary>
void easyar_SparseSpatialMap_getPointCloudBuffer(easyar_SparseSpatialMap * This, /* OUT */ easyar_Buffer * * Return);
/// <summary>
/// Returns detected planes in SparseSpatialMap.
/// </summary>
void easyar_SparseSpatialMap_getMapPlanes(easyar_SparseSpatialMap * This, /* OUT */ easyar_ListOfPlaneData * * Return);
/// <summary>
/// Perform hit test against the point cloud. The results are returned sorted by their distance to the camera in ascending order.
/// </summary>
void easyar_SparseSpatialMap_hitTestAgainstPointCloud(easyar_SparseSpatialMap * This, easyar_Vec2F cameraImagePoint, /* OUT */ easyar_ListOfVec3F * * Return);
/// <summary>
/// Performs ray cast from the user's device in the direction of given screen point.
/// Intersections with detected planes are returned. 3D positions on physical planes are sorted by distance from the device in ascending order.
/// For the camera image coordinate system ([0, 1]^2), x-right, y-down, and origin is at left-top corner. `CameraParameters.imageCoordinatesFromScreenCoordinates`_ can be used to convert points from screen coordinate system to camera image coordinate system.
/// The output point cloud coordinate is in the world coordinate system.
/// </summary>
void easyar_SparseSpatialMap_hitTestAgainstPlanes(easyar_SparseSpatialMap * This, easyar_Vec2F cameraImagePoint, /* OUT */ easyar_ListOfVec3F * * Return);
/// <summary>
/// Get the map data version of the current SparseSpatialMap.
/// </summary>
void easyar_SparseSpatialMap_getMapVersion(/* OUT */ easyar_String * * Return);
/// <summary>
/// UnloadMap specified SparseSpatialMap data via callback function.The return value of callback indicates whether unload map succeeds (true) or fails (false).
/// </summary>
void easyar_SparseSpatialMap_unloadMap(easyar_SparseSpatialMap * This, easyar_String * mapID, easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromBool resultCallBack);
/// <summary>
/// Set configurations for SparseSpatialMap. See also `SparseSpatialMapConfig`_.
/// </summary>
void easyar_SparseSpatialMap_setConfig(easyar_SparseSpatialMap * This, easyar_SparseSpatialMapConfig * config);
/// <summary>
/// Returns configurations for SparseSpatialMap. See also `SparseSpatialMapConfig`_.
/// </summary>
void easyar_SparseSpatialMap_getConfig(easyar_SparseSpatialMap * This, /* OUT */ easyar_SparseSpatialMapConfig * * Return);
/// <summary>
/// Start localization in loaded maps. Should set `LocalizationMode`_ first.
/// </summary>
bool easyar_SparseSpatialMap_startLocalization(easyar_SparseSpatialMap * This);
/// <summary>
/// Stop localization in loaded maps.
/// </summary>
void easyar_SparseSpatialMap_stopLocalization(easyar_SparseSpatialMap * This);
void easyar_SparseSpatialMap__dtor(easyar_SparseSpatialMap * This);
void easyar_SparseSpatialMap__retain(const easyar_SparseSpatialMap * This, /* OUT */ easyar_SparseSpatialMap * * Return);
const char * easyar_SparseSpatialMap__typeName(const easyar_SparseSpatialMap * This);
void easyar_ListOfPlaneData__ctor(easyar_PlaneData * const * begin, easyar_PlaneData * const * end, /* OUT */ easyar_ListOfPlaneData * * Return);
void easyar_ListOfPlaneData__dtor(easyar_ListOfPlaneData * This);
void easyar_ListOfPlaneData_copy(const easyar_ListOfPlaneData * This, /* OUT */ easyar_ListOfPlaneData * * Return);
int easyar_ListOfPlaneData_size(const easyar_ListOfPlaneData * This);
easyar_PlaneData * easyar_ListOfPlaneData_at(const easyar_ListOfPlaneData * This, int index);
void easyar_ListOfVec3F__ctor(easyar_Vec3F const * begin, easyar_Vec3F const * end, /* OUT */ easyar_ListOfVec3F * * Return);
void easyar_ListOfVec3F__dtor(easyar_ListOfVec3F * This);
void easyar_ListOfVec3F_copy(const easyar_ListOfVec3F * This, /* OUT */ easyar_ListOfVec3F * * Return);
int easyar_ListOfVec3F_size(const easyar_ListOfVec3F * This);
easyar_Vec3F easyar_ListOfVec3F_at(const easyar_ListOfVec3F * This, int index);
#ifdef __cplusplus
}
#endif
#endif
| 10,620
|
C++
|
.h
| 172
| 60.651163
| 258
| 0.766008
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,276
|
cameraparameters.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/cameraparameters.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_CAMERAPARAMETERS_H__
#define __EASYAR_CAMERAPARAMETERS_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
void easyar_CameraParameters__ctor(easyar_Vec2I size, easyar_Vec2F focalLength, easyar_Vec2F principalPoint, easyar_CameraDeviceType cameraDeviceType, int cameraOrientation, /* OUT */ easyar_CameraParameters * * Return);
/// <summary>
/// Image size.
/// </summary>
easyar_Vec2I easyar_CameraParameters_size(const easyar_CameraParameters * This);
/// <summary>
/// Focal length, the distance from effective optical center to CCD plane, divided by unit pixel density in width and height directions. The unit is pixel.
/// </summary>
easyar_Vec2F easyar_CameraParameters_focalLength(const easyar_CameraParameters * This);
/// <summary>
/// Principal point, coordinates of the intersection point of principal axis on CCD plane against the left-top corner of the image. The unit is pixel.
/// </summary>
easyar_Vec2F easyar_CameraParameters_principalPoint(const easyar_CameraParameters * This);
/// <summary>
/// Camera device type. Default, back or front camera. On desktop devices, there are only default cameras. On mobile devices, there is a differentiation between back and front cameras.
/// </summary>
easyar_CameraDeviceType easyar_CameraParameters_cameraDeviceType(const easyar_CameraParameters * This);
/// <summary>
/// Camera rotation against device natural orientation.
/// For Android phones and some Android tablets, this value is 90 degrees.
/// For Android eye-wear and some Android tablets, this value is 0 degrees.
/// For all current iOS devices, this value is 90 degrees.
/// </summary>
int easyar_CameraParameters_cameraOrientation(const easyar_CameraParameters * This);
/// <summary>
/// Creates CameraParameters with default camera intrinsics. Default intrinsics are calculated by image size, which is not very precise.
/// </summary>
void easyar_CameraParameters_createWithDefaultIntrinsics(easyar_Vec2I size, easyar_CameraDeviceType cameraDeviceType, int cameraOrientation, /* OUT */ easyar_CameraParameters * * Return);
/// <summary>
/// Calculates the angle required to rotate the camera image clockwise to align it with the screen.
/// screenRotation is the angle of rotation of displaying screen image against device natural orientation in clockwise in degrees.
/// For iOS(UIInterfaceOrientationPortrait as natural orientation):
/// * UIInterfaceOrientationPortrait: rotation = 0
/// * UIInterfaceOrientationLandscapeRight: rotation = 90
/// * UIInterfaceOrientationPortraitUpsideDown: rotation = 180
/// * UIInterfaceOrientationLandscapeLeft: rotation = 270
/// For Android:
/// * Surface.ROTATION_0 = 0
/// * Surface.ROTATION_90 = 90
/// * Surface.ROTATION_180 = 180
/// * Surface.ROTATION_270 = 270
/// </summary>
int easyar_CameraParameters_imageOrientation(const easyar_CameraParameters * This, int screenRotation);
/// <summary>
/// Calculates whether the image needed to be flipped horizontally. The image is rotated, then flipped in rendering. When cameraDeviceType is front, a flip is automatically applied. Pass manualHorizontalFlip with true to add a manual flip.
/// </summary>
bool easyar_CameraParameters_imageHorizontalFlip(const easyar_CameraParameters * This, bool manualHorizontalFlip);
/// <summary>
/// Calculates the perspective projection matrix needed by virtual object rendering. The projection transforms points from camera coordinate system to clip coordinate system ([-1, 1]^4). The form of perspective projection matrix is the same as OpenGL, that matrix multiply column vector of homogeneous coordinates of point on the right, ant not like Direct3D, that matrix multiply row vector of homogeneous coordinates of point on the left. But data arrangement is row-major, not like OpenGL's column-major. Clip coordinate system and normalized device coordinate system are defined as the same as OpenGL's default.
/// </summary>
easyar_Matrix44F easyar_CameraParameters_projection(const easyar_CameraParameters * This, float nearPlane, float farPlane, float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip);
/// <summary>
/// Calculates the orthogonal projection matrix needed by camera background rendering. The projection transforms points from image quad coordinate system ([-1, 1]^2) to clip coordinate system ([-1, 1]^4), with the undefined two dimensions unchanged. The form of orthogonal projection matrix is the same as OpenGL, that matrix multiply column vector of homogeneous coordinates of point on the right, ant not like Direct3D, that matrix multiply row vector of homogeneous coordinates of point on the left. But data arrangement is row-major, not like OpenGL's column-major. Clip coordinate system and normalized device coordinate system are defined as the same as OpenGL's default.
/// </summary>
easyar_Matrix44F easyar_CameraParameters_imageProjection(const easyar_CameraParameters * This, float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip);
/// <summary>
/// Transforms points from image coordinate system ([0, 1]^2) to screen coordinate system ([0, 1]^2). Both coordinate system is x-left, y-down, with origin at left-top.
/// </summary>
easyar_Vec2F easyar_CameraParameters_screenCoordinatesFromImageCoordinates(const easyar_CameraParameters * This, float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip, easyar_Vec2F imageCoordinates);
/// <summary>
/// Transforms points from screen coordinate system ([0, 1]^2) to image coordinate system ([0, 1]^2). Both coordinate system is x-left, y-down, with origin at left-top.
/// </summary>
easyar_Vec2F easyar_CameraParameters_imageCoordinatesFromScreenCoordinates(const easyar_CameraParameters * This, float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip, easyar_Vec2F screenCoordinates);
/// <summary>
/// Checks if two groups of parameters are equal.
/// </summary>
bool easyar_CameraParameters_equalsTo(const easyar_CameraParameters * This, easyar_CameraParameters * other);
void easyar_CameraParameters__dtor(easyar_CameraParameters * This);
void easyar_CameraParameters__retain(const easyar_CameraParameters * This, /* OUT */ easyar_CameraParameters * * Return);
const char * easyar_CameraParameters__typeName(const easyar_CameraParameters * This);
#ifdef __cplusplus
}
#endif
#endif
| 7,081
|
C++
|
.h
| 88
| 79.363636
| 685
| 0.768614
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,277
|
arcorecamera.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/arcorecamera.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_ARCORECAMERA_H__
#define __EASYAR_ARCORECAMERA_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
void easyar_ARCoreCameraDevice__ctor(/* OUT */ easyar_ARCoreCameraDevice * * Return);
/// <summary>
/// Checks if the component is available. It returns true only on Android when ARCore is installed.
/// If called with libarcore_sdk_c.so not loaded, it returns false.
/// Notice: If ARCore is not supported on the device but ARCore apk is installed via side-loading, it will return true, but ARCore will not function properly.
/// </summary>
bool easyar_ARCoreCameraDevice_isAvailable(void);
/// <summary>
/// `InputFrame`_ buffer capacity. The default is 8.
/// </summary>
int easyar_ARCoreCameraDevice_bufferCapacity(const easyar_ARCoreCameraDevice * This);
/// <summary>
/// Sets `InputFrame`_ buffer capacity.
/// </summary>
void easyar_ARCoreCameraDevice_setBufferCapacity(easyar_ARCoreCameraDevice * This, int capacity);
/// <summary>
/// `InputFrame`_ output port.
/// </summary>
void easyar_ARCoreCameraDevice_inputFrameSource(easyar_ARCoreCameraDevice * This, /* OUT */ easyar_InputFrameSource * * Return);
/// <summary>
/// Starts video stream capture.
/// </summary>
bool easyar_ARCoreCameraDevice_start(easyar_ARCoreCameraDevice * This);
/// <summary>
/// Stops video stream capture.
/// </summary>
void easyar_ARCoreCameraDevice_stop(easyar_ARCoreCameraDevice * This);
/// <summary>
/// Close. The component shall not be used after calling close.
/// </summary>
void easyar_ARCoreCameraDevice_close(easyar_ARCoreCameraDevice * This);
void easyar_ARCoreCameraDevice__dtor(easyar_ARCoreCameraDevice * This);
void easyar_ARCoreCameraDevice__retain(const easyar_ARCoreCameraDevice * This, /* OUT */ easyar_ARCoreCameraDevice * * Return);
const char * easyar_ARCoreCameraDevice__typeName(const easyar_ARCoreCameraDevice * This);
#ifdef __cplusplus
}
#endif
#endif
| 2,562
|
C++
|
.h
| 52
| 48.096154
| 158
| 0.695322
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,278
|
buffer.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/buffer.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_BUFFER_H__
#define __EASYAR_BUFFER_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Wraps a raw memory block. When Buffer is released by all holders, deleter callback will be invoked to execute user-defined memory destruction. deleter must be thread-safe.
/// </summary>
void easyar_Buffer_wrap(void * ptr, int size, easyar_FunctorOfVoid deleter, /* OUT */ easyar_Buffer * * Return);
/// <summary>
/// Creates a Buffer of specified byte size.
/// </summary>
void easyar_Buffer_create(int size, /* OUT */ easyar_Buffer * * Return);
/// <summary>
/// Returns raw data address.
/// </summary>
void * easyar_Buffer_data(const easyar_Buffer * This);
/// <summary>
/// Byte size of raw data.
/// </summary>
int easyar_Buffer_size(const easyar_Buffer * This);
/// <summary>
/// Copies raw memory. It can be used in languages or platforms without complete support for memory operations.
/// </summary>
void easyar_Buffer_memoryCopy(void * src, void * dest, int length);
/// <summary>
/// Tries to copy data from a raw memory address into Buffer. If copy succeeds, it returns true, or else it returns false. Possible failure causes includes: source or destination data range overflow.
/// </summary>
bool easyar_Buffer_tryCopyFrom(easyar_Buffer * This, void * src, int srcIndex, int index, int length);
/// <summary>
/// Copies buffer data to user array.
/// </summary>
bool easyar_Buffer_tryCopyTo(easyar_Buffer * This, int index, void * dest, int destIndex, int length);
/// <summary>
/// Creates a sub-buffer with a reference to the original Buffer. A Buffer will only be released after all its sub-buffers are released.
/// </summary>
void easyar_Buffer_partition(easyar_Buffer * This, int index, int length, /* OUT */ easyar_Buffer * * Return);
void easyar_Buffer__dtor(easyar_Buffer * This);
void easyar_Buffer__retain(const easyar_Buffer * This, /* OUT */ easyar_Buffer * * Return);
const char * easyar_Buffer__typeName(const easyar_Buffer * This);
void easyar_BufferDictionary__ctor(/* OUT */ easyar_BufferDictionary * * Return);
/// <summary>
/// Current file count.
/// </summary>
int easyar_BufferDictionary_count(const easyar_BufferDictionary * This);
/// <summary>
/// Checks if a specified path is in the dictionary.
/// </summary>
bool easyar_BufferDictionary_contains(const easyar_BufferDictionary * This, easyar_String * path);
/// <summary>
/// Tries to get the corresponding `Buffer`_ for a specified path.
/// </summary>
void easyar_BufferDictionary_tryGet(const easyar_BufferDictionary * This, easyar_String * path, /* OUT */ easyar_OptionalOfBuffer * Return);
/// <summary>
/// Sets `Buffer`_ for a specified path.
/// </summary>
void easyar_BufferDictionary_set(easyar_BufferDictionary * This, easyar_String * path, easyar_Buffer * buffer);
/// <summary>
/// Removes a specified path.
/// </summary>
bool easyar_BufferDictionary_remove(easyar_BufferDictionary * This, easyar_String * path);
/// <summary>
/// Clears the dictionary.
/// </summary>
void easyar_BufferDictionary_clear(easyar_BufferDictionary * This);
void easyar_BufferDictionary__dtor(easyar_BufferDictionary * This);
void easyar_BufferDictionary__retain(const easyar_BufferDictionary * This, /* OUT */ easyar_BufferDictionary * * Return);
const char * easyar_BufferDictionary__typeName(const easyar_BufferDictionary * This);
#ifdef __cplusplus
}
#endif
#endif
| 4,053
|
C++
|
.h
| 81
| 48.91358
| 199
| 0.699394
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,279
|
recorder_configuration.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/recorder_configuration.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_RECORDER_CONFIGURATION_H__
#define __EASYAR_RECORDER_CONFIGURATION_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
void easyar_RecorderConfiguration__ctor(/* OUT */ easyar_RecorderConfiguration * * Return);
/// <summary>
/// Sets absolute path for output video file.
/// </summary>
void easyar_RecorderConfiguration_setOutputFile(easyar_RecorderConfiguration * This, easyar_String * path);
/// <summary>
/// Sets recording profile. Default value is Quality_720P_Middle.
/// This is an all-in-one configuration, you can control in more advanced mode with other APIs.
/// </summary>
bool easyar_RecorderConfiguration_setProfile(easyar_RecorderConfiguration * This, easyar_RecordProfile profile);
/// <summary>
/// Sets recording video size. Default value is Vid720p.
/// </summary>
void easyar_RecorderConfiguration_setVideoSize(easyar_RecorderConfiguration * This, easyar_RecordVideoSize framesize);
/// <summary>
/// Sets recording video bit rate. Default value is 2500000.
/// </summary>
void easyar_RecorderConfiguration_setVideoBitrate(easyar_RecorderConfiguration * This, int bitrate);
/// <summary>
/// Sets recording audio channel count. Default value is 1.
/// </summary>
void easyar_RecorderConfiguration_setChannelCount(easyar_RecorderConfiguration * This, int count);
/// <summary>
/// Sets recording audio sample rate. Default value is 44100.
/// </summary>
void easyar_RecorderConfiguration_setAudioSampleRate(easyar_RecorderConfiguration * This, int samplerate);
/// <summary>
/// Sets recording audio bit rate. Default value is 96000.
/// </summary>
void easyar_RecorderConfiguration_setAudioBitrate(easyar_RecorderConfiguration * This, int bitrate);
/// <summary>
/// Sets recording video orientation. Default value is Landscape.
/// </summary>
void easyar_RecorderConfiguration_setVideoOrientation(easyar_RecorderConfiguration * This, easyar_RecordVideoOrientation mode);
/// <summary>
/// Sets recording zoom mode. Default value is NoZoomAndClip.
/// </summary>
void easyar_RecorderConfiguration_setZoomMode(easyar_RecorderConfiguration * This, easyar_RecordZoomMode mode);
void easyar_RecorderConfiguration__dtor(easyar_RecorderConfiguration * This);
void easyar_RecorderConfiguration__retain(const easyar_RecorderConfiguration * This, /* OUT */ easyar_RecorderConfiguration * * Return);
const char * easyar_RecorderConfiguration__typeName(const easyar_RecorderConfiguration * This);
#ifdef __cplusplus
}
#endif
#endif
| 3,132
|
C++
|
.h
| 59
| 51.932203
| 136
| 0.72846
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,281
|
types.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/types.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_TYPES_H__
#define __EASYAR_TYPES_H__
#ifndef __cplusplus
#include <stdbool.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct { char _placeHolder_; } easyar_String;
void easyar_String_from_utf8(const char * begin, const char * end, /* OUT */ easyar_String * * Return);
void easyar_String_from_utf8_begin(const char * begin, /* OUT */ easyar_String * * Return);
const char * easyar_String_begin(const easyar_String * This);
const char * easyar_String_end(const easyar_String * This);
void easyar_String_copy(const easyar_String * This, /* OUT */ easyar_String * * Return);
void easyar_String__dtor(easyar_String * This);
/// <summary>
/// class
/// ObjectTargetParameters represents the parameters to create a `ObjectTarget`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_ObjectTargetParameters;
/// <summary>
/// class
/// extends Target
/// ObjectTarget represents 3d object targets that can be tracked by `ObjectTracker`_ .
/// The size of ObjectTarget is determined by the `obj` file. You can change it by changing the object `scale`, which is default to 1.
/// A ObjectTarget should be setup using setup before any value is valid. And ObjectTarget can be tracked by `ObjectTracker`_ after a successful load into the `ObjectTracker`_ using `ObjectTracker.loadTarget`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_ObjectTarget;
/// <summary>
/// class
/// extends TargetTrackerResult
/// Result of `ObjectTracker`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_ObjectTrackerResult;
/// <summary>
/// class
/// ObjectTracker implements 3D object target detection and tracking.
/// ObjectTracker occupies (1 + SimultaneousNum) buffers of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// After creation, you can call start/stop to enable/disable the track process. start and stop are very lightweight calls.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// ObjectTracker inputs `FeedbackFrame`_ from feedbackFrameSink. `FeedbackFrameSource`_ shall be connected to feedbackFrameSink for use. Refer to `Overview <Overview.html>`_ .
/// Before a `Target`_ can be tracked by ObjectTracker, you have to load it using loadTarget/unloadTarget. You can get load/unload results from callbacks passed into the interfaces.
/// </summary>
typedef struct { char _placeHolder_; } easyar_ObjectTracker;
typedef enum
{
/// <summary>
/// Targets are recognized.
/// </summary>
easyar_CloudStatus_FoundTargets = 0,
/// <summary>
/// No targets are recognized.
/// </summary>
easyar_CloudStatus_TargetsNotFound = 1,
/// <summary>
/// Connection broke and auto reconnecting
/// </summary>
easyar_CloudStatus_Reconnecting = 2,
/// <summary>
/// Protocol error
/// </summary>
easyar_CloudStatus_ProtocolError = 3,
} easyar_CloudStatus;
/// <summary>
/// class
/// CloudRecognizer implements cloud recognition. It can only be used after created a recognition image library on the cloud. Please refer to EasyAR CRS documentation.
/// CloudRecognizer occupies one buffer of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// After creation, you can call start/stop to enable/disable running.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// CloudRecognizer inputs `InputFrame`_ from inputFrameSink. `InputFrameSource`_ shall be connected to inputFrameSink for use. Refer to `Overview <Overview.html>`_ .
/// Before using a CloudRecognizer, an `ImageTracker`_ must be setup and prepared. Any target returned from cloud should be manually put into the `ImageTracker`_ using `ImageTracker.loadTarget`_ if it need to be tracked. Then the target can be used as same as a local target after loaded into the tracker. When a target is recognized, you can get it from callback, and you should use target uid to distinguish different targets. The target runtimeID is dynamically created and cannot be used as unique identifier in the cloud situation.
/// </summary>
typedef struct { char _placeHolder_; } easyar_CloudRecognizer;
/// <summary>
/// class
/// DenseSpatialMap is used to reconstruct the environment accurately and densely. The reconstructed model is represented by `triangle mesh`, which is denoted simply by `mesh`.
/// DenseSpatialMap occupies 1 buffers of camera.
/// </summary>
typedef struct { char _placeHolder_; } easyar_DenseSpatialMap;
/// <summary>
/// record
/// The dense reconstructed model is represented by triangle mesh, or simply denoted as mesh. Because mesh updates frequently, in order to ensure efficiency, the mesh of the whole reconstruction model is divided into many mesh blocks. A mesh block is composed of a cube about 1 meter long, with attributes such as vertices and indices.
///
/// BlockInfo is used to describe the content of a mesh block. (x, y, z) is the index of mesh block, the coordinates of a mesh block's origin in world coordinate system can be obtained by multiplying (x, y, z) by the physical size of mesh block. You may filter the part you want to display in advance by the mesh block's world coordinates for the sake of saving rendering time.
/// </summary>
typedef struct
{
/// <summary>
/// x in index (x, y, z) of mesh block.
/// </summary>
int x;
/// <summary>
/// y in index (x, y, z) of mesh block.
/// </summary>
int y;
/// <summary>
/// z in index (x, y, z) of mesh block.
/// </summary>
int z;
/// <summary>
/// Number of vertices in a mesh block.
/// </summary>
int numOfVertex;
/// <summary>
/// startPointOfVertex is the starting position of the vertex data stored in the vertex buffer, indicating from where the stored vertices belong to current mesh block. It is not equal to the number of bytes of the offset from the beginning of vertex buffer. The offset is startPointOfVertex*3*4 bytes.
/// </summary>
int startPointOfVertex;
/// <summary>
/// The number of indices in a mesh block. Each of three consecutive vertices form a triangle.
/// </summary>
int numOfIndex;
/// <summary>
/// Similar to startPointOfVertex. startPointOfIndex is the starting position of the index data stored in the index buffer, indicating from where the stored indices belong to current mesh block. It is not equal to the number of bytes of the offset from the beginning of index buffer. The offset is startPointOfIndex*3*4 bytes.
/// </summary>
int startPointOfIndex;
/// <summary>
/// Version represents how many times the mesh block has updated. The larger the version, the newer the block. If the version of a mesh block increases after calling `DenseSpatialMap.updateSceneMesh`_ , it indicates that the mash block has changed.
/// </summary>
int version;
} easyar_BlockInfo;
/// <summary>
/// class
/// SceneMesh is used to manage and preserve the results of `DenseSpatialMap`_.
/// There are two kinds of meshes saved in SceneMesh, one is the mesh of the whole reconstructed scene, hereinafter referred to as `meshAll`, the other is the recently updated mesh, hereinafter referred to as `meshUpdated`. `meshAll` is a whole mesh, including all vertex data and index data, etc. `meshUpdated` is composed of several `mesh block` s, each `mesh block` is a cube, which contains the mesh formed by the object surface in the corresponding cube space.
/// `meshAll` is available only when the `DenseSpatialMap.updateSceneMesh`_ method is called specifying that all meshes need to be updated. If `meshAll` has been updated previously and not updated in recent times, the data in `meshAll` is remain the same.
/// </summary>
typedef struct { char _placeHolder_; } easyar_SceneMesh;
/// <summary>
/// class
/// extends FrameFilterResult
/// Result of `SurfaceTracker`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_SurfaceTrackerResult;
/// <summary>
/// class
/// SurfaceTracker implements tracking with environmental surfaces.
/// SurfaceTracker occupies one buffer of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// After creation, you can call start/stop to enable/disable the track process. start and stop are very lightweight calls.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// SurfaceTracker inputs `InputFrame`_ from inputFrameSink. `InputFrameSource`_ shall be connected to inputFrameSink for use. Refer to `Overview <Overview.html>`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_SurfaceTracker;
/// <summary>
/// class
/// MotionTrackerCameraDevice implements a camera device with metric-scale six degree-of-freedom motion tracking, which outputs `InputFrame`_ (including image, camera parameters, timestamp, 6DOF pose and tracking status).
/// After creation, start/stop can be invoked to start or stop data flow.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// MotionTrackerCameraDevice outputs `InputFrame`_ from inputFrameSource. inputFrameSource shall be connected to `InputFrameSink`_ for further use. Refer to `Overview <Overview.html>`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_MotionTrackerCameraDevice;
/// <summary>
/// class
/// ImageTargetParameters represents the parameters to create a `ImageTarget`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_ImageTargetParameters;
/// <summary>
/// class
/// extends Target
/// ImageTarget represents planar image targets that can be tracked by `ImageTracker`_ .
/// The fields of ImageTarget need to be filled with the create.../setupAll method before it can be read. And ImageTarget can be tracked by `ImageTracker`_ after a successful load into the `ImageTracker`_ using `ImageTracker.loadTarget`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_ImageTarget;
typedef enum
{
/// <summary>
/// Quality is preferred.
/// </summary>
easyar_ImageTrackerMode_PreferQuality = 0,
/// <summary>
/// Performance is preferred.
/// </summary>
easyar_ImageTrackerMode_PreferPerformance = 1,
} easyar_ImageTrackerMode;
/// <summary>
/// class
/// extends TargetTrackerResult
/// Result of `ImageTracker`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_ImageTrackerResult;
/// <summary>
/// class
/// ImageTracker implements image target detection and tracking.
/// ImageTracker occupies (1 + SimultaneousNum) buffers of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// After creation, you can call start/stop to enable/disable the track process. start and stop are very lightweight calls.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// ImageTracker inputs `FeedbackFrame`_ from feedbackFrameSink. `FeedbackFrameSource`_ shall be connected to feedbackFrameSink for use. Refer to `Overview <Overview.html>`_ .
/// Before a `Target`_ can be tracked by ImageTracker, you have to load it using loadTarget/unloadTarget. You can get load/unload results from callbacks passed into the interfaces.
/// </summary>
typedef struct { char _placeHolder_; } easyar_ImageTracker;
/// <summary>
/// class
/// Recorder implements recording for current rendering screen.
/// Currently Recorder only works on Android (4.3 or later) and iOS with OpenGL ES 2.0 context.
/// Due to the dependency to OpenGLES, every method in this class (except requestPermissions, including the destructor) has to be called in a single thread containing an OpenGLES context.
/// **Unity Only** If in Unity, Multi-threaded rendering is enabled, scripting thread and rendering thread will be two separate threads, which makes it impossible to call updateFrame in the rendering thread. For this reason, to use Recorder, Multi-threaded rendering option shall be disabled.
/// </summary>
typedef struct { char _placeHolder_; } easyar_Recorder;
typedef enum
{
/// <summary>
/// 1080P, low quality
/// </summary>
easyar_RecordProfile_Quality_1080P_Low = 0x00000001,
/// <summary>
/// 1080P, middle quality
/// </summary>
easyar_RecordProfile_Quality_1080P_Middle = 0x00000002,
/// <summary>
/// 1080P, high quality
/// </summary>
easyar_RecordProfile_Quality_1080P_High = 0x00000004,
/// <summary>
/// 720P, low quality
/// </summary>
easyar_RecordProfile_Quality_720P_Low = 0x00000008,
/// <summary>
/// 720P, middle quality
/// </summary>
easyar_RecordProfile_Quality_720P_Middle = 0x00000010,
/// <summary>
/// 720P, high quality
/// </summary>
easyar_RecordProfile_Quality_720P_High = 0x00000020,
/// <summary>
/// 480P, low quality
/// </summary>
easyar_RecordProfile_Quality_480P_Low = 0x00000040,
/// <summary>
/// 480P, middle quality
/// </summary>
easyar_RecordProfile_Quality_480P_Middle = 0x00000080,
/// <summary>
/// 480P, high quality
/// </summary>
easyar_RecordProfile_Quality_480P_High = 0x00000100,
/// <summary>
/// default resolution and quality, same as `Quality_720P_Middle`
/// </summary>
easyar_RecordProfile_Quality_Default = 0x00000010,
} easyar_RecordProfile;
typedef enum
{
/// <summary>
/// 1080P
/// </summary>
easyar_RecordVideoSize_Vid1080p = 0x00000002,
/// <summary>
/// 720P
/// </summary>
easyar_RecordVideoSize_Vid720p = 0x00000010,
/// <summary>
/// 480P
/// </summary>
easyar_RecordVideoSize_Vid480p = 0x00000080,
} easyar_RecordVideoSize;
typedef enum
{
/// <summary>
/// If output aspect ratio does not fit input, content will be clipped to fit output aspect ratio.
/// </summary>
easyar_RecordZoomMode_NoZoomAndClip = 0x00000000,
/// <summary>
/// If output aspect ratio does not fit input, content will not be clipped and there will be black borders in one dimension.
/// </summary>
easyar_RecordZoomMode_ZoomInWithAllContent = 0x00000001,
} easyar_RecordZoomMode;
typedef enum
{
/// <summary>
/// video recorded is landscape
/// </summary>
easyar_RecordVideoOrientation_Landscape = 0x00000000,
/// <summary>
/// video recorded is portrait
/// </summary>
easyar_RecordVideoOrientation_Portrait = 0x00000001,
} easyar_RecordVideoOrientation;
typedef enum
{
/// <summary>
/// recording start
/// </summary>
easyar_RecordStatus_OnStarted = 0x00000002,
/// <summary>
/// recording stopped
/// </summary>
easyar_RecordStatus_OnStopped = 0x00000004,
/// <summary>
/// start fail
/// </summary>
easyar_RecordStatus_FailedToStart = 0x00000202,
/// <summary>
/// file write succeed
/// </summary>
easyar_RecordStatus_FileSucceeded = 0x00000400,
/// <summary>
/// file write fail
/// </summary>
easyar_RecordStatus_FileFailed = 0x00000401,
/// <summary>
/// runtime info with description
/// </summary>
easyar_RecordStatus_LogInfo = 0x00000800,
/// <summary>
/// runtime error with description
/// </summary>
easyar_RecordStatus_LogError = 0x00001000,
} easyar_RecordStatus;
/// <summary>
/// class
/// RecorderConfiguration is startup configuration for `Recorder`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_RecorderConfiguration;
/// <summary>
/// class
/// extends FrameFilterResult
/// Describes the result of mapping and localization. Updated at the same frame rate with OutputFrame.
/// </summary>
typedef struct { char _placeHolder_; } easyar_SparseSpatialMapResult;
typedef enum
{
/// <summary>
/// Horizontal plane
/// </summary>
easyar_PlaneType_Horizontal = 0,
/// <summary>
/// Vertical plane
/// </summary>
easyar_PlaneType_Vertical = 1,
} easyar_PlaneType;
/// <summary>
/// class
/// </summary>
typedef struct { char _placeHolder_; } easyar_PlaneData;
typedef enum
{
/// <summary>
/// Attempt to perform localization in current SparseSpatialMap until success.
/// </summary>
easyar_LocalizationMode_UntilSuccess = 0,
/// <summary>
/// Perform localization only once
/// </summary>
easyar_LocalizationMode_Once = 1,
/// <summary>
/// Keep performing localization and adjust result on success
/// </summary>
easyar_LocalizationMode_KeepUpdate = 2,
/// <summary>
/// Keep performing localization and adjust localization result only when localization returns different map ID from previous results
/// </summary>
easyar_LocalizationMode_ContinousLocalize = 3,
} easyar_LocalizationMode;
/// <summary>
/// class
/// Configuration used to set the localization mode.
/// </summary>
typedef struct { char _placeHolder_; } easyar_SparseSpatialMapConfig;
/// <summary>
/// class
/// Provides core components for SparseSpatialMap, can be used for sparse spatial map building as well as localization using existing map. Also provides utilities for point cloud and plane access.
/// SparseSpatialMap occupies 2 buffers of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_SparseSpatialMap;
/// <summary>
/// class
/// SparseSpatialMap manager class, for managing sharing.
/// </summary>
typedef struct { char _placeHolder_; } easyar_SparseSpatialMapManager;
/// <summary>
/// class
/// Image helper class.
/// </summary>
typedef struct { char _placeHolder_; } easyar_ImageHelper;
/// <summary>
/// class
/// ARCoreCameraDevice implements a camera device based on ARCore, which outputs `InputFrame`_ (including image, camera parameters, timestamp, 6DOF location, and tracking status).
/// Loading of libarcore_sdk_c.so with java.lang.System.loadLibrary is required.
/// After creation, start/stop can be invoked to start or stop video stream capture.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// ARCoreCameraDevice outputs `InputFrame`_ from inputFrameSource. inputFrameSource shall be connected to `InputFrameSink`_ for use. Refer to `Overview <Overview.html>`_ .
/// bufferCapacity is the capacity of `InputFrame`_ buffer. If the count of `InputFrame`_ which has been output from the device and have not been released is more than this number, the device will not output new `InputFrame`_ , until previous `InputFrame`_ have been released. This may cause screen stuck. Refer to `Overview <Overview.html>`_ .
/// Caution: Currently, ARCore(v1.13.0) has memory leaks on creating and destroying sessions. Repeated creations and destructions will cause an increasing and non-reclaimable memory footprint.
/// </summary>
typedef struct { char _placeHolder_; } easyar_ARCoreCameraDevice;
/// <summary>
/// class
/// ARKitCameraDevice implements a camera device based on ARKit, which outputs `InputFrame`_ (including image, camera parameters, timestamp, 6DOF location, and tracking status).
/// After creation, start/stop can be invoked to start or stop data collection.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// ARKitCameraDevice outputs `InputFrame`_ from inputFrameSource. inputFrameSource shall be connected to `InputFrameSink`_ for use. Refer to `Overview <Overview.html>`_ .
/// bufferCapacity is the capacity of `InputFrame`_ buffer. If the count of `InputFrame`_ which has been output from the device and have not been released is more than this number, the device will not output new `InputFrame`_ , until previous `InputFrame`_ have been released. This may cause screen stuck. Refer to `Overview <Overview.html>`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_ARKitCameraDevice;
/// <summary>
/// class
/// Callback scheduler.
/// There are two subclasses: `DelayedCallbackScheduler`_ and `ImmediateCallbackScheduler`_ .
/// `DelayedCallbackScheduler`_ is used to delay callback to be invoked manually, and it can be used in single-threaded environments (such as various UI environments).
/// `ImmediateCallbackScheduler`_ is used to mark callback to be invoked when event is dispatched, and it can be used in multi-threaded environments (such as server or service daemon).
/// </summary>
typedef struct { char _placeHolder_; } easyar_CallbackScheduler;
/// <summary>
/// class
/// extends CallbackScheduler
/// Delayed callback scheduler.
/// It is used to delay callback to be invoked manually, and it can be used in single-threaded environments (such as various UI environments).
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_DelayedCallbackScheduler;
/// <summary>
/// class
/// extends CallbackScheduler
/// Immediate callback scheduler.
/// It is used to mark callback to be invoked when event is dispatched, and it can be used in multi-threaded environments (such as server or service daemon).
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_ImmediateCallbackScheduler;
typedef enum
{
/// <summary>
/// Normal auto focus mode. You should call autoFocus to start the focus in this mode.
/// </summary>
easyar_CameraDeviceFocusMode_Normal = 0,
/// <summary>
/// Continuous auto focus mode
/// </summary>
easyar_CameraDeviceFocusMode_Continousauto = 2,
/// <summary>
/// Infinity focus mode
/// </summary>
easyar_CameraDeviceFocusMode_Infinity = 3,
/// <summary>
/// Macro (close-up) focus mode. You should call autoFocus to start the focus in this mode.
/// </summary>
easyar_CameraDeviceFocusMode_Macro = 4,
/// <summary>
/// Medium distance focus mode
/// </summary>
easyar_CameraDeviceFocusMode_Medium = 5,
} easyar_CameraDeviceFocusMode;
typedef enum
{
/// <summary>
/// Android Camera1
/// </summary>
easyar_AndroidCameraApiType_Camera1 = 0,
/// <summary>
/// Android Camera2
/// </summary>
easyar_AndroidCameraApiType_Camera2 = 1,
} easyar_AndroidCameraApiType;
typedef enum
{
/// <summary>
/// The same as AVCaptureSessionPresetPhoto.
/// </summary>
easyar_CameraDevicePresetProfile_Photo = 0,
/// <summary>
/// The same as AVCaptureSessionPresetHigh.
/// </summary>
easyar_CameraDevicePresetProfile_High = 1,
/// <summary>
/// The same as AVCaptureSessionPresetMedium.
/// </summary>
easyar_CameraDevicePresetProfile_Medium = 2,
/// <summary>
/// The same as AVCaptureSessionPresetLow.
/// </summary>
easyar_CameraDevicePresetProfile_Low = 3,
} easyar_CameraDevicePresetProfile;
typedef enum
{
/// <summary>
/// Unknown
/// </summary>
easyar_CameraState_Unknown = 0x00000000,
/// <summary>
/// Disconnected
/// </summary>
easyar_CameraState_Disconnected = 0x00000001,
/// <summary>
/// Preempted by another application.
/// </summary>
easyar_CameraState_Preempted = 0x00000002,
} easyar_CameraState;
/// <summary>
/// class
/// CameraDevice implements a camera device, which outputs `InputFrame`_ (including image, camera paramters, and timestamp). It is available on Windows, Mac, Android and iOS.
/// After open, start/stop can be invoked to start or stop data collection. start/stop will not change previous set camera parameters.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// CameraDevice outputs `InputFrame`_ from inputFrameSource. inputFrameSource shall be connected to `InputFrameSink`_ for use. Refer to `Overview <Overview.html>`_ .
/// bufferCapacity is the capacity of `InputFrame`_ buffer. If the count of `InputFrame`_ which has been output from the device and have not been released is more than this number, the device will not output new `InputFrame`_ , until previous `InputFrame`_ have been released. This may cause screen stuck. Refer to `Overview <Overview.html>`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_CameraDevice;
typedef enum
{
/// <summary>
/// Optimized for `ImageTracker`_ , `ObjectTracker`_ and `CloudRecognizer`_ .
/// </summary>
easyar_CameraDevicePreference_PreferObjectSensing = 0,
/// <summary>
/// Optimized for `SurfaceTracker`_ .
/// </summary>
easyar_CameraDevicePreference_PreferSurfaceTracking = 1,
} easyar_CameraDevicePreference;
/// <summary>
/// class
/// It is used for selecting camera API (camera1 or camera2) on Android. camera1 is better for compatibility, but lacks some necessary information such as timestamp. camera2 has compatibility issues on some devices.
/// Different preferences will choose camera1 or camera2 based on usage.
/// </summary>
typedef struct { char _placeHolder_; } easyar_CameraDeviceSelector;
/// <summary>
/// class
/// Signal input port.
/// It is used to expose input port for a component.
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_SignalSink;
/// <summary>
/// class
/// Signal output port.
/// It is used to expose output port for a component.
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_SignalSource;
/// <summary>
/// class
/// Input frame input port.
/// It is used to expose input port for a component.
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_InputFrameSink;
/// <summary>
/// class
/// Input frame output port.
/// It is used to expose output port for a component.
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_InputFrameSource;
/// <summary>
/// class
/// Output frame input port.
/// It is used to expose input port for a component.
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_OutputFrameSink;
/// <summary>
/// class
/// Output frame output port.
/// It is used to expose output port for a component.
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_OutputFrameSource;
/// <summary>
/// class
/// Feedback frame input port.
/// It is used to expose input port for a component.
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_FeedbackFrameSink;
/// <summary>
/// class
/// Feedback frame output port.
/// It is used to expose output port for a component.
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_FeedbackFrameSource;
/// <summary>
/// class
/// Input frame fork.
/// It is used to branch and transfer input frame to multiple components in parallel.
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_InputFrameFork;
/// <summary>
/// class
/// Output frame fork.
/// It is used to branch and transfer output frame to multiple components in parallel.
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_OutputFrameFork;
/// <summary>
/// class
/// Output frame join.
/// It is used to aggregate output frame from multiple components in parallel.
/// All members of this class is thread-safe.
/// It shall be noticed that connections and disconnections to the inputs shall not be performed during the flowing of data, or it may stuck in a state that no frame can be output. (It is recommended to complete dataflow connection before start a camera.)
/// </summary>
typedef struct { char _placeHolder_; } easyar_OutputFrameJoin;
/// <summary>
/// class
/// Feedback frame fork.
/// It is used to branch and transfer feedback frame to multiple components in parallel.
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_FeedbackFrameFork;
/// <summary>
/// class
/// Input frame throttler.
/// There is a input frame input port and a input frame output port. It can be used to prevent incoming frames from entering algorithm components when they have not finished handling previous workload.
/// InputFrameThrottler occupies one buffer of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// All members of this class is thread-safe.
/// It shall be noticed that connections and disconnections to signalInput shall not be performed during the flowing of data, or it may stuck in a state that no frame can be output. (It is recommended to complete dataflow connection before start a camera.)
/// </summary>
typedef struct { char _placeHolder_; } easyar_InputFrameThrottler;
/// <summary>
/// class
/// Output frame buffer.
/// There is an output frame input port and output frame fetching function. It can be used to convert output frame fetching from asynchronous pattern to synchronous polling pattern, which fits frame by frame rendering.
/// OutputFrameBuffer occupies one buffer of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_OutputFrameBuffer;
/// <summary>
/// class
/// Input frame to output frame adapter.
/// There is an input frame input port and an output frame output port. It can be used to wrap an input frame into an output frame, which can be used for rendering without an algorithm component. Refer to `Overview <Overview.html>`_ .
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_InputFrameToOutputFrameAdapter;
/// <summary>
/// class
/// Input frame to feedback frame adapter.
/// There is an input frame input port, a historic output frame input port and a feedback frame output port. It can be used to combine an input frame and a historic output frame into a feedback frame, which is required by algorithm components such as `ImageTracker`_ .
/// On every input of an input frame, a feedback frame is generated with a previously input historic feedback frame. If there is no previously input historic feedback frame, it is null in the feedback frame.
/// InputFrameToFeedbackFrameAdapter occupies one buffer of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// All members of this class is thread-safe.
/// </summary>
typedef struct { char _placeHolder_; } easyar_InputFrameToFeedbackFrameAdapter;
/// <summary>
/// class
/// </summary>
typedef struct { char _placeHolder_; } easyar_Engine;
/// <summary>
/// class
/// Input frame.
/// It includes image, camera parameters, timestamp, camera transform matrix against world coordinate system, and tracking status,
/// among which, camera parameters, timestamp, camera transform matrix and tracking status are all optional, but specific algorithms may have special requirements on the input.
/// </summary>
typedef struct { char _placeHolder_; } easyar_InputFrame;
/// <summary>
/// class
/// FrameFilterResult is the base class for result classes of all synchronous algorithm components.
/// </summary>
typedef struct { char _placeHolder_; } easyar_FrameFilterResult;
/// <summary>
/// class
/// Output frame.
/// It includes input frame and results of synchronous components.
/// </summary>
typedef struct { char _placeHolder_; } easyar_OutputFrame;
/// <summary>
/// class
/// Feedback frame.
/// It includes an input frame and a historic output frame for use in feedback synchronous components such as `ImageTracker`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_FeedbackFrame;
typedef enum
{
/// <summary>
/// Permission granted
/// </summary>
easyar_PermissionStatus_Granted = 0x00000000,
/// <summary>
/// Permission denied
/// </summary>
easyar_PermissionStatus_Denied = 0x00000001,
/// <summary>
/// A error happened while requesting permission.
/// </summary>
easyar_PermissionStatus_Error = 0x00000002,
} easyar_PermissionStatus;
/// <summary>
/// StorageType represents where the images, jsons, videos or other files are located.
/// StorageType specifies the root path, in all interfaces, you can use relative path relative to the root path.
/// </summary>
typedef enum
{
/// <summary>
/// The app path.
/// Android: the application's `persistent data directory <https://developer.android.google.cn/reference/android/content/pm/ApplicationInfo.html#dataDir>`_
/// iOS: the application's sandbox directory
/// Windows: Windows: the application's executable directory
/// Mac: the application’s executable directory (if app is a bundle, this path is inside the bundle)
/// </summary>
easyar_StorageType_App = 0,
/// <summary>
/// The assets path.
/// Android: assets directory (inside apk)
/// iOS: the application's executable directory
/// Windows: EasyAR.dll directory
/// Mac: libEasyAR.dylib directory
/// **Note:** *this path is different if you are using Unity3D. It will point to the StreamingAssets folder.*
/// </summary>
easyar_StorageType_Assets = 1,
/// <summary>
/// The absolute path (json/image path or video path) or url (video only).
/// </summary>
easyar_StorageType_Absolute = 2,
} easyar_StorageType;
/// <summary>
/// class
/// Target is the base class for all targets that can be tracked by `ImageTracker`_ or other algorithms inside EasyAR.
/// </summary>
typedef struct { char _placeHolder_; } easyar_Target;
typedef enum
{
/// <summary>
/// The status is unknown.
/// </summary>
easyar_TargetStatus_Unknown = 0,
/// <summary>
/// The status is undefined.
/// </summary>
easyar_TargetStatus_Undefined = 1,
/// <summary>
/// The target is detected.
/// </summary>
easyar_TargetStatus_Detected = 2,
/// <summary>
/// The target is tracked.
/// </summary>
easyar_TargetStatus_Tracked = 3,
} easyar_TargetStatus;
/// <summary>
/// class
/// TargetInstance is the tracked target by trackers.
/// An TargetInstance contains a raw `Target`_ that is tracked and current status and pose of the `Target`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_TargetInstance;
/// <summary>
/// class
/// extends FrameFilterResult
/// TargetTrackerResult is the base class of `ImageTrackerResult`_ and `ObjectTrackerResult`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_TargetTrackerResult;
/// <summary>
/// class
/// TextureId encapsulates a texture object in rendering API.
/// For OpenGL/OpenGLES, getInt and fromInt shall be used. For Direct3D, getPointer and fromPointer shall be used.
/// </summary>
typedef struct { char _placeHolder_; } easyar_TextureId;
typedef enum
{
/// <summary>
/// Status to indicate something wrong happen in video open or play.
/// </summary>
easyar_VideoStatus_Error = -1,
/// <summary>
/// Status to show video finished open and is ready for play.
/// </summary>
easyar_VideoStatus_Ready = 0,
/// <summary>
/// Status to indicate video finished play and reached the end.
/// </summary>
easyar_VideoStatus_Completed = 1,
} easyar_VideoStatus;
typedef enum
{
/// <summary>
/// Normal video.
/// </summary>
easyar_VideoType_Normal = 0,
/// <summary>
/// Transparent video, left half is the RGB channel and right half is alpha channel.
/// </summary>
easyar_VideoType_TransparentSideBySide = 1,
/// <summary>
/// Transparent video, top half is the RGB channel and bottom half is alpha channel.
/// </summary>
easyar_VideoType_TransparentTopAndBottom = 2,
} easyar_VideoType;
/// <summary>
/// class
/// VideoPlayer is the class for video playback.
/// EasyAR supports normal videos, transparent videos and streaming videos. The video content will be rendered into a texture passed into the player through setRenderTexture.
/// This class only supports OpenGLES2 texture.
/// Due to the dependency to OpenGLES, every method in this class (including the destructor) has to be called in a single thread containing an OpenGLES context.
/// Current version requires width and height being mutiples of 16.
///
/// Supported video file formats
/// Windows: Media Foundation-compatible formats, more can be supported via extra codecs. Please refer to `Supported Media Formats in Media Foundation <https://docs.microsoft.com/en-us/windows/win32/medfound/supported-media-formats-in-media-foundation>`__ . DirectShow is not supported.
/// Mac: Not supported.
/// Android: System supported formats. Please refer to `Supported media formats <https://developer.android.com/guide/topics/media/media-formats>`__ .
/// iOS: System supported formats. There is no reference in effect currently.
/// </summary>
typedef struct { char _placeHolder_; } easyar_VideoPlayer;
/// <summary>
/// class
/// Buffer stores a raw byte array, which can be used to access image data.
/// To access image data in Java API, get buffer from `Image`_ and copy to a Java byte array.
/// You can always access image data since the first version of EasyAR Sense. Refer to `Image`_ .
/// </summary>
typedef struct { char _placeHolder_; } easyar_Buffer;
/// <summary>
/// class
/// A mapping from file path to `Buffer`_ . It can be used to represent multiple files in the memory.
/// </summary>
typedef struct { char _placeHolder_; } easyar_BufferDictionary;
/// <summary>
/// class
/// BufferPool is a memory pool to reduce memory allocation time consumption for functionality like custom camera interoperability, which needs to allocate memory buffers of a fixed size repeatedly.
/// </summary>
typedef struct { char _placeHolder_; } easyar_BufferPool;
typedef enum
{
/// <summary>
/// Unknown location
/// </summary>
easyar_CameraDeviceType_Unknown = 0,
/// <summary>
/// Rear camera
/// </summary>
easyar_CameraDeviceType_Back = 1,
/// <summary>
/// Front camera
/// </summary>
easyar_CameraDeviceType_Front = 2,
} easyar_CameraDeviceType;
/// <summary>
/// MotionTrackingStatus describes the quality of device motion tracking.
/// </summary>
typedef enum
{
/// <summary>
/// Result is not available and should not to be used to render virtual objects or do 3D reconstruction. This value occurs temporarily after initializing, tracking lost or relocalizing.
/// </summary>
easyar_MotionTrackingStatus_NotTracking = 0,
/// <summary>
/// Tracking is available, but the quality of the result is not good enough. This value occurs temporarily due to weak texture or excessive movement. The result can be used to render virtual objects, but should generally not be used to do 3D reconstruction.
/// </summary>
easyar_MotionTrackingStatus_Limited = 1,
/// <summary>
/// Tracking with a good quality. The result can be used to render virtual objects or do 3D reconstruction.
/// </summary>
easyar_MotionTrackingStatus_Tracking = 2,
} easyar_MotionTrackingStatus;
/// <summary>
/// class
/// Camera parameters, including image size, focal length, principal point, camera type and camera rotation against natural orientation.
/// </summary>
typedef struct { char _placeHolder_; } easyar_CameraParameters;
/// <summary>
/// PixelFormat represents the format of image pixel data. All formats follow the pixel direction from left to right and from top to bottom.
/// </summary>
typedef enum
{
/// <summary>
/// Unknown
/// </summary>
easyar_PixelFormat_Unknown = 0,
/// <summary>
/// 256 shades grayscale
/// </summary>
easyar_PixelFormat_Gray = 1,
/// <summary>
/// YUV_NV21
/// </summary>
easyar_PixelFormat_YUV_NV21 = 2,
/// <summary>
/// YUV_NV12
/// </summary>
easyar_PixelFormat_YUV_NV12 = 3,
/// <summary>
/// YUV_I420
/// </summary>
easyar_PixelFormat_YUV_I420 = 4,
/// <summary>
/// YUV_YV12
/// </summary>
easyar_PixelFormat_YUV_YV12 = 5,
/// <summary>
/// RGB888
/// </summary>
easyar_PixelFormat_RGB888 = 6,
/// <summary>
/// BGR888
/// </summary>
easyar_PixelFormat_BGR888 = 7,
/// <summary>
/// RGBA8888
/// </summary>
easyar_PixelFormat_RGBA8888 = 8,
/// <summary>
/// BGRA8888
/// </summary>
easyar_PixelFormat_BGRA8888 = 9,
} easyar_PixelFormat;
/// <summary>
/// class
/// Image stores an image data and represents an image in memory.
/// Image raw data can be accessed as byte array. The width/height/etc information are also accessible.
/// You can always access image data since the first version of EasyAR Sense.
///
/// You can do this in iOS
/// ::
///
/// #import <easyar/buffer.oc.h>
/// #import <easyar/image.oc.h>
///
/// easyar_OutputFrame * outputFrame = [outputFrameBuffer peek];
/// if (outputFrame != nil) {
/// easyar_Image * i = [[outputFrame inputFrame] image];
/// easyar_Buffer * b = [i buffer];
/// char * bytes = calloc([b size], 1);
/// memcpy(bytes, [b data], [b size]);
/// // use bytes here
/// free(bytes);
/// }
///
/// Or in Android
/// ::
///
/// import cn.easyar.*;
///
/// OutputFrame outputFrame = outputFrameBuffer.peek();
/// if (outputFrame != null) {
/// InputFrame inputFrame = outputFrame.inputFrame();
/// Image i = inputFrame.image();
/// Buffer b = i.buffer();
/// byte[] bytes = new byte[b.size()];
/// b.copyToByteArray(0, bytes, 0, bytes.length);
/// // use bytes here
/// b.dispose();
/// i.dispose();
/// inputFrame.dispose();
/// outputFrame.dispose();
/// }
/// </summary>
typedef struct { char _placeHolder_; } easyar_Image;
/// <summary>
/// class
/// JNI utility class.
/// It is used in Unity to wrap Java byte array and ByteBuffer.
/// It is not supported on iOS.
/// </summary>
typedef struct { char _placeHolder_; } easyar_JniUtility;
typedef enum
{
/// <summary>
/// Error
/// </summary>
easyar_LogLevel_Error = 0,
/// <summary>
/// Warning
/// </summary>
easyar_LogLevel_Warning = 1,
/// <summary>
/// Information
/// </summary>
easyar_LogLevel_Info = 2,
} easyar_LogLevel;
/// <summary>
/// class
/// Log class.
/// It is used to setup a custom log output function.
/// </summary>
typedef struct { char _placeHolder_; } easyar_Log;
/// <summary>
/// record
/// Square matrix of 4. The data arrangement is row-major.
/// </summary>
typedef struct
{
/// <summary>
/// The raw data of matrix.
/// </summary>
float data[16];
} easyar_Matrix44F;
/// <summary>
/// record
/// Square matrix of 3. The data arrangement is row-major.
/// </summary>
typedef struct
{
/// <summary>
/// The raw data of matrix.
/// </summary>
float data[9];
} easyar_Matrix33F;
/// <summary>
/// record
/// 4 dimensional vector of float.
/// </summary>
typedef struct
{
/// <summary>
/// The raw data of vector.
/// </summary>
float data[4];
} easyar_Vec4F;
/// <summary>
/// record
/// 3 dimensional vector of float.
/// </summary>
typedef struct
{
/// <summary>
/// The raw data of vector.
/// </summary>
float data[3];
} easyar_Vec3F;
/// <summary>
/// record
/// 2 dimensional vector of float.
/// </summary>
typedef struct
{
/// <summary>
/// The raw data of vector.
/// </summary>
float data[2];
} easyar_Vec2F;
/// <summary>
/// record
/// 4 dimensional vector of int.
/// </summary>
typedef struct
{
/// <summary>
/// The raw data of vector.
/// </summary>
int data[4];
} easyar_Vec4I;
/// <summary>
/// record
/// 2 dimensional vector of int.
/// </summary>
typedef struct
{
/// <summary>
/// The raw data of vector.
/// </summary>
int data[2];
} easyar_Vec2I;
typedef struct { bool has_value; easyar_Buffer * value; } easyar_OptionalOfBuffer;
typedef struct
{
void * _state;
void (* func)(void * _state, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfVoid;
typedef struct { bool has_value; easyar_ObjectTarget * value; } easyar_OptionalOfObjectTarget;
typedef struct { char _placeHolder_; } easyar_ListOfObjectTarget;
typedef struct { char _placeHolder_; } easyar_ListOfVec3F;
typedef struct { char _placeHolder_; } easyar_ListOfTargetInstance;
typedef struct { bool has_value; easyar_Target * value; } easyar_OptionalOfTarget;
typedef struct { bool has_value; easyar_OutputFrame * value; } easyar_OptionalOfOutputFrame;
typedef struct { bool has_value; easyar_FrameFilterResult * value; } easyar_OptionalOfFrameFilterResult;
typedef struct { char _placeHolder_; } easyar_ListOfOptionalOfFrameFilterResult;
typedef struct
{
void * _state;
void (* func)(void * _state, easyar_OutputFrame *, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfVoidFromOutputFrame;
typedef struct { bool has_value; easyar_FunctorOfVoidFromOutputFrame value; } easyar_OptionalOfFunctorOfVoidFromOutputFrame;
typedef struct
{
void * _state;
void (* func)(void * _state, easyar_Target *, bool, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfVoidFromTargetAndBool;
typedef struct { char _placeHolder_; } easyar_ListOfTarget;
typedef struct
{
void * _state;
void (* func)(void * _state, easyar_CloudStatus, easyar_ListOfTarget *, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfVoidFromCloudStatusAndListOfTarget;
typedef struct { bool has_value; easyar_FunctorOfVoidFromCloudStatusAndListOfTarget value; } easyar_OptionalOfFunctorOfVoidFromCloudStatusAndListOfTarget;
typedef struct { char _placeHolder_; } easyar_ListOfBlockInfo;
typedef struct
{
void * _state;
void (* func)(void * _state, easyar_InputFrame *, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfVoidFromInputFrame;
typedef struct { bool has_value; easyar_FunctorOfVoidFromInputFrame value; } easyar_OptionalOfFunctorOfVoidFromInputFrame;
typedef struct { bool has_value; easyar_ImageTarget * value; } easyar_OptionalOfImageTarget;
typedef struct { char _placeHolder_; } easyar_ListOfImageTarget;
typedef struct { char _placeHolder_; } easyar_ListOfImage;
typedef struct
{
void * _state;
void (* func)(void * _state, easyar_PermissionStatus, easyar_String *, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfVoidFromPermissionStatusAndString;
typedef struct { bool has_value; easyar_FunctorOfVoidFromPermissionStatusAndString value; } easyar_OptionalOfFunctorOfVoidFromPermissionStatusAndString;
typedef struct
{
void * _state;
void (* func)(void * _state, easyar_RecordStatus, easyar_String *, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfVoidFromRecordStatusAndString;
typedef struct { bool has_value; easyar_FunctorOfVoidFromRecordStatusAndString value; } easyar_OptionalOfFunctorOfVoidFromRecordStatusAndString;
typedef struct { bool has_value; easyar_Matrix44F value; } easyar_OptionalOfMatrix44F;
typedef struct { char _placeHolder_; } easyar_ListOfPlaneData;
typedef struct
{
void * _state;
void (* func)(void * _state, bool, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfVoidFromBool;
typedef struct { bool has_value; easyar_FunctorOfVoidFromBool value; } easyar_OptionalOfFunctorOfVoidFromBool;
typedef struct { bool has_value; easyar_Image * value; } easyar_OptionalOfImage;
typedef struct
{
void * _state;
void (* func)(void * _state, bool, easyar_String *, easyar_String *, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfVoidFromBoolAndStringAndString;
typedef struct
{
void * _state;
void (* func)(void * _state, bool, easyar_String *, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfVoidFromBoolAndString;
typedef struct
{
void * _state;
void (* func)(void * _state, easyar_CameraState, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfVoidFromCameraState;
typedef struct { bool has_value; easyar_FunctorOfVoidFromCameraState value; } easyar_OptionalOfFunctorOfVoidFromCameraState;
typedef struct { bool has_value; easyar_FunctorOfVoid value; } easyar_OptionalOfFunctorOfVoid;
typedef struct
{
void * _state;
void (* func)(void * _state, easyar_FeedbackFrame *, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfVoidFromFeedbackFrame;
typedef struct { bool has_value; easyar_FunctorOfVoidFromFeedbackFrame value; } easyar_OptionalOfFunctorOfVoidFromFeedbackFrame;
typedef struct { char _placeHolder_; } easyar_ListOfOutputFrame;
typedef struct
{
void * _state;
void (* func)(void * _state, easyar_ListOfOutputFrame *, /* OUT */ easyar_OutputFrame * *, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfOutputFrameFromListOfOutputFrame;
typedef struct
{
void * _state;
void (* func)(void * _state, easyar_VideoStatus, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfVoidFromVideoStatus;
typedef struct { bool has_value; easyar_FunctorOfVoidFromVideoStatus value; } easyar_OptionalOfFunctorOfVoidFromVideoStatus;
typedef struct
{
void * _state;
void (* func)(void * _state, easyar_LogLevel, easyar_String *, /* OUT */ easyar_String * * _exception);
void (* destroy)(void * _state);
} easyar_FunctorOfVoidFromLogLevelAndString;
#ifdef __cplusplus
}
#endif
#endif
| 51,956
|
C++
|
.h
| 1,166
| 41.848199
| 536
| 0.718757
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,283
|
imagehelper.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/imagehelper.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// Image helper class.
/// </summary>
@interface easyar_ImageHelper : NSObject
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Decodes a JPEG or PNG file.
/// </summary>
+ (easyar_Image *)decode:(easyar_Buffer *)buffer;
@end
| 967
|
C++
|
.h
| 20
| 46.95
| 127
| 0.552716
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,285
|
densespatialmap.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/densespatialmap.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// DenseSpatialMap is used to reconstruct the environment accurately and densely. The reconstructed model is represented by `triangle mesh`, which is denoted simply by `mesh`.
/// DenseSpatialMap occupies 1 buffers of camera.
/// </summary>
@interface easyar_DenseSpatialMap : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Returns True when the device supports dense reconstruction, otherwise returns False.
/// </summary>
+ (bool)isAvailable;
/// <summary>
/// Input port for input frame. For DenseSpatialMap to work, the inputFrame must include image and it's camera parameters and spatial information (cameraTransform and trackingStatus). See also `InputFrameSink`_ .
/// </summary>
- (easyar_InputFrameSink *)inputFrameSink;
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
- (int)bufferRequirement;
/// <summary>
/// Create `DenseSpatialMap`_ object.
/// </summary>
+ (easyar_DenseSpatialMap *)create;
/// <summary>
/// Start or continue runninng `DenseSpatialMap`_ algorithm.
/// </summary>
- (bool)start;
/// <summary>
/// Pause the reconstruction algorithm. Call `start` to resume reconstruction.
/// </summary>
- (void)stop;
/// <summary>
/// Close `DenseSpatialMap`_ algorithm.
/// </summary>
- (void)close;
/// <summary>
/// Get the mesh management object of type `SceneMesh`_ . The contents will automatically update after calling the `DenseSpatialMap.updateSceneMesh`_ function.
/// </summary>
- (easyar_SceneMesh *)getMesh;
/// <summary>
/// Get the lastest updated mesh and save it to the `SceneMesh`_ object obtained by `DenseSpatialMap.getMesh`_ .
/// The parameter `updateMeshAll` indicates whether to perform a `full update` or an `incremental update`. When `updateMeshAll` is True, `full update` is performed. All meshes are saved to `SceneMesh`_ . When `updateMeshAll` is False, `incremental update` is performed, and only the most recently updated mesh is saved to `SceneMesh`_ .
/// `Full update` will take extra time and memory space, causing performance degradation.
/// </summary>
- (bool)updateSceneMesh:(bool)updateMeshAll;
@end
| 2,847
|
C++
|
.h
| 55
| 50.618182
| 336
| 0.687859
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,288
|
dataflow.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/dataflow.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// Signal input port.
/// It is used to expose input port for a component.
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_SignalSink : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Input data.
/// </summary>
- (void)handle;
@end
/// <summary>
/// Signal output port.
/// It is used to expose output port for a component.
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_SignalSource : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Sets data handler.
/// </summary>
- (void)setHandler:(void (^)())handler;
/// <summary>
/// Connects to input port.
/// </summary>
- (void)connect:(easyar_SignalSink *)sink;
/// <summary>
/// Disconnects.
/// </summary>
- (void)disconnect;
@end
/// <summary>
/// Input frame input port.
/// It is used to expose input port for a component.
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_InputFrameSink : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Input data.
/// </summary>
- (void)handle:(easyar_InputFrame *)inputData;
@end
/// <summary>
/// Input frame output port.
/// It is used to expose output port for a component.
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_InputFrameSource : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Sets data handler.
/// </summary>
- (void)setHandler:(void (^)(easyar_InputFrame *))handler;
/// <summary>
/// Connects to input port.
/// </summary>
- (void)connect:(easyar_InputFrameSink *)sink;
/// <summary>
/// Disconnects.
/// </summary>
- (void)disconnect;
@end
/// <summary>
/// Output frame input port.
/// It is used to expose input port for a component.
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_OutputFrameSink : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Input data.
/// </summary>
- (void)handle:(easyar_OutputFrame *)inputData;
@end
/// <summary>
/// Output frame output port.
/// It is used to expose output port for a component.
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_OutputFrameSource : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Sets data handler.
/// </summary>
- (void)setHandler:(void (^)(easyar_OutputFrame *))handler;
/// <summary>
/// Connects to input port.
/// </summary>
- (void)connect:(easyar_OutputFrameSink *)sink;
/// <summary>
/// Disconnects.
/// </summary>
- (void)disconnect;
@end
/// <summary>
/// Feedback frame input port.
/// It is used to expose input port for a component.
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_FeedbackFrameSink : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Input data.
/// </summary>
- (void)handle:(easyar_FeedbackFrame *)inputData;
@end
/// <summary>
/// Feedback frame output port.
/// It is used to expose output port for a component.
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_FeedbackFrameSource : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Sets data handler.
/// </summary>
- (void)setHandler:(void (^)(easyar_FeedbackFrame *))handler;
/// <summary>
/// Connects to input port.
/// </summary>
- (void)connect:(easyar_FeedbackFrameSink *)sink;
/// <summary>
/// Disconnects.
/// </summary>
- (void)disconnect;
@end
/// <summary>
/// Input frame fork.
/// It is used to branch and transfer input frame to multiple components in parallel.
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_InputFrameFork : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Input port.
/// </summary>
- (easyar_InputFrameSink *)input;
/// <summary>
/// Output port.
/// </summary>
- (easyar_InputFrameSource *)output:(int)index;
/// <summary>
/// Output count.
/// </summary>
- (int)outputCount;
/// <summary>
/// Creates an instance.
/// </summary>
+ (easyar_InputFrameFork *)create:(int)outputCount;
@end
/// <summary>
/// Output frame fork.
/// It is used to branch and transfer output frame to multiple components in parallel.
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_OutputFrameFork : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Input port.
/// </summary>
- (easyar_OutputFrameSink *)input;
/// <summary>
/// Output port.
/// </summary>
- (easyar_OutputFrameSource *)output:(int)index;
/// <summary>
/// Output count.
/// </summary>
- (int)outputCount;
/// <summary>
/// Creates an instance.
/// </summary>
+ (easyar_OutputFrameFork *)create:(int)outputCount;
@end
/// <summary>
/// Output frame join.
/// It is used to aggregate output frame from multiple components in parallel.
/// All members of this class is thread-safe.
/// It shall be noticed that connections and disconnections to the inputs shall not be performed during the flowing of data, or it may stuck in a state that no frame can be output. (It is recommended to complete dataflow connection before start a camera.)
/// </summary>
@interface easyar_OutputFrameJoin : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Input port.
/// </summary>
- (easyar_OutputFrameSink *)input:(int)index;
/// <summary>
/// Output port.
/// </summary>
- (easyar_OutputFrameSource *)output;
/// <summary>
/// Input count.
/// </summary>
- (int)inputCount;
/// <summary>
/// Creates an instance. The default joiner will be used, which takes input frame from the first input and first result or null of each input. The first result of every input will be placed at the corresponding input index of results of the final output frame.
/// </summary>
+ (easyar_OutputFrameJoin *)create:(int)inputCount;
/// <summary>
/// Creates an instance. A custom joiner is specified.
/// </summary>
+ (easyar_OutputFrameJoin *)createWithJoiner:(int)inputCount joiner:(easyar_OutputFrame * (^)(NSArray<easyar_OutputFrame *> *))joiner;
@end
/// <summary>
/// Feedback frame fork.
/// It is used to branch and transfer feedback frame to multiple components in parallel.
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_FeedbackFrameFork : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Input port.
/// </summary>
- (easyar_FeedbackFrameSink *)input;
/// <summary>
/// Output port.
/// </summary>
- (easyar_FeedbackFrameSource *)output:(int)index;
/// <summary>
/// Output count.
/// </summary>
- (int)outputCount;
/// <summary>
/// Creates an instance.
/// </summary>
+ (easyar_FeedbackFrameFork *)create:(int)outputCount;
@end
/// <summary>
/// Input frame throttler.
/// There is a input frame input port and a input frame output port. It can be used to prevent incoming frames from entering algorithm components when they have not finished handling previous workload.
/// InputFrameThrottler occupies one buffer of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// All members of this class is thread-safe.
/// It shall be noticed that connections and disconnections to signalInput shall not be performed during the flowing of data, or it may stuck in a state that no frame can be output. (It is recommended to complete dataflow connection before start a camera.)
/// </summary>
@interface easyar_InputFrameThrottler : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Input port.
/// </summary>
- (easyar_InputFrameSink *)input;
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
- (int)bufferRequirement;
/// <summary>
/// Output port.
/// </summary>
- (easyar_InputFrameSource *)output;
/// <summary>
/// Input port for clearance signal.
/// </summary>
- (easyar_SignalSink *)signalInput;
/// <summary>
/// Creates an instance.
/// </summary>
+ (easyar_InputFrameThrottler *)create;
@end
/// <summary>
/// Output frame buffer.
/// There is an output frame input port and output frame fetching function. It can be used to convert output frame fetching from asynchronous pattern to synchronous polling pattern, which fits frame by frame rendering.
/// OutputFrameBuffer occupies one buffer of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_OutputFrameBuffer : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Input port.
/// </summary>
- (easyar_OutputFrameSink *)input;
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
- (int)bufferRequirement;
/// <summary>
/// Output port for frame arrival. It can be connected to `InputFrameThrottler.signalInput`_ .
/// </summary>
- (easyar_SignalSource *)signalOutput;
/// <summary>
/// Fetches the most recent `OutputFrame`_ .
/// </summary>
- (easyar_OutputFrame *)peek;
/// <summary>
/// Creates an instance.
/// </summary>
+ (easyar_OutputFrameBuffer *)create;
/// <summary>
/// Pauses output of `OutputFrame`_ . After execution, all results of `OutputFrameBuffer.peek`_ will be empty. `OutputFrameBuffer.signalOutput`_ is not affected.
/// </summary>
- (void)pause;
/// <summary>
/// Resumes output of `OutputFrame`_ .
/// </summary>
- (void)resume;
@end
/// <summary>
/// Input frame to output frame adapter.
/// There is an input frame input port and an output frame output port. It can be used to wrap an input frame into an output frame, which can be used for rendering without an algorithm component. Refer to `Overview <Overview.html>`_ .
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_InputFrameToOutputFrameAdapter : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Input port.
/// </summary>
- (easyar_InputFrameSink *)input;
/// <summary>
/// Output port.
/// </summary>
- (easyar_OutputFrameSource *)output;
/// <summary>
/// Creates an instance.
/// </summary>
+ (easyar_InputFrameToOutputFrameAdapter *)create;
@end
/// <summary>
/// Input frame to feedback frame adapter.
/// There is an input frame input port, a historic output frame input port and a feedback frame output port. It can be used to combine an input frame and a historic output frame into a feedback frame, which is required by algorithm components such as `ImageTracker`_ .
/// On every input of an input frame, a feedback frame is generated with a previously input historic feedback frame. If there is no previously input historic feedback frame, it is null in the feedback frame.
/// InputFrameToFeedbackFrameAdapter occupies one buffer of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// All members of this class is thread-safe.
/// </summary>
@interface easyar_InputFrameToFeedbackFrameAdapter : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Input port.
/// </summary>
- (easyar_InputFrameSink *)input;
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
- (int)bufferRequirement;
/// <summary>
/// Side input port for historic output frame input.
/// </summary>
- (easyar_OutputFrameSink *)sideInput;
/// <summary>
/// Output port.
/// </summary>
- (easyar_FeedbackFrameSource *)output;
/// <summary>
/// Creates an instance.
/// </summary>
+ (easyar_InputFrameToFeedbackFrameAdapter *)create;
@end
| 13,007
|
C++
|
.h
| 371
| 33.876011
| 268
| 0.719526
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,290
|
objecttracker.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/objecttracker.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
#import "easyar/target.oc.h"
/// <summary>
/// Result of `ObjectTracker`_ .
/// </summary>
@interface easyar_ObjectTrackerResult : easyar_TargetTrackerResult
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Returns the list of `TargetInstance`_ contained in the result.
/// </summary>
- (NSArray<easyar_TargetInstance *> *)targetInstances;
/// <summary>
/// Sets the list of `TargetInstance`_ contained in the result.
/// </summary>
- (void)setTargetInstances:(NSArray<easyar_TargetInstance *> *)instances;
@end
/// <summary>
/// ObjectTracker implements 3D object target detection and tracking.
/// ObjectTracker occupies (1 + SimultaneousNum) buffers of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// After creation, you can call start/stop to enable/disable the track process. start and stop are very lightweight calls.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// ObjectTracker inputs `FeedbackFrame`_ from feedbackFrameSink. `FeedbackFrameSource`_ shall be connected to feedbackFrameSink for use. Refer to `Overview <Overview.html>`_ .
/// Before a `Target`_ can be tracked by ObjectTracker, you have to load it using loadTarget/unloadTarget. You can get load/unload results from callbacks passed into the interfaces.
/// </summary>
@interface easyar_ObjectTracker : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Returns true.
/// </summary>
+ (bool)isAvailable;
/// <summary>
/// `FeedbackFrame`_ input port. The InputFrame member of FeedbackFrame must have raw image, timestamp, and camera parameters.
/// </summary>
- (easyar_FeedbackFrameSink *)feedbackFrameSink;
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
- (int)bufferRequirement;
/// <summary>
/// `OutputFrame`_ output port.
/// </summary>
- (easyar_OutputFrameSource *)outputFrameSource;
/// <summary>
/// Creates an instance.
/// </summary>
+ (easyar_ObjectTracker *)create;
/// <summary>
/// Starts the track algorithm.
/// </summary>
- (bool)start;
/// <summary>
/// Stops the track algorithm. Call start to start the track again.
/// </summary>
- (void)stop;
/// <summary>
/// Close. The component shall not be used after calling close.
/// </summary>
- (void)close;
/// <summary>
/// Load a `Target`_ into the tracker. A Target can only be tracked by tracker after a successful load.
/// This method is an asynchronous method. A load operation may take some time to finish and detection of a new/lost target may take more time during the load. The track time after detection will not be affected. If you want to know the load result, you have to handle the callback data. The callback will be called from the thread specified by `CallbackScheduler`_ . It will not block the track thread or any other operations except other load/unload.
/// </summary>
- (void)loadTarget:(easyar_Target *)target callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler callback:(void (^)(easyar_Target * target, bool status))callback;
/// <summary>
/// Unload a `Target`_ from the tracker.
/// This method is an asynchronous method. An unload operation may take some time to finish and detection of a new/lost target may take more time during the unload. If you want to know the unload result, you have to handle the callback data. The callback will be called from the thread specified by `CallbackScheduler`_ . It will not block the track thread or any other operations except other load/unload.
/// </summary>
- (void)unloadTarget:(easyar_Target *)target callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler callback:(void (^)(easyar_Target * target, bool status))callback;
/// <summary>
/// Returns current loaded targets in the tracker. If an asynchronous load/unload is in progress, the returned value will not reflect the result until all load/unload finish.
/// </summary>
- (NSArray<easyar_Target *> *)targets;
/// <summary>
/// Sets the max number of targets which will be the simultaneously tracked by the tracker. The default value is 1.
/// </summary>
- (bool)setSimultaneousNum:(int)num;
/// <summary>
/// Gets the max number of targets which will be the simultaneously tracked by the tracker. The default value is 1.
/// </summary>
- (int)simultaneousNum;
@end
| 5,203
|
C++
|
.h
| 91
| 56.043956
| 452
| 0.721569
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,293
|
camera.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/camera.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// CameraDevice implements a camera device, which outputs `InputFrame`_ (including image, camera paramters, and timestamp). It is available on Windows, Mac, Android and iOS.
/// After open, start/stop can be invoked to start or stop data collection. start/stop will not change previous set camera parameters.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// CameraDevice outputs `InputFrame`_ from inputFrameSource. inputFrameSource shall be connected to `InputFrameSink`_ for use. Refer to `Overview <Overview.html>`_ .
/// bufferCapacity is the capacity of `InputFrame`_ buffer. If the count of `InputFrame`_ which has been output from the device and have not been released is more than this number, the device will not output new `InputFrame`_ , until previous `InputFrame`_ have been released. This may cause screen stuck. Refer to `Overview <Overview.html>`_ .
/// </summary>
@interface easyar_CameraDevice : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_CameraDevice *) create;
/// <summary>
/// Checks if the component is available. It returns true only on Windows, Mac, Android or iOS.
/// </summary>
+ (bool)isAvailable;
/// <summary>
/// Gets current camera API (camera1 or camera2) on Android. camera1 is better for compatibility, but lacks some necessary information such as timestamp. camera2 has compatibility issues on some devices.
/// </summary>
- (easyar_AndroidCameraApiType)androidCameraApiType;
/// <summary>
/// Sets current camera API (camera1 or camera2) on Android. It must be called before calling openWithIndex, openWithSpecificType or openWithPreferredType, or it will not take effect.
/// It is recommended to use `CameraDeviceSelector`_ to create camera with camera API set to recommended based on primary algorithm to run.
/// </summary>
- (void)setAndroidCameraApiType:(easyar_AndroidCameraApiType)type;
/// <summary>
/// `InputFrame`_ buffer capacity. The default is 8.
/// </summary>
- (int)bufferCapacity;
/// <summary>
/// Sets `InputFrame`_ buffer capacity.
/// </summary>
- (void)setBufferCapacity:(int)capacity;
/// <summary>
/// `InputFrame`_ output port.
/// </summary>
- (easyar_InputFrameSource *)inputFrameSource;
/// <summary>
/// Sets callback on state change to notify state of camera disconnection or preemption. It is only available on Windows.
/// </summary>
- (void)setStateChangedCallback:(easyar_CallbackScheduler *)callbackScheduler stateChangedCallback:(void (^)(easyar_CameraState))stateChangedCallback;
/// <summary>
/// Requests camera permission from operating system. You can call this function or request permission directly from operating system. It is only available on Android and iOS. On other platforms, it will call the callback directly with status being granted. This function need to be called from the UI thread.
/// </summary>
+ (void)requestPermissions:(easyar_CallbackScheduler *)callbackScheduler permissionCallback:(void (^)(easyar_PermissionStatus status, NSString * value))permissionCallback;
/// <summary>
/// Gets count of cameras recognized by the operating system.
/// </summary>
+ (int)cameraCount;
/// <summary>
/// Opens a camera by index.
/// </summary>
- (bool)openWithIndex:(int)cameraIndex;
/// <summary>
/// Opens a camera by specific camera device type. If no camera is matched, false will be returned. On Mac, camera device types can not be distinguished.
/// </summary>
- (bool)openWithSpecificType:(easyar_CameraDeviceType)type;
/// <summary>
/// Opens a camera by camera device type. If no camera is matched, the first camera will be used.
/// </summary>
- (bool)openWithPreferredType:(easyar_CameraDeviceType)type;
/// <summary>
/// Starts video stream capture.
/// </summary>
- (bool)start;
/// <summary>
/// Stops video stream capture. It will only stop capture and will not change previous set camera parameters.
/// </summary>
- (void)stop;
/// <summary>
/// Close. The component shall not be used after calling close.
/// </summary>
- (void)close;
/// <summary>
/// Camera index.
/// </summary>
- (int)index;
/// <summary>
/// Camera type.
/// </summary>
- (easyar_CameraDeviceType)type;
/// <summary>
/// Camera parameters, including image size, focal length, principal point, camera type and camera rotation against natural orientation. Call after a successful open.
/// </summary>
- (easyar_CameraParameters *)cameraParameters;
/// <summary>
/// Sets camera parameters. Call after a successful open.
/// </summary>
- (void)setCameraParameters:(easyar_CameraParameters *)cameraParameters;
/// <summary>
/// Gets the current preview size. Call after a successful open.
/// </summary>
- (easyar_Vec2I *)size;
/// <summary>
/// Gets the number of supported preview sizes. Call after a successful open.
/// </summary>
- (int)supportedSizeCount;
/// <summary>
/// Gets the index-th supported preview size. It returns {0, 0} if index is out of range. Call after a successful open.
/// </summary>
- (easyar_Vec2I *)supportedSize:(int)index;
/// <summary>
/// Sets the preview size. The available nearest value will be selected. Call size to get the actual size. Call after a successful open. frameRateRange may change after calling setSize.
/// </summary>
- (bool)setSize:(easyar_Vec2I *)size;
/// <summary>
/// Gets the number of supported frame rate ranges. Call after a successful open.
/// </summary>
- (int)supportedFrameRateRangeCount;
/// <summary>
/// Gets range lower bound of the index-th supported frame rate range. Call after a successful open.
/// </summary>
- (float)supportedFrameRateRangeLower:(int)index;
/// <summary>
/// Gets range upper bound of the index-th supported frame rate range. Call after a successful open.
/// </summary>
- (float)supportedFrameRateRangeUpper:(int)index;
/// <summary>
/// Gets current index of frame rate range. Call after a successful open.
/// </summary>
- (int)frameRateRange;
/// <summary>
/// Sets current index of frame rate range. Call after a successful open.
/// </summary>
- (bool)setFrameRateRange:(int)index;
/// <summary>
/// Sets flash torch mode to on. Call after a successful open.
/// </summary>
- (bool)setFlashTorchMode:(bool)on;
/// <summary>
/// Sets focus mode to focusMode. Call after a successful open.
/// </summary>
- (bool)setFocusMode:(easyar_CameraDeviceFocusMode)focusMode;
/// <summary>
/// Does auto focus once. Call after start. It is only available when FocusMode is Normal or Macro.
/// </summary>
- (bool)autoFocus;
@end
/// <summary>
/// It is used for selecting camera API (camera1 or camera2) on Android. camera1 is better for compatibility, but lacks some necessary information such as timestamp. camera2 has compatibility issues on some devices.
/// Different preferences will choose camera1 or camera2 based on usage.
/// </summary>
@interface easyar_CameraDeviceSelector : NSObject
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Creates `CameraDevice`_ with a specified preference.
/// </summary>
+ (easyar_CameraDevice *)createCameraDevice:(easyar_CameraDevicePreference)preference;
@end
| 7,863
|
C++
|
.h
| 158
| 48.689873
| 350
| 0.732354
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,294
|
recorder.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/recorder.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// Recorder implements recording for current rendering screen.
/// Currently Recorder only works on Android (4.3 or later) and iOS with OpenGL ES 2.0 context.
/// Due to the dependency to OpenGLES, every method in this class (except requestPermissions, including the destructor) has to be called in a single thread containing an OpenGLES context.
/// **Unity Only** If in Unity, Multi-threaded rendering is enabled, scripting thread and rendering thread will be two separate threads, which makes it impossible to call updateFrame in the rendering thread. For this reason, to use Recorder, Multi-threaded rendering option shall be disabled.
/// </summary>
@interface easyar_Recorder : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Returns true only on Android 4.3 or later, or on iOS.
/// </summary>
+ (bool)isAvailable;
/// <summary>
/// Requests recording permissions from operating system. You can call this function or request permission directly from operating system. It is only available on Android and iOS. On other platforms, it will call the callback directly with status being granted. This function need to be called from the UI thread.
/// </summary>
+ (void)requestPermissions:(easyar_CallbackScheduler *)callbackScheduler permissionCallback:(void (^)(easyar_PermissionStatus status, NSString * value))permissionCallback;
/// <summary>
/// Creates an instance and initialize recording. statusCallback will dispatch event of status change and corresponding log.
/// </summary>
+ (easyar_Recorder *)create:(easyar_RecorderConfiguration *)config callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler statusCallback:(void (^)(easyar_RecordStatus status, NSString * value))statusCallback;
/// <summary>
/// Start recording.
/// </summary>
- (void)start;
/// <summary>
/// Update and record a frame using texture data.
/// </summary>
- (void)updateFrame:(easyar_TextureId *)texture width:(int)width height:(int)height;
/// <summary>
/// Stop recording. When calling stop, it will wait for file write to end and returns whether recording is successful.
/// </summary>
- (bool)stop;
@end
| 2,862
|
C++
|
.h
| 43
| 65.372093
| 313
| 0.707222
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,296
|
buffer.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/buffer.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// Buffer stores a raw byte array, which can be used to access image data.
/// To access image data in Java API, get buffer from `Image`_ and copy to a Java byte array.
/// You can always access image data since the first version of EasyAR Sense. Refer to `Image`_ .
/// </summary>
@interface easyar_Buffer : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Wraps a raw memory block. When Buffer is released by all holders, deleter callback will be invoked to execute user-defined memory destruction. deleter must be thread-safe.
/// </summary>
+ (easyar_Buffer *)wrap:(void *)ptr size:(int)size deleter:(void (^)())deleter;
/// <summary>
/// Creates a Buffer of specified byte size.
/// </summary>
+ (easyar_Buffer *)create:(int)size;
/// <summary>
/// Returns raw data address.
/// </summary>
- (void *)data;
/// <summary>
/// Byte size of raw data.
/// </summary>
- (int)size;
/// <summary>
/// Copies raw memory. It can be used in languages or platforms without complete support for memory operations.
/// </summary>
+ (void)memoryCopy:(void *)src dest:(void *)dest length:(int)length;
/// <summary>
/// Tries to copy data from a raw memory address into Buffer. If copy succeeds, it returns true, or else it returns false. Possible failure causes includes: source or destination data range overflow.
/// </summary>
- (bool)tryCopyFrom:(void *)src srcIndex:(int)srcIndex index:(int)index length:(int)length;
/// <summary>
/// Copies buffer data to user array.
/// </summary>
- (bool)tryCopyTo:(int)index dest:(void *)dest destIndex:(int)destIndex length:(int)length;
/// <summary>
/// Creates a sub-buffer with a reference to the original Buffer. A Buffer will only be released after all its sub-buffers are released.
/// </summary>
- (easyar_Buffer *)partition:(int)index length:(int)length;
@end
/// <summary>
/// A mapping from file path to `Buffer`_ . It can be used to represent multiple files in the memory.
/// </summary>
@interface easyar_BufferDictionary : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_BufferDictionary *) create;
/// <summary>
/// Current file count.
/// </summary>
- (int)count;
/// <summary>
/// Checks if a specified path is in the dictionary.
/// </summary>
- (bool)contains:(NSString *)path;
/// <summary>
/// Tries to get the corresponding `Buffer`_ for a specified path.
/// </summary>
- (easyar_Buffer *)tryGet:(NSString *)path;
/// <summary>
/// Sets `Buffer`_ for a specified path.
/// </summary>
- (void)set:(NSString *)path buffer:(easyar_Buffer *)buffer;
/// <summary>
/// Removes a specified path.
/// </summary>
- (bool)remove:(NSString *)path;
/// <summary>
/// Clears the dictionary.
/// </summary>
- (void)clear;
@end
| 3,478
|
C++
|
.h
| 82
| 41.268293
| 199
| 0.669326
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,297
|
camera.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/camera.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_CAMERA_H__
#define __EASYAR_CAMERA_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
void easyar_CameraDevice__ctor(/* OUT */ easyar_CameraDevice * * Return);
/// <summary>
/// Checks if the component is available. It returns true only on Windows, Mac, Android or iOS.
/// </summary>
bool easyar_CameraDevice_isAvailable(void);
/// <summary>
/// Gets current camera API (camera1 or camera2) on Android. camera1 is better for compatibility, but lacks some necessary information such as timestamp. camera2 has compatibility issues on some devices.
/// </summary>
easyar_AndroidCameraApiType easyar_CameraDevice_androidCameraApiType(easyar_CameraDevice * This);
/// <summary>
/// Sets current camera API (camera1 or camera2) on Android. It must be called before calling openWithIndex, openWithSpecificType or openWithPreferredType, or it will not take effect.
/// It is recommended to use `CameraDeviceSelector`_ to create camera with camera API set to recommended based on primary algorithm to run.
/// </summary>
void easyar_CameraDevice_setAndroidCameraApiType(easyar_CameraDevice * This, easyar_AndroidCameraApiType type);
/// <summary>
/// `InputFrame`_ buffer capacity. The default is 8.
/// </summary>
int easyar_CameraDevice_bufferCapacity(const easyar_CameraDevice * This);
/// <summary>
/// Sets `InputFrame`_ buffer capacity.
/// </summary>
void easyar_CameraDevice_setBufferCapacity(easyar_CameraDevice * This, int capacity);
/// <summary>
/// `InputFrame`_ output port.
/// </summary>
void easyar_CameraDevice_inputFrameSource(easyar_CameraDevice * This, /* OUT */ easyar_InputFrameSource * * Return);
/// <summary>
/// Sets callback on state change to notify state of camera disconnection or preemption. It is only available on Windows.
/// </summary>
void easyar_CameraDevice_setStateChangedCallback(easyar_CameraDevice * This, easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromCameraState stateChangedCallback);
/// <summary>
/// Requests camera permission from operating system. You can call this function or request permission directly from operating system. It is only available on Android and iOS. On other platforms, it will call the callback directly with status being granted. This function need to be called from the UI thread.
/// </summary>
void easyar_CameraDevice_requestPermissions(easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromPermissionStatusAndString permissionCallback);
/// <summary>
/// Gets count of cameras recognized by the operating system.
/// </summary>
int easyar_CameraDevice_cameraCount(void);
/// <summary>
/// Opens a camera by index.
/// </summary>
bool easyar_CameraDevice_openWithIndex(easyar_CameraDevice * This, int cameraIndex);
/// <summary>
/// Opens a camera by specific camera device type. If no camera is matched, false will be returned. On Mac, camera device types can not be distinguished.
/// </summary>
bool easyar_CameraDevice_openWithSpecificType(easyar_CameraDevice * This, easyar_CameraDeviceType type);
/// <summary>
/// Opens a camera by camera device type. If no camera is matched, the first camera will be used.
/// </summary>
bool easyar_CameraDevice_openWithPreferredType(easyar_CameraDevice * This, easyar_CameraDeviceType type);
/// <summary>
/// Starts video stream capture.
/// </summary>
bool easyar_CameraDevice_start(easyar_CameraDevice * This);
/// <summary>
/// Stops video stream capture. It will only stop capture and will not change previous set camera parameters.
/// </summary>
void easyar_CameraDevice_stop(easyar_CameraDevice * This);
/// <summary>
/// Close. The component shall not be used after calling close.
/// </summary>
void easyar_CameraDevice_close(easyar_CameraDevice * This);
/// <summary>
/// Camera index.
/// </summary>
int easyar_CameraDevice_index(const easyar_CameraDevice * This);
/// <summary>
/// Camera type.
/// </summary>
easyar_CameraDeviceType easyar_CameraDevice_type(const easyar_CameraDevice * This);
/// <summary>
/// Camera parameters, including image size, focal length, principal point, camera type and camera rotation against natural orientation. Call after a successful open.
/// </summary>
void easyar_CameraDevice_cameraParameters(easyar_CameraDevice * This, /* OUT */ easyar_CameraParameters * * Return);
/// <summary>
/// Sets camera parameters. Call after a successful open.
/// </summary>
void easyar_CameraDevice_setCameraParameters(easyar_CameraDevice * This, easyar_CameraParameters * cameraParameters);
/// <summary>
/// Gets the current preview size. Call after a successful open.
/// </summary>
easyar_Vec2I easyar_CameraDevice_size(const easyar_CameraDevice * This);
/// <summary>
/// Gets the number of supported preview sizes. Call after a successful open.
/// </summary>
int easyar_CameraDevice_supportedSizeCount(const easyar_CameraDevice * This);
/// <summary>
/// Gets the index-th supported preview size. It returns {0, 0} if index is out of range. Call after a successful open.
/// </summary>
easyar_Vec2I easyar_CameraDevice_supportedSize(const easyar_CameraDevice * This, int index);
/// <summary>
/// Sets the preview size. The available nearest value will be selected. Call size to get the actual size. Call after a successful open. frameRateRange may change after calling setSize.
/// </summary>
bool easyar_CameraDevice_setSize(easyar_CameraDevice * This, easyar_Vec2I size);
/// <summary>
/// Gets the number of supported frame rate ranges. Call after a successful open.
/// </summary>
int easyar_CameraDevice_supportedFrameRateRangeCount(const easyar_CameraDevice * This);
/// <summary>
/// Gets range lower bound of the index-th supported frame rate range. Call after a successful open.
/// </summary>
float easyar_CameraDevice_supportedFrameRateRangeLower(const easyar_CameraDevice * This, int index);
/// <summary>
/// Gets range upper bound of the index-th supported frame rate range. Call after a successful open.
/// </summary>
float easyar_CameraDevice_supportedFrameRateRangeUpper(const easyar_CameraDevice * This, int index);
/// <summary>
/// Gets current index of frame rate range. Call after a successful open.
/// </summary>
int easyar_CameraDevice_frameRateRange(const easyar_CameraDevice * This);
/// <summary>
/// Sets current index of frame rate range. Call after a successful open.
/// </summary>
bool easyar_CameraDevice_setFrameRateRange(easyar_CameraDevice * This, int index);
/// <summary>
/// Sets flash torch mode to on. Call after a successful open.
/// </summary>
bool easyar_CameraDevice_setFlashTorchMode(easyar_CameraDevice * This, bool on);
/// <summary>
/// Sets focus mode to focusMode. Call after a successful open.
/// </summary>
bool easyar_CameraDevice_setFocusMode(easyar_CameraDevice * This, easyar_CameraDeviceFocusMode focusMode);
/// <summary>
/// Does auto focus once. Call after start. It is only available when FocusMode is Normal or Macro.
/// </summary>
bool easyar_CameraDevice_autoFocus(easyar_CameraDevice * This);
void easyar_CameraDevice__dtor(easyar_CameraDevice * This);
void easyar_CameraDevice__retain(const easyar_CameraDevice * This, /* OUT */ easyar_CameraDevice * * Return);
const char * easyar_CameraDevice__typeName(const easyar_CameraDevice * This);
/// <summary>
/// Creates `CameraDevice`_ with a specified preference.
/// </summary>
void easyar_CameraDeviceSelector_createCameraDevice(easyar_CameraDevicePreference preference, /* OUT */ easyar_CameraDevice * * Return);
#ifdef __cplusplus
}
#endif
#endif
| 8,176
|
C++
|
.h
| 151
| 53.07947
| 309
| 0.753213
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,298
|
arkitcamera.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/arkitcamera.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// ARKitCameraDevice implements a camera device based on ARKit, which outputs `InputFrame`_ (including image, camera parameters, timestamp, 6DOF location, and tracking status).
/// After creation, start/stop can be invoked to start or stop data collection.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// ARKitCameraDevice outputs `InputFrame`_ from inputFrameSource. inputFrameSource shall be connected to `InputFrameSink`_ for use. Refer to `Overview <Overview.html>`_ .
/// bufferCapacity is the capacity of `InputFrame`_ buffer. If the count of `InputFrame`_ which has been output from the device and have not been released is more than this number, the device will not output new `InputFrame`_ , until previous `InputFrame`_ have been released. This may cause screen stuck. Refer to `Overview <Overview.html>`_ .
/// </summary>
@interface easyar_ARKitCameraDevice : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_ARKitCameraDevice *) create;
/// <summary>
/// Checks if the component is available. It returns true only on iOS 11 or later when ARKit is supported by hardware.
/// </summary>
+ (bool)isAvailable;
/// <summary>
/// `InputFrame`_ buffer capacity. The default is 8.
/// </summary>
- (int)bufferCapacity;
/// <summary>
/// Sets `InputFrame`_ buffer capacity.
/// </summary>
- (void)setBufferCapacity:(int)capacity;
/// <summary>
/// `InputFrame`_ output port.
/// </summary>
- (easyar_InputFrameSource *)inputFrameSource;
/// <summary>
/// Starts video stream capture.
/// </summary>
- (bool)start;
/// <summary>
/// Stops video stream capture.
/// </summary>
- (void)stop;
/// <summary>
/// Close. The component shall not be used after calling close.
/// </summary>
- (void)close;
@end
| 2,542
|
C++
|
.h
| 49
| 50.714286
| 350
| 0.673642
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,300
|
motiontracker.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/motiontracker.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_MOTIONTRACKER_H__
#define __EASYAR_MOTIONTRACKER_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Create MotionTrackerCameraDevice object.
/// </summary>
void easyar_MotionTrackerCameraDevice__ctor(/* OUT */ easyar_MotionTrackerCameraDevice * * Return);
/// <summary>
/// Check if the devices supports motion tracking. Returns True if the device supports Motion Tracking, otherwise returns False.
/// </summary>
bool easyar_MotionTrackerCameraDevice_isAvailable(void);
/// <summary>
/// Set `InputFrame`_ buffer capacity.
/// bufferCapacity is the capacity of `InputFrame`_ buffer. If the count of `InputFrame`_ which has been output from the device and have not been released is higher than this number, the device will not output new `InputFrame`_ until previous `InputFrame`_ has been released. This may cause screen stuck. Refer to `Overview <Overview.html>`_ .
/// </summary>
void easyar_MotionTrackerCameraDevice_setBufferCapacity(easyar_MotionTrackerCameraDevice * This, int capacity);
/// <summary>
/// Get `InputFrame`_ buffer capacity. The default is 8.
/// </summary>
int easyar_MotionTrackerCameraDevice_bufferCapacity(const easyar_MotionTrackerCameraDevice * This);
/// <summary>
/// `InputFrame`_ output port.
/// </summary>
void easyar_MotionTrackerCameraDevice_inputFrameSource(easyar_MotionTrackerCameraDevice * This, /* OUT */ easyar_InputFrameSource * * Return);
/// <summary>
/// Start motion tracking or resume motion tracking after pause.
/// Notice: Calling start after pausing will trigger device relocalization. Tracking will resume when the relocalization process succeeds.
/// </summary>
bool easyar_MotionTrackerCameraDevice_start(easyar_MotionTrackerCameraDevice * This);
/// <summary>
/// Pause motion tracking. Call `start` to trigger relocation, resume motion tracking if the relocation succeeds.
/// </summary>
void easyar_MotionTrackerCameraDevice_stop(easyar_MotionTrackerCameraDevice * This);
/// <summary>
/// Close motion tracking. The component shall not be used after calling close.
/// </summary>
void easyar_MotionTrackerCameraDevice_close(easyar_MotionTrackerCameraDevice * This);
void easyar_MotionTrackerCameraDevice__dtor(easyar_MotionTrackerCameraDevice * This);
void easyar_MotionTrackerCameraDevice__retain(const easyar_MotionTrackerCameraDevice * This, /* OUT */ easyar_MotionTrackerCameraDevice * * Return);
const char * easyar_MotionTrackerCameraDevice__typeName(const easyar_MotionTrackerCameraDevice * This);
#ifdef __cplusplus
}
#endif
#endif
| 3,216
|
C++
|
.h
| 55
| 57.309091
| 349
| 0.727157
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,301
|
videoplayer.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/videoplayer.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// VideoPlayer is the class for video playback.
/// EasyAR supports normal videos, transparent videos and streaming videos. The video content will be rendered into a texture passed into the player through setRenderTexture.
/// This class only supports OpenGLES2 texture.
/// Due to the dependency to OpenGLES, every method in this class (including the destructor) has to be called in a single thread containing an OpenGLES context.
/// Current version requires width and height being mutiples of 16.
///
/// Supported video file formats
/// Windows: Media Foundation-compatible formats, more can be supported via extra codecs. Please refer to `Supported Media Formats in Media Foundation <https://docs.microsoft.com/en-us/windows/win32/medfound/supported-media-formats-in-media-foundation>`__ . DirectShow is not supported.
/// Mac: Not supported.
/// Android: System supported formats. Please refer to `Supported media formats <https://developer.android.com/guide/topics/media/media-formats>`__ .
/// iOS: System supported formats. There is no reference in effect currently.
/// </summary>
@interface easyar_VideoPlayer : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_VideoPlayer *) create;
/// <summary>
/// Checks if the component is available. It returns true only on Windows, Android or iOS. It's not available on Mac.
/// </summary>
+ (bool)isAvailable;
/// <summary>
/// Sets the video type. The type will default to normal video if not set manually. It should be called before open.
/// </summary>
- (void)setVideoType:(easyar_VideoType)videoType;
/// <summary>
/// Passes the texture to display video into player. It should be set before open.
/// </summary>
- (void)setRenderTexture:(easyar_TextureId *)texture;
/// <summary>
/// Opens a video from path.
/// path can be a local video file (path/to/video.mp4) or url (http://www.../.../video.mp4). storageType indicates the type of path. See `StorageType`_ for more description.
/// This method is an asynchronous method. Open may take some time to finish. If you want to know the open result or the play status while playing, you have to handle callback. The callback will be called from a different thread. You can check if the open finished successfully and start play after a successful open.
/// </summary>
- (void)open:(NSString *)path storageType:(easyar_StorageType)storageType callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler callback:(void (^)(easyar_VideoStatus status))callback;
/// <summary>
/// Closes the video.
/// </summary>
- (void)close;
/// <summary>
/// Starts or continues to play video.
/// </summary>
- (bool)play;
/// <summary>
/// Stops the video playback.
/// </summary>
- (void)stop;
/// <summary>
/// Pauses the video playback.
/// </summary>
- (void)pause;
/// <summary>
/// Checks whether video texture is ready for render. Use this to check if texture passed into the player has been touched.
/// </summary>
- (bool)isRenderTextureAvailable;
/// <summary>
/// Updates texture data. This should be called in the renderer thread when isRenderTextureAvailable returns true.
/// </summary>
- (void)updateFrame;
/// <summary>
/// Returns the video duration. Use after a successful open.
/// </summary>
- (int)duration;
/// <summary>
/// Returns the current position of video. Use after a successful open.
/// </summary>
- (int)currentPosition;
/// <summary>
/// Seeks to play to position . Use after a successful open.
/// </summary>
- (bool)seek:(int)position;
/// <summary>
/// Returns the video size. Use after a successful open.
/// </summary>
- (easyar_Vec2I *)size;
/// <summary>
/// Returns current volume. Use after a successful open.
/// </summary>
- (float)volume;
/// <summary>
/// Sets volume of the video. Use after a successful open.
/// </summary>
- (bool)setVolume:(float)volume;
@end
| 4,570
|
C++
|
.h
| 93
| 48.053763
| 317
| 0.705303
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,302
|
recorder.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/recorder.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_RECORDER_H__
#define __EASYAR_RECORDER_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Returns true only on Android 4.3 or later, or on iOS.
/// </summary>
bool easyar_Recorder_isAvailable(void);
/// <summary>
/// Requests recording permissions from operating system. You can call this function or request permission directly from operating system. It is only available on Android and iOS. On other platforms, it will call the callback directly with status being granted. This function need to be called from the UI thread.
/// </summary>
void easyar_Recorder_requestPermissions(easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromPermissionStatusAndString permissionCallback);
/// <summary>
/// Creates an instance and initialize recording. statusCallback will dispatch event of status change and corresponding log.
/// </summary>
void easyar_Recorder_create(easyar_RecorderConfiguration * config, easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromRecordStatusAndString statusCallback, /* OUT */ easyar_Recorder * * Return);
/// <summary>
/// Start recording.
/// </summary>
void easyar_Recorder_start(easyar_Recorder * This);
/// <summary>
/// Update and record a frame using texture data.
/// </summary>
void easyar_Recorder_updateFrame(easyar_Recorder * This, easyar_TextureId * texture, int width, int height);
/// <summary>
/// Stop recording. When calling stop, it will wait for file write to end and returns whether recording is successful.
/// </summary>
bool easyar_Recorder_stop(easyar_Recorder * This);
void easyar_Recorder__dtor(easyar_Recorder * This);
void easyar_Recorder__retain(const easyar_Recorder * This, /* OUT */ easyar_Recorder * * Return);
const char * easyar_Recorder__typeName(const easyar_Recorder * This);
#ifdef __cplusplus
}
#endif
#endif
| 2,541
|
C++
|
.h
| 45
| 55.266667
| 313
| 0.702051
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,303
|
cloud.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/cloud.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// CloudRecognizer implements cloud recognition. It can only be used after created a recognition image library on the cloud. Please refer to EasyAR CRS documentation.
/// CloudRecognizer occupies one buffer of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// After creation, you can call start/stop to enable/disable running.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// CloudRecognizer inputs `InputFrame`_ from inputFrameSink. `InputFrameSource`_ shall be connected to inputFrameSink for use. Refer to `Overview <Overview.html>`_ .
/// Before using a CloudRecognizer, an `ImageTracker`_ must be setup and prepared. Any target returned from cloud should be manually put into the `ImageTracker`_ using `ImageTracker.loadTarget`_ if it need to be tracked. Then the target can be used as same as a local target after loaded into the tracker. When a target is recognized, you can get it from callback, and you should use target uid to distinguish different targets. The target runtimeID is dynamically created and cannot be used as unique identifier in the cloud situation.
/// </summary>
@interface easyar_CloudRecognizer : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Returns true.
/// </summary>
+ (bool)isAvailable;
/// <summary>
/// `InputFrame`_ input port. Raw image and timestamp are essential.
/// </summary>
- (easyar_InputFrameSink *)inputFrameSink;
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
- (int)bufferRequirement;
/// <summary>
/// Creates an instance and connects to the server.
/// </summary>
+ (easyar_CloudRecognizer *)create:(NSString *)cloudRecognitionServiceServerAddress apiKey:(NSString *)apiKey apiSecret:(NSString *)apiSecret cloudRecognitionServiceAppId:(NSString *)cloudRecognitionServiceAppId callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler callback:(void (^)(easyar_CloudStatus status, NSArray<easyar_Target *> * targets))callback;
/// <summary>
/// Starts the recognition.
/// </summary>
- (bool)start;
/// <summary>
/// Stops the recognition.
/// </summary>
- (void)stop;
/// <summary>
/// Stops the recognition and closes connection. The component shall not be used after calling close.
/// </summary>
- (void)close;
@end
| 3,195
|
C++
|
.h
| 49
| 64.040816
| 536
| 0.710644
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,306
|
cloud.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/cloud.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_CLOUD_H__
#define __EASYAR_CLOUD_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Returns true.
/// </summary>
bool easyar_CloudRecognizer_isAvailable(void);
/// <summary>
/// `InputFrame`_ input port. Raw image and timestamp are essential.
/// </summary>
void easyar_CloudRecognizer_inputFrameSink(easyar_CloudRecognizer * This, /* OUT */ easyar_InputFrameSink * * Return);
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
int easyar_CloudRecognizer_bufferRequirement(easyar_CloudRecognizer * This);
/// <summary>
/// Creates an instance and connects to the server.
/// </summary>
void easyar_CloudRecognizer_create(easyar_String * cloudRecognitionServiceServerAddress, easyar_String * apiKey, easyar_String * apiSecret, easyar_String * cloudRecognitionServiceAppId, easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromCloudStatusAndListOfTarget callback, /* OUT */ easyar_CloudRecognizer * * Return);
/// <summary>
/// Starts the recognition.
/// </summary>
bool easyar_CloudRecognizer_start(easyar_CloudRecognizer * This);
/// <summary>
/// Stops the recognition.
/// </summary>
void easyar_CloudRecognizer_stop(easyar_CloudRecognizer * This);
/// <summary>
/// Stops the recognition and closes connection. The component shall not be used after calling close.
/// </summary>
void easyar_CloudRecognizer_close(easyar_CloudRecognizer * This);
void easyar_CloudRecognizer__dtor(easyar_CloudRecognizer * This);
void easyar_CloudRecognizer__retain(const easyar_CloudRecognizer * This, /* OUT */ easyar_CloudRecognizer * * Return);
const char * easyar_CloudRecognizer__typeName(const easyar_CloudRecognizer * This);
void easyar_ListOfTarget__ctor(easyar_Target * const * begin, easyar_Target * const * end, /* OUT */ easyar_ListOfTarget * * Return);
void easyar_ListOfTarget__dtor(easyar_ListOfTarget * This);
void easyar_ListOfTarget_copy(const easyar_ListOfTarget * This, /* OUT */ easyar_ListOfTarget * * Return);
int easyar_ListOfTarget_size(const easyar_ListOfTarget * This);
easyar_Target * easyar_ListOfTarget_at(const easyar_ListOfTarget * This, int index);
#ifdef __cplusplus
}
#endif
#endif
| 2,866
|
C++
|
.h
| 54
| 51.888889
| 348
| 0.705924
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,307
|
objecttracker.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/objecttracker.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_OBJECTTRACKER_H__
#define __EASYAR_OBJECTTRACKER_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Returns the list of `TargetInstance`_ contained in the result.
/// </summary>
void easyar_ObjectTrackerResult_targetInstances(const easyar_ObjectTrackerResult * This, /* OUT */ easyar_ListOfTargetInstance * * Return);
/// <summary>
/// Sets the list of `TargetInstance`_ contained in the result.
/// </summary>
void easyar_ObjectTrackerResult_setTargetInstances(easyar_ObjectTrackerResult * This, easyar_ListOfTargetInstance * instances);
void easyar_ObjectTrackerResult__dtor(easyar_ObjectTrackerResult * This);
void easyar_ObjectTrackerResult__retain(const easyar_ObjectTrackerResult * This, /* OUT */ easyar_ObjectTrackerResult * * Return);
const char * easyar_ObjectTrackerResult__typeName(const easyar_ObjectTrackerResult * This);
void easyar_castObjectTrackerResultToFrameFilterResult(const easyar_ObjectTrackerResult * This, /* OUT */ easyar_FrameFilterResult * * Return);
void easyar_tryCastFrameFilterResultToObjectTrackerResult(const easyar_FrameFilterResult * This, /* OUT */ easyar_ObjectTrackerResult * * Return);
void easyar_castObjectTrackerResultToTargetTrackerResult(const easyar_ObjectTrackerResult * This, /* OUT */ easyar_TargetTrackerResult * * Return);
void easyar_tryCastTargetTrackerResultToObjectTrackerResult(const easyar_TargetTrackerResult * This, /* OUT */ easyar_ObjectTrackerResult * * Return);
/// <summary>
/// Returns true.
/// </summary>
bool easyar_ObjectTracker_isAvailable(void);
/// <summary>
/// `FeedbackFrame`_ input port. The InputFrame member of FeedbackFrame must have raw image, timestamp, and camera parameters.
/// </summary>
void easyar_ObjectTracker_feedbackFrameSink(easyar_ObjectTracker * This, /* OUT */ easyar_FeedbackFrameSink * * Return);
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
int easyar_ObjectTracker_bufferRequirement(easyar_ObjectTracker * This);
/// <summary>
/// `OutputFrame`_ output port.
/// </summary>
void easyar_ObjectTracker_outputFrameSource(easyar_ObjectTracker * This, /* OUT */ easyar_OutputFrameSource * * Return);
/// <summary>
/// Creates an instance.
/// </summary>
void easyar_ObjectTracker_create(/* OUT */ easyar_ObjectTracker * * Return);
/// <summary>
/// Starts the track algorithm.
/// </summary>
bool easyar_ObjectTracker_start(easyar_ObjectTracker * This);
/// <summary>
/// Stops the track algorithm. Call start to start the track again.
/// </summary>
void easyar_ObjectTracker_stop(easyar_ObjectTracker * This);
/// <summary>
/// Close. The component shall not be used after calling close.
/// </summary>
void easyar_ObjectTracker_close(easyar_ObjectTracker * This);
/// <summary>
/// Load a `Target`_ into the tracker. A Target can only be tracked by tracker after a successful load.
/// This method is an asynchronous method. A load operation may take some time to finish and detection of a new/lost target may take more time during the load. The track time after detection will not be affected. If you want to know the load result, you have to handle the callback data. The callback will be called from the thread specified by `CallbackScheduler`_ . It will not block the track thread or any other operations except other load/unload.
/// </summary>
void easyar_ObjectTracker_loadTarget(easyar_ObjectTracker * This, easyar_Target * target, easyar_CallbackScheduler * callbackScheduler, easyar_FunctorOfVoidFromTargetAndBool callback);
/// <summary>
/// Unload a `Target`_ from the tracker.
/// This method is an asynchronous method. An unload operation may take some time to finish and detection of a new/lost target may take more time during the unload. If you want to know the unload result, you have to handle the callback data. The callback will be called from the thread specified by `CallbackScheduler`_ . It will not block the track thread or any other operations except other load/unload.
/// </summary>
void easyar_ObjectTracker_unloadTarget(easyar_ObjectTracker * This, easyar_Target * target, easyar_CallbackScheduler * callbackScheduler, easyar_FunctorOfVoidFromTargetAndBool callback);
/// <summary>
/// Returns current loaded targets in the tracker. If an asynchronous load/unload is in progress, the returned value will not reflect the result until all load/unload finish.
/// </summary>
void easyar_ObjectTracker_targets(const easyar_ObjectTracker * This, /* OUT */ easyar_ListOfTarget * * Return);
/// <summary>
/// Sets the max number of targets which will be the simultaneously tracked by the tracker. The default value is 1.
/// </summary>
bool easyar_ObjectTracker_setSimultaneousNum(easyar_ObjectTracker * This, int num);
/// <summary>
/// Gets the max number of targets which will be the simultaneously tracked by the tracker. The default value is 1.
/// </summary>
int easyar_ObjectTracker_simultaneousNum(const easyar_ObjectTracker * This);
void easyar_ObjectTracker__dtor(easyar_ObjectTracker * This);
void easyar_ObjectTracker__retain(const easyar_ObjectTracker * This, /* OUT */ easyar_ObjectTracker * * Return);
const char * easyar_ObjectTracker__typeName(const easyar_ObjectTracker * This);
void easyar_ListOfTargetInstance__ctor(easyar_TargetInstance * const * begin, easyar_TargetInstance * const * end, /* OUT */ easyar_ListOfTargetInstance * * Return);
void easyar_ListOfTargetInstance__dtor(easyar_ListOfTargetInstance * This);
void easyar_ListOfTargetInstance_copy(const easyar_ListOfTargetInstance * This, /* OUT */ easyar_ListOfTargetInstance * * Return);
int easyar_ListOfTargetInstance_size(const easyar_ListOfTargetInstance * This);
easyar_TargetInstance * easyar_ListOfTargetInstance_at(const easyar_ListOfTargetInstance * This, int index);
void easyar_ListOfTarget__ctor(easyar_Target * const * begin, easyar_Target * const * end, /* OUT */ easyar_ListOfTarget * * Return);
void easyar_ListOfTarget__dtor(easyar_ListOfTarget * This);
void easyar_ListOfTarget_copy(const easyar_ListOfTarget * This, /* OUT */ easyar_ListOfTarget * * Return);
int easyar_ListOfTarget_size(const easyar_ListOfTarget * This);
easyar_Target * easyar_ListOfTarget_at(const easyar_ListOfTarget * This, int index);
#ifdef __cplusplus
}
#endif
#endif
| 6,910
|
C++
|
.h
| 100
| 67.98
| 452
| 0.754487
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,308
|
engine.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/engine.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
@interface easyar_Engine : NSObject
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Gets the version schema hash, which can be used to ensure type declarations consistent with runtime library.
/// </summary>
+ (int)schemaHash;
+ (bool)initialize:(NSString *)key;
/// <summary>
/// Handles the app onPause, pauses internal tasks.
/// </summary>
+ (void)onPause;
/// <summary>
/// Handles the app onResume, resumes internal tasks.
/// </summary>
+ (void)onResume;
/// <summary>
/// Gets error message on initialization failure.
/// </summary>
+ (NSString *)errorMessage;
/// <summary>
/// Gets the version number of EasyARSense.
/// </summary>
+ (NSString *)versionString;
/// <summary>
/// Gets the product name of EasyARSense. (Including variant, operating system and CPU architecture.)
/// </summary>
+ (NSString *)name;
@end
| 1,554
|
C++
|
.h
| 38
| 39.684211
| 127
| 0.619363
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,309
|
bufferpool.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/bufferpool.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_BUFFERPOOL_H__
#define __EASYAR_BUFFERPOOL_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// block_size is the byte size of each `Buffer`_ .
/// capacity is the maximum count of `Buffer`_ .
/// </summary>
void easyar_BufferPool__ctor(int block_size, int capacity, /* OUT */ easyar_BufferPool * * Return);
/// <summary>
/// The byte size of each `Buffer`_ .
/// </summary>
int easyar_BufferPool_block_size(const easyar_BufferPool * This);
/// <summary>
/// The maximum count of `Buffer`_ .
/// </summary>
int easyar_BufferPool_capacity(const easyar_BufferPool * This);
/// <summary>
/// Current acquired count of `Buffer`_ .
/// </summary>
int easyar_BufferPool_size(const easyar_BufferPool * This);
/// <summary>
/// Tries to acquire a memory block. If current acquired count of `Buffer`_ does not reach maximum, a new `Buffer`_ is fetched or allocated, or else null is returned.
/// </summary>
void easyar_BufferPool_tryAcquire(easyar_BufferPool * This, /* OUT */ easyar_OptionalOfBuffer * Return);
void easyar_BufferPool__dtor(easyar_BufferPool * This);
void easyar_BufferPool__retain(const easyar_BufferPool * This, /* OUT */ easyar_BufferPool * * Return);
const char * easyar_BufferPool__typeName(const easyar_BufferPool * This);
#ifdef __cplusplus
}
#endif
#endif
| 1,980
|
C++
|
.h
| 42
| 45.928571
| 166
| 0.64282
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,311
|
imagetarget.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/imagetarget.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
#import "easyar/target.oc.h"
/// <summary>
/// ImageTargetParameters represents the parameters to create a `ImageTarget`_ .
/// </summary>
@interface easyar_ImageTargetParameters : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_ImageTargetParameters *) create;
/// <summary>
/// Gets image.
/// </summary>
- (easyar_Image *)image;
/// <summary>
/// Sets image.
/// </summary>
- (void)setImage:(easyar_Image *)image;
/// <summary>
/// Gets target name. It can be used to distinguish targets.
/// </summary>
- (NSString *)name;
/// <summary>
/// Sets target name.
/// </summary>
- (void)setName:(NSString *)name;
/// <summary>
/// Gets the target uid. A target uid is useful in cloud based algorithms. If no cloud is used, you can set this uid in the json config as an alternative method to distinguish from targets.
/// </summary>
- (NSString *)uid;
/// <summary>
/// Sets target uid.
/// </summary>
- (void)setUid:(NSString *)uid;
/// <summary>
/// Gets meta data.
/// </summary>
- (NSString *)meta;
/// <summary>
/// Sets meta data。
/// </summary>
- (void)setMeta:(NSString *)meta;
/// <summary>
/// Gets the scale of image. The value is the physical image width divided by 1 meter. The default value is 1.
/// </summary>
- (float)scale;
/// <summary>
/// Sets the scale of image. The value is the physical image width divided by 1 meter. The default value is 1.
/// It is needed to set the model scale in rendering engine separately.
/// </summary>
- (void)setScale:(float)scale;
@end
/// <summary>
/// ImageTarget represents planar image targets that can be tracked by `ImageTracker`_ .
/// The fields of ImageTarget need to be filled with the create.../setupAll method before it can be read. And ImageTarget can be tracked by `ImageTracker`_ after a successful load into the `ImageTracker`_ using `ImageTracker.loadTarget`_ .
/// </summary>
@interface easyar_ImageTarget : easyar_Target
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_ImageTarget *) create;
/// <summary>
/// Creates a target from parameters.
/// </summary>
+ (easyar_ImageTarget *)createFromParameters:(easyar_ImageTargetParameters *)parameters;
/// <summary>
/// Creates a target from an etd file.
/// </summary>
+ (easyar_ImageTarget *)createFromTargetFile:(NSString *)path storageType:(easyar_StorageType)storageType;
/// <summary>
/// Creates a target from an etd data buffer.
/// </summary>
+ (easyar_ImageTarget *)createFromTargetData:(easyar_Buffer *)buffer;
/// <summary>
/// Saves as an etd file.
/// </summary>
- (bool)save:(NSString *)path;
/// <summary>
/// Creates a target from an image file. If not needed, name, uid, meta can be passed with empty string, and scale can be passed with default value 1.
/// </summary>
+ (easyar_ImageTarget *)createFromImageFile:(NSString *)path storageType:(easyar_StorageType)storageType name:(NSString *)name uid:(NSString *)uid meta:(NSString *)meta scale:(float)scale;
/// <summary>
/// Setup all targets listed in the json file or json string from path with storageType. This method only parses the json file or string.
/// If path is json file path, storageType should be `App` or `Assets` or `Absolute` indicating the path type. Paths inside json files should be absolute path or relative path to the json file.
/// See `StorageType`_ for more descriptions.
/// </summary>
+ (NSArray<easyar_ImageTarget *> *)setupAll:(NSString *)path storageType:(easyar_StorageType)storageType;
/// <summary>
/// The scale of image. The value is the physical image width divided by 1 meter. The default value is 1.
/// </summary>
- (float)scale;
/// <summary>
/// The aspect ratio of image, width divided by height.
/// </summary>
- (float)aspectRatio;
/// <summary>
/// Sets image target scale, this will overwrite the value set in the json file or the default value. The value is the physical image width divided by 1 meter. The default value is 1.
/// It is needed to set the model scale in rendering engine separately.
/// </summary>
- (bool)setScale:(float)scale;
/// <summary>
/// Returns a list of images that stored in the target. It is generally used to get image data from cloud returned target.
/// </summary>
- (NSArray<easyar_Image *> *)images;
/// <summary>
/// Returns the target id. A target id is a integer number generated at runtime. This id is non-zero and increasing globally.
/// </summary>
- (int)runtimeID;
/// <summary>
/// Returns the target uid. A target uid is useful in cloud based algorithms. If no cloud is used, you can set this uid in the json config as a alternative method to distinguish from targets.
/// </summary>
- (NSString *)uid;
/// <summary>
/// Returns the target name. Name is used to distinguish targets in a json file.
/// </summary>
- (NSString *)name;
/// <summary>
/// Set name. It will erase previously set data or data from cloud.
/// </summary>
- (void)setName:(NSString *)name;
/// <summary>
/// Returns the meta data set by setMetaData. Or, in a cloud returned target, returns the meta data set in the cloud server.
/// </summary>
- (NSString *)meta;
/// <summary>
/// Set meta data. It will erase previously set data or data from cloud.
/// </summary>
- (void)setMeta:(NSString *)data;
@end
| 5,934
|
C++
|
.h
| 135
| 42.851852
| 239
| 0.697839
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,312
|
arkitcamera.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/arkitcamera.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_ARKITCAMERA_H__
#define __EASYAR_ARKITCAMERA_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
void easyar_ARKitCameraDevice__ctor(/* OUT */ easyar_ARKitCameraDevice * * Return);
/// <summary>
/// Checks if the component is available. It returns true only on iOS 11 or later when ARKit is supported by hardware.
/// </summary>
bool easyar_ARKitCameraDevice_isAvailable(void);
/// <summary>
/// `InputFrame`_ buffer capacity. The default is 8.
/// </summary>
int easyar_ARKitCameraDevice_bufferCapacity(const easyar_ARKitCameraDevice * This);
/// <summary>
/// Sets `InputFrame`_ buffer capacity.
/// </summary>
void easyar_ARKitCameraDevice_setBufferCapacity(easyar_ARKitCameraDevice * This, int capacity);
/// <summary>
/// `InputFrame`_ output port.
/// </summary>
void easyar_ARKitCameraDevice_inputFrameSource(easyar_ARKitCameraDevice * This, /* OUT */ easyar_InputFrameSource * * Return);
/// <summary>
/// Starts video stream capture.
/// </summary>
bool easyar_ARKitCameraDevice_start(easyar_ARKitCameraDevice * This);
/// <summary>
/// Stops video stream capture.
/// </summary>
void easyar_ARKitCameraDevice_stop(easyar_ARKitCameraDevice * This);
/// <summary>
/// Close. The component shall not be used after calling close.
/// </summary>
void easyar_ARKitCameraDevice_close(easyar_ARKitCameraDevice * This);
void easyar_ARKitCameraDevice__dtor(easyar_ARKitCameraDevice * This);
void easyar_ARKitCameraDevice__retain(const easyar_ARKitCameraDevice * This, /* OUT */ easyar_ARKitCameraDevice * * Return);
const char * easyar_ARKitCameraDevice__typeName(const easyar_ARKitCameraDevice * This);
#ifdef __cplusplus
}
#endif
#endif
| 2,330
|
C++
|
.h
| 50
| 45.42
| 127
| 0.68472
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,315
|
recorder_configuration.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/recorder_configuration.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// RecorderConfiguration is startup configuration for `Recorder`_ .
/// </summary>
@interface easyar_RecorderConfiguration : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_RecorderConfiguration *) create;
/// <summary>
/// Sets absolute path for output video file.
/// </summary>
- (void)setOutputFile:(NSString *)path;
/// <summary>
/// Sets recording profile. Default value is Quality_720P_Middle.
/// This is an all-in-one configuration, you can control in more advanced mode with other APIs.
/// </summary>
- (bool)setProfile:(easyar_RecordProfile)profile;
/// <summary>
/// Sets recording video size. Default value is Vid720p.
/// </summary>
- (void)setVideoSize:(easyar_RecordVideoSize)framesize;
/// <summary>
/// Sets recording video bit rate. Default value is 2500000.
/// </summary>
- (void)setVideoBitrate:(int)bitrate;
/// <summary>
/// Sets recording audio channel count. Default value is 1.
/// </summary>
- (void)setChannelCount:(int)count;
/// <summary>
/// Sets recording audio sample rate. Default value is 44100.
/// </summary>
- (void)setAudioSampleRate:(int)samplerate;
/// <summary>
/// Sets recording audio bit rate. Default value is 96000.
/// </summary>
- (void)setAudioBitrate:(int)bitrate;
/// <summary>
/// Sets recording video orientation. Default value is Landscape.
/// </summary>
- (void)setVideoOrientation:(easyar_RecordVideoOrientation)mode;
/// <summary>
/// Sets recording zoom mode. Default value is NoZoomAndClip.
/// </summary>
- (void)setZoomMode:(easyar_RecordZoomMode)mode;
@end
| 2,272
|
C++
|
.h
| 54
| 40.925926
| 127
| 0.666516
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,316
|
image.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/image.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// Image stores an image data and represents an image in memory.
/// Image raw data can be accessed as byte array. The width/height/etc information are also accessible.
/// You can always access image data since the first version of EasyAR Sense.
///
/// You can do this in iOS
/// ::
///
/// #import <easyar/buffer.oc.h>
/// #import <easyar/image.oc.h>
///
/// easyar_OutputFrame * outputFrame = [outputFrameBuffer peek];
/// if (outputFrame != nil) {
/// easyar_Image * i = [[outputFrame inputFrame] image];
/// easyar_Buffer * b = [i buffer];
/// char * bytes = calloc([b size], 1);
/// memcpy(bytes, [b data], [b size]);
/// // use bytes here
/// free(bytes);
/// }
///
/// Or in Android
/// ::
///
/// import cn.easyar.*;
///
/// OutputFrame outputFrame = outputFrameBuffer.peek();
/// if (outputFrame != null) {
/// InputFrame inputFrame = outputFrame.inputFrame();
/// Image i = inputFrame.image();
/// Buffer b = i.buffer();
/// byte[] bytes = new byte[b.size()];
/// b.copyToByteArray(0, bytes, 0, bytes.length);
/// // use bytes here
/// b.dispose();
/// i.dispose();
/// inputFrame.dispose();
/// outputFrame.dispose();
/// }
/// </summary>
@interface easyar_Image : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_Image *) create:(easyar_Buffer *)buffer format:(easyar_PixelFormat)format width:(int)width height:(int)height;
/// <summary>
/// Returns buffer inside image. It can be used to access internal data of image. The content of `Buffer`_ shall not be modified, as they may be accessed from other threads.
/// </summary>
- (easyar_Buffer *)buffer;
/// <summary>
/// Returns image format.
/// </summary>
- (easyar_PixelFormat)format;
/// <summary>
/// Returns image width.
/// </summary>
- (int)width;
/// <summary>
/// Returns image height.
/// </summary>
- (int)height;
/// <summary>
/// Checks if the image is empty.
/// </summary>
- (bool)empty;
@end
| 2,798
|
C++
|
.h
| 74
| 36.702703
| 173
| 0.586156
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,317
|
imagetarget.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/imagetarget.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_IMAGETARGET_H__
#define __EASYAR_IMAGETARGET_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
void easyar_ImageTargetParameters__ctor(/* OUT */ easyar_ImageTargetParameters * * Return);
/// <summary>
/// Gets image.
/// </summary>
void easyar_ImageTargetParameters_image(easyar_ImageTargetParameters * This, /* OUT */ easyar_Image * * Return);
/// <summary>
/// Sets image.
/// </summary>
void easyar_ImageTargetParameters_setImage(easyar_ImageTargetParameters * This, easyar_Image * image);
/// <summary>
/// Gets target name. It can be used to distinguish targets.
/// </summary>
void easyar_ImageTargetParameters_name(easyar_ImageTargetParameters * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Sets target name.
/// </summary>
void easyar_ImageTargetParameters_setName(easyar_ImageTargetParameters * This, easyar_String * name);
/// <summary>
/// Gets the target uid. A target uid is useful in cloud based algorithms. If no cloud is used, you can set this uid in the json config as an alternative method to distinguish from targets.
/// </summary>
void easyar_ImageTargetParameters_uid(easyar_ImageTargetParameters * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Sets target uid.
/// </summary>
void easyar_ImageTargetParameters_setUid(easyar_ImageTargetParameters * This, easyar_String * uid);
/// <summary>
/// Gets meta data.
/// </summary>
void easyar_ImageTargetParameters_meta(easyar_ImageTargetParameters * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Sets meta data。
/// </summary>
void easyar_ImageTargetParameters_setMeta(easyar_ImageTargetParameters * This, easyar_String * meta);
/// <summary>
/// Gets the scale of image. The value is the physical image width divided by 1 meter. The default value is 1.
/// </summary>
float easyar_ImageTargetParameters_scale(easyar_ImageTargetParameters * This);
/// <summary>
/// Sets the scale of image. The value is the physical image width divided by 1 meter. The default value is 1.
/// It is needed to set the model scale in rendering engine separately.
/// </summary>
void easyar_ImageTargetParameters_setScale(easyar_ImageTargetParameters * This, float scale);
void easyar_ImageTargetParameters__dtor(easyar_ImageTargetParameters * This);
void easyar_ImageTargetParameters__retain(const easyar_ImageTargetParameters * This, /* OUT */ easyar_ImageTargetParameters * * Return);
const char * easyar_ImageTargetParameters__typeName(const easyar_ImageTargetParameters * This);
void easyar_ImageTarget__ctor(/* OUT */ easyar_ImageTarget * * Return);
/// <summary>
/// Creates a target from parameters.
/// </summary>
void easyar_ImageTarget_createFromParameters(easyar_ImageTargetParameters * parameters, /* OUT */ easyar_OptionalOfImageTarget * Return);
/// <summary>
/// Creates a target from an etd file.
/// </summary>
void easyar_ImageTarget_createFromTargetFile(easyar_String * path, easyar_StorageType storageType, /* OUT */ easyar_OptionalOfImageTarget * Return);
/// <summary>
/// Creates a target from an etd data buffer.
/// </summary>
void easyar_ImageTarget_createFromTargetData(easyar_Buffer * buffer, /* OUT */ easyar_OptionalOfImageTarget * Return);
/// <summary>
/// Saves as an etd file.
/// </summary>
bool easyar_ImageTarget_save(easyar_ImageTarget * This, easyar_String * path);
/// <summary>
/// Creates a target from an image file. If not needed, name, uid, meta can be passed with empty string, and scale can be passed with default value 1.
/// </summary>
void easyar_ImageTarget_createFromImageFile(easyar_String * path, easyar_StorageType storageType, easyar_String * name, easyar_String * uid, easyar_String * meta, float scale, /* OUT */ easyar_OptionalOfImageTarget * Return);
/// <summary>
/// Setup all targets listed in the json file or json string from path with storageType. This method only parses the json file or string.
/// If path is json file path, storageType should be `App` or `Assets` or `Absolute` indicating the path type. Paths inside json files should be absolute path or relative path to the json file.
/// See `StorageType`_ for more descriptions.
/// </summary>
void easyar_ImageTarget_setupAll(easyar_String * path, easyar_StorageType storageType, /* OUT */ easyar_ListOfImageTarget * * Return);
/// <summary>
/// The scale of image. The value is the physical image width divided by 1 meter. The default value is 1.
/// </summary>
float easyar_ImageTarget_scale(const easyar_ImageTarget * This);
/// <summary>
/// The aspect ratio of image, width divided by height.
/// </summary>
float easyar_ImageTarget_aspectRatio(const easyar_ImageTarget * This);
/// <summary>
/// Sets image target scale, this will overwrite the value set in the json file or the default value. The value is the physical image width divided by 1 meter. The default value is 1.
/// It is needed to set the model scale in rendering engine separately.
/// </summary>
bool easyar_ImageTarget_setScale(easyar_ImageTarget * This, float scale);
/// <summary>
/// Returns a list of images that stored in the target. It is generally used to get image data from cloud returned target.
/// </summary>
void easyar_ImageTarget_images(easyar_ImageTarget * This, /* OUT */ easyar_ListOfImage * * Return);
/// <summary>
/// Returns the target id. A target id is a integer number generated at runtime. This id is non-zero and increasing globally.
/// </summary>
int easyar_ImageTarget_runtimeID(const easyar_ImageTarget * This);
/// <summary>
/// Returns the target uid. A target uid is useful in cloud based algorithms. If no cloud is used, you can set this uid in the json config as a alternative method to distinguish from targets.
/// </summary>
void easyar_ImageTarget_uid(const easyar_ImageTarget * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Returns the target name. Name is used to distinguish targets in a json file.
/// </summary>
void easyar_ImageTarget_name(const easyar_ImageTarget * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Set name. It will erase previously set data or data from cloud.
/// </summary>
void easyar_ImageTarget_setName(easyar_ImageTarget * This, easyar_String * name);
/// <summary>
/// Returns the meta data set by setMetaData. Or, in a cloud returned target, returns the meta data set in the cloud server.
/// </summary>
void easyar_ImageTarget_meta(const easyar_ImageTarget * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Set meta data. It will erase previously set data or data from cloud.
/// </summary>
void easyar_ImageTarget_setMeta(easyar_ImageTarget * This, easyar_String * data);
void easyar_ImageTarget__dtor(easyar_ImageTarget * This);
void easyar_ImageTarget__retain(const easyar_ImageTarget * This, /* OUT */ easyar_ImageTarget * * Return);
const char * easyar_ImageTarget__typeName(const easyar_ImageTarget * This);
void easyar_castImageTargetToTarget(const easyar_ImageTarget * This, /* OUT */ easyar_Target * * Return);
void easyar_tryCastTargetToImageTarget(const easyar_Target * This, /* OUT */ easyar_ImageTarget * * Return);
void easyar_ListOfImageTarget__ctor(easyar_ImageTarget * const * begin, easyar_ImageTarget * const * end, /* OUT */ easyar_ListOfImageTarget * * Return);
void easyar_ListOfImageTarget__dtor(easyar_ListOfImageTarget * This);
void easyar_ListOfImageTarget_copy(const easyar_ListOfImageTarget * This, /* OUT */ easyar_ListOfImageTarget * * Return);
int easyar_ListOfImageTarget_size(const easyar_ListOfImageTarget * This);
easyar_ImageTarget * easyar_ListOfImageTarget_at(const easyar_ListOfImageTarget * This, int index);
void easyar_ListOfImage__ctor(easyar_Image * const * begin, easyar_Image * const * end, /* OUT */ easyar_ListOfImage * * Return);
void easyar_ListOfImage__dtor(easyar_ListOfImage * This);
void easyar_ListOfImage_copy(const easyar_ListOfImage * This, /* OUT */ easyar_ListOfImage * * Return);
int easyar_ListOfImage_size(const easyar_ListOfImage * This);
easyar_Image * easyar_ListOfImage_at(const easyar_ListOfImage * This, int index);
#ifdef __cplusplus
}
#endif
#endif
| 8,727
|
C++
|
.h
| 146
| 58.678082
| 225
| 0.736664
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,318
|
matrix.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/matrix.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// record
/// Square matrix of 4. The data arrangement is row-major.
/// </summary>
@interface easyar_Matrix44F : NSObject
/// <summary>
/// The raw data of matrix.
/// </summary>
@property (nonatomic) NSArray<NSNumber *> * data;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)create:(NSArray<NSNumber *> *)data;
@end
/// <summary>
/// record
/// Square matrix of 3. The data arrangement is row-major.
/// </summary>
@interface easyar_Matrix33F : NSObject
/// <summary>
/// The raw data of matrix.
/// </summary>
@property (nonatomic) NSArray<NSNumber *> * data;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)create:(NSArray<NSNumber *> *)data;
@end
| 1,440
|
C++
|
.h
| 35
| 39.742857
| 127
| 0.607477
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,319
|
arcorecamera.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/arcorecamera.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
/// <summary>
/// ARCoreCameraDevice implements a camera device based on ARCore, which outputs `InputFrame`_ (including image, camera parameters, timestamp, 6DOF location, and tracking status).
/// Loading of libarcore_sdk_c.so with java.lang.System.loadLibrary is required.
/// After creation, start/stop can be invoked to start or stop video stream capture.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// ARCoreCameraDevice outputs `InputFrame`_ from inputFrameSource. inputFrameSource shall be connected to `InputFrameSink`_ for use. Refer to `Overview <Overview.html>`_ .
/// bufferCapacity is the capacity of `InputFrame`_ buffer. If the count of `InputFrame`_ which has been output from the device and have not been released is more than this number, the device will not output new `InputFrame`_ , until previous `InputFrame`_ have been released. This may cause screen stuck. Refer to `Overview <Overview.html>`_ .
/// Caution: Currently, ARCore(v1.13.0) has memory leaks on creating and destroying sessions. Repeated creations and destructions will cause an increasing and non-reclaimable memory footprint.
/// </summary>
@interface easyar_ARCoreCameraDevice : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+ (easyar_ARCoreCameraDevice *) create;
/// <summary>
/// Checks if the component is available. It returns true only on Android when ARCore is installed.
/// If called with libarcore_sdk_c.so not loaded, it returns false.
/// Notice: If ARCore is not supported on the device but ARCore apk is installed via side-loading, it will return true, but ARCore will not function properly.
/// </summary>
+ (bool)isAvailable;
/// <summary>
/// `InputFrame`_ buffer capacity. The default is 8.
/// </summary>
- (int)bufferCapacity;
/// <summary>
/// Sets `InputFrame`_ buffer capacity.
/// </summary>
- (void)setBufferCapacity:(int)capacity;
/// <summary>
/// `InputFrame`_ output port.
/// </summary>
- (easyar_InputFrameSource *)inputFrameSource;
/// <summary>
/// Starts video stream capture.
/// </summary>
- (bool)start;
/// <summary>
/// Stops video stream capture.
/// </summary>
- (void)stop;
/// <summary>
/// Close. The component shall not be used after calling close.
/// </summary>
- (void)close;
@end
| 3,035
|
C++
|
.h
| 53
| 56.113208
| 350
| 0.693679
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,320
|
frame.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/frame.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_FRAME_H__
#define __EASYAR_FRAME_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Index, an automatic incremental value, which is different for every input frame.
/// </summary>
int easyar_InputFrame_index(const easyar_InputFrame * This);
/// <summary>
/// Gets image.
/// </summary>
void easyar_InputFrame_image(const easyar_InputFrame * This, /* OUT */ easyar_Image * * Return);
/// <summary>
/// Checks if there are camera parameters.
/// </summary>
bool easyar_InputFrame_hasCameraParameters(const easyar_InputFrame * This);
/// <summary>
/// Gets camera parameters.
/// </summary>
void easyar_InputFrame_cameraParameters(const easyar_InputFrame * This, /* OUT */ easyar_CameraParameters * * Return);
/// <summary>
/// Checks if there is temporal information (timestamp).
/// </summary>
bool easyar_InputFrame_hasTemporalInformation(const easyar_InputFrame * This);
/// <summary>
/// Timestamp.
/// </summary>
double easyar_InputFrame_timestamp(const easyar_InputFrame * This);
/// <summary>
/// Checks if there is spatial information (cameraTransform and trackingStatus).
/// </summary>
bool easyar_InputFrame_hasSpatialInformation(const easyar_InputFrame * This);
/// <summary>
/// Camera transform matrix against world coordinate system. Camera coordinate system and world coordinate system are all right-handed. For the camera coordinate system, the origin is the optical center, x-right, y-up, and z in the direction of light going into camera. (The right and up, on mobile devices, is the right and up when the device is in the natural orientation.) The data arrangement is row-major, not like OpenGL's column-major.
/// </summary>
easyar_Matrix44F easyar_InputFrame_cameraTransform(const easyar_InputFrame * This);
/// <summary>
/// Gets device motion tracking status: `MotionTrackingStatus`_ .
/// </summary>
easyar_MotionTrackingStatus easyar_InputFrame_trackingStatus(const easyar_InputFrame * This);
/// <summary>
/// Creates an instance.
/// </summary>
void easyar_InputFrame_create(easyar_Image * image, easyar_CameraParameters * cameraParameters, double timestamp, easyar_Matrix44F cameraTransform, easyar_MotionTrackingStatus trackingStatus, /* OUT */ easyar_InputFrame * * Return);
/// <summary>
/// Creates an instance with image, camera parameters, and timestamp.
/// </summary>
void easyar_InputFrame_createWithImageAndCameraParametersAndTemporal(easyar_Image * image, easyar_CameraParameters * cameraParameters, double timestamp, /* OUT */ easyar_InputFrame * * Return);
/// <summary>
/// Creates an instance with image and camera parameters.
/// </summary>
void easyar_InputFrame_createWithImageAndCameraParameters(easyar_Image * image, easyar_CameraParameters * cameraParameters, /* OUT */ easyar_InputFrame * * Return);
/// <summary>
/// Creates an instance with image.
/// </summary>
void easyar_InputFrame_createWithImage(easyar_Image * image, /* OUT */ easyar_InputFrame * * Return);
void easyar_InputFrame__dtor(easyar_InputFrame * This);
void easyar_InputFrame__retain(const easyar_InputFrame * This, /* OUT */ easyar_InputFrame * * Return);
const char * easyar_InputFrame__typeName(const easyar_InputFrame * This);
void easyar_FrameFilterResult__dtor(easyar_FrameFilterResult * This);
void easyar_FrameFilterResult__retain(const easyar_FrameFilterResult * This, /* OUT */ easyar_FrameFilterResult * * Return);
const char * easyar_FrameFilterResult__typeName(const easyar_FrameFilterResult * This);
void easyar_OutputFrame__ctor(easyar_InputFrame * inputFrame, easyar_ListOfOptionalOfFrameFilterResult * results, /* OUT */ easyar_OutputFrame * * Return);
/// <summary>
/// Index, an automatic incremental value, which is different for every output frame.
/// </summary>
int easyar_OutputFrame_index(const easyar_OutputFrame * This);
/// <summary>
/// Corresponding input frame.
/// </summary>
void easyar_OutputFrame_inputFrame(const easyar_OutputFrame * This, /* OUT */ easyar_InputFrame * * Return);
/// <summary>
/// Results of synchronous components.
/// </summary>
void easyar_OutputFrame_results(const easyar_OutputFrame * This, /* OUT */ easyar_ListOfOptionalOfFrameFilterResult * * Return);
void easyar_OutputFrame__dtor(easyar_OutputFrame * This);
void easyar_OutputFrame__retain(const easyar_OutputFrame * This, /* OUT */ easyar_OutputFrame * * Return);
const char * easyar_OutputFrame__typeName(const easyar_OutputFrame * This);
void easyar_FeedbackFrame__ctor(easyar_InputFrame * inputFrame, easyar_OptionalOfOutputFrame previousOutputFrame, /* OUT */ easyar_FeedbackFrame * * Return);
/// <summary>
/// Input frame.
/// </summary>
void easyar_FeedbackFrame_inputFrame(const easyar_FeedbackFrame * This, /* OUT */ easyar_InputFrame * * Return);
/// <summary>
/// Historic output frame.
/// </summary>
void easyar_FeedbackFrame_previousOutputFrame(const easyar_FeedbackFrame * This, /* OUT */ easyar_OptionalOfOutputFrame * Return);
void easyar_FeedbackFrame__dtor(easyar_FeedbackFrame * This);
void easyar_FeedbackFrame__retain(const easyar_FeedbackFrame * This, /* OUT */ easyar_FeedbackFrame * * Return);
const char * easyar_FeedbackFrame__typeName(const easyar_FeedbackFrame * This);
void easyar_ListOfOptionalOfFrameFilterResult__ctor(easyar_OptionalOfFrameFilterResult const * begin, easyar_OptionalOfFrameFilterResult const * end, /* OUT */ easyar_ListOfOptionalOfFrameFilterResult * * Return);
void easyar_ListOfOptionalOfFrameFilterResult__dtor(easyar_ListOfOptionalOfFrameFilterResult * This);
void easyar_ListOfOptionalOfFrameFilterResult_copy(const easyar_ListOfOptionalOfFrameFilterResult * This, /* OUT */ easyar_ListOfOptionalOfFrameFilterResult * * Return);
int easyar_ListOfOptionalOfFrameFilterResult_size(const easyar_ListOfOptionalOfFrameFilterResult * This);
easyar_OptionalOfFrameFilterResult easyar_ListOfOptionalOfFrameFilterResult_at(const easyar_ListOfOptionalOfFrameFilterResult * This, int index);
#ifdef __cplusplus
}
#endif
#endif
| 6,624
|
C++
|
.h
| 109
| 59.651376
| 446
| 0.749769
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,321
|
log.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/log.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_LOG_H__
#define __EASYAR_LOG_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Sets custom log output function.
/// </summary>
void easyar_Log_setLogFunc(easyar_FunctorOfVoidFromLogLevelAndString func);
/// <summary>
/// Clears custom log output function and reverts to default log output function.
/// </summary>
void easyar_Log_resetLogFunc(void);
#ifdef __cplusplus
}
#endif
#endif
| 1,096
|
C++
|
.h
| 26
| 40.807692
| 127
| 0.586239
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,322
|
objecttarget.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/objecttarget.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_OBJECTTARGET_H__
#define __EASYAR_OBJECTTARGET_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
void easyar_ObjectTargetParameters__ctor(/* OUT */ easyar_ObjectTargetParameters * * Return);
/// <summary>
/// Gets `Buffer`_ dictionary.
/// </summary>
void easyar_ObjectTargetParameters_bufferDictionary(easyar_ObjectTargetParameters * This, /* OUT */ easyar_BufferDictionary * * Return);
/// <summary>
/// Sets `Buffer`_ dictionary. obj, mtl and jpg/png files shall be loaded into the dictionay, and be able to be located by relative or absolute paths.
/// </summary>
void easyar_ObjectTargetParameters_setBufferDictionary(easyar_ObjectTargetParameters * This, easyar_BufferDictionary * bufferDictionary);
/// <summary>
/// Gets obj file path.
/// </summary>
void easyar_ObjectTargetParameters_objPath(easyar_ObjectTargetParameters * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Sets obj file path.
/// </summary>
void easyar_ObjectTargetParameters_setObjPath(easyar_ObjectTargetParameters * This, easyar_String * objPath);
/// <summary>
/// Gets target name. It can be used to distinguish targets.
/// </summary>
void easyar_ObjectTargetParameters_name(easyar_ObjectTargetParameters * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Sets target name.
/// </summary>
void easyar_ObjectTargetParameters_setName(easyar_ObjectTargetParameters * This, easyar_String * name);
/// <summary>
/// Gets the target uid. You can set this uid in the json config as a method to distinguish from targets.
/// </summary>
void easyar_ObjectTargetParameters_uid(easyar_ObjectTargetParameters * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Sets target uid.
/// </summary>
void easyar_ObjectTargetParameters_setUid(easyar_ObjectTargetParameters * This, easyar_String * uid);
/// <summary>
/// Gets meta data.
/// </summary>
void easyar_ObjectTargetParameters_meta(easyar_ObjectTargetParameters * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Sets meta data。
/// </summary>
void easyar_ObjectTargetParameters_setMeta(easyar_ObjectTargetParameters * This, easyar_String * meta);
/// <summary>
/// Gets the scale of model. The value is the physical scale divided by model coordinate system scale. The default value is 1. (Supposing the unit of model coordinate system is 1 meter.)
/// </summary>
float easyar_ObjectTargetParameters_scale(easyar_ObjectTargetParameters * This);
/// <summary>
/// Sets the scale of model. The value is the physical scale divided by model coordinate system scale. The default value is 1. (Supposing the unit of model coordinate system is 1 meter.)
/// It is needed to set the model scale in rendering engine separately.
/// </summary>
void easyar_ObjectTargetParameters_setScale(easyar_ObjectTargetParameters * This, float size);
void easyar_ObjectTargetParameters__dtor(easyar_ObjectTargetParameters * This);
void easyar_ObjectTargetParameters__retain(const easyar_ObjectTargetParameters * This, /* OUT */ easyar_ObjectTargetParameters * * Return);
const char * easyar_ObjectTargetParameters__typeName(const easyar_ObjectTargetParameters * This);
void easyar_ObjectTarget__ctor(/* OUT */ easyar_ObjectTarget * * Return);
/// <summary>
/// Creates a target from parameters.
/// </summary>
void easyar_ObjectTarget_createFromParameters(easyar_ObjectTargetParameters * parameters, /* OUT */ easyar_OptionalOfObjectTarget * Return);
/// <summary>
/// Creats a target from obj, mtl and jpg/png files.
/// </summary>
void easyar_ObjectTarget_createFromObjectFile(easyar_String * path, easyar_StorageType storageType, easyar_String * name, easyar_String * uid, easyar_String * meta, float scale, /* OUT */ easyar_OptionalOfObjectTarget * Return);
/// <summary>
/// Setup all targets listed in the json file or json string from path with storageType. This method only parses the json file or string.
/// If path is json file path, storageType should be `App` or `Assets` or `Absolute` indicating the path type. Paths inside json files should be absolute path or relative path to the json file.
/// See `StorageType`_ for more descriptions.
/// </summary>
void easyar_ObjectTarget_setupAll(easyar_String * path, easyar_StorageType storageType, /* OUT */ easyar_ListOfObjectTarget * * Return);
/// <summary>
/// The scale of model. The value is the physical scale divided by model coordinate system scale. The default value is 1. (Supposing the unit of model coordinate system is 1 meter.)
/// </summary>
float easyar_ObjectTarget_scale(const easyar_ObjectTarget * This);
/// <summary>
/// The bounding box of object, it contains the 8 points of the box.
/// Vertices's indices are defined and stored following the rule:
/// ::
///
/// 4-----7
/// /| /|
/// 5-----6 | z
/// | | | | |
/// | 0---|-3 o---y
/// |/ |/ /
/// 1-----2 x
/// </summary>
void easyar_ObjectTarget_boundingBox(easyar_ObjectTarget * This, /* OUT */ easyar_ListOfVec3F * * Return);
/// <summary>
/// Sets model target scale, this will overwrite the value set in the json file or the default value. The value is the physical scale divided by model coordinate system scale. The default value is 1. (Supposing the unit of model coordinate system is 1 meter.)
/// It is needed to set the model scale in rendering engine separately.
/// It also should been done before loading ObjectTarget into `ObjectTracker`_ using `ObjectTracker.loadTarget`_.
/// </summary>
bool easyar_ObjectTarget_setScale(easyar_ObjectTarget * This, float scale);
/// <summary>
/// Returns the target id. A target id is a integer number generated at runtime. This id is non-zero and increasing globally.
/// </summary>
int easyar_ObjectTarget_runtimeID(const easyar_ObjectTarget * This);
/// <summary>
/// Returns the target uid. A target uid is useful in cloud based algorithms. If no cloud is used, you can set this uid in the json config as a alternative method to distinguish from targets.
/// </summary>
void easyar_ObjectTarget_uid(const easyar_ObjectTarget * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Returns the target name. Name is used to distinguish targets in a json file.
/// </summary>
void easyar_ObjectTarget_name(const easyar_ObjectTarget * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Set name. It will erase previously set data or data from cloud.
/// </summary>
void easyar_ObjectTarget_setName(easyar_ObjectTarget * This, easyar_String * name);
/// <summary>
/// Returns the meta data set by setMetaData. Or, in a cloud returned target, returns the meta data set in the cloud server.
/// </summary>
void easyar_ObjectTarget_meta(const easyar_ObjectTarget * This, /* OUT */ easyar_String * * Return);
/// <summary>
/// Set meta data. It will erase previously set data or data from cloud.
/// </summary>
void easyar_ObjectTarget_setMeta(easyar_ObjectTarget * This, easyar_String * data);
void easyar_ObjectTarget__dtor(easyar_ObjectTarget * This);
void easyar_ObjectTarget__retain(const easyar_ObjectTarget * This, /* OUT */ easyar_ObjectTarget * * Return);
const char * easyar_ObjectTarget__typeName(const easyar_ObjectTarget * This);
void easyar_castObjectTargetToTarget(const easyar_ObjectTarget * This, /* OUT */ easyar_Target * * Return);
void easyar_tryCastTargetToObjectTarget(const easyar_Target * This, /* OUT */ easyar_ObjectTarget * * Return);
void easyar_ListOfObjectTarget__ctor(easyar_ObjectTarget * const * begin, easyar_ObjectTarget * const * end, /* OUT */ easyar_ListOfObjectTarget * * Return);
void easyar_ListOfObjectTarget__dtor(easyar_ListOfObjectTarget * This);
void easyar_ListOfObjectTarget_copy(const easyar_ListOfObjectTarget * This, /* OUT */ easyar_ListOfObjectTarget * * Return);
int easyar_ListOfObjectTarget_size(const easyar_ListOfObjectTarget * This);
easyar_ObjectTarget * easyar_ListOfObjectTarget_at(const easyar_ListOfObjectTarget * This, int index);
void easyar_ListOfVec3F__ctor(easyar_Vec3F const * begin, easyar_Vec3F const * end, /* OUT */ easyar_ListOfVec3F * * Return);
void easyar_ListOfVec3F__dtor(easyar_ListOfVec3F * This);
void easyar_ListOfVec3F_copy(const easyar_ListOfVec3F * This, /* OUT */ easyar_ListOfVec3F * * Return);
int easyar_ListOfVec3F_size(const easyar_ListOfVec3F * This);
easyar_Vec3F easyar_ListOfVec3F_at(const easyar_ListOfVec3F * This, int index);
#ifdef __cplusplus
}
#endif
#endif
| 9,063
|
C++
|
.h
| 149
| 59.731544
| 259
| 0.73236
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,323
|
surfacetracker.oc.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/surfacetracker.oc.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#import "easyar/types.oc.h"
#import "easyar/frame.oc.h"
/// <summary>
/// Result of `SurfaceTracker`_ .
/// </summary>
@interface easyar_SurfaceTrackerResult : easyar_FrameFilterResult
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Camera transform against world coordinate system. Camera coordinate system and world coordinate system are all right-handed. For the camera coordinate system, the origin is the optical center, x-right, y-up, and z in the direction of light going into camera. (The right and up, on mobile devices, is the right and up when the device is in the natural orientation.) For the world coordinate system, y is up (to the opposite of gravity). The data arrangement is row-major, not like OpenGL's column-major.
/// </summary>
- (easyar_Matrix44F *)transform;
@end
/// <summary>
/// SurfaceTracker implements tracking with environmental surfaces.
/// SurfaceTracker occupies one buffer of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to `Overview <Overview.html>`_ .
/// After creation, you can call start/stop to enable/disable the track process. start and stop are very lightweight calls.
/// When the component is not needed anymore, call close function to close it. It shall not be used after calling close.
/// SurfaceTracker inputs `InputFrame`_ from inputFrameSink. `InputFrameSource`_ shall be connected to inputFrameSink for use. Refer to `Overview <Overview.html>`_ .
/// </summary>
@interface easyar_SurfaceTracker : easyar_RefBase
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// <summary>
/// Returns true only on Android or iOS when accelerometer and gyroscope are available.
/// </summary>
+ (bool)isAvailable;
/// <summary>
/// `InputFrame`_ input port. InputFrame must have raw image, timestamp, and camera parameters.
/// </summary>
- (easyar_InputFrameSink *)inputFrameSink;
/// <summary>
/// Camera buffers occupied in this component.
/// </summary>
- (int)bufferRequirement;
/// <summary>
/// `OutputFrame`_ output port.
/// </summary>
- (easyar_OutputFrameSource *)outputFrameSource;
/// <summary>
/// Creates an instance.
/// </summary>
+ (easyar_SurfaceTracker *)create;
/// <summary>
/// Starts the track algorithm.
/// </summary>
- (bool)start;
/// <summary>
/// Stops the track algorithm. Call start to start the track again.
/// </summary>
- (void)stop;
/// <summary>
/// Close. The component shall not be used after calling close.
/// </summary>
- (void)close;
/// <summary>
/// Sets the tracking target to a point on camera image. For the camera image coordinate system ([0, 1]^2), x-right, y-down, and origin is at left-top corner. `CameraParameters.imageCoordinatesFromScreenCoordinates`_ can be used to convert points from screen coordinate system to camera image coordinate system.
/// </summary>
- (void)alignTargetToCameraImagePoint:(easyar_Vec2F *)cameraImagePoint;
@end
| 3,687
|
C++
|
.h
| 68
| 53.044118
| 510
| 0.706681
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,324
|
texture.h
|
wuyt_Kuromu/Assets/Plugins/EasyAR.bundle/Contents/Headers/texture.h
|
//=============================================================================================================================
//
// EasyAR Sense 4.0.0-final-7bc4102ce
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_TEXTURE_H__
#define __EASYAR_TEXTURE_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/// <summary>
/// Gets ID of an OpenGL/OpenGLES texture object.
/// </summary>
int easyar_TextureId_getInt(easyar_TextureId * This);
/// <summary>
/// Gets pointer of a Direct3D texture object.
/// </summary>
void * easyar_TextureId_getPointer(easyar_TextureId * This);
/// <summary>
/// Creates from ID of an OpenGL/OpenGLES texture object.
/// </summary>
void easyar_TextureId_fromInt(int _value, /* OUT */ easyar_TextureId * * Return);
/// <summary>
/// Creates from pointer of a Direct3D texture object.
/// </summary>
void easyar_TextureId_fromPointer(void * ptr, /* OUT */ easyar_TextureId * * Return);
void easyar_TextureId__dtor(easyar_TextureId * This);
void easyar_TextureId__retain(const easyar_TextureId * This, /* OUT */ easyar_TextureId * * Return);
const char * easyar_TextureId__typeName(const easyar_TextureId * This);
#ifdef __cplusplus
}
#endif
#endif
| 1,651
|
C++
|
.h
| 37
| 43.378378
| 127
| 0.62866
|
wuyt/Kuromu
| 30
| 7
| 0
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,325
|
AntiJumpDisconnect.cpp
|
TheStarport_FLHook/plugins/anti_jump_disconnect/AntiJumpDisconnect.cpp
|
/**
* @date Feb 2010
* @author Cannon (Ported by Raikkonen 2022)
* @defgroup AntiJumpDisconnect Anti Jump Disconnect
* @brief
* The "Anti Jump Disconnect" plugin will kill a player if they disconnect during the jump animation.
* If tempban is loaded then they will also be banned for 5 minutes.
*
* @paragraph cmds Player Commands
* There are no player commands in this plugin.
*
* @paragraph adminCmds Admin Commands
* There are no admin commands in this plugin.
*
* @paragraph configuration Configuration
* No configuration file is needed.
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*
* @paragraph optional Optional Plugin Dependencies
* This plugin uses the "Temp Ban" plugin.
*/
// Includes
#include "AntiJumpDisconnect.h"
#include "Features/TempBan.hpp"
constexpr auto TempBanDurationMinutes = 5;
namespace Plugins::AntiJumpDisconnect
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
void ClearClientInfo(ClientId& client)
{
global->mapInfo[client].bInWrapGate = false;
}
/** @ingroup AntiJumpDisconnect
* @brief Kills and possibly bans the player. This depends on if the Temp Ban plugin is active.
*/
void KillBan(ClientId& client)
{
if (global->mapInfo[client].bInWrapGate)
{
if (const auto ban = Hk::Player::Kill(client); ban.has_error())
{
PrintUserCmdText(client, Hk::Err::ErrGetText(ban.error()));
return;
}
// tempban for 5 minutes
TempBanManager::i()->AddTempBan(client, TempBanDurationMinutes);
}
}
/** @ingroup AntiJumpDisconnect
* @brief Hook on Disconnect. Calls KillBan.
*/
void DisConnect(ClientId& client, [[maybe_unused]] const enum EFLConnection& state)
{
KillBan(client);
}
/** @ingroup AntiJumpDisconnect
* @brief Hook on CharacterInfoReq (Character Select screen). Calls KillBan.
*/
void CharacterInfoReq(ClientId& client, [[maybe_unused]] const bool& p2)
{
KillBan(client);
}
/** @ingroup AntiJumpDisconnect
* @brief Hook on JumpInComplete. Sets the "In Gate" variable to false.
*/
void JumpInComplete([[maybe_unused]] const SystemId& system, [[maybe_unused]] const ShipId& ship)
{
ClientId& client = Hk::Client::GetClientIdByShip(ship).value();
global->mapInfo[client].bInWrapGate = false;
}
/** @ingroup AntiJumpDisconnect
* @brief Hook on SystemSwitchOutComplete. Sets the "In Gate" variable to true.
*/
void SystemSwitchOutComplete([[maybe_unused]] const ShipId& ship, ClientId& client)
{
global->mapInfo[client].bInWrapGate = true;
}
} // namespace Plugins::AntiJumpDisconnect
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace Plugins::AntiJumpDisconnect;
DefaultDllMain();
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("Anti Jump Disconnect Plugin by Cannon");
pi->shortName("anti_jump_disconnect");
pi->mayUnload(true);
pi->returnCode(&global->returncode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::FLHook__ClearClientInfo, &ClearClientInfo, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__DisConnect, &DisConnect);
pi->emplaceHook(HookedCall::IServerImpl__CharacterInfoReq, &CharacterInfoReq);
pi->emplaceHook(HookedCall::IServerImpl__JumpInComplete, &JumpInComplete);
pi->emplaceHook(HookedCall::IServerImpl__SystemSwitchOutComplete, &SystemSwitchOutComplete);
}
| 3,493
|
C++
|
.cpp
| 97
| 33.659794
| 111
| 0.737807
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,326
|
LightControl.cpp
|
TheStarport_FLHook/plugins/light_control/LightControl.cpp
|
/**
* @date Feb, 2010
* @author Cannon (Ported by Nen)
* @defgroup LightControl Light Control
* @brief
* Adds functionality to change the lights on player ships.
*
* @paragraph cmds Player Commands
* All commands are prefixed with '/' unless explicitly specified.
* - lights show - Shows the current equipped lights.
* - lights options [Page Number] - Shows a page of lights that can be swapped to.
* - lights change <Light Point> <Item> - Swap a light.
*
* @paragraph adminCmds Admin Commands
* There are no admin commands in this plugin.
*
* @paragraph configuration Configuration
* @code
* {
* "bases": ["li01_01_base"],
* "cost": 0,
* "introMessage1": "Light customization facilities are available here.",
* "introMessage2": "Type /lights on your console to see options.",
* "lights": ["SmallWhite","LargeGreen"],
* "itemsPerPage": 24,
* "notifyAvailabilityOnEnter": false
* }
* @endcode
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*
* @paragraph optional Optional Plugin Dependencies
* This plugin has no dependencies.
*/
#include "LightControl.h"
#include "refl.hpp"
namespace Plugins::LightControl
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
auto RegexReplace(const jpWide::NumSub& m1, const void*, const void*)
{
return L" " + m1[0];
}
void LoadSettings()
{
auto config = Serializer::JsonToObject<Config>();
if (config.lights.empty())
{
for (const auto& lights = DataManager::c()->GetLights(); const auto& [id, light] : lights)
{
config.lights.emplace_back(stows(light.nickname));
}
// Save to populate it!
Serializer::SaveToJson(config);
}
// Sort into alphabetical order
std::ranges::sort(config.lights);
global->config = std::make_unique<Config>(config);
for (const auto& base : config.bases)
{
uint baseIdHash = CreateID(base.c_str());
global->config->baseIdHashes.emplace_back(baseIdHash);
}
for (const auto& light : config.lights)
{
uint lightIdHash = CreateID(wstos(light).c_str());
global->config->lightsHashed.emplace_back(lightIdHash);
}
}
/** @ingroup LightControl
* @brief Hook on BaseEnter. Shows availability messages if configured.
*/
void BaseEnter(const uint& baseId, ClientId& client)
{
if (!global->config->notifyAvailabilityOnEnter || std::ranges::find(global->config->baseIdHashes, baseId) == global->config->baseIdHashes.end())
{
return;
}
if (!global->config->introMessage1.empty())
PrintUserCmdText(client, global->config->introMessage1);
if (!global->config->introMessage2.empty())
PrintUserCmdText(client, global->config->introMessage2);
}
/** @ingroup LightControl
* @brief Returns a baseId if in a valid base.
*/
uint IsInValidBase(ClientId& client)
{
const auto baseId = Hk::Player::GetCurrentBase(client);
if (baseId.has_error())
{
const std::wstring errorString = Hk::Err::ErrGetText(baseId.error());
PrintUserCmdText(client, L"ERR:" + errorString);
return 0;
}
if (!global->config->baseIdHashes.empty() && std::ranges::find(global->config->baseIdHashes, baseId.value()) == global->config->baseIdHashes.end())
{
PrintUserCmdText(client, L"Light customization is not available at this facility.");
return 0;
}
return baseId.value();
}
/** @ingroup LightControl
* @brief Show the setup of the player's ship.
*/
void UserCmdShowSetup(ClientId& client)
{
PrintUserCmdText(client, L"Current light setup:");
std::vector<EquipDesc> lights;
const st6::list<EquipDesc>& eqLst = Players[client].equipDescList.equip;
for (const auto& i : eqLst)
{
if (std::ranges::find(global->config->lightsHashed, i.iArchId) == global->config->lightsHashed.end())
{
continue;
}
lights.emplace_back(i);
}
if (lights.empty())
{
PrintUserCmdText(client, L"Error: You have no valid hard points that can be changed. ");
return;
}
std::ranges::sort(lights, [](const EquipDesc& a, const EquipDesc& b) { return a.get_hardpoint().value < b.get_hardpoint().value; });
int itemNumber = 1;
for (const auto& i : lights)
{
const auto& index = std::ranges::find(global->config->lightsHashed, i.iArchId);
if (index == global->config->lightsHashed.end())
{
continue;
}
const auto& str = global->config->lights[std::distance(global->config->lightsHashed.begin(), index)];
PrintUserCmdText(client,
std::format(
L"| {}: {}", itemNumber, jpWide::MatchEvaluator(RegexReplace).setRegexObject(&global->regex).setSubject(str).setFindAll().nreplace()));
itemNumber++;
}
}
/** @ingroup LightControl
* @brief Shows the lights available to be used.
*/
void UserCmdListLights(ClientId& client, const std::wstring& param)
{
if (global->config->lights.empty())
{
PrintUserCmdText(client, L"Error: There are no available options. ");
return;
}
uint pageNumber = 0;
if (!GetParam(param, ' ', 1).empty())
{
pageNumber = ToUInt(GetParam(param, ' ', 1)) - 1;
}
else
{
pageNumber = 0;
}
const uint lightsSize = static_cast<int>(global->config->lights.size());
// +1 the quotient to account for the last page being the remainder.
const uint maxPages = global->config->lights.size() / global->config->itemsPerPage + 1;
if (pageNumber >= maxPages)
{
PrintUserCmdText(client, std::format(L"Error, invalid page number, the valid page numbers are any integer between 1 and {}", maxPages));
return;
}
PrintUserCmdText(client, std::format(L"Displaying {} items from page {} of {}", global->config->itemsPerPage, pageNumber + 1, maxPages));
uint j = 0;
for (uint i = pageNumber * global->config->itemsPerPage; (i < lightsSize && j < global->config->itemsPerPage); i++, j++)
{
PrintUserCmdText(
client, jpWide::MatchEvaluator(RegexReplace).setRegexObject(&global->regex).setSubject(global->config->lights[i]).setFindAll().nreplace());
}
}
/** @ingroup LightControl
* @brief Change the item on the Slot Id to the specified item.
*/
void UserCmdChangeItem(ClientId& client, const std::wstring& param)
{
if (const auto cash = Hk::Player::GetCash(client); cash.has_value() && cash.value() < global->config->cost)
{
PrintUserCmdText(client, std::format(L"Error: Not enough credits, the cost is {}", global->config->cost));
return;
}
std::vector<std::wstring> hardPointIds;
const std::wstring inputParam = (GetParam(param, ' ', 1));
if (inputParam != L"all")
{
for (const auto i : inputParam)
{
if (!(std::isdigit(i) || i == L'-'))
{
PrintUserCmdText(client,
L"Error: Please input an appropriate light point \n"
L"Example: 1-2-3 , 1 , or all.");
return;
}
}
hardPointIds = Split(inputParam, L'-');
if (hardPointIds.empty())
hardPointIds.emplace_back(inputParam);
}
const std::wstring selectedLight = ReplaceStr(ViewToWString(GetParamToEnd(param, ' ', 2)), L" ", L"");
std::vector<EquipDesc> lights;
st6::list<EquipDesc>& eqLst = Players[client].equipDescList.equip;
for (const auto& i : eqLst)
{
if (std::ranges::find(global->config->lightsHashed, i.iArchId) == global->config->lightsHashed.end())
{
continue;
}
lights.emplace_back(i);
}
if (lights.empty())
{
PrintUserCmdText(client, L"Error: You have no valid hard points that can be changed. ");
return;
}
std::ranges::sort(lights, [](const EquipDesc& a, const EquipDesc& b) { return a.get_hardpoint().value < b.get_hardpoint().value; });
// if the user inputted all, filling of hardpoint ids will be skipped and thus empty, fill it with all possible hard point indexes.
if (hardPointIds.empty())
{
for (uint i = 1; i < lights.size() + 1; i++)
{
hardPointIds.emplace_back(std::format(L"{}", i));
}
}
if (Hk::Player::GetCash(client).value() <= global->config->cost * hardPointIds.size())
{
PrintUserCmdText(client,
std::format(L"This light change require a total {} cash, you only have {} cash.",
global->config->cost * hardPointIds.size(),
Hk::Player::GetCash(client).value()));
return;
}
for (const auto& hardPointIdString : hardPointIds)
{
const auto hardPointId = ToUInt(hardPointIdString) - 1;
if (hardPointId > lights.size())
{
PrintUserCmdText(client, L"Error: Invalid light point");
return;
}
const auto lightId = CreateID(wstos(selectedLight).c_str());
if (std::ranges::find(global->config->lightsHashed, lightId) == global->config->lightsHashed.end())
{
PrintUserCmdText(client, std::format(L"ERR: {} is not a valid option", selectedLight));
return;
}
const auto& selectedLightEquipDesc = lights[hardPointId];
const auto light = std::find_if(
eqLst.begin(), eqLst.end(), [&selectedLightEquipDesc](const EquipDesc& eq) { return eq.get_id() == selectedLightEquipDesc.get_id(); });
light->iArchId = lightId;
auto err = Hk::Player::SetEquip(client, eqLst);
if (err.has_error())
{
PrintUserCmdText(client, L"ERR: " + Hk::Err::ErrGetText(err.error()));
return;
}
}
if (global->config->cost != 0)
{
const auto err = Hk::Player::RemoveCash(client, global->config->cost * hardPointIds.size());
if (err.has_error())
{
PrintUserCmdText(client, L"ERR: " + Hk::Err::ErrGetText(err.error()));
return;
}
}
Hk::Player::SaveChar(client);
PrintUserCmdText(client, L"Light(s) successfully changed, when you are finished with all your changes, log off for them to take effect. ");
}
/** @ingroup LightControl
* @brief Custom user command handler.
*/
void UserCommandHandler(ClientId& client, const std::wstring& param)
{
if (const auto subCommand = GetParam(param, ' ', 0); subCommand == L"change")
{
if (!IsInValidBase(client))
{
return;
}
UserCmdChangeItem(client, param);
}
else if (subCommand == L"show")
{
UserCmdShowSetup(client);
}
else if (subCommand == L"options")
{
UserCmdListLights(client, param);
}
else
{
PrintUserCmdText(client,
L"Usage: /lights show\n"
L"Usage: /lights options [page number]\n"
L"Usage: /lights change <Light Point> <Item>");
if (global->config->cost > 0)
{
PrintUserCmdText(client, std::format(L"Each light changed will cost {} credits.", global->config->cost));
}
PrintUserCmdText(client, L"Please log off for light changes to take effect.");
}
}
// Client command processing
const std::vector commands = {{
CreateUserCommand(L"/lights", L"", UserCommandHandler, L""),
}};
} // namespace Plugins::LightControl
using namespace Plugins::LightControl;
REFL_AUTO(
type(Config), field(lights), field(cost), field(bases), field(introMessage1), field(introMessage2), field(notifyAvailabilityOnEnter), field(itemsPerPage))
DefaultDllMainSettings(LoadSettings);
// Functions to hook
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("lightControl");
pi->shortName("lightControl");
pi->mayUnload(true);
pi->commands(&commands);
pi->returnCode(&global->returnCode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::IServerImpl__BaseEnter, &BaseEnter);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
}
| 11,375
|
C++
|
.cpp
| 329
| 31.100304
| 158
| 0.69137
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,327
|
Restarts.cpp
|
TheStarport_FLHook/plugins/restarts/Restarts.cpp
|
/**
* @date Feb 2010
* @author Cannon, ported by Raikkonen and Nen
* @defgroup Restarts Restarts
* @brief
* The plugin allows the players to apply a predefined template onto their character (ship, location, reps).
* Available restarts are stored as .fl files and should be located in EXE/config/restarts
*
* @paragraph cmds Player Commands
* -showrestarts - lists available templates
* -restart <restartName> - applies the chosen template onto this character
*
* @paragraph adminCmds Admin Commands
* None
*
* @paragraph configuration Configuration
* @code
* {
* "availableRestarts": {"zoner": 0},
* "enableRestartCost": false,
* "maxCash": 1000000,
* "maxRank": 5
* }
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*/
#include "Restarts.h"
namespace Plugins::Restart
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
void LoadSettings()
{
auto config = Serializer::JsonToObject<Config>();
global->config = std::make_unique<Config>(config);
}
/* User Commands */
void UserCmd_ShowRestarts(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
if (global->config->availableRestarts.empty())
{
PrintUserCmdText(client, L"There are no restarts available.");
return;
}
PrintUserCmdText(client, L"You can use these restarts:");
for (const auto& [key, value] : global->config->availableRestarts)
{
if (global->config->enableRestartCost)
{
PrintUserCmdText(client, std::format(L"{} - ${}", key, value));
}
else
{
PrintUserCmdText(client, key);
}
}
}
void UserCmd_Restart(ClientId& client, const std::wstring& param)
{
std::wstring restartTemplate = GetParam(param, ' ', 0);
if (!restartTemplate.length())
{
PrintUserCmdText(client, L"ERR Invalid parameters");
PrintUserCmdText(client, L"/restart <template>");
}
// Get the character name for this connection.
Restart restart;
restart.characterName = reinterpret_cast<const wchar_t*>(Players.GetActiveCharacterName(client));
// Searching restart
std::filesystem::path directory = "config\\restarts";
if (!std::filesystem::exists(directory))
{
PrintUserCmdText(client, L"There has been an error with the restarts plugin. Please contact an Administrator.");
AddLog(LogType::Normal, LogLevel::Err, "Missing restarts folder in config folder.");
return;
}
for (const auto& entity : std::filesystem::directory_iterator(directory))
{
if (entity.is_directory() || entity.path().extension().string() != ".fl")
{
continue;
}
if (entity.path().filename().string() == wstos(restartTemplate + L".fl"))
{
restart.restartFile = entity.path().string();
}
}
if (restart.restartFile.empty())
{
PrintUserCmdText(client, L"ERR Template does not exist");
return;
}
// Saving the characters forces an anti-cheat checks and fixes
// up a multitude of other problems.
Hk::Player::SaveChar(client);
if (!Hk::Client::IsValidClientID(client))
return;
if (auto base = Hk::Player::GetCurrentBase(client); base.has_error())
{
PrintUserCmdText(client, L"ERR Not in base");
return;
}
if (global->config->maxRank != 0)
{
const auto rank = Hk::Player::GetRank(restart.characterName);
if (rank.has_error() || rank.value() > global->config->maxRank)
{
PrintUserCmdText(client,
L"ERR You must create a new char to "
L"restart. Your rank is too high");
return;
}
}
const auto cash = Hk::Player::GetCash(restart.characterName);
if (cash.has_error())
{
PrintUserCmdText(client, L"ERR " + Hk::Err::ErrGetText(cash.error()));
return;
}
if (global->config->maxCash != 0 && cash > global->config->maxCash)
{
PrintUserCmdText(client,
L"ERR You must create a new char to "
L"restart. Your cash is too high");
return;
}
if (global->config->enableRestartCost)
{
if (cash < global->config->availableRestarts[restartTemplate])
{
PrintUserCmdText(client,
L"You need $" + std::to_wstring(global->config->availableRestarts[restartTemplate] - cash.value()) + L" more credits to use this template");
return;
}
restart.cash = cash.value() - global->config->availableRestarts[restartTemplate];
}
else
restart.cash = cash.value();
if (const CAccount* acc = Players.FindAccountFromClientID(client))
{
restart.directory = Hk::Client::GetAccountDirName(acc);
restart.characterFile = Hk::Client::GetCharFileName(restart.characterName).value();
global->pendingRestarts.push_back(restart);
Hk::Player::KickReason(restart.characterName, L"Updating character, please wait 10 seconds before reconnecting");
}
return;
}
/* Hooks */
void ProcessPendingRestarts()
{
while (global->pendingRestarts.size())
{
Restart restart = global->pendingRestarts.back();
if (!Hk::Client::GetClientIdFromCharName(restart.characterName).has_error())
return;
global->pendingRestarts.pop_back();
try
{
// Overwrite the existing character file
std::string scCharFile = CoreGlobals::c()->accPath + wstos(restart.directory) + "\\" + wstos(restart.characterFile) + ".fl";
std::string scTimeStampDesc = IniGetS(scCharFile, "Player", "description", "");
std::string scTimeStamp = IniGetS(scCharFile, "Player", "tstamp", "0");
if (!::CopyFileA(restart.restartFile.c_str(), scCharFile.c_str(), FALSE))
throw std::runtime_error("copy template");
FlcDecodeFile(scCharFile.c_str(), scCharFile.c_str());
IniWriteW(scCharFile, "Player", "name", restart.characterName);
IniWrite(scCharFile, "Player", "description", scTimeStampDesc);
IniWrite(scCharFile, "Player", "tstamp", scTimeStamp);
IniWrite(scCharFile, "Player", "money", std::to_string(restart.cash));
if (!FLHookConfig::i()->general.disableCharfileEncryption)
FlcEncodeFile(scCharFile.c_str(), scCharFile.c_str());
AddLog(
LogType::Normal, LogLevel::Info, std::format("User restart {} for {}", restart.restartFile.c_str(), wstos(restart.characterName).c_str()));
}
catch (char* err)
{
AddLog(LogType::Normal, LogLevel::Err, std::format("User restart failed ({}) for {}", err, wstos(restart.characterName).c_str()));
}
catch (...)
{
AddLog(LogType::Normal, LogLevel::Err, std::format("User restart failed for {}", wstos(restart.characterName)));
}
}
}
const std::vector<Timer> timers = {{ProcessPendingRestarts, 1}};
// Client command processing
const std::vector commands = {{
CreateUserCommand(L"/restart", L"<name>", UserCmd_Restart, L"Restart with a template. This wipes your character!"),
CreateUserCommand(L"/showrestarts", L"", UserCmd_ShowRestarts, L"Shows the available restarts on the server."),
}};
} // namespace Plugins::Restart
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace Plugins::Restart;
REFL_AUTO(type(Config), field(maxCash), field(maxRank), field(enableRestartCost), field(availableRestarts))
DefaultDllMainSettings(LoadSettings);
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("Restarts");
pi->shortName("restarts");
pi->mayUnload(true);
pi->commands(&commands);
pi->timers(&timers);
pi->returnCode(&global->returnCode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
}
| 7,528
|
C++
|
.cpp
| 207
| 32.898551
| 148
| 0.696887
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,328
|
DailyTasks.cpp
|
TheStarport_FLHook/plugins/daily_tasks/DailyTasks.cpp
|
/**
* @date 2024
* @author IrateRedKite
* @defgroup DailyTasks Daily Tasks
* @brief
* The plugin assigns randomly generated tasks to players that they can complete for a reward.
*
* @paragraph cmds Player Commands
* - showtasks - Shows the current tasks assigned to the player's account, time remaining and completion status.
* - resettasks - Resets and rerolls the player's assigned tasks. This can be done once per day.
* @paragraph adminCmds Admin Commands
* There are no admin commands in this plugin.
* @paragraph configuration Configuration
* @code
*{
* "itemRewardPool": {
* "commodity_alien_artifacts": [
* 10,
* 25
* ],
* "commodity_diamonds": [
* 25,
* 40
* ],
* "commodity_luxury_consumer_goods": [
* 5,
* 10
* ]
* },
* "maxCreditsReward": 10000,
* "minCreditsReward": 5000,
* "resetTime": 12,
* "taskDuration": 86400,
* "taskItemAcquisitionTargets": {
* "commodity_mox_fuel": [
* 8,
* 16
* ],
* "commodity_optronics": [
* 3,
* 5
* ],
* "commodity_super_alloys": [
* 10,
* 15
* ]
* },
* "taskNpcKillTargets": {
* "fc_x_grp": [
* 3,
* 5
* ],
* "li_n_grp": [
* 10,
* 15
* ]
* },
* "taskPlayerKillTargets": [
* 1,
* 3
* ],
* "taskQuantity": 3,
* "taskTradeBaseTargets": [
* "li03_01_base",
* "li03_02_base",
* "li03_03_base"
* ],
* "taskTradeItemTargets": {
* "commodity_cardamine": [
* 5,
* 10
* ],
* "commodity_construction_machinery": [
* 10,
* 25
* ],
* "commodity_scrap_metal": [
* 25,
* 40
* ]
* }
*}
* @endcode
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*
* @paragraph optional Optional Plugin Dependencies
* This plugin has no optional dependencies.
*/
// Includes
#include "DailyTasks.hpp"
namespace Plugins::DailyTasks
{
const auto global = std::make_unique<Global>();
void LoadSettings()
{
// Load JSON config
auto config = Serializer::JsonToObject<Config>();
global->config = std::make_unique<Config>(std::move(config));
// Check if task config values are populated. If they're populated, add them to the pool.
if (!global->config->taskItemAcquisitionTargets.empty())
{
global->taskTypePool.emplace_back(TaskType::GetItem);
}
if (!global->config->taskNpcKillTargets.empty())
{
global->taskTypePool.emplace_back(TaskType::KillNpc);
}
if (!global->config->taskPlayerKillTargets.empty())
{
global->taskTypePool.emplace_back(TaskType::KillPlayer);
}
if (!global->config->taskTradeBaseTargets.empty() && !global->config->taskTradeItemTargets.empty())
{
global->taskTypePool.emplace_back(TaskType::SellItem);
}
// Check if taskTypePool is empty after these checks and if so throw an error in the console.
if (global->taskTypePool.empty())
{
AddLog(LogType::Normal, LogLevel::Err, "No tasks have been defined in daily_tasks.json. No daily tasks will be generated.");
return;
}
AddLog(LogType::Normal,
LogLevel::Info,
std::format("{} possible random daily tasks have been loaded into the pool.", static_cast<int>(global->taskTypePool.size())));
// Convert the config inputs into something we can work with.
for (const auto& [key, value] : global->config->itemRewardPool)
{
global->itemRewardPool[CreateID(key.c_str())] = value;
}
for (const auto& [key, value] : global->config->taskTradeItemTargets)
{
global->taskTradeItemTargets[CreateID(key.c_str())] = value;
}
for (const auto& [key, value] : global->config->taskItemAcquisitionTargets)
{
global->taskItemAcquisitionTargets[CreateID(key.c_str())] = value;
}
for (const auto& [key, value] : global->config->taskNpcKillTargets)
{
global->taskNpcKillTargets[MakeId(key.c_str())] = value;
}
for (const auto& base : global->config->taskTradeBaseTargets)
{
global->taskTradeBaseTargets.emplace_back(CreateID(base.c_str()));
}
}
/** @ingroup DailyTasks
* @brief Fetches the value of goods defined in itemRewardPool for later use.
*/
void GetGoodBaseValues()
{
for (auto& good : *GoodList_get()->get_list())
{
if ((good->iType == 0 || good->iType == 1) && good->fPrice != 0 && global->itemRewardPool.contains(good->iArchId))
{
global->goodList.insert({good->iArchId, good->fPrice});
auto ids = good->iIdSName;
auto var = Hk::Message::GetWStringFromIdS(ids);
AddLog(LogType::Normal, LogLevel::Debug, std::format("Load prices in for {}", wstos(var)));
}
}
AddLog(LogType::Normal, LogLevel::Debug, std::format("Loaded {} goods into the reward pool", global->goodList.size()));
}
// Function: Generates a random int between min and max
int RandomNumber(int min, int max)
{
static std::random_device dev;
static auto engine = std::mt19937(dev());
auto range = std::uniform_int_distribution(min, max);
return range(engine);
}
// Function: Picks a random key from a map
uint RandomIdKey(std::map<uint, std::vector<int>> map)
{
auto iterator = map.begin();
std::advance(iterator, RandomNumber(0, map.size() - 1));
auto& outputId = iterator->first;
return outputId;
}
/** @ingroup DailyTasks
* @brief Saves the task status of an account to the appropriate tasks.json file.
*/
void SaveTaskStatusToJson(CAccount* account)
{
auto& taskList = global->accountTasks.at(account);
auto taskJsonPath = Hk::Client::GetAccountDirName(account);
char dataPath[MAX_PATH];
GetUserDataPath(dataPath);
Serializer::SaveToJson(taskList, std::format("{}\\Accts\\MultiPlayer\\{}\\daily_tasks.json", dataPath, wstos(taskJsonPath)));
AddLog(LogType::Normal,
LogLevel::Debug,
std::format("Saving a task status update to {}\\Accts\\MultiPlayer\\{}\\daily_tasks.json", dataPath, wstos(taskJsonPath)));
}
/** @ingroup DailyTasks
* @brief Writes the status of an account to the appropriate tasks.json file.
*/
void LoadTaskStatusFromJson(CAccount* account)
{
auto taskJsonPath = Hk::Client::GetAccountDirName(account);
char dataPath[MAX_PATH];
GetUserDataPath(dataPath);
auto taskList = Serializer::JsonToObject<Tasks>(std::format("{}\\Accts\\MultiPlayer\\{}\\daily_tasks.json", dataPath, wstos(taskJsonPath)), true);
global->accountTasks[account] = taskList;
}
/** @ingroup DailyTasks
* @brief Generates random rewards for users who complete daily tasks, based on parameters set in daily_tasks.json.
*/
void GenerateReward(ClientId& client, float holdSize = 0.f)
{
auto creditReward = RandomNumber(global->config->minCreditsReward, global->config->maxCreditsReward);
auto itemReward = RandomIdKey(global->itemRewardPool);
auto itemQuantity = RandomNumber(global->itemRewardPool[itemReward][0], global->itemRewardPool[itemReward][1]);
int surplusCreditReward = 0;
if (itemQuantity > static_cast<int>(holdSize))
{
surplusCreditReward = ((static_cast<int>(holdSize) - itemQuantity) * -1) * static_cast<int>(global->goodList[itemReward]);
itemQuantity = static_cast<int>(holdSize);
}
Hk::Player::AddCash(client, creditReward + surplusCreditReward);
if (itemQuantity)
{
Hk::Player::AddCargo(client, itemReward, itemQuantity, false);
if (const auto& equip = Players[client].equipDescList.equip; &equip != &Players[client].lShadowEquipDescList.equip)
{
Players[client].lShadowEquipDescList.equip = equip;
}
}
PrintUserCmdText(client,
std::format(L"Task completed! You have been awarded {} credits and {} units of {}.",
creditReward + surplusCreditReward,
itemQuantity,
Hk::Message::GetWStringFromIdS(Archetype::GetEquipment(itemReward)->iIdsName)));
}
/** @ingroup DailyTasks
* @brief Hook on ShipDestroyed to see if a task needs to be updated.
*/
void ShipDestroyed([[maybe_unused]] DamageList** damage, const DWORD** ecx, const uint& kill)
{
if (kill == 1)
{
const CShip* ship = Hk::Player::CShipFromShipDestroyed(ecx);
if (ClientId client = ship->GetOwnerPlayer())
{
const DamageList* dmg = *damage;
const auto killerId = Hk::Client::GetClientIdByShip(
dmg->get_cause() == DamageCause::Unknown ? ClientInfo[client].dmgLast.get_inflictor_id() : dmg->get_inflictor_id());
const auto victimId = Hk::Client::GetClientIdByShip(ship->get_id());
for (auto& task : global->accountTasks[Hk::Client::GetAccountByClientID(killerId.value())].tasks)
{
if (task.taskType == TaskType::KillPlayer && !task.isCompleted && victimId.has_value())
{
task.quantityCompleted++;
}
if (task.quantityCompleted == task.quantity && task.taskType == TaskType::KillPlayer && task.isCompleted == false)
{
auto remainingHoldSize = 0.f;
pub::Player::GetRemainingHoldSize(killerId.value(), remainingHoldSize);
task.isCompleted = true;
SaveTaskStatusToJson(Hk::Client::GetAccountByClientID(killerId.value()));
PrintUserCmdText(killerId.value(), std::format(L"You have completed {}", stows(task.taskDescription)));
Hk::Client::PlaySoundEffect(killerId.value(), CreateID("ui_gain_level"));
GenerateReward(killerId.value(), remainingHoldSize);
}
}
}
else
{
const DamageList* dmg = *damage;
const auto killerId = Hk::Client::GetClientIdByShip(
dmg->get_cause() == DamageCause::Unknown ? ClientInfo[client].dmgLast.get_inflictor_id() : dmg->get_inflictor_id());
int reputation;
pub::SpaceObj::GetRep(ship->get_id(), reputation);
uint affiliation;
pub::Reputation::GetAffiliation(reputation, affiliation);
for (auto& task : global->accountTasks[Hk::Client::GetAccountByClientID(killerId.value())].tasks)
{
if (task.taskType == TaskType::KillNpc && !task.isCompleted && task.npcFactionTarget == affiliation)
{
task.quantityCompleted++;
}
if (task.quantityCompleted == task.quantity && task.taskType == TaskType::KillNpc && !task.isCompleted &&
task.npcFactionTarget == affiliation)
{
auto remainingHoldSize = 0.f;
pub::Player::GetRemainingHoldSize(killerId.value(), remainingHoldSize);
task.isCompleted = true;
SaveTaskStatusToJson(Hk::Client::GetAccountByClientID(killerId.value()));
PrintUserCmdText(killerId.value(), std::format(L"You have completed {}", stows(task.taskDescription)));
Hk::Client::PlaySoundEffect(killerId.value(), CreateID("ui_gain_level"));
GenerateReward(killerId.value(), remainingHoldSize);
}
}
}
}
}
/** @ingroup DailyTasks
* @brief Hook on GFGoodSell to see if a task needs to be updated.
*/
void ItemSold(const struct SGFGoodSellInfo& gsi, ClientId& client)
{
auto base = Hk::Player::GetCurrentBase(client);
auto account = Hk::Client::GetAccountByClientID(client);
auto remainingHoldSize = 0.f;
pub::Player::GetRemainingHoldSize(client, remainingHoldSize);
for (auto& task : global->accountTasks[account].tasks)
{
if (task.isCompleted)
{
continue;
}
if (task.taskType == TaskType::SellItem && task.itemTarget == gsi.iArchId && task.baseTarget == base.value())
{
task.quantityCompleted += gsi.iCount;
if (task.quantityCompleted >= task.quantity)
{
task.isCompleted = true;
SaveTaskStatusToJson(account);
PrintUserCmdText(client, std::format(L"You have completed {}", stows(task.taskDescription)));
Hk::Client::PlaySoundEffect(client, CreateID("ui_gain_level"));
GenerateReward(client, remainingHoldSize);
}
}
else if (task.taskType == TaskType::GetItem && task.itemTarget == gsi.iArchId)
{
task.quantityCompleted = std::clamp(task.quantityCompleted - gsi.iCount, 0, task.quantity);
SaveTaskStatusToJson(account);
}
}
}
/** @ingroup DailyTasks
* @brief Hook on GFGoodBuy to see if a task needs to be updated.
*/
void ItemPurchased(SGFGoodBuyInfo const& gbi, ClientId& client)
{
auto base = Hk::Player::GetCurrentBase(client);
auto account = Hk::Client::GetAccountByClientID(client);
auto remainingHoldSize = 0.f;
pub::Player::GetRemainingHoldSize(client, remainingHoldSize);
for (auto& task : global->accountTasks[account].tasks)
{
if (task.isCompleted)
{
continue;
}
if (task.taskType == TaskType::GetItem && task.itemTarget == gbi.iGoodId)
{
task.quantityCompleted += gbi.iCount;
if (task.quantityCompleted >= task.quantity)
{
task.isCompleted = true;
SaveTaskStatusToJson(account);
PrintUserCmdText(client, std::format(L"You have completed {}", stows(task.taskDescription)));
Hk::Client::PlaySoundEffect(client, CreateID("ui_gain_level"));
auto purchasedCargoAmount = static_cast<float>(gbi.iCount);
GenerateReward(client, remainingHoldSize - purchasedCargoAmount);
}
}
else if (task.taskType == TaskType::SellItem && task.baseTarget == base.value() && task.itemTarget == gbi.iGoodId)
{
task.quantityCompleted = std::clamp(task.quantityCompleted - gbi.iCount, 0, task.quantity);
SaveTaskStatusToJson(account);
}
}
}
void GenerateIndividualTask(CAccount* account, TaskType taskType)
{
using enum TaskType;
Task task;
task.isCompleted = false;
task.quantityCompleted = 0;
task.setTime = Hk::Time::GetUnixSeconds();
if (taskType == GetItem)
{
auto itemAcquisitionTarget = RandomIdKey(global->taskItemAcquisitionTargets);
auto itemArch = Archetype::GetEquipment(itemAcquisitionTarget);
if (!itemArch)
{
AddLog(LogType::Normal, LogLevel::Err, "Failed to generate a GetItem task. No valid item ArchID was found. The task was not created.");
return;
}
task.taskType = GetItem;
task.itemTarget = itemAcquisitionTarget;
task.quantity =
RandomNumber(global->taskItemAcquisitionTargets.at(itemAcquisitionTarget)[0], global->taskItemAcquisitionTargets.at(itemAcquisitionTarget)[1]);
task.taskDescription = std::format("Buy {} units of {}.", task.quantity, wstos(Hk::Message::GetWStringFromIdS(itemArch->iIdsName)));
AddLog(LogType::Normal, LogLevel::Debug, std::format("Creating an 'Acquire Items' task to '{}'", task.taskDescription));
}
else if (taskType == KillNpc)
{
const auto& npcFactionTarget = RandomIdKey(global->taskNpcKillTargets);
auto npcQuantity = RandomNumber(global->taskNpcKillTargets.at(npcFactionTarget)[0], global->taskNpcKillTargets.at(npcFactionTarget)[1]);
uint npcFactionIds;
pub::Reputation::GetGroupName(npcFactionTarget, npcFactionIds);
task.taskType = KillNpc;
task.taskDescription = std::format("Destroy {} ships belonging to {}", npcQuantity, wstos(Hk::Message::GetWStringFromIdS(npcFactionIds)));
task.npcFactionTarget = npcFactionTarget;
task.quantity = npcQuantity;
AddLog(LogType::Normal, LogLevel::Debug, std::format("Creating a 'Kill NPCs' task to '{}'", task.taskDescription));
}
else if (taskType == KillPlayer)
{
task.taskType = KillPlayer;
task.quantity = RandomNumber(global->config->taskPlayerKillTargets[0], global->config->taskPlayerKillTargets[1]);
task.taskDescription = std::format("Destroy {} player ships.", task.quantity);
AddLog(LogType::Normal, LogLevel::Debug, std::format("Creating a 'Kill Players' task to '{}'", task.taskDescription));
}
else if (taskType == SellItem)
{
const auto& tradeBaseTarget = global->taskTradeBaseTargets[RandomNumber(0, global->taskTradeBaseTargets.size() - 1)];
auto tradeItemTarget = RandomIdKey(global->taskTradeItemTargets);
auto baseArch = Universe::get_base(tradeBaseTarget);
auto itemArch = Archetype::GetEquipment(tradeItemTarget);
if (!baseArch || !itemArch)
{
AddLog(LogType::Normal,
LogLevel::Err,
"Failed to generate a SellItem task. No valid item ArchID or base BaseID was found. The task was not created.");
return;
}
task.taskType = SellItem;
task.baseTarget = tradeBaseTarget;
task.itemTarget = tradeItemTarget;
task.quantity = RandomNumber(global->taskTradeItemTargets.at(tradeItemTarget)[0], global->taskTradeItemTargets.at(tradeItemTarget)[1]);
task.taskDescription = std::format("Sell {} units of {} at {}.",
task.quantity,
wstos(Hk::Message::GetWStringFromIdS(itemArch->iIdsName)),
wstos(Hk::Message::GetWStringFromIdS(baseArch->baseIdS)));
AddLog(LogType::Normal, LogLevel::Debug, std::format("Creating a 'Sell Cargo' task to '{}'", task.taskDescription));
}
if (!global->accountTasks.contains(account))
{
global->accountTasks[account] = {};
}
global->accountTasks[account].tasks.emplace_back(task);
}
/** @ingroup DailyTasks
* @brief Generates a daily task for a player and writes it to their config.json
*/
void GenerateDailyTask(CAccount* account)
{
using enum TaskType;
// Choose and create a random task from the available pool.
const auto& randomTask = global->taskTypePool[RandomNumber(0, global->taskTypePool.size() - 1)];
if (randomTask == GetItem)
{
GenerateIndividualTask(account, GetItem);
}
if (randomTask == KillNpc)
{
GenerateIndividualTask(account, KillNpc);
}
if (randomTask == KillPlayer)
{
GenerateIndividualTask(account, KillPlayer);
}
if (randomTask == SellItem)
{
GenerateIndividualTask(account, SellItem);
}
}
/** @ingroup DailyTasks
* @brief Hook OnBaseEnter to save any task updates to the user's config.json file.
*/
void SaveTaskStatusOnBaseEnter([[maybe_unused]] BaseId& baseId, ClientId& client)
{
auto account = Hk::Client::GetAccountByClientID(client);
SaveTaskStatusToJson(account);
}
void PrintTasks(ClientId& client)
{
auto account = Hk::Client::GetAccountByClientID(client);
PrintUserCmdText(client, L"CURRENT DAILY TASKS");
for (auto& task : global->accountTasks[account].tasks)
{
int taskExpiry = ((86400 - (Hk::Time::GetUnixSeconds() - task.setTime)) / 60) / 60;
if (!task.isCompleted)
{
PrintUserCmdText(client,
std::format(L"{} | Expires in {} hours | {}/{} remaining.",
stows(task.taskDescription),
taskExpiry,
task.quantity - task.quantityCompleted,
task.quantity));
}
else
{
PrintUserCmdText(client, stows(task.taskDescription + " | Task Completed"));
}
}
}
/** @ingroup DailyTasks
* @brief Hook on PlayerLaunch to display the task list when the player undocks.
*/
void DisplayTasksOnLaunch([[maybe_unused]] const std::string_view& charFilename, ClientId& client)
{
if (global->config->displayMessage)
{
PrintTasks(client);
PrintUserCmdText(client, L"To view this list again, type /showtasks in chat.");
}
}
/** @ingroup DailyTasks
* @brief Iterates over online players and checks the time status of their tasks, clearing and resetting them if they exceed 24 hours.
*/
void DailyTaskCheck()
{
auto onlinePlayers = Hk::Admin::GetPlayers();
auto currentTime = Hk::Time::GetUnixSeconds();
for (const auto& players : onlinePlayers)
{
auto account = Hk::Client::GetAccountByClientID(players.client);
auto accountId = account->wszAccId;
for (const auto& tasks : global->accountTasks[account].tasks)
{
if ((currentTime - tasks.setTime) < 86400)
{
return;
}
AddLog(LogType::Normal, LogLevel::Debug, std::format("Tasks for {} are out of date, refreshing and creating new tasks...", wstos(accountId)));
global->accountTasks[account].tasks.erase(global->accountTasks[account].tasks.begin(), global->accountTasks[account].tasks.end());
for (int iterator = 0; iterator < global->config->taskQuantity; iterator++)
{
GenerateDailyTask(account);
}
}
}
}
/** @ingroup DailyTasks
* @brief Keeps track of time and initiates cleanup once per day.
*/
void DailyTimerTick()
{
// Checks the current hour to see if global->dailyReset should be flipped back to false
if (std::chrono::duration_cast<std::chrono::hours>(std::chrono::system_clock::now().time_since_epoch()).count() % 24 == global->config->resetTime ||
std::chrono::duration_cast<std::chrono::hours>(std::chrono::system_clock::now().time_since_epoch()).count() % 24 == global->config->resetTime + 1 &&
global->dailyReset == false)
{
global->dailyReset = true;
global->tasksReset.clear();
}
else
{
global->dailyReset = false;
}
DailyTaskCheck();
}
/** @ingroup DailyTasks
* @brief A user command to show the tasks a player currently has and their status.
*/
void UserCmdShowDailyTasks(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
PrintTasks(client);
}
/** @ingroup DailyTasks
* @brief A user command to reset the user's tasks and reroll them if they have not already started to complete them.
*/
void UserCmdResetDailyTasks(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
auto account = Hk::Client::GetAccountByClientID(client);
auto accountId = account->wszAccId;
for (const auto& tasks : global->accountTasks[account].tasks)
{
if (tasks.isCompleted)
{
PrintUserCmdText(client,
std::format(L"You have completed one or more of your daily tasks today, and cannot reset them until {}:00", global->config->resetTime));
return;
}
}
if (global->tasksReset[account] == false)
{
AddLog(LogType::Normal, LogLevel::Debug, std::format("{} is resetting their daily tasks.", wstos(accountId)));
global->accountTasks[account].tasks.erase(global->accountTasks[account].tasks.begin(), global->accountTasks[account].tasks.end());
for (int iterator = 0; iterator < global->config->taskQuantity; iterator++)
{
GenerateDailyTask(account);
}
global->tasksReset[account] = true;
SaveTaskStatusToJson(account);
PrintUserCmdText(client, L"Your daily tasks have been reset.");
}
else
{
PrintUserCmdText(client, L"You've already reset your daily tasks for today.");
}
}
/** @ingroup DailyTasks
* @brief Hook on Login to check a player's task status and assign new tasks if they don't have any or their previous ones had expired.
*/
void OnLogin([[maybe_unused]] struct SLoginInfo const& login, ClientId& client)
{
auto account = Hk::Client::GetAccountByClientID(client);
auto accountId = account->wszAccId;
LoadTaskStatusFromJson(account);
AddLog(LogType::Normal, LogLevel::Debug, std::format("Loading tasks for {} from stored json file...", wstos(accountId)));
if (global->accountTasks[account].tasks.empty())
{
AddLog(LogType::Normal, LogLevel::Debug, std::format("No tasks saved for {}, creating new tasks...", wstos(accountId)));
for (int iterator = 0; iterator < global->config->taskQuantity; iterator++)
{
GenerateDailyTask(account);
}
SaveTaskStatusToJson(account);
return;
}
else
{
// If tasks are older than 24 hours, refresh them.
if ((Hk::Time::GetUnixSeconds() - global->accountTasks[account].tasks[0].setTime) > 86400)
{
AddLog(LogType::Normal, LogLevel::Debug, std::format("Tasks for {} are out of date, refreshing and creating new tasks...", wstos(accountId)));
global->accountTasks[account].tasks.erase(global->accountTasks[account].tasks.begin(), global->accountTasks[account].tasks.end());
for (int iterator = 0; iterator < global->config->taskQuantity; iterator++)
{
GenerateDailyTask(account);
}
}
SaveTaskStatusToJson(account);
return;
}
}
const std::vector commands = {{
CreateUserCommand(L"/showtasks", L"", UserCmdShowDailyTasks, L"Shows a list of current daily tasks for the user"),
CreateUserCommand(L"/resettasks", L"", UserCmdResetDailyTasks, L"Resets the user's daily tasks if none have already been completed"),
}};
} // namespace Plugins::DailyTasks
using namespace Plugins::DailyTasks;
REFL_AUTO(type(Config), field(taskQuantity), field(minCreditsReward), field(maxCreditsReward), field(itemRewardPool), field(taskTradeBaseTargets),
field(taskTradeItemTargets), field(taskItemAcquisitionTargets), field(taskNpcKillTargets), field(taskPlayerKillTargets), field(taskDuration),
field(resetTime), field(displayMessage));
REFL_AUTO(type(Tasks), field(tasks));
REFL_AUTO(type(Task), field(taskType), field(quantity), field(itemTarget), field(baseTarget), field(npcFactionTarget), field(taskDescription),
field(isCompleted), field(setTime), field(quantityCompleted));
DefaultDllMainSettings(LoadSettings);
const std::vector<Timer> timers = {{DailyTimerTick, 3600}};
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("Daily Tasks");
pi->shortName("dailytasks");
pi->mayUnload(true);
pi->commands(&commands);
pi->timers(&timers);
pi->returnCode(&global->returnCode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__Startup, &GetGoodBaseValues, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__Login, &OnLogin, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__GFGoodBuy, &ItemPurchased, HookStep::After);
pi->emplaceHook(HookedCall::IEngine__ShipDestroyed, &ShipDestroyed);
pi->emplaceHook(HookedCall::IServerImpl__GFGoodSell, &ItemSold, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__BaseEnter, &SaveTaskStatusOnBaseEnter, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__CharacterSelect, &DisplayTasksOnLaunch);
}
| 25,632
|
C++
|
.cpp
| 656
| 35.471037
| 154
| 0.704936
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,329
|
NPCControl.cpp
|
TheStarport_FLHook/plugins/npc_control/NPCControl.cpp
|
/**
* @date Dec, 2015
* @author Discovery Devs, Raikkonen
* @defgroup NPCControl NPC Control
* @brief
* The NPC Control plugin allows admins to spawn and control NPC ships using any ship loadout in the server files.
* This is especially useful during events.
*
* @paragraph cmds Player Commands
* None
*
* @paragraph adminCmds Admin Commands
* All commands are prefixed with '.' unless explicitly specified.
* - aicreate [number] [name] - Creates X amount of the specified NPCs. The name for the NPC is configured in the json file.
* - aidestroy - Destroys the targeted ship if it was spawned using this plugin. Otherwise, destroy all spawned ships.
* - aicancel - Cancels the current command given to the npcs.
* - aifollow [player] - Instructs all spawned ships to follow the targeted player, or the character specified in the command.
* - aicome - Make the spawned ships fly to your position.
* - aifleet [name] - Spawn a fleet of ships specified in the config file.
* - fleetlist - List available fleets to spawn.
* - npclist - List available singular NPCs.
*
* @paragraph configuration Configuration
* @code
* {
* "fleetInfo": {
* "example": {
* "member": {
* "example": 5
* },
* "name": "example"
* }
* },
* "npcInfo": {
* "example": {
* "graph": "FIGHTER",
* "iff": "fc_fl_grp",
* "infocard2Id": 197809,
* "infocardId": 197808,
* "loadout": "MP_ge_fighter",
* "pilot": "pilot_pirate_ace",
* "shipArch": "ge_fighter"
* }
* },
* "npcInfocardIds": [
* 197808
* ],
* "startupNpcs": [
* {
* "name": "example",
* "position": [
* -33367.0,
* 120.0,
* -28810.0
* ],
* "spawnChance": 1.0,
* "rotation": [
* 0.0,
* 0.0,
* 0.0
* ],
* "system": "li01"
* }
* ]
* }
* @endcode
*
* @paragraph ipc IPC Interfaces Exposed
* NpcCommunicator: exposes CreateNpc method with parameters (const std::wstring& name, Vector position, const Matrix& rotation, SystemId systemId, bool
* varyPosition)
*/
#define SPDLOG_USE_STD_FORMAT
#include "NPCControl.h"
namespace Plugins::Npc
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
/** @ingroup NPCControl
* @brief Returns a random float between two numbers
*/
float RandomFloatRange(float a, float b)
{
return ((b - a) * (static_cast<float>(rand()) / RAND_MAX)) + a;
}
/** @ingroup NPCControl
* @brief Return random infocard Id from list that was loaded in
*/
uint RandomInfocardID()
{
int randomIndex = rand() % global->config->npcInfocardIds.size();
return global->config->npcInfocardIds.at(randomIndex);
}
/** @ingroup NPCControl
* @brief Checks if a ship is one of our spawned NPCs and if so, removes it from our data
*/
bool IsHookNPC(CShip* ship)
{
// If it's a player do nothing
if (ship->is_player() == true)
{
return false;
}
// Is it a FLHook NPC?
auto iter = global->spawnedNpcs.begin();
while (iter != global->spawnedNpcs.end())
{
if (*iter == ship->get_id())
{
ship->clear_equip_and_cargo();
global->spawnedNpcs.erase(iter);
return true;
}
iter++;
}
return false;
}
/** @ingroup NPCControl
* @brief Hook on ship destroyed to remove from our data
*/
void ShipDestroyed([[maybe_unused]] DamageList** _dmg, [[maybe_unused]] const DWORD** ecx, const uint& kill)
{
if (kill)
{
CShip* cShip = Hk::Player::CShipFromShipDestroyed(ecx);
IsHookNPC(cShip);
}
}
/** @ingroup NPCControl
* @brief Checks to ensure an NPC is valid before attempting to spawn it. loadout, iff and pilot are all optional, but do require valid values to
* avoid a crash if populated
*/
bool CheckNpc(const std::wstring& npcName)
{
auto npc = global->config->npcInfo.find(npcName);
if (npc == global->config->npcInfo.end())
{
Console::ConErr(std::format("The provided NPC name, '{}' was not found.", wstos(npcName)));
return false;
}
bool validity = true;
// Check solar solarArch is valid
if (!Archetype::GetShip(CreateID(npc->second.shipArch.c_str())))
{
Console::ConErr(std::format("The shipArch '{}' for '{}' is invalid. Spawning this NPC may cause a crash", npc->second.shipArch, wstos(npcName)));
validity = false;
}
// Check the loadout is valid
EquipDescVector loadout;
pub::GetLoadout(loadout, npc->second.loadoutId);
if (!npc->second.loadout.empty() && loadout.equip.empty())
{
Console::ConErr(
std::format("The loadout '{}' loaded for '{}' is invalid. Spawning this NPC may cause a crash", npc->second.loadout, wstos(npcName)));
validity = false;
}
// Check if solar iff is valid
uint npcIff;
pub::Reputation::GetReputationGroup(npcIff, npc->second.iff.c_str());
if (!npc->second.iff.empty() && npcIff == UINT_MAX)
{
Console::ConErr(
std::format("The reputation '{}' loaded for '{}' is invalid. Spawning this NPC may cause a crash", npc->second.iff, wstos(npcName)));
validity = false;
}
// Check solar pilot is valid
if (!npc->second.pilot.empty() && !Hk::Personalities::GetPersonality(npc->second.pilot).has_value())
{
Console::ConErr(std::format("The pilot '{}' loaded for '{}' is invalid. Spawning this NPC may cause a crash", npc->second.pilot, wstos(npcName)));
validity = false;
}
return validity;
}
/** @ingroup NPCControl
* @brief Function to spawn an NPC
*/
uint CreateNPC(const std::wstring& name, Vector position, const Matrix& rotation, SystemId systemId, bool varyPosition)
{
if (!CheckNpc(name))
{
Console::ConWarn(std::format("Unable to spawn '{}', invalid data was found in the npcInfo", wstos(name)));
return 0;
}
Console::ConDebug(std::format("Spawning npc '{}'", wstos(name)));
Npc arch = global->config->npcInfo[name];
pub::SpaceObj::ShipInfo si;
memset(&si, 0, sizeof(si));
si.iFlag = 1;
si.iSystem = systemId;
si.shipArchetype = arch.shipArchId;
si.mOrientation = rotation;
si.iLoadout = arch.loadoutId;
si.iLook1 = CreateID("li_newscaster_head_gen_hat");
si.iLook2 = CreateID("pl_female1_journeyman_body");
si.iComm = CreateID("comm_br_darcy_female");
si.iPilotVoice = CreateID("pilot_f_leg_f01a");
si.iHealth = -1;
si.iLevel = 19;
if (varyPosition)
{
si.vPos.x = position.x + RandomFloatRange(0, 1000);
si.vPos.y = position.y + RandomFloatRange(0, 1000);
si.vPos.z = position.z + RandomFloatRange(0, 2000);
}
else
{
si.vPos.x = position.x;
si.vPos.y = position.y;
si.vPos.z = position.z;
}
// Define the string used for the scanner name. Because the
// following entry is empty, the pilot_name is used. This
// can be overriden to display the ship type instead.
FmtStr scanner_name(0, nullptr);
scanner_name.begin_mad_lib(0);
scanner_name.end_mad_lib();
// Define the string used for the pilot name. The example
// below shows the use of multiple part names.
FmtStr pilot_name(0, nullptr);
pilot_name.begin_mad_lib(16163); // ids of "%s0 %s1"
if (arch.infocardId != 0)
{
pilot_name.append_string(arch.infocardId);
if (arch.infocard2Id != 0)
{
pilot_name.append_string(arch.infocard2Id);
}
}
else
{
pilot_name.append_string(RandomInfocardID()); // ids that replaces %s0
pilot_name.append_string(RandomInfocardID()); // ids that replaces %s1
}
pilot_name.end_mad_lib();
pub::Reputation::Alloc(si.iRep, scanner_name, pilot_name);
pub::Reputation::SetAffiliation(si.iRep, arch.iffId);
// Get personality
pub::AI::SetPersonalityParams personalityParams;
personalityParams.iStateGraph = pub::StateGraph::get_state_graph(arch.graph.c_str(), pub::StateGraph::TYPE_STANDARD);
personalityParams.bStateId = true;
const auto personality = Hk::Personalities::GetPersonality(arch.pilot);
if (personality.has_error())
{
std::string errorMessage = arch.pilot + " is not recognised as a pilot name.";
AddLog(LogType::Normal, LogLevel::Err, errorMessage);
return 0;
}
personalityParams.personality = personality.value();
// Create the ship in space
uint spaceObj;
pub::SpaceObj::Create(spaceObj, si);
// Add the personality to the space obj
pub::AI::SubmitState(spaceObj, &personalityParams);
global->spawnedNpcs.push_back(spaceObj);
constexpr auto level = static_cast<spdlog::level::level_enum>(LogLevel::Info);
std::string logMessage = "Created " + wstos(name);
global->log->log(level, logMessage);
return spaceObj;
}
/** @ingroup NPCControl
* @brief Load plugin settings into memory
*/
void LoadSettings()
{
global->log = spdlog::basic_logger_mt<spdlog::async_factory>("npcs", "logs/npc.log");
auto config = Serializer::JsonToObject<Config>();
for (auto& [name, npc] : config.npcInfo)
{
npc.shipArchId = CreateID(npc.shipArch.c_str());
npc.loadoutId = CreateID(npc.loadout.c_str());
pub::Reputation::GetReputationGroup(npc.iffId, npc.iff.c_str());
}
for (auto& npc : config.startupNpcs)
{
// Check if defined startupNpcs are valid before spawning them
if (!config.npcInfo.contains(npc.name))
{
Console::ConErr(std::format("Attempted to load an NPC that was not defined in npcInfo: {}", wstos(npc.name)));
continue;
}
npc.systemId = CreateID(npc.system.c_str());
npc.positionVector.x = npc.position[0];
npc.positionVector.y = npc.position[1];
npc.positionVector.z = npc.position[2];
npc.rotationMatrix = EulerMatrix({npc.rotation[0], npc.rotation[1], npc.rotation[2]});
}
global->config = std::make_unique<Config>(config);
}
/** @ingroup NPCControl
* @brief Main Load Settings function, calls the one above. Had to use this hook instead of LoadSettings otherwise NPCs wouldnt appear on server startup
*/
void AfterStartup()
{
LoadSettings();
// Check validity of NPCs on server startup and print any problems to the console
for (const auto& [key, value] : global->config->npcInfo)
{
CheckNpc(key);
}
// Initalize for random number generator (new C++ 11 standard)
std::random_device rd; // Used to obtain a seed
std::mt19937 mt(rd()); // Mersenne Twister algorithm seeded with the variable above
std::uniform_real_distribution<float> dist(0.0f, 1.0f);
int spawned = 0;
// Some checks on load, to ensure that values provided for NPCs are valid. Unfortunately we can't easily check loadouts or the state graph here
for (const auto& [key, value] : global->config->npcInfo)
{
// Check if NPC iff is valid
uint npcIff;
pub::Reputation::GetReputationGroup(npcIff, value.iff.c_str());
if (npcIff == UINT_MAX)
{
Console::ConErr(std::format("Loaded invalid reputation {}", value.iff));
}
// Check NPC pilot is valid
if (!Hk::Personalities::GetPersonality(value.pilot).has_value())
{
Console::ConErr(std::format("Loaded invalid pilot {}", value.pilot));
}
// Check NPC shipArch is valid
if (!Archetype::GetShip(CreateID(value.shipArch.c_str())))
{
Console::ConErr(std::format("Attempted to load invalid shipArch {}", value.shipArch));
}
}
for (const auto& npc : global->config->startupNpcs)
{
// Check spawn chance is valid
if (npc.spawnChance < 0 || npc.spawnChance > 1)
{
Console::ConErr(std::format("Spawn chance must be between 0 and 1 for NPC '{}'", wstos(npc.name)));
continue;
}
// Spawn NPC if spawn chance allows it
if (dist(mt) <= npc.spawnChance)
{
CreateNPC(npc.name, npc.positionVector, npc.rotationMatrix, npc.systemId, false);
spawned++;
}
}
Console::ConInfo(std::format("{} NPCs loaded on startup", spawned));
}
/** @ingroup NPCControl
* @brief Admin command to make NPCs
*/
void AdminCmdAIMake(CCmds* cmds, int amount, const std::wstring& NpcType)
{
if (!(cmds->rights & RIGHT_SUPERADMIN))
{
cmds->Print("ERR No permission");
return;
}
if (!amount)
amount = 1;
if (const auto& iter = global->config->npcInfo.find(NpcType); iter == global->config->npcInfo.end())
{
cmds->Print("ERR Wrong NPC name");
return;
}
const auto ship = Hk::Player::GetShip(Hk::Client::GetClientIdFromCharName(cmds->GetAdminName()).value());
if (!ship.has_value())
return;
SystemId system = Hk::Player::GetSystem(Hk::Client::GetClientIdFromCharName(cmds->GetAdminName()).value()).value();
auto [position, rotation] = Hk::Solar::GetLocation(ship.value(), IdType::Ship).value();
// Creation counter
for (int i = 0; i < amount; i++)
{
CreateNPC(NpcType, position, rotation, system, true);
}
}
/** @ingroup NPCControl
* @brief Admin command to destroy the AI
*/
void AdminCmdAIKill(CCmds* commands)
{
if (!(commands->rights & RIGHT_SUPERADMIN))
{
commands->Print("ERR No permission");
return;
}
// Destroy targeted ship
if (commands->IsPlayer())
{
if (auto const target = Hk::Player::GetTarget(commands->GetAdminName()); target.has_value())
{
if (const auto it = std::ranges::find(global->spawnedNpcs, target.value()); target.value() && it != global->spawnedNpcs.end())
{
pub::SpaceObj::Destroy(target.value(), DestroyType::FUSE);
commands->Print("OK");
return;
}
}
}
// Destroy all ships - Copy into new vector since the old one will be modified in ShipDestroy hook
for (std::vector<uint> tempSpawnedNpcs = global->spawnedNpcs; const auto& npc : tempSpawnedNpcs)
pub::SpaceObj::Destroy(npc, DestroyType::FUSE);
commands->Print("OK");
}
/** @ingroup NPCControl
* @brief Admin command to make AI come to your position
*/
void AdminCmdAICome(CCmds* commands)
{
if (!(commands->rights & RIGHT_SUPERADMIN))
{
commands->Print("ERR No permission");
return;
}
if (auto ship = Hk::Player::GetShip(Hk::Client::GetClientIdFromCharName(commands->GetAdminName()).value()); ship.has_value())
{
auto [pos, rot] = Hk::Solar::GetLocation(ship.value(), IdType::Ship).value();
for (const auto& npc : global->spawnedNpcs)
{
pub::AI::DirectiveCancelOp cancelOP;
pub::AI::SubmitDirective(npc, &cancelOP);
pub::AI::DirectiveGotoOp go;
go.iGotoType = 1;
go.vPos = pos;
go.vPos.x = pos.x + RandomFloatRange(0, 500);
go.vPos.y = pos.y + RandomFloatRange(0, 500);
go.vPos.z = pos.z + RandomFloatRange(0, 500);
go.fRange = 0;
pub::AI::SubmitDirective(npc, &go);
}
}
commands->Print("OK");
return;
}
void AiFollow(uint ship, uint npc)
{
pub::AI::DirectiveCancelOp cancelOP;
pub::AI::SubmitDirective(npc, &cancelOP);
pub::AI::DirectiveFollowOp testOP;
testOP.iFollowSpaceObj = ship;
testOP.fMaxDistance = 100;
pub::AI::SubmitDirective(npc, &testOP);
}
/** @ingroup NPCControl
* @brief Admin command to make AI follow target (or admin) until death
*/
void AdminCmdAIFollow(CCmds* commands, std::wstring characterName)
{
if (!(commands->rights & RIGHT_SUPERADMIN))
{
commands->Print("ERR No permission");
return;
}
// If no player specified follow the admin
uint client;
if (characterName == L"")
{
client = Hk::Client::GetClientIdFromCharName(commands->GetAdminName()).value();
characterName = commands->GetAdminName();
}
// Follow the player specified
else
client = Hk::Client::GetClientIdFromCharName(characterName).value();
if (client == UINT_MAX)
commands->Print(std::format("{} is not online", wstos(characterName)));
else
{
const auto ship = Hk::Player::GetShip(client);
if (ship.has_value())
{
if (const auto target = Hk::Player::GetTarget(client); target.has_value())
{
if (const auto it = std::ranges::find(global->spawnedNpcs, target.value()); target.value() && it != global->spawnedNpcs.end())
{
AiFollow(ship.value(), target.value());
}
else
{
for (const auto& npc : global->spawnedNpcs)
AiFollow(ship.value(), npc);
}
commands->Print(std::format("Following {}", wstos(characterName)));
}
}
else
{
commands->Print(std::format("{} is not in space", wstos(characterName)));
}
}
}
/** @ingroup NPCControl
* @brief Admin command to cancel the current operation
*/
void AdminCmdAICancel(CCmds* commands)
{
if (!(commands->rights & RIGHT_SUPERADMIN))
{
commands->Print("ERR No permission");
return;
}
// Is the admin targeting an NPC?
if (const auto target = Hk::Player::GetTarget(commands->GetAdminName()); target.has_value())
{
if (const auto it = std::ranges::find(global->spawnedNpcs, target.value()); target.value() && it != global->spawnedNpcs.end())
{
pub::AI::DirectiveCancelOp cancelOp;
pub::AI::SubmitDirective(target.value(), &cancelOp);
}
}
// Cancel all NPC actions
else
{
for (const auto& npc : global->spawnedNpcs)
{
pub::AI::DirectiveCancelOp cancelOp;
pub::AI::SubmitDirective(npc, &cancelOp);
}
}
commands->Print("OK");
}
/** @ingroup NPCControl
* @brief Admin command to list NPCs
*/
void AdminCmdListNPCs(CCmds* commands)
{
if (!(commands->rights & RIGHT_SUPERADMIN))
{
commands->Print("ERR No permission");
return;
}
commands->Print(std::format("Available NPCs: {}", global->config->npcInfo.size()));
for (auto const& [name, npc] : global->config->npcInfo)
commands->Print(std::format("|{}", wstos(name)));
}
/** @ingroup NPCControl
* @brief Admin command to list NPC fleets
*/
void AdminCmdListNPCFleets(CCmds* cmds)
{
if (!(cmds->rights & RIGHT_SUPERADMIN))
{
cmds->Print("ERR No permission");
return;
}
cmds->Print(std::format("Available fleets: {}", global->config->fleetInfo.size()));
for (auto const& [name, npc] : global->config->fleetInfo)
cmds->Print(std::format("|{}", wstos(name)));
}
/** @ingroup NPCControl
* @brief Admin command to spawn a Fleet
*/
void AdminCmdAIFleet(CCmds* commands, const std::wstring& fleetName)
{
if (!(commands->rights & RIGHT_SUPERADMIN))
{
commands->Print("ERR No permission");
return;
}
if (const auto& iter = global->config->fleetInfo.find(fleetName); iter != global->config->fleetInfo.end())
for (auto const& [name, amount] : iter->second.member)
AdminCmdAIMake(commands, amount, name);
else
{
commands->Print("ERR Wrong Fleet name");
return;
}
}
/** @ingroup NPCControl
* @brief Admin command processing
*/
bool ExecuteCommandString(CCmds* commands, const std::wstring& cmd)
{
global->returnCode = ReturnCode::SkipAll;
if (cmd == L"aicreate")
AdminCmdAIMake(commands, commands->ArgInt(1), commands->ArgStr(2));
else if (cmd == L"aidestroy")
AdminCmdAIKill(commands);
else if (cmd == L"aicancel")
AdminCmdAICancel(commands);
else if (cmd == L"aifollow")
AdminCmdAIFollow(commands, commands->ArgCharname(1));
else if (cmd == L"aicome")
AdminCmdAICome(commands);
else if (cmd == L"aifleet")
AdminCmdAIFleet(commands, commands->ArgStr(1));
else if (cmd == L"fleetlist")
AdminCmdListNPCFleets(commands);
else if (cmd == L"npclist")
AdminCmdListNPCs(commands);
else
{
global->returnCode = ReturnCode::Default;
return false;
}
return true;
}
NpcCommunicator::NpcCommunicator(const std::string& plug) : PluginCommunicator(plug)
{
this->CreateNpc = CreateNPC;
}
} // namespace Plugins::Npc
using namespace Plugins::Npc;
DefaultDllMainSettings(AfterStartup);
REFL_AUTO(type(Npc), field(shipArch), field(loadout), field(iff), field(infocardId), field(infocard2Id), field(pilot), field(graph));
REFL_AUTO(type(Fleet), field(name), field(member));
REFL_AUTO(type(StartupNpc), field(name), field(system), field(position), field(rotation), field(spawnChance));
REFL_AUTO(type(Config), field(npcInfo), field(fleetInfo), field(startupNpcs), field(npcInfocardIds));
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name(NpcCommunicator::pluginName);
pi->shortName("npc");
pi->mayUnload(true);
pi->returnCode(&global->returnCode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::IServerImpl__Startup, &AfterStartup, HookStep::After);
pi->emplaceHook(HookedCall::FLHook__AdminCommand__Process, &ExecuteCommandString);
pi->emplaceHook(HookedCall::IEngine__ShipDestroyed, &ShipDestroyed);
// Register IPC
global->communicator = new NpcCommunicator(NpcCommunicator::pluginName);
PluginCommunicator::ExportPluginCommunicator(global->communicator);
}
| 20,664
|
C++
|
.cpp
| 614
| 30.408795
| 153
| 0.679289
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,330
|
NPCSpinProtection.cpp
|
TheStarport_FLHook/plugins/npc_spin_protection/NPCSpinProtection.cpp
|
/**
* @date Feb 2010
* @author Cannon, ported by Raikkonen
* @defgroup Stats Stats
* @brief
* The plugin tries to normalize the multiplayer specific unnatural physics.
*
* @paragraph cmds Player Commands
* None
*
* @paragraph adminCmds Admin Commands
* None
*
* @paragraph configuration Configuration
* @code
* {
* "spinImpulseMultiplier": -1.0,
* "spinProtectionMass": 180.0
* }
* @endcode
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*/
// Includes
#include "NPCSpinProtection.h"
namespace Plugins::NPCSpinProtection
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
// Load configuration file
void LoadSettings()
{
auto config = Serializer::JsonToObject<Config>();
global->config = std::make_unique<Config>(config);
}
void SPObjCollision(struct SSPObjCollisionInfo const& ci, ClientId& client)
{
// If spin protection is off, do nothing.
if (ci.iColliderObjectId == 0 || global->config->spinProtectionMass == -1.0f)
return;
float targetMass = Hk::Solar::GetMass(ci.iColliderObjectId).value();
// Don't do spin protect unless the hit ship is big
if (targetMass < global->config->spinProtectionMass)
return;
uint clientShip = Hk::Player::GetShip(client).value();
float clientMass = Hk::Solar::GetMass(clientShip).value();
// Don't do spin protect unless the hit ship is 2 times larger than the
// hitter
if (targetMass < clientMass * 2)
return;
auto motion = Hk::Solar::GetMotion(ci.iColliderObjectId);
if (motion.has_error())
{
Console::ConWarn(wstos(Hk::Err::ErrGetText(motion.error())));
return;
}
auto [V1, V2] = motion.value();
// crash prevention in case of null vectors
if (V1.x == 0.0f && V1.y == 0.0f && V1.z == 0.0f && V2.x == 0.0f && V2.y == 0.0f && V2.z == 0.0f)
return;
V1.x *= global->config->spinImpulseMultiplier * clientMass;
V1.y *= global->config->spinImpulseMultiplier * clientMass;
V1.z *= global->config->spinImpulseMultiplier * clientMass;
V2.x *= global->config->spinImpulseMultiplier * clientMass;
V2.y *= global->config->spinImpulseMultiplier * clientMass;
V2.z *= global->config->spinImpulseMultiplier * clientMass;
pub::SpaceObj::AddImpulse(ci.iColliderObjectId, V1, V2);
}
} // namespace Plugins::NPCSpinProtection
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FLHOOK STUFF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace Plugins::NPCSpinProtection;
DefaultDllMainSettings(LoadSettings);
REFL_AUTO(type(Config), field(spinProtectionMass), field(spinImpulseMultiplier))
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("Spin Protection");
pi->shortName("spin_protection");
pi->mayUnload(true);
pi->returnCode(&global->returnCode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__SPObjCollision, &SPObjCollision);
}
| 3,183
|
C++
|
.cpp
| 86
| 34.581395
| 111
| 0.681803
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,331
|
Message.cpp
|
TheStarport_FLHook/plugins/message/Message.cpp
|
/**
* @date Feb, 2010
* @author Cannon (Ported by Raikkonen)
* @defgroup Message Message
* @brief Handles different types of messages, banners and faction invitations.
*
* @paragraph cmds Player Commands
* All commands are prefixed with '/' unless explicitly specified.
* - setmsg <n> <msg text> - Sets a preset message.
* - showmsgs - Show your preset messages.
* - {0-9} - Send preset message from slot 0-9.
* - l{0-9} - Send preset message to local chat from slot 0-9.
* - g{0-9} - Send preset message to group chat from slot 0-9.
* - t{0-9} - Send preset message to last target from slot 0-9.
* - target <message> - Send a message to previous/current target.
* - reply <message> - Send a message to the last person to PM you.
* - privatemsg <charname> <message> - Send private message to the specified player.
* - factionmsg <tag> <message> - Send a message to the specified faction tag.
* - factioninvite <tag> - Send a group invite to online members of the specified tag.
* - lastpm - Shows the send of the last PM received.
* - set chattime <on/off> - Enable time stamps on chat.
* - me - Prints your name plus other text to system. Eg, /me thinks would say Bob thinks in system chat.
* - do - Prints red text to system chat.
* - time - Prints the current server time.
*
* @paragraph adminCmds Admin Commands
* There are no admin commands in this plugin.
*
* @paragraph configuration Configuration
* @code
* {
* "CustomHelp": false,
* "DisconnectSwearingInSpaceMsg": "%player has been kicked for swearing",
* "DisconnectSwearingInSpaceRange": 5000.0,
* "EnableDo": true,
* "EnableMe": true,
* "EnableSetMessage": false,
* "GreetingBannerLines": ["<TRA data="0xDA70D608" mask="-1"/><TEXT>Welcome to the server.</TEXT>"],
* "SpecialBannerLines": ["<TRA data="0x40B60000" mask="-1"/><TEXT>This is a special banner.</TEXT>"],
* "SpecialBannerTimeout": 5,
* "StandardBannerLines": ["<TRA data="0x40B60000" mask="-1"/><TEXT>Here is a standard banner.</TEXT>"],
* "StandardBannerTimeout": 60,
* "SuppressMistypedCommands": true,
* "SwearWords": [""]
* }
* @endcode
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*
* @paragraph optional Optional Plugin Dependencies
* - Mail
* - Tempban
*/
#include "Message.h"
#include "Features/Mail.hpp"
#include "Features/TempBan.hpp"
namespace Plugins::Message
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
long GetNumberFromCmd(const std::wstring& param)
{
const auto numStr = param[2];
wchar_t* _;
return std::wcstol(&numStr, &_, 10);
}
/** @ingroup Message
* @brief Load the msgs for specified client Id into memory.
*/
static void LoadMsgs(ClientId client)
{
// Load from disk the messages.
for (int msgSlot = 0; msgSlot < NumberOfSlots; msgSlot++)
{
global->info[client].slots[msgSlot] = Hk::Ini::GetCharacterIniString(client, L"msg." + std::to_wstring(msgSlot));
}
// Chat time settings.
global->info[client].showChatTime = Hk::Ini::GetCharacterIniBool(client, L"msg.chat_time");
}
/** @ingroup Message
* @brief Show the greeting banner to the specified player.
*/
static void ShowGreetingBanner(int client)
{
for (const auto& line : global->config->greetingBannerLines)
{
if (line.find(L"<TRA") == 0)
Hk::Message::FMsg(client, line);
else
PrintUserCmdText(client, line);
}
}
/** @ingroup Message
* @brief Load the custom message templates and show the greeting banner to the specified player.
*/
static void PlayerLogin([[maybe_unused]] const std::string_view& charFilename, ClientId& client)
{
LoadMsgs(client);
ShowGreetingBanner(client);
}
/** @ingroup Message
* @brief Show the special banner to all players.
*/
static void ShowSpecialBanner()
{
PlayerData* playerData = nullptr;
while ((playerData = Players.traverse_active(playerData)))
{
ClientId client = playerData->iOnlineId;
for (const auto& line : global->config->specialBannerLines)
{
if (line.find(L"<TRA") == 0)
Hk::Message::FMsg(client, line);
else
PrintUserCmdText(client, line);
}
}
}
/** @ingroup Message
* @brief Show the next standard banner to all players.
*/
static void ShowStandardBanner()
{
if (global->config->standardBannerLines.empty())
return;
static size_t curStandardBanner = 0;
if (++curStandardBanner >= global->config->standardBannerLines.size())
curStandardBanner = 0;
PlayerData* playerData = nullptr;
while ((playerData = Players.traverse_active(playerData)))
{
ClientId client = playerData->iOnlineId;
if (global->config->standardBannerLines[curStandardBanner].find(L"<TRA") == 0)
Hk::Message::FMsg(client, global->config->standardBannerLines[curStandardBanner]);
else
PrintUserCmdText(client, global->config->standardBannerLines[curStandardBanner].c_str());
}
}
/** @ingroup Message
* @brief Replace #t and #c tags with current target name and current ship location. Return false if tags cannot be replaced.
*/
static bool ReplaceMessageTags(ClientId client, const ClientInfo& clientData, std::wstring& msg)
{
if (msg.find(L"#t") != -1)
{
if (clientData.targetClientId == UINT_MAX)
{
PrintUserCmdText(client, L"ERR Target not available");
return false;
}
const auto targetName = Hk::Client::GetCharacterNameByID(clientData.targetClientId);
msg = ReplaceStr(msg, L"#t", targetName.value());
}
if (msg.find(L"#c") != -1)
{
const auto location = Hk::Solar::GetLocation(client, IdType::Client);
const auto system = Hk::Player::GetSystem(client);
const Vector& position = location.value().first;
if (location.has_value() && system.has_value())
{
const std::wstring curLocation = Hk::Math::VectorToSectorCoord<std::wstring>(system.value(), position);
msg = ReplaceStr(msg, L"#c", curLocation);
}
else
{
PrintUserCmdText(client, L"ERR Target not available");
return false;
}
}
return true;
}
/** @ingroup Message
* @brief Returns a string with the preset message
*/
std::wstring GetPresetMessage(ClientId client, int msgSlot)
{
const auto iter = global->info.find(client);
if (iter == global->info.end() || iter->second.slots[msgSlot].empty())
{
PrintUserCmdText(client, L"ERR No message defined");
return L"";
}
// Replace the tag #t with name of the targeted player.
std::wstring msg = iter->second.slots[msgSlot];
if (!ReplaceMessageTags(client, iter->second, msg))
return L"";
return msg;
}
/** @ingroup Message
* @brief Send an preset message to the local system chat
*/
void SendPresetLocalMessage(ClientId client, int msgSlot)
{
if (!global->config->enableSetMessage)
{
PrintUserCmdText(client, L"Set commands disabled");
return;
}
if (msgSlot < 0 || msgSlot > 9)
{
PrintUserCmdText(client, L"ERR Invalid parameters");
PrintUserCmdText(client, L"Usage: /ln (n=0-9)");
return;
}
Hk::Message::SendLocalSystemChat(client, GetPresetMessage(client, msgSlot));
}
/** @ingroup Message
* @brief Send a preset message to the last/current target.
*/
void SendPresetToLastTarget(ClientId client, int msgSlot)
{
if (!global->config->enableSetMessage)
{
PrintUserCmdText(client, L"Set commands disabled");
return;
}
UserCmd_SendToLastTarget(client, GetPresetMessage(client, msgSlot));
}
/** @ingroup Message
* @brief Send an preset message to the system chat
*/
void SendPresetSystemMessage(ClientId client, int msgSlot)
{
if (!global->config->enableSetMessage)
{
PrintUserCmdText(client, L"Set commands disabled");
return;
}
Hk::Message::SendSystemChat(client, GetPresetMessage(client, msgSlot));
}
/** @ingroup Message
* @brief Send an preset message to the last PM sender
*/
void SendPresetLastPMSender(ClientId& client, int msgSlot)
{
if (!global->config->enableSetMessage)
{
PrintUserCmdText(client, L"Set commands disabled");
return;
}
UserCmd_ReplyToLastPMSender(client, GetPresetMessage(client, msgSlot));
}
/** @ingroup Message
* @brief Send an preset message to the group chat
*/
void SendPresetGroupMessage(ClientId& client, int msgSlot)
{
if (!global->config->enableSetMessage)
{
PrintUserCmdText(client, L"Set commands disabled");
return;
}
Hk::Message::SendGroupChat(client, GetPresetMessage(client, msgSlot));
}
/** @ingroup Message
* @brief Clean up when a client disconnects
*/
void ClearClientInfo(ClientId& client)
{
global->info.erase(client);
}
/** @ingroup Message
* @brief This function is called when the admin command rehash is called and when the module is loaded.
*/
void LoadSettings()
{
// For every active player load their msg settings.
for (const auto& p : Hk::Admin::GetPlayers())
LoadMsgs(p.client);
auto config = Serializer::JsonToObject<Config>();
global->config = std::make_unique<Config>(config);
}
/** @ingroup Message
* @brief On this timer display banners
*/
void OneSecondTimer()
{
if (static int specialBannerTimer = 0; ++specialBannerTimer > global->config->specialBannerTimeout)
{
specialBannerTimer = 0;
ShowSpecialBanner();
}
if (static int standardBannerTimer = 0; ++standardBannerTimer > global->config->standardBannerTimeout)
{
standardBannerTimer = 0;
ShowStandardBanner();
}
}
const std::vector<Timer> timers = {{OneSecondTimer, 1}};
/** @ingroup Message
* @brief On client disconnect remove any references to this client.
*/
void DisConnect(ClientId& client, const enum EFLConnection [[maybe_unused]])
{
auto iter = global->info.begin();
while (iter != global->info.end())
{
if (iter->second.lastPmClientId == client)
iter->second.lastPmClientId = -1;
if (iter->second.targetClientId == client)
iter->second.targetClientId = -1;
++iter;
}
global->info.erase(client);
}
/** @ingroup Message
* @brief On client F1 or entry to char select menu.
*/
void CharacterInfoReq(unsigned int client, bool [[maybe_unused]])
{
auto iter = global->info.begin();
while (iter != global->info.end())
{
if (iter->second.lastPmClientId == client)
iter->second.lastPmClientId = -1;
if (iter->second.targetClientId == client)
iter->second.targetClientId = -1;
++iter;
}
}
/** @ingroup Message
* @brief When a char selects a target and the target is a player ship then record the target's client.
*/
void SetTarget(const ClientId& uClientId, struct XSetTarget const& p2)
{
// The iSpaceId *appears* to represent a player ship Id when it is
// targeted but this might not be the case. Also note that
// GetClientIdByShip returns 0 on failure not -1.
const auto targetClientId = Hk::Client::GetClientIdByShip(p2.iSpaceId);
if (targetClientId.has_value())
{
const auto iter = global->info.find(uClientId);
if (iter != global->info.end())
{
iter->second.targetClientId = targetClientId.value();
}
}
}
/** @ingroup Message
* @brief Hook on SubmitChat. Suppresses swearing. Records the last user to PM.
*/
bool SubmitChat(const ClientId& client, const unsigned long& msgSize, const void** rdlReader, const uint& cIdTo, const int [[maybe_unused]])
{
// Ignore group join/leave commands
if (cIdTo == 0x10004)
return false;
// Extract text from rdlReader
BinaryRDLReader rdl;
wchar_t wszBuf[1024];
uint iRet1;
rdl.extract_text_from_buffer((unsigned short*)wszBuf, sizeof(wszBuf), iRet1, (const char*)*rdlReader, msgSize);
const std::wstring chatMsg = ToLower(wszBuf);
if (const bool isGroup = (cIdTo == 0x10003 || !chatMsg.find(L"/g ") || !chatMsg.find(L"/group ")); !isGroup)
{
// If a restricted word appears in the message take appropriate action.
for (const auto& word : global->config->swearWords)
{
if (chatMsg.find(word) != -1)
{
PrintUserCmdText(client, L"This is an automated message.");
PrintUserCmdText(client, L"Please do not swear or you may be sanctioned.");
global->info[client].swearWordWarnings++;
if (global->info[client].swearWordWarnings > 2)
{
const std::wstring charname = reinterpret_cast<const wchar_t*>(Players.GetActiveCharacterName(client));
AddLog(LogType::Kick,
LogLevel::Info,
wstos(std::format(L"Swearing tempban on {} ({}) reason='{}'",
charname,
Hk::Client::GetAccountID(Hk::Client::GetAccountByCharName(charname).value()).value(),
chatMsg.c_str())));
TempBanManager::i()->AddTempBan(client,
global->config->swearingTempBanDuration,
std::format(L"Swearing tempban for {} minutes.", global->config->swearingTempBanDuration));
if (global->config->disconnectSwearingInSpaceRange > 0.0f)
{
std::wstring msg = global->config->disconnectSwearingInSpaceMsg;
msg = ReplaceStr(msg, L"%time", GetTimeString(FLHookConfig::i()->messages.dieMsg));
msg = ReplaceStr(msg, L"%player", charname);
PrintLocalUserCmdText(client, msg, global->config->disconnectSwearingInSpaceRange);
}
}
return true;
}
}
}
/// When a private chat message is sent from one client to another record
/// who sent the message so that the receiver can reply using the /r command
/// */
if (client < 0x10000 && cIdTo > 0 && cIdTo < 0x10000)
{
const auto iter = global->info.find(cIdTo);
if (iter != global->info.end())
{
iter->second.lastPmClientId = client;
}
}
return false;
}
/** @ingroup Message
* @brief Prints RedText in the style of New Player messages.
*/
void RedText(const std::wstring& XMLMsg, uint systemId)
{
char szBuf[0x1000];
uint iRet;
if (const auto err = Hk::Message::FMsgEncodeXML(XMLMsg, szBuf, sizeof(szBuf), iRet); err.has_error())
return;
// Send to all players in system
PlayerData* playerData = nullptr;
while ((playerData = Players.traverse_active(playerData)))
{
ClientId client = playerData->iOnlineId;
if (SystemId iClientSystemId = Hk::Player::GetSystem(client).value(); systemId == iClientSystemId)
Hk::Message::FMsgSendChat(client, szBuf, iRet);
}
}
/** @ingroup Message
* @brief When a chat message is sent to a client and this client has showchattime on insert the time on the line immediately before the chat message
*/
bool SendChat(ClientId& client, const uint& msgTarget, const uint& msgSize, void** rdlReader)
{
// Return immediately if the chat line is the time.
if (global->sendingTime)
return false;
// Ignore group messages (I don't know if they ever get here
if (msgTarget == 0x10004)
return false;
if (global->config->suppressMistypedCommands)
{
// Extract text from rdlReader
BinaryRDLReader rdl;
wchar_t wszBuf[1024];
uint iRet1;
const void* rdlReader2 = *rdlReader;
rdl.extract_text_from_buffer((unsigned short*)wszBuf, sizeof(wszBuf), iRet1, (const char*)rdlReader2, msgSize);
std::wstring chatMsg = wszBuf;
// Find the ': ' which indicates the end of the sending player name.
const size_t textStartPos = chatMsg.find(L": ");
if (textStartPos != std::string::npos &&
((chatMsg.find(L": /") == textStartPos && chatMsg.find(L": //") != textStartPos) || chatMsg.find(L": .") == textStartPos))
{
return true;
}
}
if (global->info[client].showChatTime)
{
// Send time with gray color (BEBEBE) in small text (90) above the chat
// line.
global->sendingTime = true;
Hk::Message::FMsg(
client, L"<TRA data=\"0xBEBEBE90\" mask=\"-1\"/><TEXT>" + XMLText(GetTimeString(FLHookConfig::i()->messages.dieMsg)) + L"</TEXT>");
global->sendingTime = false;
}
return false;
}
/** @ingroup Message
* @brief Set a preset message
*/
void UserCmd_SetMsg(ClientId& client, const std::wstring& param)
{
if (!global->config->enableSetMessage)
{
PrintUserCmdText(client, L"Set commands disabled");
return;
}
const int msgSlot = ToInt(GetParam(param, ' ', 0));
const std::wstring msg = GetParamToEnd(ViewToWString(param), ' ', 1);
if (msgSlot < 0 || msgSlot > 9 || msg.empty())
{
PrintUserCmdText(client, L"ERR Invalid parameters");
PrintUserCmdText(client, L"Usage: /setmsg <n> <msg text>");
return;
}
Hk::Ini::SetCharacterIni(client, L"msg." + std::to_wstring(msgSlot), ViewToWString(msg));
// Update the character cache
global->info[client].slots[msgSlot] = msg;
PrintUserCmdText(client, L"OK");
}
/** @ingroup Message
* @brief Show preset messages
*/
void UserCmd_ShowMsgs(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
if (!global->config->enableSetMessage)
{
PrintUserCmdText(client, L"Set commands disabled");
return;
}
const auto iter = global->info.find(client);
if (iter == global->info.end())
{
PrintUserCmdText(client, L"ERR No messages");
return;
}
for (int i = 0; i < NumberOfSlots; i++)
{
PrintUserCmdText(client, std::format(L"{}: {}", i, iter->second.slots[i]));
}
PrintUserCmdText(client, L"OK");
}
/** @ingroup Message
* @brief User Commands for /0-9
*/
void UserCmd_Msg(ClientId& client, const std::wstring& param)
{
const auto numStr = param[1];
wchar_t* _;
long num = std::wcstol(&numStr, &_, 10);
if (FLHookConfig::c()->messages.defaultLocalChat)
{
SendPresetLocalMessage(client, num);
}
else
{
SendPresetSystemMessage(client, num);
}
}
/** @ingroup Message
* @brief User Commands for /r0-9
*/
void UserCmd_RMsg(ClientId& client, const std::wstring& param)
{
long num = GetNumberFromCmd(param);
SendPresetLastPMSender(client, num);
}
/** @ingroup Message
* @brief User Commands for /s0-9
*/
void UserCmd_SMsg(ClientId& client, const std::wstring& param)
{
long num = GetNumberFromCmd(param);
SendPresetSystemMessage(client, num);
}
/** @ingroup Message
* @brief User Commands for /l0-9
*/
void UserCmd_LMsg(ClientId& client, const std::wstring& param)
{
long num = GetNumberFromCmd(param);
SendPresetLocalMessage(client, num);
}
/** @ingroup Message
* @brief User Commands for /g0-9
*/
void UserCmd_GMsg(ClientId& client, const std::wstring& param)
{
long num = GetNumberFromCmd(param);
SendPresetGroupMessage(client, num);
}
/** @ingroup Message
* @brief User Commands for /t0-9
*/
void UserCmd_TMsg(ClientId& client, const std::wstring& param)
{
long num = GetNumberFromCmd(param);
SendPresetToLastTarget(client, num);
}
/** @ingroup Message
* @brief Send an message to the last person that PM'd this client.
*/
void UserCmd_ReplyToLastPMSender(ClientId& client, const std::wstring& param)
{
const auto iter = global->info.find(client);
if (iter == global->info.end())
{
// There's no way for this to happen! yeah right.
PrintUserCmdText(client, L"ERR No message defined");
return;
}
const std::wstring msg = GetParamToEnd(param, ' ', 0);
if (iter->second.lastPmClientId == UINT_MAX)
{
PrintUserCmdText(client, L"ERR PM sender not available");
return;
}
global->info[iter->second.lastPmClientId].lastPmClientId = client;
Hk::Message::SendPrivateChat(client, iter->second.lastPmClientId, ViewToWString(msg));
}
/** @ingroup Message
* @brief Shows the sender of the last PM and the last char targeted
*/
void UserCmd_ShowLastPMSender(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
const auto iter = global->info.find(client);
if (iter == global->info.end())
{
// There's no way for this to happen! yeah right.
PrintUserCmdText(client, L"ERR No message defined");
return;
}
std::wstring senderCharname = L"<not available>" + std::to_wstring(iter->second.lastPmClientId);
if (iter->second.lastPmClientId != -1 && Hk::Client::IsValidClientID(iter->second.lastPmClientId))
senderCharname = (const wchar_t*)Players.GetActiveCharacterName(iter->second.lastPmClientId);
std::wstring targetCharname = L"<not available>" + std::to_wstring(iter->second.targetClientId);
if (iter->second.targetClientId != -1 && Hk::Client::IsValidClientID(iter->second.targetClientId))
targetCharname = (const wchar_t*)Players.GetActiveCharacterName(iter->second.targetClientId);
PrintUserCmdText(client, L"OK sender=" + senderCharname + L" target=" + targetCharname);
}
/** @ingroup Message
* @brief Send a message to the last/current target.
*/
void UserCmd_SendToLastTarget(ClientId& client, const std::wstring& param)
{
const auto iter = global->info.find(client);
if (iter == global->info.end())
{
// There's no way for this to happen! yeah right.
PrintUserCmdText(client, L"ERR No message defined");
return;
}
const std::wstring msg = GetParamToEnd(param, ' ', 0);
if (iter->second.targetClientId == UINT_MAX)
{
PrintUserCmdText(client, L"ERR PM target not available");
return;
}
global->info[iter->second.targetClientId].lastPmClientId = client;
Hk::Message::SendPrivateChat(client, iter->second.targetClientId, ViewToWString(msg));
}
/** @ingroup Message
* @brief Send a private message to the specified charname. If the player is offline the message will be delivery when they next login.
*/
void UserCmd_PrivateMsg(ClientId& client, const std::wstring& param)
{
const std::wstring usage = L"Usage: /privatemsg <charname> <messsage> or /pm ...";
const std::wstring charname = (const wchar_t*)Players.GetActiveCharacterName(client);
const std::wstring& targetCharname = GetParam(param, ' ', 0);
const std::wstring msg = GetParamToEnd(param, ' ', 1);
if (charname.size() == 0 || msg.size() == 0)
{
PrintUserCmdText(client, L"ERR Invalid parameters");
PrintUserCmdText(client, usage);
return;
}
if (!Hk::Client::GetAccountByCharName(targetCharname))
{
PrintUserCmdText(client, L"ERR charname does not exist");
return;
}
const auto clientId = Hk::Client::GetClientIdFromCharName(targetCharname);
if (clientId.has_error())
{
MailManager::MailItem item;
item.author = wstos(charname);
item.subject = "Private Message";
item.body = wstos(msg);
MailManager::i()->SendNewMail(targetCharname, item);
MailManager::i()->SendMailNotification(targetCharname);
PrintUserCmdText(client, L"OK message saved to mailbox");
}
else
{
global->info[clientId.value()].lastPmClientId = client;
Hk::Message::SendPrivateChat(client, clientId.value(), ViewToWString(msg));
}
}
/** @ingroup Message
* @brief Send a private message to the specified clientid.
*/
void UserCmd_PrivateMsgID(ClientId& client, const std::wstring& param)
{
std::wstring charname = (const wchar_t*)Players.GetActiveCharacterName(client);
const std::wstring& clientId = GetParam(param, ' ', 0);
const std::wstring msg = GetParamToEnd(param, ' ', 1);
uint iToClientId = ToInt(clientId);
if (!Hk::Client::IsValidClientID(iToClientId) || Hk::Client::IsInCharSelectMenu(iToClientId))
{
PrintUserCmdText(client, L"ERR Invalid client-id");
return;
}
global->info[iToClientId].lastPmClientId = client;
Hk::Message::SendPrivateChat(client, iToClientId, ViewToWString(msg));
}
/** @ingroup Message
* @brief Send a message to all players with a particular prefix.
*/
void UserCmd_FactionMsg(ClientId& client, const std::wstring& param)
{
std::wstring sender = (const wchar_t*)Players.GetActiveCharacterName(client);
const std::wstring& charnamePrefix = GetParam(param, ' ', 0);
const std::wstring& msg = GetParamToEnd(param, ' ', 1);
if (charnamePrefix.size() < 3 || msg.empty())
{
PrintUserCmdText(client, L"ERR Invalid parameters");
PrintUserCmdText(client, L"Usage: /factionmsg <tag> <message> or /fm ...");
return;
}
bool bSenderReceived = false;
bool bMsgSent = false;
for (const auto& player : Hk::Admin::GetPlayers())
{
if (ToLower(player.character).find(ToLower(charnamePrefix)) == std::string::npos)
continue;
if (player.client == client)
bSenderReceived = true;
Hk::Message::FormatSendChat(player.client, sender, ViewToWString(msg), L"FF7BFF");
bMsgSent = true;
}
if (!bSenderReceived)
Hk::Message::FormatSendChat(client, sender, ViewToWString(msg), L"FF7BFF");
if (bMsgSent == false)
PrintUserCmdText(client, L"ERR No chars found");
}
/** @ingroup Message
* @brief User command for enabling the chat timestamps.
*/
void UserCmd_SetChatTime(ClientId& client, const std::wstring& param)
{
const std::wstring param1 = ToLower(GetParam(param, ' ', 0));
bool bShowChatTime = false;
if (!param1.compare(L"on"))
bShowChatTime = true;
else if (!param1.compare(L"off"))
bShowChatTime = false;
else
{
PrintUserCmdText(client, L"ERR Invalid parameters");
PrintUserCmdText(client, L"Usage: /set chattime [on|off]");
}
std::wstring charname = (const wchar_t*)Players.GetActiveCharacterName(client);
Hk::Ini::SetCharacterIni(client, L"msg.chat_time", bShowChatTime ? L"true" : L"false");
// Update the client cache.
if (const auto iter = global->info.find(client); iter != global->info.end())
iter->second.showChatTime = bShowChatTime;
// Send confirmation msg
PrintUserCmdText(client, L"OK");
}
/** @ingroup Message
* @brief Prints the current server time.
*/
void UserCmd_Time(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
// Send time with gray color (BEBEBE) in small text (90) above the chat line.
PrintUserCmdText(client, GetTimeString(FLHookConfig::i()->general.localTime));
}
/** @ingroup Message
* @brief Me command allow players to type "/me powers his engines" which would print: "Trent powers his engines"
*/
void UserCmd_Me(ClientId& client, const std::wstring& param)
{
if (global->config->enableMe)
{
const std::wstring charname = (const wchar_t*)Players.GetActiveCharacterName(client);
SystemId systemId = Hk::Player::GetSystem(client).value();
// Encode message using the death message style (red text).
std::wstring XMLMsg = L"<TRA data=\"" + FLHookConfig::i()->messages.msgStyle.deathMsgStyle + L"\" mask=\"-1\"/> <TEXT>";
XMLMsg += charname + L" ";
XMLMsg += XMLText(ViewToWString(GetParamToEnd(param, ' ', 0)));
XMLMsg += L"</TEXT>";
RedText(XMLMsg, systemId);
}
else
{
PrintUserCmdText(client, L"Command not enabled.");
}
}
/** @ingroup Message
* @brief Do command allow players to type "/do Nomad fighters detected" which would print: "Nomad fighters detected" in the standard red text
*/
void UserCmd_Do(ClientId& client, const std::wstring& param)
{
if (global->config->enableDo)
{
SystemId systemId = Hk::Player::GetSystem(client).value();
// Encode message using the death message style (red text).
std::wstring XMLMsg = L"<TRA data=\"" + FLHookConfig::i()->messages.msgStyle.deathMsgStyle + L"\" mask=\"-1\"/> <TEXT>";
XMLMsg += XMLText(ViewToWString(GetParamToEnd(ViewToWString(param), ' ', 0)));
XMLMsg += L"</TEXT>";
RedText(XMLMsg, systemId);
}
else
{
PrintUserCmdText(client, L"Command not enabled.");
}
}
// Client command processing
const std::vector commands = {{
CreateUserCommand(L"/setmsg", L"<n> <msg text>", UserCmd_SetMsg, L"Sets a preset message."),
CreateUserCommand(L"/showmsgs", L"", UserCmd_ShowMsgs, L"Show your preset messages."),
CreateUserCommand(CmdArr({L"/0", L"/1", L"/2", L"/3", L"/4", L"/5", L"/6", L"/7", L"/8", L"/9"}), L"/<msgNumber>", UserCmd_Msg,
L"Send preset message from slot [0-9]."),
CreateUserCommand(CmdArr({L"/s0", L"/s1", L"/s2", L"/s3", L"/s4", L"/s5", L"/s6", L"/s7", L"/s8", L"/s9"}), L"/s<msgNumber>", UserCmd_SMsg,
L"Send preset message to system chat from slot [0-9]."),
CreateUserCommand(CmdArr({L"/l0", L"/l1", L"/l2", L"/l3", L"/l4", L"/l5", L"/l6", L"/l7", L"/l8", L"/l9"}), L"/l<msgNumber>", UserCmd_LMsg,
L"Send preset message to local chat from slot [0-9]."),
CreateUserCommand(CmdArr({L"/r0", L"/r1", L"/r2", L"/r3", L"/r4", L"/r5", L"/r6", L"/r7", L"/r8", L"/r9"}), L"/r<msgNumber>", UserCmd_RMsg,
L"Send preset message to local chat from slot [0-9]."),
CreateUserCommand(CmdArr({L"/g0", L"/g1", L"/g2", L"/g3", L"/g4", L"/g5", L"/g6", L"/g7", L"/g8", L"/g9"}), L"/g<msgNumber>", UserCmd_GMsg,
L"Send preset message to group chat from slot [0-9]."),
CreateUserCommand(CmdArr({L"/t0", L"/t1", L"/t2", L"/t3", L"/t4", L"/t5", L"/t6", L"/t7", L"/t8", L"/t9"}), L"/t<msgNumber>", UserCmd_TMsg,
L"Send preset message to target from slot [0-9]."),
CreateUserCommand(L"/target", L"<message>", UserCmd_SendToLastTarget, L"Send a message to previous/current target."),
CreateUserCommand(L"/t", L"<message>", UserCmd_SendToLastTarget, L"Shortcut for /target."),
CreateUserCommand(L"/reply", L"<message>", UserCmd_ReplyToLastPMSender, L"Send a message to the last person to PM you."),
CreateUserCommand(L"/r", L"<message>", UserCmd_ReplyToLastPMSender, L"Shortcut for /reply."),
CreateUserCommand(L"/privatemsg$", L"<clientid> <message>", UserCmd_PrivateMsgID, L"Send private message to the specified client id."),
CreateUserCommand(L"/pm$", L"<clientid> <message>", UserCmd_PrivateMsgID, L"Shortcut for /privatemsg$."),
CreateUserCommand(L"/privatemsg", L"<charname> <message>", UserCmd_PrivateMsg, L"Send private message to the specified character name."),
CreateUserCommand(L"/pm", L"<charname> <message>", UserCmd_PrivateMsg, L"Shortcut for /privatemsg."),
CreateUserCommand(L"/factionmsg", L"<tag> <message>", UserCmd_FactionMsg, L"Send a message to the specified faction tag."),
CreateUserCommand(L"/fm", L"<tag> <message>", UserCmd_FactionMsg, L"Shortcut for /factionmsg."),
CreateUserCommand(L"/lastpm", L"", UserCmd_ShowLastPMSender, L"Shows the send of the last PM received."),
CreateUserCommand(L"/set chattime", L"<on|off>", UserCmd_SetChatTime, L"Enable time stamps on chat."),
CreateUserCommand(L"/me", L"<message>", UserCmd_Me, L"Prints your name plus other text to system. Eg, /me thinks would say Bob thinks in system chat."),
CreateUserCommand(L"/do", L"<message>", UserCmd_Do, L"Prints red text to system chat."),
CreateUserCommand(L"/time", L"", UserCmd_Time, L"Prints the current server time."),
}};
} // namespace Plugins::Message
using namespace Plugins::Message;
REFL_AUTO(type(Config), field(greetingBannerLines), field(specialBannerLines), field(standardBannerLines), field(specialBannerTimeout),
field(standardBannerTimeout), field(customHelp), field(suppressMistypedCommands), field(enableSetMessage), field(enableMe), field(enableDo),
field(disconnectSwearingInSpaceMsg), field(disconnectSwearingInSpaceRange), field(swearWords), field(swearingTempBanDuration))
DefaultDllMainSettings(LoadSettings);
// Functions to hook
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("Message");
pi->shortName("message");
pi->mayUnload(true);
pi->commands(&commands);
pi->returnCode(&global->returncode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::IServerImpl__SubmitChat, &SubmitChat);
pi->emplaceHook(HookedCall::IChat__SendChat, &SendChat);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__SetTarget, &SetTarget);
pi->emplaceHook(HookedCall::IServerImpl__DisConnect, &DisConnect);
pi->emplaceHook(HookedCall::FLHook__ClearClientInfo, &ClearClientInfo, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__CharacterSelect, &PlayerLogin, HookStep::After);
}
| 31,682
|
C++
|
.cpp
| 832
| 34.692308
| 157
| 0.703454
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,332
|
CargoDrop.cpp
|
TheStarport_FLHook/plugins/cargo_drop/CargoDrop.cpp
|
/**
* @date Feb 2010
* @author Cannon (Ported by Raikkonen 2022)
* @defgroup CargoDrop Cargo Drop
* @brief
* The "Cargo Drop" plugin handles consequences for a player who disconnects whilst in space and allows servers to ensure that cargo items are dropped on player
* death rather than lost. Is also allows server owners to set additional commodities that are spawned as loot when a player ship dies based on hull mass (i.e.
* salvage).
*
* @paragraph cmds Player Commands
* There are no player commands in this plugin.
*
* @paragraph adminCmds Admin Commands
* There are no admin commands in this plugin.
*
* @paragraph configuration Configuration
* @code
* {
* "cargoDropContainer": "lootcrate_ast_loot_metal",
* "disconnectMsg": "%player is attempting to engage cloaking device",
* "disconnectingPlayersRange": 5000.0,
* "playerOnDeathCargo": ["commodity_super_alloys", "commodity_engine_components"]
* "hullDropFactor": 0.1,
* "killDisconnectingPlayers": true,
* "lootDisconnectingPlayers": true,
* "noLootItems": [],
* "reportDisconnectingPlayers": true
* }
* @endcode
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*
* @paragraph optional Optional Plugin Dependencies
* None.
*/
// Includes
#include "CargoDrop.h"
namespace Plugins::CargoDrop
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
void LoadSettings()
{
auto config = Serializer::JsonToObject<Config>();
for (const auto& cargo : config.playerOnDeathCargo)
{
global->playerOnDeathCargo.push_back(CreateID(cargo.c_str()));
}
for (const auto& noLootItem : config.noLootItems)
{
global->noLootItemsIds.push_back(CreateID(noLootItem.c_str()));
}
global->config = std::make_unique<Config>(config);
}
/** @ingroup CargoDrop
* @brief Timer that checks if a player has disconnected and punished them if so.
*/
void DisconnectCheck()
{
// Disconnecting while interacting checks.
for (auto& [client, snd] : global->info)
{
// If selecting a character or invalid, do nothing.
if (!Hk::Client::IsValidClientID(client) || Hk::Client::IsInCharSelectMenu(client))
continue;
// If not in space, do nothing
auto ship = Hk::Player::GetShip(client);
if (ship.has_error())
continue;
if (ClientInfo[client].tmF1Time || ClientInfo[client].tmF1TimeDisconnect)
{
std::wstring characterName = reinterpret_cast<const wchar_t*>(Players.GetActiveCharacterName(client));
// Drain the ship's shields.
pub::SpaceObj::DrainShields(ship.value());
// Simulate an obj update to stop the ship in space.
SSPObjUpdateInfo updateInfo {};
snd.lastTimestamp += 1.0;
updateInfo.dTimestamp = snd.lastTimestamp;
updateInfo.cState = 0;
updateInfo.fThrottle = 0;
updateInfo.vPos = snd.lastPosition;
updateInfo.vDir = snd.lastDirection;
Server.SPObjUpdate(updateInfo, client);
if (!snd.f1DisconnectProcessed)
{
snd.f1DisconnectProcessed = true;
// Send disconnect report to all ships in scanner range.
if (global->config->reportDisconnectingPlayers)
{
std::wstring msg = stows(global->config->disconnectMsg);
msg = ReplaceStr(msg, L"%time", GetTimeString(FLHookConfig::i()->general.localTime));
msg = ReplaceStr(msg, L"%player", characterName);
PrintLocalUserCmdText(client, msg, global->config->disconnectingPlayersRange);
}
// Drop the player's cargo.
if (global->config->lootDisconnectingPlayers && Hk::Player::IsInRange(client, global->config->disconnectingPlayersRange))
{
const auto system = Hk::Player::GetSystem(client);
auto [position, _] = Hk::Solar::GetLocation(ship.value(), IdType::Ship).value();
position.x += 30.0f;
int remainingHoldSize = 0;
if (const auto cargo = Hk::Player::EnumCargo(client, remainingHoldSize); cargo.has_value())
{
for (const auto& [id, count, archId, status, mission, mounted, hardpoint] : cargo.value())
{
if (!mounted && std::ranges::find(global->noLootItemsIds, archId) == global->noLootItemsIds.end())
{
Hk::Player::RemoveCargo(characterName, id, count);
Server.MineAsteroid(system.value(), position, global->cargoDropContainerId, archId, count, client);
}
}
}
Hk::Player::SaveChar(characterName);
}
// Kill if other ships are in scanner range.
if (global->config->killDisconnectingPlayers && Hk::Player::IsInRange(client, global->config->disconnectingPlayersRange))
{
pub::SpaceObj::SetRelativeHealth(ship.value(), 0.0f);
}
}
}
}
}
const std::vector<Timer> timers = {{DisconnectCheck, 1}};
/** @ingroup CargoDrop
* @brief Hook for ship destruction. It's easier to hook this than the PlayerDeath one. Drop a percentage of cargo + some loot representing ship bits.
*/
void SendDeathMsg([[maybe_unused]] const std::wstring& message, const SystemId& system, ClientId& clientVictim, ClientId& clientKiller)
{
// If player ship loot dropping is enabled then check for a loot drop.
if (global->config->hullDropFactor == 0.0f || !global->config->enablePlayerCargoDropOnDeath)
{
return;
}
int remainingHoldSize;
auto cargo = Hk::Player::EnumCargo(clientVictim, remainingHoldSize);
if (cargo.has_error())
{
return;
}
auto ship = Archetype::GetShip(Hk::Player::GetShipID(clientVictim).value());
auto [position, _] = Hk::Solar::GetLocation(Hk::Player::GetShip(clientVictim).value(), IdType::Ship).value();
position.x += 30.0f;
for (const auto& [iId, count, archId, status, mission, mounted, hardpoint] : cargo.value())
{
if (!mounted && !mission && std::ranges::find(global->noLootItemsIds, archId) == global->noLootItemsIds.end())
{
Server.MineAsteroid(
system, position, global->cargoDropContainerId, archId, std::min(count, global->config->maxPlayerCargoDropCount), clientKiller);
}
}
if (const auto hullDropTotal = int(global->config->hullDropFactor * float(ship->fMass)); hullDropTotal > 0)
{
Console::ConDebug(std::format("Cargo drop in system {:#X} at {:.2f}, {:.2f}, {:.2f} for ship size of shipMass={} iHullDrop={}\n",
system,
position.x,
position.y,
position.z,
ship->fMass,
hullDropTotal));
for (const auto& playerCargo : global->playerOnDeathCargo)
{
Server.MineAsteroid(system, position, global->cargoDropContainerId, playerCargo, int(hullDropTotal), clientKiller);
}
}
}
/** @ingroup CargoDrop
* @brief Clear our variables so that we can recycle clients without confusion.
*/
void ClearClientInfo(ClientId& client)
{
global->info.erase(client);
}
/** @ingroup CargoDrop
* @brief Hook on SPObjUpdate, used to get the timestamp from the player. Used to figure out if the player has disconnected in the timer.
*/
void SPObjUpdate(struct SSPObjUpdateInfo const& ui, ClientId& client)
{
global->info[client].lastTimestamp = ui.dTimestamp;
global->info[client].lastPosition = ui.vPos;
global->info[client].lastDirection = ui.vDir;
}
} // namespace Plugins::CargoDrop
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace Plugins::CargoDrop;
REFL_AUTO(type(Config), field(reportDisconnectingPlayers), field(killDisconnectingPlayers), field(lootDisconnectingPlayers), field(disconnectingPlayersRange),
field(hullDropFactor), field(disconnectMsg), field(cargoDropContainer), field(playerOnDeathCargo), field(noLootItems), field(enablePlayerCargoDropOnDeath),
field(maxPlayerCargoDropCount))
DefaultDllMainSettings(LoadSettings);
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("Cargo Drop");
pi->shortName("cargo_drop");
pi->mayUnload(true);
pi->timers(&timers);
pi->returnCode(&global->returnCode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::FLHook__ClearClientInfo, &ClearClientInfo, HookStep::After);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
pi->emplaceHook(HookedCall::IEngine__SendDeathMessage, &SendDeathMsg);
pi->emplaceHook(HookedCall::IServerImpl__SPObjUpdate, &SPObjUpdate);
}
| 8,323
|
C++
|
.cpp
| 203
| 37.147783
| 160
| 0.711743
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,333
|
Event.cpp
|
TheStarport_FLHook/plugins/event/Event.cpp
|
/**
* @date June, 2022
* @author Cannon (Ported by Raikkonen)
* @defgroup Event Event
* @brief
* This plugin is used to create NPC and Cargo missions. For example, a base needs to be sold a certain amount of a commodity.
*
* @paragraph cmds Player Commands
* There are no player commands in this plugin.
*
* @paragraph adminCmds Admin Commands
* There are no admin commands in this plugin.
*
* @paragraph configuration Configuration
* @code
* {
* "CargoMissions": {
* "Example": {
* "base": "li01_01_base",
* "current_amount": 0,
* "item": "commodity_gold",
* "required_amount": 99
* }
* },
* "NpcMissions": {
* "Example": {
* "current_amount": 0,
* "reputation": "li_n_grp",
* "required_amount": 99,
* "sector": "D1",
* "system": "li01"
* }
* }
* }
* @endcode
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*
* @paragraph optional Optional Plugin Dependencies
* This plugin has no dependencies.
*/
#include "Event.h"
namespace Plugins::Event
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
void LoadSettings()
{
global->CargoMissions.clear();
global->NpcMissions.clear();
auto config = Serializer::JsonToObject<Config>();
for (const auto& [missionName, cargoMission] : config.CargoMissions)
{
if (missionName == "Example")
continue;
CARGO_MISSION cargo_mission;
cargo_mission.nickname = missionName;
cargo_mission.base = CreateID(cargoMission.base.c_str());
global->nicknameToNameMap[cargo_mission.base] = cargoMission.base;
cargo_mission.item = CreateID(cargoMission.item.c_str());
global->nicknameToNameMap[cargo_mission.item] = cargoMission.item;
cargo_mission.required_amount = cargoMission.required_amount;
cargo_mission.current_amount = cargoMission.current_amount;
global->CargoMissions.push_back(cargo_mission);
}
for (const auto& [missionName, mission] : config.NpcMissions)
{
if (missionName == "Example")
continue;
NPC_MISSION npc_mission;
npc_mission.nickname = missionName;
npc_mission.system = CreateID(mission.system.c_str());
global->nicknameToNameMap[npc_mission.system] = mission.system;
npc_mission.sector = mission.sector;
pub::Reputation::GetReputationGroup(npc_mission.reputation, mission.reputation.c_str());
global->nicknameToNameMap[npc_mission.reputation] = mission.reputation;
npc_mission.required_amount = mission.required_amount;
npc_mission.current_amount = mission.current_amount;
global->NpcMissions.push_back(npc_mission);
}
global->config = std::make_unique<Config>(config);
Console::ConInfo(std::format("CargoMissionSettings loaded [{}]", global->CargoMissions.size()));
Console::ConInfo(std::format("NpcMissionSettings loaded [{}]", global->NpcMissions.size()));
}
/** @ingroup Event
* @brief Save mission status every 100 seconds.
*/
void SaveMissionStatus()
{
if (global->CargoMissions.empty() && global->NpcMissions.empty())
return;
std::ofstream out("config/event.json");
nlohmann::json jExport;
for (auto& mission : global->CargoMissions)
{
nlohmann::json jsonMission = {{"base", global->nicknameToNameMap[mission.base]},
{"item", global->nicknameToNameMap[mission.item]},
{"current_amount", mission.current_amount},
{"required_amount", mission.required_amount}};
jExport["CargoMissions"][mission.nickname] = jsonMission;
}
for (auto& mission : global->NpcMissions)
{
nlohmann::json jsonMission = {{"system", global->nicknameToNameMap[mission.system]},
{"reputation", global->nicknameToNameMap[mission.reputation]},
{"sector", mission.sector},
{"current_amount", mission.current_amount},
{"required_amount", mission.required_amount}};
jExport["NpcMissions"][mission.nickname] = jsonMission;
}
out << std::setw(4) << jExport;
out.close();
}
const std::vector<Timer> timers = {{SaveMissionStatus, 100}};
/** @ingroup Event
* @brief Hook on ShipDestroyed to see if an NPC mission needs to be updated.
*/
void ShipDestroyed([[maybe_unused]] DamageList** _dmg, const DWORD** ecx, const uint& iKill)
{
if (iKill)
{
const CShip* cShip = Hk::Player::CShipFromShipDestroyed(ecx);
int Reputation;
pub::SpaceObj::GetRep(cShip->get_id(), Reputation);
uint Affiliation;
pub::Reputation::GetAffiliation(Reputation, Affiliation);
SystemId System = Hk::Solar::GetSystemBySpaceId(cShip->get_id()).value();
const Vector position = cShip->get_position();
const std::string sector = Hk::Math::VectorToSectorCoord<std::string>(System, position);
for (auto& mission : global->NpcMissions)
{
if (Affiliation == mission.reputation && System == mission.system && (mission.sector.empty() || mission.sector == sector) &&
mission.current_amount < mission.required_amount)
{
mission.current_amount++;
}
}
}
}
/** @ingroup Event
* @brief Hook on GFGoodBuy to see if a cargo mission needs to be updated.
*/
void GFGoodBuy(struct SGFGoodBuyInfo const& gbi, ClientId& client)
{
auto base = Hk::Player::GetCurrentBase(client);
for (auto& mission : global->CargoMissions)
{
if (mission.base == base.value() && mission.item == gbi.iGoodId)
{
mission.current_amount -= gbi.iCount;
if (mission.current_amount < 0)
mission.current_amount = 0;
}
}
}
/** @ingroup Event
* @brief Hook on GFGoodSell to see if a cargo mission needs to be updated.
*/
void GFGoodSell(const struct SGFGoodSellInfo& gsi, ClientId& client)
{
auto base = Hk::Player::GetCurrentBase(client);
for (auto& mission : global->CargoMissions)
{
if (mission.base == base.value() && mission.item == gsi.iArchId && mission.current_amount < mission.required_amount)
{
int needed = mission.required_amount - mission.current_amount;
if (needed > gsi.iCount)
{
mission.current_amount += gsi.iCount;
needed = mission.required_amount - mission.current_amount;
PrintUserCmdText(client, std::format(L"{} units remaining to complete mission objective", needed));
}
else
{
PrintUserCmdText(client, L"Mission objective completed");
}
}
}
}
} // namespace Plugins::Event
using namespace Plugins::Event;
REFL_AUTO(type(Config::CARGO_MISSION_REFLECTABLE), field(nickname), field(base), field(item), field(required_amount), field(current_amount))
REFL_AUTO(
type(Config::NPC_MISSION_REFLECTABLE), field(nickname), field(system), field(sector), field(reputation), field(required_amount), field(current_amount))
REFL_AUTO(type(Config), field(CargoMissions), field(NpcMissions))
DefaultDllMainSettings(LoadSettings);
/** Functions to hook */
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("Event");
pi->shortName("event");
pi->mayUnload(true);
pi->timers(&timers);
pi->returnCode(&global->returncode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::IServerImpl__Startup, &LoadSettings, HookStep::After);
pi->emplaceHook(HookedCall::IEngine__ShipDestroyed, &ShipDestroyed);
pi->emplaceHook(HookedCall::IServerImpl__GFGoodBuy, &GFGoodBuy);
pi->emplaceHook(HookedCall::IServerImpl__GFGoodSell, &GFGoodSell);
}
| 7,442
|
C++
|
.cpp
| 201
| 33.711443
| 155
| 0.702733
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,334
|
IPBan.cpp
|
TheStarport_FLHook/plugins/ip_ban/IPBan.cpp
|
/**
* @date Feb, 2010
* @author Cannon (Ported by Raikkonen)
* @defgroup IPBan IP Ban
* @brief
* This plugin is used to ban players based on their IP address.
*
* @paragraph cmds Player Commands
* There are no player commands in this plugin.
*
* @paragraph adminCmds Admin Commands
* All commands are prefixed with '.' unless explicitly specified.
* - authchar <charname> - Allow a character to connect even if they are in a restricted IP range.
* - reloadbans - Reload the bans from file.
*
* @paragraph configuration Configuration
* No configuration file is needed.
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*
* @paragraph optional Optional Plugin Dependencies
* This plugin has no dependencies.
*/
#include "IPBan.h"
namespace Plugins::IPBan
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
/** @ingroup IPBan
* @brief Return true if this client is on a banned IP range.
*/
static bool IsBanned(ClientId client)
{
std::wstring wscIP = Hk::Admin::GetPlayerIP(client);
std::string scIP = wstos(wscIP);
// Check for an IP range match.
for (const auto& ban : global->ipBans.Bans)
if (Wildcard::Fit(ban.c_str(), scIP.c_str()))
return true;
// To avoid plugin comms with DSAce because I ran out of time to make this
// work, I use something of a trick to get the login Id.
// Read all login Id files in the account and look for the one with a
// matching IP to this player. If we find a matching IP then we've got a
// login Id we can check.
if (const CAccount* acc = Players.FindAccountFromClientID(client))
{
bool isBannedLoginId = false;
std::wstring dir = Hk::Client::GetAccountDirName(acc);
WIN32_FIND_DATA findFileData;
std::string scFileSearchPath = CoreGlobals::c()->accPath + "\\" + wstos(dir) + "\\login_*.ini"; // Looks like DSAM generates this file
if (HANDLE hFileFind = FindFirstFile(scFileSearchPath.c_str(), &findFileData); hFileFind != INVALID_HANDLE_VALUE)
{
do
{
// Read the login Id and IP from the login Id record.
std::string loginId;
std::string loginId2;
std::string thisIP;
std::string filePath = CoreGlobals::c()->accPath + wstos(dir) + "\\" + findFileData.cFileName;
FILE* f;
fopen_s(&f, filePath.c_str(), "r");
if (f)
{
if (char szBuf[200]; fgets(szBuf, sizeof(szBuf), f) != nullptr)
{
std::string sz = szBuf;
try
{
loginId = Trim(GetParam(sz, '\t', 1).substr(3, std::string::npos));
thisIP = Trim(GetParam(sz, '\t', 2).substr(3, std::string::npos));
if (GetParam(sz, '\t', 3).length() > 4)
loginId2 = Trim(GetParam(sz, '\t', 3).substr(4, std::string::npos));
}
catch (...)
{
Console::ConErr(std::format("ERR Corrupt loginid file {}", filePath));
}
}
fclose(f);
}
if (FLHookConfig::i()->general.debugMode)
{
Console::ConInfo(std::format("Checking for ban on IP {} Login Id1 {} Id2 {} Client {}\n", thisIP, loginId, loginId2, client));
}
// If the login Id has been read then check it to see if it has
// been banned
if (thisIP == scIP && loginId.length())
{
for (const auto& ban : global->loginIdBans.Bans)
{
if (ban == loginId || ban == loginId2)
{
Console::ConWarn(std::format("* Kicking player on Id ban: ip={} id1={} id2={}\n", thisIP, loginId, loginId2));
isBannedLoginId = true;
break;
}
}
}
} while (FindNextFile(hFileFind, &findFileData));
FindClose(hFileFind);
}
if (isBannedLoginId)
return true;
}
return false;
}
/** @ingroup IPBan
* @brief Return true if this client is in in the AuthenticatedAccounts.json file indicating that the client can connect even if they are otherwise on a
* restricted IP range.
*/
static bool IsAuthenticated(ClientId client)
{
const CAccount* acc = Players.FindAccountFromClientID(client);
if (!acc)
return false;
std::wstring directory = Hk::Client::GetAccountDirName(acc);
return (std::ranges::find(global->authenticatedAccounts.Accounts, directory) != global->authenticatedAccounts.Accounts.end());
}
/** @ingroup IPBan
* @brief Reload IP Bans from file.
*/
static void ReloadIPBans()
{
global->ipBans = Serializer::JsonToObject<IPBans>();
if (FLHookConfig::i()->general.debugMode)
Console::ConInfo(std::format("Loading IP bans from {}", global->ipBans.File()));
Console::ConInfo(std::format("IP Bans [{}]", global->ipBans.Bans.size()));
}
/** @ingroup IPBan
* @brief Reload Login Id bans from file.
*/
static void ReloadLoginIdBans()
{
global->loginIdBans = Serializer::JsonToObject<LoginIdBans>();
if (FLHookConfig::i()->general.debugMode)
Console::ConInfo(std::format("Loading Login Id bans from {}", global->loginIdBans.File()));
Console::ConInfo(std::format("Login Id Bans [{}]", global->loginIdBans.Bans.size()));
}
/** @ingroup IPBan
* @brief Reload Authenticated Accounts from file.
*/
static void ReloadAuthenticatedAccounts()
{
global->authenticatedAccounts = Serializer::JsonToObject<AuthenticatedAccounts>();
if (FLHookConfig::i()->general.debugMode)
Console::ConInfo(std::format("Loading Authenticated Accounts from {}", global->authenticatedAccounts.File()));
Console::ConInfo(std::format("Authenticated Accounts [{}]", global->authenticatedAccounts.Accounts.size()));
}
/// Reload the ipbans file.
void LoadSettings()
{
auto config = Serializer::JsonToObject<Config>();
global->config = std::make_unique<Config>(config);
ReloadIPBans();
ReloadLoginIdBans();
ReloadAuthenticatedAccounts();
}
/** @ingroup IPBan
* @brief Hook on PlayerLaunch. Checks if player is banned and kicks if so.
*/
void PlayerLaunch([[maybe_unused]] const uint& ship, ClientId& client)
{
if (!global->IPChecked[client])
{
global->IPChecked[client] = true;
if (IsBanned(client) && !IsAuthenticated(client))
{
AddKickLog(client, "IP banned");
Hk::Player::MsgAndKick(client, global->config->BanMessage, 15000L);
}
}
}
/** @ingroup IPBan
* @brief Hook on BaseEnter. Checks if player is banned and kicks if so.
*/
void BaseEnter([[maybe_unused]] const uint& baseId, ClientId& client)
{
if (!global->IPChecked[client])
{
global->IPChecked[client] = true;
if (IsBanned(client) && !IsAuthenticated(client))
{
AddKickLog(client, "IP banned");
Hk::Player::MsgAndKick(client, global->config->BanMessage, 7000L);
}
}
}
/** @ingroup IPBan
* @brief Hook on ClearClientInfo. Resets the checked variable for the client Id.
*/
void ClearClientInfo(ClientId client)
{
global->IPChecked[client] = false;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ADMIN COMMANDS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
/** @ingroup IPBan
* @brief Is called when an admin types ".reloadbans".
*/
void AdminCmd_ReloadBans(CCmds* cmds)
{
ReloadLoginIdBans();
ReloadIPBans();
ReloadAuthenticatedAccounts();
cmds->Print("OK");
}
/** @ingroup IPBan
* @brief Is called when an admin types ".authchar".
*/
void AdminCmd_AuthenticateChar(CCmds* cmds, const std::wstring& wscCharname)
{
if (!(cmds->rights & RIGHT_SUPERADMIN))
{
cmds->Print("ERR No permission");
return;
}
st6::wstring str((ushort*)wscCharname.c_str());
const CAccount* acc = Players.FindAccountFromCharacterName(str);
if (!acc)
return;
if (std::wstring directory = Hk::Client::GetAccountDirName(acc);
std::ranges::find(global->authenticatedAccounts.Accounts, directory) == global->authenticatedAccounts.Accounts.end())
global->authenticatedAccounts.Accounts.emplace_back(directory);
return;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ADMIN COMMAND PROCESSING
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
/** @ingroup IPBan
* @brief Is called when an admin types ".help".
*/
void CmdHelp_Callback(CCmds* classptr)
{
classptr->Print("authchar <charname>");
classptr->Print("reloadbans");
}
/** @ingroup IPBan
* @brief Admin command callback. Compare the chat entry to see if it match a command
*/
bool ExecuteCommandString_Callback(CCmds* cmds, const std::wstring& cmd)
{
if (cmd == L"authchar")
{
global->returncode = ReturnCode::SkipAll;
AdminCmd_AuthenticateChar(cmds, cmds->ArgStr(1));
return true;
}
else if (cmd == L"reloadbans")
{
global->returncode = ReturnCode::SkipAll;
AdminCmd_ReloadBans(cmds);
return true;
}
return false;
}
} // namespace Plugins::IPBan
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FLHOOK STUFF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace Plugins::IPBan;
REFL_AUTO(type(IPBans), field(Bans))
REFL_AUTO(type(LoginIdBans), field(Bans))
REFL_AUTO(type(AuthenticatedAccounts), field(Accounts))
REFL_AUTO(type(Config), field(BanMessage))
DefaultDllMainSettings(LoadSettings);
// Functions to hook
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("IP Ban Plugin");
pi->shortName("ip_ban");
pi->mayUnload(true);
pi->returnCode(&global->returncode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__BaseEnter, &BaseEnter);
pi->emplaceHook(HookedCall::FLHook__AdminCommand__Process, &ExecuteCommandString_Callback);
pi->emplaceHook(HookedCall::FLHook__AdminCommand__Help, &CmdHelp_Callback);
pi->emplaceHook(HookedCall::IServerImpl__PlayerLaunch, &PlayerLaunch);
pi->emplaceHook(HookedCall::FLHook__ClearClientInfo, &ClearClientInfo);
}
| 10,154
|
C++
|
.cpp
| 282
| 32.471631
| 153
| 0.651917
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,335
|
Arena.cpp
|
TheStarport_FLHook/plugins/arena/Arena.cpp
|
/**
* @date August, 2022
* @author MadHunter (Ported by Raikkonen 2022)
* @defgroup Arena Arena
* @brief
* This plugin is used to beam players to/from an arena system for the purpose of pvp.
*
* @paragraph cmds Player Commands
* All commands are prefixed with '/' unless explicitly specified.
* - arena (configurable) - This beams the player to the pvp system.
* - return - This returns the player to their last docked base.
*
* @paragraph adminCmds Admin Commands
* There are no admin commands in this plugin.
*
* @paragraph configuration Configuration
* @code
* {
* "command": "arena",
* "restrictedSystem": "Li01",
* "targetBase": "Li02_01_Base",
* "targetSystem": "Li02"
* }
* @endcode
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*
* @paragraph optional Optional Plugin Dependencies
* This plugin uses the "Base" plugin.
*/
#include "Arena.h"
namespace Plugins::Arena
{
const auto global = std::make_unique<Global>();
/// Clear client info when a client connects.
void ClearClientInfo(ClientId& client)
{
global->transferFlags[client] = ClientState::None;
}
// Client command processing
void UserCmd_Conn(ClientId& client, const std::wstring& param);
void UserCmd_Return(ClientId& client, const std::wstring& param);
const std::vector commands = {{
CreateUserCommand(L"/arena", L"", UserCmd_Conn, L"Sends you to the designated arena system."),
CreateUserCommand(L"/return", L"", UserCmd_Return, L"Returns you to your last docked base."),
}};
/// Load the configuration
void LoadSettings()
{
Config conf = Serializer::JsonToObject<Config>();
conf.wscCommand = L"/" + stows(conf.command);
conf.restrictedSystemId = CreateID(conf.restrictedSystem.c_str());
conf.targetBaseId = CreateID(conf.targetBase.c_str());
conf.targetSystemId = CreateID(conf.targetSystem.c_str());
global->config = std::make_unique<Config>(std::move(conf));
auto& cmd = const_cast<UserCommand&>(commands[0]);
cmd = CreateUserCommand(global->config->wscCommand, cmd.usage, cmd.proc, cmd.description);
// global->baseCommunicator = static_cast<BaseCommunicator*>(PluginCommunicator::ImportPluginCommunicator(BaseCommunicator::pluginName));
}
/** @ingroup Arena
* @brief Returns true if the client is docked, returns false otherwise.
*/
bool IsDockedClient(unsigned int client)
{
return Hk::Player::GetCurrentBase(client).has_value();
}
/** @ingroup Arena
* @brief Returns true if the client doesn't hold any commodities, returns false otherwise. This is to prevent people using the arena system as a trade
* shortcut.
*/
bool ValidateCargo(ClientId& client)
{
if (const auto playerName = Hk::Client::GetCharacterNameByID(client); playerName.has_error())
{
PrintUserCmdText(client, Hk::Err::ErrGetText(playerName.error()));
return false;
}
int holdSize = 0;
const auto cargo = Hk::Player::EnumCargo(client, holdSize);
if (cargo.has_error())
{
PrintUserCmdText(client, Hk::Err::ErrGetText(cargo.error()));
return false;
}
for (const auto& item : cargo.value())
{
bool flag = false;
pub::IsCommodity(item.iArchId, flag);
// Some commodity present.
if (flag)
return false;
}
return true;
}
/** @ingroup Arena
* @brief Stores the return point for the client in their save file (this should be changed).
*/
void StoreReturnPointForClient(unsigned int client)
{
// It's not docked at a custom base, check for a regular base
auto base = Hk::Player::GetCurrentBase(client);
if (base.has_error())
return;
Hk::Ini::SetCharacterIni(client, L"conn.retbase", std::to_wstring(base.value()));
}
/** @ingroup Arena
* @brief This returns the return base id that is stored in the client's save file.
*/
unsigned int ReadReturnPointForClient(unsigned int client)
{
return Hk::Ini::GetCharacterIniUint(client, L"conn.retbase");
}
/** @ingroup Arena
* @brief Move the specified client to the specified base.
*/
void MoveClient(unsigned int client, unsigned int targetBase)
{
// Ask that another plugin handle the beam.
// if (global->baseCommunicator && global->baseCommunicator->CustomBaseBeam(client, targetBase))
// return;
// No plugin handled it, do it ourselves.
SystemId system = Hk::Player::GetSystem(client).value();
const Universe::IBase* base = Universe::get_base(targetBase);
Hk::Player::Beam(client, targetBase);
// if not in the same system, emulate F1 charload
if (base->systemId != system)
{
Server.BaseEnter(targetBase, client);
Server.BaseExit(targetBase, client);
std::wstring wscCharFileName;
const auto charFileName = Hk::Client::GetCharFileName(client);
if (charFileName.has_error())
return;
auto fileName = charFileName.value() + L".fl";
CHARACTER_ID cId;
strcpy_s(cId.szCharFilename, wstos(wscCharFileName.substr(0, 14)).c_str());
Server.CharacterSelect(cId, client);
}
}
/** @ingroup Arena
* @brief Checks the client is in the specified base. Returns true is so, returns false otherwise.
*/
bool CheckReturnDock(unsigned int client, unsigned int target)
{
if (auto base = Hk::Player::GetCurrentBase(client); base.value() == target)
return true;
return false;
}
/** @ingroup Arena
* @brief Hook on CharacterSelect. Sets their transfer flag to "None".
*/
void CharacterSelect([[maybe_unused]] const std::string& charFilename, ClientId& client)
{
global->transferFlags[client] = ClientState::None;
}
/** @ingroup Arena
* @brief Hook on PlayerLaunch. If their transfer flags are set appropriately, redirect the undock to either the arena base or the return point
*/
void PlayerLaunch_AFTER([[maybe_unused]] const uint& ship, ClientId& client)
{
if (global->transferFlags[client] == ClientState::Transfer)
{
if (!ValidateCargo(client))
{
PrintUserCmdText(client, StrInfo2);
return;
}
global->transferFlags[client] = ClientState::None;
MoveClient(client, global->config->targetBaseId);
return;
}
if (global->transferFlags[client] == ClientState::Return)
{
if (!ValidateCargo(client))
{
PrintUserCmdText(client, StrInfo2);
return;
}
global->transferFlags[client] = ClientState::None;
const unsigned int returnPoint = ReadReturnPointForClient(client);
if (!returnPoint)
return;
MoveClient(client, returnPoint);
Hk::Ini::SetCharacterIni(client, L"conn.retbase", L"0");
return;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// USER COMMANDS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
/** @ingroup Arena
* @brief Used to switch to the arena system
*/
void UserCmd_Conn(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
// Prohibit jump if in a restricted system or in the target system
if (SystemId system = Hk::Player::GetSystem(client).value(); system == global->config->restrictedSystemId || system == global->config->targetSystemId)
{
PrintUserCmdText(client, L"ERR Cannot use command in this system or base");
return;
}
if (!IsDockedClient(client))
{
PrintUserCmdText(client, StrInfo1);
return;
}
if (!ValidateCargo(client))
{
PrintUserCmdText(client, StrInfo2);
return;
}
StoreReturnPointForClient(client);
PrintUserCmdText(client, L"Redirecting undock to Arena.");
global->transferFlags[client] = ClientState::Transfer;
}
/** @ingroup Arena
* @brief Used to return from the arena system.
*/
void UserCmd_Return(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
if (!ReadReturnPointForClient(client))
{
PrintUserCmdText(client, L"No return possible");
return;
}
if (!IsDockedClient(client))
{
PrintUserCmdText(client, StrInfo1);
return;
}
if (!CheckReturnDock(client, global->config->targetBaseId))
{
PrintUserCmdText(client, L"Not in correct base");
return;
}
if (!ValidateCargo(client))
{
PrintUserCmdText(client, StrInfo2);
return;
}
PrintUserCmdText(client, L"Redirecting undock to previous base");
global->transferFlags[client] = ClientState::Return;
}
} // namespace Plugins::Arena
using namespace Plugins::Arena;
REFL_AUTO(type(Config), field(command), field(targetBase), field(targetSystem), field(restrictedSystem))
DefaultDllMainSettings(LoadSettings);
// Functions to hook
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("Arena");
pi->shortName("arena");
pi->mayUnload(true);
pi->commands(&commands);
pi->returnCode(&global->returnCode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__CharacterSelect, &CharacterSelect);
pi->emplaceHook(HookedCall::IServerImpl__PlayerLaunch, &PlayerLaunch_AFTER, HookStep::After);
pi->emplaceHook(HookedCall::FLHook__ClearClientInfo, &ClearClientInfo, HookStep::After);
}
| 9,131
|
C++
|
.cpp
| 263
| 31.749049
| 152
| 0.713104
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,336
|
Afk.cpp
|
TheStarport_FLHook/plugins/afk/Afk.cpp
|
/**
* @date August, 2022
* @author Raikkonen
* @defgroup AwayFromKeyboard Away from Keyboard
* @brief
* The AFK plugin allows you to set yourself as Away from Keyboard.
* This will notify other players if they try and speak to you, that you are not at your desk.
*
* @paragraph cmds Player Commands
* All commands are prefixed with '/' unless explicitly specified.
* - afk - Sets your status to Away from Keyboard. Other players will notified if they try to speak to you.
* - back - Removes the AFK status.
*
* @paragraph adminCmds Admin Commands
* There are no admin commands in this plugin.
*
* @paragraph configuration Configuration
* No configuration file is needed.
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*/
#include "Afk.h"
namespace Plugins::Afk
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
/** @ingroup AwayFromKeyboard
* @brief This command is called when a player types /afk. It prints a message in red text to nearby players saying they are afk. It will also let anyone
* who messages them know too.
*/
void UserCmdAfk(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
global->awayClients.emplace_back(client);
const std::wstring playerName = reinterpret_cast<const wchar_t*>(Players.GetActiveCharacterName(client));
const auto message = Hk::Message::FormatMsg(MessageColor::Red, MessageFormat::Normal, playerName + L" is now away from keyboard.");
const auto systemId = Hk::Player::GetSystem(client);
if (systemId.has_error())
{
PrintUserCmdText(client, Hk::Err::ErrGetText(systemId.error()));
return;
}
Hk::Message::FMsgS(systemId.value(), message);
PrintUserCmdText(client, L"Use the /back command to stop sending automatic replies to PMs.");
}
/** @ingroup AwayFromKeyboard
* @brief This command is called when a player types /back. It removes the afk status and welcomes the player back.
* who messages them know too.
*/
void UserCmdBack(ClientId& client)
{
if (const auto it = global->awayClients.begin(); std::find(it, global->awayClients.end(), client) != global->awayClients.end())
{
const auto systemId = Hk::Player::GetSystem(client);
if (systemId.has_error())
{
PrintUserCmdText(client, Hk::Err::ErrGetText(systemId.error()));
return;
}
global->awayClients.erase(it);
const std::wstring playerName = reinterpret_cast<const wchar_t*>(Players.GetActiveCharacterName(client));
const auto message = Hk::Message::FormatMsg(MessageColor::Red, MessageFormat::Normal, playerName + L" has returned");
Hk::Message::FMsgS(systemId.value(), message);
return;
}
}
// Clean up when a client disconnects
void ClearClientInfo(ClientId& client)
{
auto [first, last] = std::ranges::remove(global->awayClients, client);
global->awayClients.erase(first, last);
}
// Hook on chat being sent (This gets called twice with the client and to
// swapped
void Cb_SendChat(ClientId& client, ClientId& to, [[maybe_unused]] const uint& size, [[maybe_unused]] void** rdl)
{
if (std::ranges::find(global->awayClients, to) != global->awayClients.end())
PrintUserCmdText(client, L"This user is away from keyboard.");
}
// Hooks on chat being submitted
void SubmitChat(ClientId& client, [[maybe_unused]] const unsigned long& lP1, [[maybe_unused]] void const** rdlReader, [[maybe_unused]] ClientId& to,
[[maybe_unused]] const int& iP2)
{
if (const auto it = global->awayClients.begin();
Hk::Client::IsValidClientID(client) && std::find(it, global->awayClients.end(), client) != global->awayClients.end())
UserCmdBack(client);
}
// Client command processing
const std::vector commands = {{
CreateUserCommand(L"/afk", L"", UserCmdAfk, L"Sets your status to \"Away from Keyboard\". Other players will notified if they try to speak to you."),
CreateUserCommand(L"/back", L"", UserCmdBack, L"Removes the AFK status."),
}};
} // namespace Plugins::Afk
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FLHOOK STUFF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace Plugins::Afk;
DefaultDllMain();
// Functions to hook
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("AFK");
pi->shortName("afk");
pi->mayUnload(true);
pi->commands(&commands);
pi->returnCode(&global->returnCode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::FLHook__ClearClientInfo, &ClearClientInfo, HookStep::After);
pi->emplaceHook(HookedCall::IChat__SendChat, &Cb_SendChat);
pi->emplaceHook(HookedCall::IServerImpl__SubmitChat, &SubmitChat);
}
| 4,818
|
C++
|
.cpp
| 111
| 40.711712
| 154
| 0.700448
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,337
|
Main.cpp
|
TheStarport_FLHook/plugins/_plugin_template/Main.cpp
|
// This is a template with the bare minimum to have a functional plugin.
//
// This is free software; you can redistribute it and/or modify it as
// you wish without restriction. If you do then I would appreciate
// being notified and/or mentioned somewhere.
// Includes
#include "Main.hpp"
#include <random>
namespace Plugins::Template
{
const auto global = std::make_unique<Global>();
// Put things that are performed on plugin load here!
void LoadSettings()
{
// Load JSON config
auto config = Serializer::JsonToObject<Config>();
global->config = std::make_unique<Config>(std::move(config));
}
// Demo command
void UserCmdTemplate(ClientId& client, const std::wstring& param)
{
// Access our config value
if (global->config->overrideUserNumber)
{
std::random_device dev;
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> dist(1, 6); // distribution in range [1, 1000]
PrintUserCmdText(client, std::format(L"The gods decided your number is actually: {}", dist(rng)));
return;
}
if (const auto number = ToInt(GetParam(param, ' ', 0)); number > 0)
{
PrintUserCmdText(client, L"You put in the following number: " + std::to_wstring(number));
}
else
{
PrintUserCmdText(client, L"ERR: You must provide a valid positive non-zero number.");
}
}
// Define usable chat commands here
const std::vector commands = {{
CreateUserCommand(L"/template", L"<number>", UserCmdTemplate, L"Outputs a user provided non-zero number."),
}};
// Demo admin command
void AdminCmdTemplate(CCmds* cmds, float number)
{
if (cmds->ArgStrToEnd(1).length() == 0)
{
cmds->Print("ERR Usage: template <number>");
return;
}
if (!(cmds->rights & RIGHT_SUPERADMIN))
{
cmds->Print("ERR No permission");
return;
}
cmds->Print(std::format("Template is {}", number));
return;
}
// Admin command callback. Compare the chat entry to see if it match a command
bool ExecuteCommandString(CCmds* cmds, const std::wstring& cmd)
{
if (cmd == L"template")
{
AdminCmdTemplate(cmds, cmds->ArgFloat(1));
}
else
{
return false;
}
global->returnCode = ReturnCode::SkipAll;
return true;
}
} // namespace Plugins::Template
using namespace Plugins::Template;
REFL_AUTO(type(Config), field(overrideUserNumber));
DefaultDllMainSettings(LoadSettings);
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
// Full name of your plugin
pi->name("$projectname$");
// Shortened name, all lower case, no spaces. Abbreviation when possible.
pi->shortName("$safeprojectname$");
pi->mayUnload(true);
pi->commands(&commands);
pi->returnCode(&global->returnCode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
pi->emplaceHook(HookedCall::FLHook__AdminCommand__Process, &ExecuteCommandString);
}
| 2,950
|
C++
|
.cpp
| 91
| 29.736264
| 112
| 0.726312
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,338
|
Stats.cpp
|
TheStarport_FLHook/plugins/stats/Stats.cpp
|
/**
* @date Jan 2023
* @author Raikkonen
* @defgroup Stats Stats
* @brief
* The Stats plugin collects various statistics and exports them into a JSON for later view.
*
* @paragraph cmds Player Commands
* None
*
* @paragraph adminCmds Admin Commands
* None
*
* @paragraph configuration Configuration
* @code
* {
* "FilePath": "EXPORTS",
* "StatsFile": "stats.json"
* }
* @endcode
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*/
// Includes
#include "Stats.h"
#include <Tools/Serialization/Attributes.hpp>
namespace Plugins::Stats
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
/** @ingroup Stats
* @brief Load configuration file
*/
void LoadSettings()
{
global->jsonFileName = Serializer::JsonToObject<FileName>();
if (!std::filesystem::exists(global->jsonFileName.FilePath))
std::filesystem::create_directories(global->jsonFileName.FilePath);
Hk::Message::LoadStringDLLs();
// Load in shiparch.ini to generate Ids based off the nickname and generate
// ship names via ids_name
std::string shiparchfile = "..\\data\\ships\\shiparch.ini";
INI_Reader ini;
if (ini.open(shiparchfile.c_str(), false))
{
while (ini.read_header())
{
if (ini.is_header("Ship"))
{
int idsname = 0;
while (ini.read_value())
{
if (ini.is_value("nickname"))
{
uint shiphash = CreateID(ini.get_value_string(0));
global->Ships[shiphash] = Hk::Message::GetWStringFromIdS(idsname);
}
if (ini.is_value("ids_name"))
{
idsname = ini.get_value_int(0);
}
}
}
}
ini.close();
}
}
/** @ingroup Stats
* @brief Encodes the string as UTF-8 and removes double quotes which are invalid json
*/
std::string Encode(const std::wstring_view& data)
{
if (data.empty())
{
return "";
}
const auto size = WideCharToMultiByte(CP_UTF8, 0, &data.at(0), (int)data.size(), nullptr, 0, nullptr, nullptr);
if (size <= 0)
{
throw std::runtime_error(std::format("WideCharToMultiByte() failed: {}", std::to_string(size)));
}
std::string convertedString(size, 0);
WideCharToMultiByte(CP_UTF8, 0, &data.at(0), (int)data.size(), &convertedString.at(0), size, nullptr, nullptr);
std::string sanitizedString;
sanitizedString.reserve(convertedString.size());
for (char pos : convertedString)
{
if (pos == '\"')
sanitizedString.append(""");
else
sanitizedString.append(1, pos);
}
return sanitizedString;
}
/** @ingroup Stats
* @brief Function to export load and player data to a json file
*/
void ExportJSON()
{
std::ofstream out(global->jsonFileName.FilePath + "\\" + global->jsonFileName.StatsFile);
nlohmann::json jExport;
jExport["serverload"] = CoreGlobals::c()->serverLoadInMs;
nlohmann::json jPlayers = nlohmann::json::array();
for (const std::list<PlayerInfo> lstPlayers = Hk::Admin::GetPlayers(); auto& lstPlayer : lstPlayers)
{
nlohmann::json jPlayer;
// Add name
jPlayer["name"] = Encode(lstPlayer.character);
// Add rank
int iRank = Hk::Player::GetRank(lstPlayer.client).value();
jPlayer["rank"] = std::to_string(iRank);
// Add group
int groupId = Players.GetGroupID(lstPlayer.client);
jPlayer["group"] = groupId ? std::to_string(groupId) : "None";
// Add ship
const Archetype::Ship* ship = Archetype::GetShip(Players[lstPlayer.client].shipArchetype);
jPlayer["ship"] = ship ? wstos(global->Ships[ship->get_id()]) : "Unknown";
// Add system
SystemId iSystemId = Hk::Player::GetSystem(lstPlayer.client).value();
const Universe::ISystem* iSys = Universe::get_system(iSystemId);
jPlayer["system"] = wstos(Hk::Message::GetWStringFromIdS(iSys->strid_name));
jPlayers.push_back(jPlayer);
}
jExport["players"] = jPlayers;
out << jExport;
out.close();
}
/** @ingroup Stats
* @brief Hook for updating stats
*/
void DisConnect_AFTER([[maybe_unused]] uint client, [[maybe_unused]] enum EFLConnection state)
{
ExportJSON();
}
/** @ingroup Stats
* @brief Hook for updating stats
*/
void PlayerLaunch_AFTER([[maybe_unused]] const uint& ship, [[maybe_unused]] ClientId& client)
{
ExportJSON();
}
/** @ingroup Stats
* @brief Hook for updating stats
*/
void CharacterSelect_AFTER([[maybe_unused]] const std::string& charFilename, [[maybe_unused]] ClientId& client)
{
ExportJSON();
}
} // namespace Plugins::Stats
using namespace Plugins::Stats;
REFL_AUTO(type(FileName), field(FilePath, AttrNotEmptyNotWhiteSpace<std::string> {}), field(StatsFile, AttrNotEmptyNotWhiteSpace<std::string> {}))
DefaultDllMainSettings(LoadSettings);
// Functions to hook
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("Stats");
pi->shortName("stats");
pi->mayUnload(true);
pi->returnCode(&global->returncode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__PlayerLaunch, &PlayerLaunch_AFTER, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__DisConnect, &DisConnect_AFTER, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__CharacterSelect, &CharacterSelect_AFTER, HookStep::After);
}
| 5,349
|
C++
|
.cpp
| 166
| 29.024096
| 146
| 0.703862
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,339
|
MiscCommands.cpp
|
TheStarport_FLHook/plugins/misc_commands/MiscCommands.cpp
|
/**
* @date Feb, 2010
* @author Cannon (Ported by Raikkonen 2022)
* @defgroup MiscCommands Misc Commands
* @brief
* The "Misc Commands" plugin provides an array of useful commands that serve as general quality of life features or game enhancements.
* They are commands that do not really fit into another plugin, or have the significance to belong in FLHook Core.
*
* @paragraph cmds Player Commands
* All commands are prefixed with '/' unless explicitly specified.
* - lights - Activate optional ship lights, these usually default to ones on the docking light hardpoints.
* - shields - De/Reactivate your shields
* - pos - Prints the current absolute position of your ship
* - stuck - Nudges the ship 10m away from where they currently are while stationary. Designed to prevent player capital ships from being wedged.
* - droprep - Lowers the reputation of the current faction you are affiliated with.
* - coin - Toss a coin and print the result in local chat.
* - dice [sides] - Tosses a dice with the specified number of sides, defaulting to 6.
* - value - Prints the total value of your ship.
*
* @paragraph adminCmds Admin Commands
* All commands are prefixed with '.' unless explicitly specified.
* - smiteall [die] - Remove all shields of all players within 15k and plays music.
* If [die] is specified, then instead of lowering shields, it kills the players.
*
* @paragraph configuration Configuration
* @code
* {
* "coinMessage": "%player tosses %result",
* "diceMessage": "%player rolled %number of %max",
* "repDropCost": 0,
* "smiteMusicId": "music_danger",
* "stuckMessage": "Attention! Stand Clear. Towing %player"
* }
* @endcode
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*/
#include "MiscCommands.h"
namespace Plugins::MiscCommands
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
// Load the configuration
void LoadSettings()
{
auto config = Serializer::JsonToObject<Config>();
global->smiteMusicHash = CreateID(config.smiteMusicId.c_str());
global->config = std::make_unique<Config>(config);
}
/** Clean up when a client disconnects */
void ClearClientInfo(ClientId& client)
{
global->mapInfo.erase(client);
}
/** One second timer */
void OneSecondTimer()
{
// Drop player shields and keep them down.
for (const auto& [id, info] : global->mapInfo)
{
if (auto charName = Hk::Client::GetCharacterNameByID(id); info.shieldsDown && charName.has_value())
{
if (const auto playerInfo = Hk::Admin::GetPlayerInfo(charName.value(), false); playerInfo.has_value() && playerInfo.value().ship)
{
pub::SpaceObj::DrainShields(playerInfo.value().ship);
}
}
}
}
const std::vector<Timer> timers = {{OneSecondTimer, 1}};
static void SetLights(ClientId client, bool lightsStatus)
{
auto ship = Hk::Player::GetShip(client);
if (ship.has_error())
{
PrintUserCmdText(client, L"ERR Not in space");
return;
}
bool bLights = false;
for (st6::list<EquipDesc> const& eqLst = Players[client].equipDescList.equip; const auto& eq : eqLst)
{
std::string hp = ToLower(eq.szHardPoint.value);
if (hp.find("dock") != std::string::npos)
{
XActivateEquip ActivateEq;
ActivateEq.bActivate = lightsStatus;
ActivateEq.iSpaceId = ship.value();
ActivateEq.sId = eq.sId;
Server.ActivateEquip(client, ActivateEq);
bLights = true;
}
}
if (bLights)
PrintUserCmdText(client, std::format(L" Lights {}", lightsStatus ? L"on" : L"off"));
else
PrintUserCmdText(client, L"Light control not available");
}
/** @ingroup MiscCommands
* @brief Print the current location of your ship
*/
void UserCmdPos(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
const auto playerInfo = Hk::Admin::GetPlayerInfo(Hk::Client::GetCharacterNameByID(client).value(), false);
if (playerInfo.has_error() || !playerInfo.value().ship)
{
PrintUserCmdText(client, L"ERR Not in space");
return;
}
auto [pos, rot] = Hk::Solar::GetLocation(playerInfo.value().ship, IdType::Ship).value();
Vector erot = Hk::Math::MatrixToEuler(rot);
wchar_t buf[100];
_snwprintf_s(buf, sizeof(buf), L"Position %0.0f %0.0f %0.0f Orient %0.0f %0.0f %0.0f", pos.x, pos.y, pos.z, erot.x, erot.y, erot.z);
PrintUserCmdText(client, buf);
}
/** @ingroup MiscCommands
* @brief Nudge your ship 15 meters on all axis to try and dislodge a stuck ship.
*/
void UserCmdStuck(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
std::wstring wscCharname = (const wchar_t*)Players.GetActiveCharacterName(client);
const auto playerInfo = Hk::Admin::GetPlayerInfo(Hk::Client::GetCharacterNameByID(client).value(), false);
if (playerInfo.has_error() || !playerInfo.value().ship)
{
PrintUserCmdText(client, L"ERR Not in space");
return;
}
auto motion = Hk::Solar::GetMotion(playerInfo.value().ship);
if (motion.has_error())
{
Console::ConWarn(wstos(Hk::Err::ErrGetText(motion.error())));
}
const auto& [dir1, dir2] = motion.value();
if (dir1.x > 5 || dir1.y > 5 || dir1.z > 5)
{
PrintUserCmdText(client, L"ERR Ship is moving");
return;
}
auto [pos, rot] = Hk::Solar::GetLocation(playerInfo.value().ship, IdType::Ship).value();
pos.x += 15;
pos.y += 15;
pos.z += 15;
Hk::Player::RelocateClient(client, pos, rot);
std::wstring wscMsg = global->config->stuckMessage;
wscMsg = ReplaceStr(wscMsg, L"%player", wscCharname);
PrintLocalUserCmdText(client, wscMsg, 6000.0f);
}
/** @ingroup MiscCommands
* @brief Command to remove your current affiliation if applicable.
*/
void UserCmdDropRep(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
if (!global->config->enableDropRep)
{
PrintUserCmdText(client, L"Command Disabled");
return;
}
auto repGroupNick = Hk::Ini::GetFromPlayerFile(client, L"rep_group");
if (repGroupNick.has_error())
{
PrintUserCmdText(client, Hk::Err::ErrGetText(repGroupNick.error()));
return;
}
// Read the current number of credits for the player
// and check that the character has enough cash.
const auto iCash = Hk::Player::GetCash(client);
if (iCash.has_error())
{
PrintUserCmdText(client, std::format(L"ERR {}", Hk::Err::ErrGetText(iCash.error())));
return;
}
if (global->config->repDropCost > 0 && iCash < global->config->repDropCost)
{
PrintUserCmdText(client, L"ERR Insufficient credits");
return;
}
if (const auto repValue = Hk::Player::GetRep(client, repGroupNick.value()); repValue.has_error())
{
PrintUserCmdText(client, std::format(L"ERR {}", Hk::Err::ErrGetText(repValue.error())));
return;
}
Hk::Player::SetRep(client, repGroupNick.value(), 0.599f);
PrintUserCmdText(client, L"OK Reputation dropped, logout for change to take effect.");
// Remove cash if we're charging for it.
if (global->config->repDropCost > 0)
{
Hk::Player::RemoveCash(client, global->config->repDropCost);
}
}
/** @ingroup MiscCommands
* @brief Roll a dice with the specified number of sides, or 6 is not specified.
*/
void UserCmdDice(ClientId& client, const std::wstring& param)
{
const std::wstring charName = reinterpret_cast<const wchar_t*>(Players.GetActiveCharacterName(client));
int max = ToInt(GetParam(param, ' ', 0));
if (max <= 1)
max = 6;
const uint number = rand() % max + 1;
std::wstring msg = global->config->diceMessage;
msg = ReplaceStr(msg, L"%player", charName);
msg = ReplaceStr(msg, L"%number", std::to_wstring(number));
msg = ReplaceStr(msg, L"%max", std::to_wstring(max));
PrintLocalUserCmdText(client, msg, 6000.0f);
}
/** @ingroup MiscCommands
* @brief Throw the dice and tell all players within 6 km
*/
void UserCmdCoin(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
const std::wstring charName = (const wchar_t*)Players.GetActiveCharacterName(client);
const uint number = (rand() % 2);
std::wstring msg = global->config->coinMessage;
msg = ReplaceStr(msg, L"%player", charName);
msg = ReplaceStr(msg, L"%result", (number == 1) ? L"heads" : L"tails");
PrintLocalUserCmdText(client, msg, 6000.0f);
}
void UserCmdValue(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
auto shipValue = Hk::Player::GetShipValue(client);
if (shipValue.has_error())
{
PrintUserCmdText(client, Hk::Err::ErrGetText(shipValue.error()));
}
else
{
PrintUserCmdText(client, stows(std::format("{}", shipValue.value())));
}
}
/** @ingroup MiscCommands
* @brief Activate or deactivate docking lights on your ship.
*/
void UserCmdLights(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
global->mapInfo[client].lightsOn = !global->mapInfo[client].lightsOn;
SetLights(client, global->mapInfo[client].lightsOn);
}
/** @ingroup MiscCommands
* @brief Disable/Enable your shields at will.
*/
void UserCmdShields(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
global->mapInfo[client].shieldsDown = !global->mapInfo[client].shieldsDown;
PrintUserCmdText(client, std::format(L"Shields {}", global->mapInfo[client].shieldsDown ? L"Disabled" : L"Enabled"));
}
// Client command processing
const std::vector commands = {{
CreateUserCommand(L"/togglelights", L"", UserCmdLights, L"Activate optional ship lights"),
CreateUserCommand(L"/shields", L"", UserCmdShields, L"Toggles your shields on or off."),
CreateUserCommand(L"/pos", L"", UserCmdPos, L"Prints the current absolute position of your ship."),
CreateUserCommand(L"/stuck", L"", UserCmdStuck, L"Nudges your ship 10m away from where they currently are while stationary."),
CreateUserCommand(L"/droprep", L"", UserCmdDropRep, L"Lowers your reputation of the current faction you are affiliated with"),
CreateUserCommand(L"/dice", L"[Sides]", UserCmdDice, L"Tosses a dice with the specified number of sides, defaulting to 6."),
CreateUserCommand(L"/coin", L"", UserCmdCoin, L"Toss a coin and print the result in local chat."),
CreateUserCommand(L"/value", L"", UserCmdValue, L"Prints the total value of your ship."),
}};
/** @} */ // End of user commands
//! Smite all players in radar range
void AdminCmdSmiteAll(CCmds* cmds)
{
if (!(cmds->rights & RIGHT_SUPERADMIN))
{
cmds->Print("ERR No permission");
return;
}
const auto playerInfo = Hk::Admin::GetPlayerInfo(cmds->GetAdminName(), false);
if (playerInfo.has_error() || !playerInfo.value().ship)
{
cmds->Print("ERR Not in space");
return;
}
const bool bKillAll = cmds->ArgStr(1) == L"die";
const auto& [fromShipPos, _] = Hk::Solar::GetLocation(playerInfo.value().ship, IdType::Ship).value();
pub::Audio::Tryptich music;
music.iDunno = 0;
music.iDunno2 = 0;
music.iDunno3 = 0;
music.iMusicId = global->smiteMusicHash;
pub::Audio::SetMusic(playerInfo.value().client, music);
// For all players in system...
PlayerData* playerData = nullptr;
while ((playerData = Players.traverse_active(playerData)))
{
// Get the this player's current system and location in the system.
ClientId client = playerData->iOnlineId;
if (client == playerInfo.value().client)
continue;
if (playerInfo.value().iSystem != Hk::Player::GetSystem(client).value())
continue;
uint ship = Hk::Player::GetShip(client).value();
const auto& [playerPosition, _] = Hk::Solar::GetLocation(ship, IdType::Ship).value();
// Is player within scanner range (15K) of the sending char.
if (Hk::Math::Distance3D(playerPosition, fromShipPos) > 14999)
continue;
pub::Audio::SetMusic(client, music);
global->mapInfo[client].shieldsDown = true;
if (bKillAll)
{
if (const auto obj = Hk::Client::GetInspect(client); obj.has_value())
{
Hk::Admin::LightFuse(reinterpret_cast<IObjRW*>(obj.value()), CreateID("death_comm"), 0.0f, 0.0f, 0.0f);
}
}
}
cmds->Print("OK");
return;
}
bool ExecuteCommandString(CCmds* cmds, const std::wstring& cmd)
{
if (!cmds->IsPlayer())
return false;
if (cmd == L"smiteall")
{
global->returncode = ReturnCode::SkipAll;
AdminCmdSmiteAll(cmds);
return true;
}
return false;
}
} // namespace Plugins::MiscCommands
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FLHOOK STUFF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace Plugins::MiscCommands;
// REFL_AUTO must be global namespace
REFL_AUTO(type(Config), field(repDropCost), field(stuckMessage), field(diceMessage), field(coinMessage), field(smiteMusicId), field(enableDropRep))
DefaultDllMainSettings(LoadSettings);
// Functions to hook
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("Misc Commands");
pi->shortName("MiscCommands");
pi->mayUnload(true);
pi->commands(&commands);
pi->timers(&timers);
pi->returnCode(&global->returncode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::FLHook__AdminCommand__Process, &ExecuteCommandString);
pi->emplaceHook(HookedCall::FLHook__ClearClientInfo, &ClearClientInfo, HookStep::After);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
}
| 13,381
|
C++
|
.cpp
| 341
| 36.152493
| 147
| 0.699861
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,340
|
KillTracker.cpp
|
TheStarport_FLHook/plugins/kill_tracker/KillTracker.cpp
|
/**
* @date Unknown
* @author ||KOS||Acid (Ported by Raikkonen)
* @defgroup KillTracker Kill Tracker
* @brief
* This plugin is used to count pvp kills and save them in the player file. Vanilla doesn't do this by default.
* Also keeps track of damage taken between players, prints greatest damage contributor.
*
* @paragraph cmds Player Commands
* All commands are prefixed with '/' unless explicitly specified.
* - kills {client} - Shows the pvp kills for a player if a client id is specified, or if not, the player who typed it.
*
* @paragraph adminCmds Admin Commands
* There are no admin commands in this plugin.
*
* @paragraph configuration Configuration
* No configuration file is needed.
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*
* @paragraph optional Optional Plugin Dependencies
* This plugin has no dependencies.
*/
#include "KillTracker.h"
IMPORT uint g_DmgTo;
namespace Plugins::KillTracker
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
/** @ingroup KillTracker
* @brief Prints number of NPC kills for each arch
*/
void PrintNPCKills(uint client, std::wstring& charFile, int& numKills)
{
for (const auto lines = Hk::Player::ReadCharFile(charFile); auto& str : lines.value())
{
if (std::wstring lineName = Trim(GetParam(str, '=', 0)); lineName == L"ship_type_killed")
{
uint shipArchId = ToUInt(GetParam(str, '=', 1));
int count = ToInt(GetParam(str, ',', 1).c_str());
numKills += count;
const Archetype::Ship* ship = Archetype::GetShip(shipArchId);
if (!ship)
continue;
PrintUserCmdText(client, std::format(L"NPC kills: {} {}", Hk::Message::GetWStringFromIdS(ship->iIdsName), count));
}
}
PrintUserCmdText(client, std::format(L"Total kills: {}", numKills));
}
/** @ingroup KillTracker
* @brief Called when a player types "/kills".
*/
void UserCmd_Kills(ClientId& client, const std::wstring& wscParam)
{
std::wstring targetCharName = GetParam(wscParam, ' ', 0);
uint clientId;
if (!targetCharName.empty())
{
const auto clientPlayer = Hk::Client::GetClientIdFromCharName(targetCharName);
if (clientPlayer.has_error())
{
PrintUserCmdText(client, Hk::Err::ErrGetText(clientPlayer.error()));
return;
}
clientId = clientPlayer.value();
}
else
{
clientId = client;
}
int numKills = Hk::Player::GetPvpKills(client).value();
PrintUserCmdText(client, std::format(L"PvP kills: {}", numKills));
if (global->config->enableNPCKillOutput)
{
std::wstring printCharname = Hk::Client::GetCharacterNameByID(clientId).value();
PrintNPCKills(client, printCharname, numKills);
}
int rank = Hk::Player::GetRank(client).value();
PrintUserCmdText(client, std::format(L"Level: {}", rank));
}
/** @ingroup KillTracker
* @brief Keeps track of the kills of the player during their current session
*/
void TrackKillStreaks(ClientId& clientVictim, ClientId& clientKiller = NULL)
{
if (clientKiller != NULL)
{
if (auto killerKillStreak = global->killStreaks.find(clientKiller); killerKillStreak != global->killStreaks.end())
{
global->killStreaks[clientKiller]++;
}
else if (killerKillStreak == global->killStreaks.end())
{
global->killStreaks[clientKiller] = 1;
};
}
if (auto victimKillStreak = global->killStreaks.find(clientVictim); victimKillStreak != global->killStreaks.end())
{
global->killStreaks[clientVictim] = 0;
}
}
/** @ingroup KillTracker
* @brief Hook on ShipDestroyed. Increments the number of kills of a player if there is one.
*/
void ShipDestroyed(DamageList** _dmg, const DWORD** ecx, const uint& kill)
{
if (kill == 1)
{
const CShip* cShip = Hk::Player::CShipFromShipDestroyed(ecx);
if (ClientId client = cShip->GetOwnerPlayer())
{
const DamageList* dmg = *_dmg;
const auto killerId = Hk::Client::GetClientIdByShip(
dmg->get_cause() == DamageCause::Unknown ? ClientInfo[client].dmgLast.get_inflictor_id() : dmg->get_inflictor_id());
const auto victimId = Hk::Client::GetClientIdByShip(cShip->get_id());
if (killerId.has_value() && victimId.has_value() && killerId.value() != client)
{
Hk::Player::IncrementPvpKills(killerId.value());
TrackKillStreaks(*victimId, *killerId);
}
else if (victimId.has_value() && killerId.value() != client)
{
TrackKillStreaks(*victimId);
}
}
}
}
/** @ingroup KillTracker
* @brief Hook on damage entry
*/
void AddDamageEntry(
const DamageList** damageList, const ushort& subObjId, const float& newHitPoints, [[maybe_unused]] const enum DamageEntry::SubObjFate& fate)
{
if (global->config->enableDamageTracking && g_DmgTo && subObjId == 1)
{
if (const auto& inflictor = (*damageList)->inflictorPlayerId; inflictor && g_DmgTo && inflictor != g_DmgTo)
{
float hpLost = global->lastPlayerHealth[g_DmgTo] - newHitPoints;
global->damageArray[inflictor][g_DmgTo] += hpLost;
}
global->lastPlayerHealth[g_DmgTo] = newHitPoints;
}
}
/** @ingroup KillTracker
* @brief Clears the damage taken for a given ClientId
*/
void clearDamageTaken(ClientId& victim)
{
for (auto& damageEntry : global->damageArray[victim])
damageEntry = 0.0f;
}
/** @ingroup KillTracker
* @brief Clears the damage done for a given ClientId
*/
void clearDamageDone(ClientId& inflictor)
{
for (int i = 1; i < MaxClientId + 1; i++)
global->damageArray[i][inflictor] = 0.0f;
}
/** @ingroup KillTracker
* @brief Hook on SendDeathMessage, prints out the various messages this plugin is responsible for sending
*/
void SendDeathMessage([[maybe_unused]] const std::wstring& message, const SystemId& system, ClientId& clientVictim, ClientId& clientKiller)
{
if (global->config->enableDamageTracking && clientVictim && clientKiller)
{
uint greatestInflictorId = 0;
float greatestDamageDealt = 0.0f;
float totalDamageTaken = 0.0f;
for (uint inflictorIndex = 1; inflictorIndex < global->damageArray[0].size(); inflictorIndex++)
{
float damageDealt = global->damageArray[inflictorIndex][clientVictim];
totalDamageTaken += damageDealt;
if (damageDealt > greatestDamageDealt)
{
greatestDamageDealt = damageDealt;
greatestInflictorId = inflictorIndex;
}
}
clearDamageTaken(clientVictim);
if (totalDamageTaken == 0.0f || greatestInflictorId == 0)
return;
std::wstring victimName = Hk::Client::GetCharacterNameByID(clientVictim).value();
std::wstring greatestInflictorName = Hk::Client::GetCharacterNameByID(greatestInflictorId).value();
auto damage = static_cast<uint>(ceil((greatestDamageDealt / totalDamageTaken) * 100));
std::wstring greatestDamageMessage =
std::vformat(global->config->deathDamageTemplate, std::make_wformat_args(victimName, greatestInflictorName, damage));
greatestDamageMessage = Hk::Message::FormatMsg(MessageColor::Orange, MessageFormat::Normal, greatestDamageMessage);
Hk::Message::FMsgS(system, greatestDamageMessage);
}
// Messages relating to kill streaks
if (!global->killStreakTemplates.empty() && clientVictim && clientKiller)
{
std::wstring killerName = Hk::Client::GetCharacterNameByID(clientKiller).value();
std::wstring victimName = Hk::Client::GetCharacterNameByID(clientVictim).value();
uint numKills;
if (global->killStreaks.contains(clientKiller))
{
numKills = global->killStreaks[clientKiller];
}
const auto templateMessage = global->killStreakTemplates.find(numKills);
if (templateMessage != global->killStreakTemplates.end())
{
std::wstring killStreakMessage = std::vformat(templateMessage->second, std::make_wformat_args(killerName, victimName, numKills));
killStreakMessage = Hk::Message::FormatMsg(MessageColor::Orange, MessageFormat::Normal, killStreakMessage);
Hk::Message::FMsgS(system, killStreakMessage);
}
}
// Messages relating to milestones
if (!global->milestoneTemplates.empty() && clientKiller)
{
std::wstring killerName = Hk::Client::GetCharacterNameByID(clientKiller).value();
auto numServerKills = Hk::Player::GetPvpKills(killerName).value();
auto templateMessage = global->milestoneTemplates.find(numServerKills);
if (templateMessage != global->milestoneTemplates.end())
{
std::wstring milestoneMessage = std::vformat(templateMessage->second, std::make_wformat_args(killerName, numServerKills));
milestoneMessage = Hk::Message::FormatMsg(MessageColor::Orange, MessageFormat::Normal, milestoneMessage);
Hk::Message::FMsgS(system, milestoneMessage);
}
}
}
/** @ingroup KillTracker
* @brief Disconnect hook. Clears all the info we are tracking
*/
void Disconnect(ClientId& client, [[maybe_unused]] EFLConnection conn)
{
if (global->config->enableDamageTracking)
{
clearDamageTaken(client);
clearDamageDone(client);
}
if (!global->killStreakTemplates.empty())
{
auto clientStreakEntry = global->killStreaks.find(client);
if (clientStreakEntry != global->killStreaks.end())
{
global->killStreaks.erase(clientStreakEntry);
}
}
}
/** @ingroup KillTracker
* @brief PlayerLaunch hook. Clears damage tracking
*/
void PlayerLaunch([[maybe_unused]] ShipId shipId, ClientId& client)
{
if (global->config->enableDamageTracking)
{
clearDamageTaken(client);
clearDamageDone(client);
if (Hk::Client::IsValidClientID(client))
{
float maxHp = Archetype::GetShip(Hk::Player::GetShipID(client).value())->fHitPoints;
global->lastPlayerHealth[client] = maxHp * Players[client].fRelativeHealth;
}
}
}
/** @ingroup KillTracker
* @brief CharacterSelect hook. Clears damage tracking
*/
void CharacterSelect([[maybe_unused]] CHARACTER_ID const& cid, ClientId& client)
{
if (global->config->enableDamageTracking)
{
clearDamageTaken(client);
clearDamageDone(client);
}
}
const std::vector commands = {{
CreateUserCommand(L"/kills", L"[playerName]", UserCmd_Kills, L"Displays how many pvp kills you (or player you named) have."),
}};
/** @ingroup KillTracker
* @brief LoadSettings hook. Loads/generates config file and sets up global variables
*/
void LoadSettings()
{
auto config = Serializer::JsonToObject<Config>();
global->config = std::make_unique<Config>(config);
for (auto& subArray : global->damageArray)
subArray.fill(0.0f);
for (auto const& killStreakTemplate : global->config->killStreakTemplates)
{
global->killStreakTemplates[killStreakTemplate.number] = killStreakTemplate.message;
}
for (auto const& milestoneTemplate : global->config->milestoneTemplates)
{
global->milestoneTemplates[milestoneTemplate.number] = milestoneTemplate.message;
}
}
} // namespace Plugins::KillTracker
using namespace Plugins::KillTracker;
REFL_AUTO(type(KillMessage), field(number), field(message));
REFL_AUTO(
type(Config), field(enableNPCKillOutput), field(deathDamageTemplate), field(enableDamageTracking), field(killStreakTemplates), field(milestoneTemplates));
DefaultDllMainSettings(LoadSettings);
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("Kill Tracker");
pi->shortName("killtracker");
pi->mayUnload(true);
pi->commands(&commands);
pi->returnCode(&global->returncode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
pi->emplaceHook(HookedCall::IEngine__ShipDestroyed, &ShipDestroyed);
pi->emplaceHook(HookedCall::IEngine__AddDamageEntry, &AddDamageEntry, HookStep::After);
pi->emplaceHook(HookedCall::IEngine__SendDeathMessage, &SendDeathMessage);
pi->emplaceHook(HookedCall::IServerImpl__DisConnect, &Disconnect);
pi->emplaceHook(HookedCall::IServerImpl__PlayerLaunch, &PlayerLaunch);
pi->emplaceHook(HookedCall::IServerImpl__CharacterSelect, &CharacterSelect);
}
| 11,933
|
C++
|
.cpp
| 312
| 34.913462
| 158
| 0.734812
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,341
|
Sql.cpp
|
TheStarport_FLHook/plugins/warehouse/Sql.cpp
|
#include "Warehouse.h"
namespace Plugins::Warehouse
{
void CreateSqlTables()
{
if (!global->sql.tableExists("bases"))
{
global->sql.exec("CREATE TABLE bases ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"baseId INTEGER NOT NULL CHECK(baseId >= 0));"
"CREATE TABLE players(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE,"
"baseId REFERENCES bases(baseId) ON UPDATE CASCADE NOT NULL,"
"accountId TEXT(32, 32) NOT NULL);"
"CREATE TABLE items(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE,"
"quantity INTEGER NOT NULL CHECK(quantity > 0),"
"playerId INTEGER REFERENCES players(id) ON UPDATE CASCADE NOT NULL,"
"itemId INTEGER NOT NULL);");
global->sql.exec("CREATE INDEX IDX_baseId ON bases(baseId);"
"CREATE INDEX IDX_accountId ON players(accountId);"
"CREATE INDEX IDX_item_id ON items(itemId);");
}
}
int64 GetOrAddBase(BaseId& base)
{
SQLite::Statement baseId(global->sql, "SELECT id FROM bases WHERE baseId = ?;");
baseId.bind(1, base);
if (baseId.executeStep())
{
return baseId.getColumn(0).getInt64();
}
SQLite::Statement query(global->sql, "INSERT INTO bases (baseId) VALUES(?);");
query.bind(1, base);
query.exec();
return global->sql.getLastInsertRowid();
}
int64 GetOrAddPlayer(int64 baseId, const CAccount* acc)
{
const std::string accName = wstos(acc->wszAccId);
SQLite::Statement playerId(global->sql, "SELECT id FROM players WHERE baseId = ? AND accountId = ?;");
playerId.bind(1, baseId);
playerId.bind(2, accName);
if (playerId.executeStep())
{
return playerId.getColumn(0).getInt64();
}
SQLite::Statement query(global->sql, "INSERT INTO players (baseId, accountId) VALUES(?, ?);");
query.bind(1, baseId);
query.bind(2, accName);
query.exec();
return global->sql.getLastInsertRowid();
}
void AdjustItemCount(int64 itemId, int64 count)
{
SQLite::Statement query(global->sql, "UPDATE items SET quantity = ? WHERE id = ?");
query.bind(1, count);
query.bind(2, itemId);
query.exec();
}
WareHouseItem GetOrAddItem(EquipId& item, int64 playerId, int64 quantity)
{
SQLite::Statement itemId(global->sql, "SELECT id, quantity FROM items WHERE playerId = ? AND itemId = ?;");
itemId.bind(1, playerId);
itemId.bind(2, item);
if (itemId.executeStep())
{
auto currentId = itemId.getColumn(0).getInt64();
auto currentQuantity = itemId.getColumn(1).getInt64();
if (quantity > 0)
{
currentQuantity += quantity;
AdjustItemCount(currentId, currentQuantity);
}
return {currentId, item, currentQuantity};
}
if (quantity <= 0)
{
return {0, 0};
}
SQLite::Statement query(global->sql, "INSERT INTO items (itemId, quantity, playerId) VALUES(?, ?, ?);");
query.bind(1, item);
query.bind(2, quantity);
query.bind(3, playerId);
query.exec();
return {global->sql.getLastInsertRowid(), item, quantity};
}
int64 RemoveItem(const int64& sqlId, int64 playerId, int64 quantity)
{
SQLite::Statement itemQuery(global->sql, "SELECT quantity FROM items WHERE playerId = ? AND id = ?;");
itemQuery.bind(1, playerId);
itemQuery.bind(2, sqlId);
if(!itemQuery.executeStep())
{
return 0;
}
const auto itemCount = itemQuery.getColumn(0).getInt64();
if (quantity >= itemCount)
{
SQLite::Statement query(global->sql, "DELETE FROM items WHERE id = ?;");
query.bind(1, sqlId);
return query.exec() ? itemCount : 0;
}
AdjustItemCount(sqlId, itemCount - quantity);
return quantity;
}
std::vector<WareHouseItem> GetAllItemsOnBase(int64 sqlPlayerId, int64 flBaseId)
{
std::vector<WareHouseItem> itemList;
SQLite::Statement query(global->sql, "SELECT items.id, itemId, quantity FROM items INNER JOIN players "
"ON items.playerId = players.id WHERE players.id = ? AND baseId = ? ;");
query.bind(1, sqlPlayerId);
query.bind(2, flBaseId);
while (query.executeStep())
{
WareHouseItem item = {query.getColumn(0).getInt64(), query.getColumn(1).getUInt(), query.getColumn(2).getInt64()};
itemList.emplace_back(item);
}
return itemList;
}
std::map<int64, std::vector<WareHouseItem>> GetAllBases(int64 playerId)
{
std::map<int64, std::vector<WareHouseItem>> basesWithItems;
SQLite::Statement query(global->sql, "SELECT bases.baseId FROM bases INNER JOIN "
"players ON players.baseId = bases.id WHERE players.id = ?;");
query.bind(1, playerId);
while (query.executeStep())
{
int64 baseId = query.getColumn(0).getInt64();
auto itemsOnBase = GetAllItemsOnBase(playerId, baseId);
if (!itemsOnBase.empty())
{
basesWithItems[baseId] = itemsOnBase;
}
}
return basesWithItems;
}
} // namespace Plugins::Warehouse
| 4,875
|
C++
|
.cpp
| 136
| 31.102941
| 117
| 0.681086
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,342
|
Warehouse.cpp
|
TheStarport_FLHook/plugins/warehouse/Warehouse.cpp
|
/**
* @date Jan, 2023
* @author Lazrius
* @defgroup Warehouse Warehouse
* @brief
* The Warehouse plugin allows players to deposit and withdraw various commodities and equipment on NPC stations, stored on internal SQL database.
*
* @paragraph cmds Player Commands
* -warehouse store <ID> <count> - deposits specified equipment or commodity into the base warehouse
* -warehouse list - lists unmounted equipment and commodities avalable for deposit
* -warehouse withdraw <ID> <count> - transfers specified equipment or commodity into your ship cargo hold
* -warehouse liststored - lists equipment and commodities deposited
*
* @paragraph adminCmds Admin Commands
* None
*
* @paragraph configuration Configuration
* @code
* {
* "costPerStackStore": 100,
* "costPerStackWithdraw": 50,
* "restrictedBases": ["Li01_01_base", "Li01_02_base"],
* "restrictedItems": ["li_gun01_mark01","li_gun01_mark02"]
* }
* @endcode
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*/
#include "Warehouse.h"
#include <Tools/Serialization/Attributes.hpp>
namespace Plugins::Warehouse
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
void LoadSettings()
{
global->config = Serializer::JsonToObject<Config>();
for (const auto& i : global->config.restrictedItems)
{
global->config.restrictedItemsHashed.emplace_back(CreateID(i.c_str()));
}
for (const auto& i : global->config.restrictedBases)
{
global->config.restrictedBasesHashed.emplace_back(CreateID(i.c_str()));
}
CreateSqlTables();
}
void UserCmdStoreItem(uint client, const std::wstring& param, uint base)
{
// This is a generated number to allow players to select the item they want to store.
const uint databaseItemId = ToUInt(GetParam(param, ' ', 1));
if (!databaseItemId)
{
PrintUserCmdText(client, L"Error Invalid Item Number");
return;
}
int _;
const auto cargo = Hk::Player::EnumCargo(client, _);
std::vector<CARGO_INFO> filteredCargo;
for (auto& info : cargo.value())
{
if (info.bMounted || info.fStatus < 1.f)
continue;
filteredCargo.emplace_back(info);
}
const uint itemCount = std::max(1u, ToUInt(GetParam(param, ' ', 2)));
if (databaseItemId > filteredCargo.size())
{
PrintUserCmdText(client, L"Error Invalid Item Number");
return;
}
const auto& item = filteredCargo[databaseItemId - 1];
if (itemCount > static_cast<uint>(item.iCount))
{
PrintUserCmdText(client, L"Error Invalid Item Quantity");
return;
}
if (std::ranges::find(global->config.restrictedItemsHashed, item.iArchId) != global->config.restrictedItemsHashed.end())
{
PrintUserCmdText(client, L"Error: This item is restricted from being stored.");
return;
}
if (const uint cash = Hk::Player::GetCash(client).value(); cash < global->config.costPerStackStore)
{
PrintUserCmdText(
client, std::format(L"Not enough credits. The fee for storing items at this station is {} credits.", global->config.costPerStackStore));
return;
}
Hk::Player::RemoveCash(client, global->config.costPerStackStore);
Hk::Player::RemoveCargo(client, item.iId, itemCount);
const auto account = Hk::Client::GetAccountByClientID(client);
const auto sqlBaseId = GetOrAddBase(base);
const auto sqlPlayerId = GetOrAddPlayer(sqlBaseId, account);
const auto wareHouseItem = GetOrAddItem(item.iArchId, sqlPlayerId, itemCount);
PrintUserCmdText(client, std::format(L"Successfully stored {} item(s) for a total of {}", itemCount, wareHouseItem.quantity, wareHouseItem.id));
Hk::Player::SaveChar(client);
}
void UserCmdGetItems(uint client, [[maybe_unused]] const std::wstring& param, [[maybe_unused]] uint base)
{
int _;
const auto cargo = Hk::Player::EnumCargo(client, _);
int index = 0;
for (const auto& info : cargo.value())
{
if (info.bMounted || info.fStatus < 1.f)
continue;
const auto* equip = Archetype::GetEquipment(info.iArchId);
index++;
PrintUserCmdText(client, std::format(L"{}) {} x{}", index, Hk::Message::GetWStringFromIdS(equip->iIdsName), info.iCount));
}
}
void UserCmdGetWarehouseItems(uint client, const std::wstring& param, uint baseId)
{
const auto account = Hk::Client::GetAccountByClientID(client);
const auto sqlBaseId = GetOrAddBase(baseId);
const auto sqlPlayerId = GetOrAddPlayer(sqlBaseId, account);
const auto paramCheck = GetParam(param, ' ', 1);
if (paramCheck == L"all")
{
const auto baseMap = GetAllBases(sqlPlayerId);
if (baseMap.empty())
{
PrintUserCmdText(client, L"You have no items stored anywhere.");
return;
}
for (auto& i : baseMap)
{
const auto base = Universe::get_base(static_cast<uint>(i.first));
const auto baseName = Hk::Message::GetWStringFromIdS(base->baseIdS);
PrintUserCmdText(client, std::format(L"{} : {} item(s)", baseName, i.second.size()));
}
return;
}
const auto itemList = GetAllItemsOnBase(sqlPlayerId, baseId);
if (itemList.empty())
{
PrintUserCmdText(client, L"You have no items stored at this warehouse.");
return;
}
int index = 0;
for (const auto& info : itemList)
{
const auto* equip = Archetype::GetEquipment(info.equipArchId);
if (!equip)
{
Console::ConWarn(std::format("Item archetype {} no loner exists", info.equipArchId));
continue;
}
index++;
PrintUserCmdText(client, std::format(L"{}) {} x{}", index, Hk::Message::GetWStringFromIdS(equip->iIdsName), info.quantity));
}
}
void UserCmdWithdrawItem(uint client, const std::wstring& param, uint base)
{
// This is a generated number to allow players to select the item they want to store.
const uint itemId = ToInt(GetParam(param, ' ', 1));
if (!itemId)
{
PrintUserCmdText(client, L"Error Invalid Item Number");
return;
}
int remainingCargo;
const auto cargo = Hk::Player::EnumCargo(client, remainingCargo);
const int itemCount = std::max(1, ToInt(GetParam(param, ' ', 2)));
if (const uint cash = Hk::Player::GetCash(client).value(); cash < global->config.costPerStackWithdraw)
{
PrintUserCmdText(
client, std::format(L"Not enough credits. The fee for storing items at this station is {} credits.", global->config.costPerStackWithdraw));
return;
}
const auto account = Hk::Client::GetAccountByClientID(client);
const auto sqlBaseId = GetOrAddBase(base);
const auto sqlPlayerId = GetOrAddPlayer(sqlBaseId, account);
const auto itemList = GetAllItemsOnBase(sqlPlayerId, sqlBaseId);
if (itemId > itemList.size())
{
PrintUserCmdText(client, L"Error Invalid Item Number");
return;
}
WareHouseItem warehouseItem = itemList.at(itemId - 1);
const auto itemArch = Archetype::GetEquipment(warehouseItem.equipArchId);
if (!itemArch)
{
Console::ConWarn("User tried to withdraw an item that no longer exists");
PrintUserCmdText(client, L"Internal server error. Item does not exist.");
return;
}
if (itemArch->fVolume * static_cast<float>(itemCount) > std::floor(remainingCargo))
{
PrintUserCmdText(client, L"Withdraw request denied. Your ship cannot accomodate cargo of this size");
return;
}
const auto withdrawnQuantity = RemoveItem(warehouseItem.id, sqlPlayerId, itemCount);
if (withdrawnQuantity == 0)
{
PrintUserCmdText(client, L"Invalid item Id");
return;
}
Hk::Player::AddCargo(client, warehouseItem.equipArchId, static_cast<int>(withdrawnQuantity), false);
Hk::Player::RemoveCash(client, global->config.costPerStackWithdraw);
Hk::Player::SaveChar(client);
PrintUserCmdText(client,
std::format(L"Successfully withdrawn Item: {} x{}", Hk::Message::GetWStringFromIdS(itemArch->iIdsName), std::to_wstring(withdrawnQuantity)));
}
void UserCmdWarehouse(ClientId& client, const std::wstring& param)
{
const std::wstring cmd = GetParam(param, ' ', 0);
if (cmd.empty())
{
PrintUserCmdText(client,
L"Usage: /warehouse store <itemId> <count> : Stores the item number from /warehouse list and the count if it is a stackable item such as "
L"goods.\n"
L"Usage: /warehouse list :Lists any cargo or unmounted equipment that you may store in this base's warehouse.\n"
L"Usage: /warehouse withdraw <itemId> <count> : Withdraws the item number listed from /warehouse liststored and the amount and places it in "
L"your cargo.\n"
L"Usage: /warehouse liststored [all]: Lists the stored items you have in this base's warehouse. Stating all will show all bases you have items "
L"on.");
return;
}
auto base = Hk::Player::GetCurrentBase(client);
if (base.has_error())
{
PrintUserCmdText(client, L"You must be docked in order to use this command.");
return;
}
auto baseVal = base.value();
if (std::ranges::find(global->config.restrictedBasesHashed, baseVal) != global->config.restrictedBasesHashed.end())
{
PrintUserCmdText(client, L"Error: The base you're attempting to use warehouse on is restricted.");
return;
}
if (cmd == L"store")
{
UserCmdStoreItem(client, param, base.value());
}
else if (cmd == L"list")
{
UserCmdGetItems(client, param, base.value());
}
else if (cmd == L"withdraw")
{
UserCmdWithdrawItem(client, param, base.value());
}
else if (cmd == L"liststored")
{
UserCmdGetWarehouseItems(client, param, base.value());
}
else
{
PrintUserCmdText(client, L"Invalid Command. Refer to /warehouse to see usage.");
}
}
const std::vector commands = {{
CreateUserCommand(L"/warehouse", L"", UserCmdWarehouse, L""),
}};
} // namespace Plugins::Warehouse
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FLHOOK STUFF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace Plugins::Warehouse;
REFL_AUTO(type(Config), field(restrictedBases), field(restrictedItems), field(costPerStackWithdraw, AttrMin {0u}, AttrMax {100000u}),
field(costPerStackStore, AttrMin {0u}, AttrMax {100000u}))
// Do things when the dll is loaded
BOOL WINAPI DllMain([[maybe_unused]] const HINSTANCE& hinstDLL, [[maybe_unused]] const DWORD fdwReason, [[maybe_unused]] const LPVOID& lpvReserved)
{
return true;
}
// Functions to hook
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("warehouse");
pi->shortName("warehouse");
pi->mayUnload(true);
pi->returnCode(&global->returnCode);
pi->commands(&commands);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
}
| 10,702
|
C++
|
.cpp
| 279
| 35.060932
| 151
| 0.707538
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,343
|
LootTables.cpp
|
TheStarport_FLHook/plugins/loot_tables/LootTables.cpp
|
/**
* @date 23/07/2023
* @author Shiniri
* @defgroup LootTables Loot Tables
* @brief
* This plugin implements functionality which allows for more control over what items get
* dropped when a ship is destroyed, and over their drop probabilities.
*
* @paragraph cmds Player Commands
* There are no cmds player commands in this plugin.
*
* @paragraph adminCmds Admin Commands
* There are no admin commands in this plugin.
*
* @paragraph configuration Configuration
* No configuration file is needed.
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*
* @paragraph optional Optional Plugin Dependencies
* This plugin depends on <random>
*/
// Includes
#include "LootTables.hpp"
namespace Plugins::LootTables
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
/** @ingroup LootTables
* @brief Checks if a certain item is on board a ship. (Potentially replaced in future)
* For now this also only works for commodities!
*/
bool CheckForItem(CShip* ship, const uint triggerItemHashed)
{
CEquipTraverser traverser(UINT_MAX);
CEquip const* equip = GetEquipManager(ship)->Traverse(traverser);
while (equip)
{
EquipDesc equipDesc;
equip->GetEquipDesc(equipDesc);
if (equipDesc.iArchId == triggerItemHashed)
{
return true;
}
equip = GetEquipManager(ship)->Traverse(traverser);
}
return false;
}
/** @ingroup LootTables
* @brief Hook on ShipDestroyed. Applies loot table if possible, drops one of the items from the table at random.
*/
void ShipDestroyed([[maybe_unused]] DamageList** dmgList, const DWORD** ecx, [[maybe_unused]] const uint& kill)
{
// Calculate what Item to drop
static std::random_device randomDevice; // Used to obtain a seed
static std::mt19937 mersenneTwisterEngine(randomDevice()); // Mersenne Twister algorithm seeded with the variable above
// Get cShip from NPC?
CShip* ship = Hk::Player::CShipFromShipDestroyed(ecx);
for (auto const& lootTable : global->config->lootTables)
{
// Check if the killed Ship has an Item on board, which would trigger the loot table
if (!CheckForItem(ship, lootTable.triggerItemHashed))
{
// Drop nothing
return;
}
// Check if the Loot Table in question applies to the destroyed ship
if (const bool isPlayer = ship->is_player(); !((isPlayer && lootTable.applyToPlayers) || (!isPlayer && lootTable.applyToNpcs)))
{
// Drop nothing
return;
}
// roll n times, depending on loottable
for (int i = 0; i < lootTable.rollCount; i++)
{
// Accumulate weights
std::vector<uint> weights;
weights.reserve(lootTable.dropWeights.size());
std::ranges::transform(lootTable.dropWeights, std::back_inserter(weights), [](const DropWeight& dw) { return dw.weighting; });
// Choose a random index
std::discrete_distribution<> discreteDistribution(weights.begin(), weights.end());
auto chosenIndex = discreteDistribution(mersenneTwisterEngine);
// Drop item corresponding to said index
Server.MineAsteroid(ship->iSystem,
ship->get_position(),
global->config->lootDropContainerHashed,
lootTable.dropWeights[chosenIndex].itemHashed,
lootTable.dropWeights[chosenIndex].dropCount,
ship->GetOwnerPlayer());
}
}
}
/** @ingroup KillTracker
* @brief LoadSettings hook. Loads/generates config file
*/
void LoadSettings()
{
// Load JSON config
auto config = Serializer::JsonToObject<Config>();
// Hash nicknames
config.lootDropContainerHashed = CreateID(config.lootDropContainer.c_str());
for (auto& lootTable : config.lootTables)
{
lootTable.triggerItemHashed = CreateID(lootTable.triggerItem.c_str());
}
global->config = std::make_unique<Config>(std::move(config));
}
} // namespace Plugins::LootTables
using namespace Plugins::LootTables;
REFL_AUTO(type(DropWeight), field(weighting), field(item), field(dropCount));
REFL_AUTO(type(LootTable), field(rollCount), field(applyToPlayers), field(applyToNpcs), field(triggerItem), field(dropWeights));
REFL_AUTO(type(Config), field(lootDropContainer), field(lootTables));
DefaultDllMainSettings(LoadSettings);
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("Loot Tables");
pi->shortName("loottables");
pi->mayUnload(true);
pi->returnCode(&global->returncode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
pi->emplaceHook(HookedCall::IEngine__ShipDestroyed, &ShipDestroyed);
}
| 4,644
|
C++
|
.cpp
| 124
| 34.25
| 130
| 0.739942
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,344
|
Tax.cpp
|
TheStarport_FLHook/plugins/tax/Tax.cpp
|
/**
* @date July, 2022
* @author Nekura Mew
* @defgroup Tax Tax
* @brief
* The Tax plugin allows players to issue 'formally' make credit demands and declare hostilities.
*
* @paragraph cmds Player Commands
* -tax <amount> - demand listed amount from the player, for amount equal zero, it declares hostilities.
* -pay - submits the demanded payment to the issuing player
*
* @paragraph adminCmds Admin Commands
* None
*
* @paragraph configuration Configuration
* @code
* {
* "cannotPay": "This rogue isn't interested in money. Run for cover, they want to kill you!",
* "customColor": 9498256,
* "customFormat": 144,
* "huntingMessage": "You are being hunted by %s. Run for cover, they want to kill you!",
* "huntingMessageOriginator": "Good luck hunting %s !",
* "killDisconnectingPlayers": true,
* "maxTax": 300,
* "minplaytimeSec": 0,
* "taxRequestReceived": "You have received a tax request: Pay %d credits to %s! Type \"/pay\" to pay the tax."
* }
* @endcode
*
* @paragraph ipc IPC Interfaces Exposed
* This plugin does not expose any functionality.
*/
#include "Tax.h"
#include <Tools/Serialization/Attributes.hpp>
namespace Plugins::Tax
{
const std::unique_ptr<Global> global = std::make_unique<Global>();
// Functions
void RemoveTax(const Tax& toRemove)
{
auto taxToRemove = std::ranges::find_if(
global->lsttax, [&toRemove](const Tax& tax) { return tax.targetId == toRemove.targetId && tax.initiatorId == toRemove.initiatorId; });
global->lsttax.erase(taxToRemove);
}
void UserCmdTax(ClientId& client, const std::wstring& param)
{
const auto& noPvpSystems = FLHookConfig::c()->general.noPVPSystemsHashed;
// no-pvp check
if (SystemId system = Hk::Player::GetSystem(client).value(); std::ranges::find(noPvpSystems, system) == noPvpSystems.end())
{
PrintUserCmdText(client, L"Error: You cannot tax in a No-PvP system.");
return;
}
const std::wstring taxAmount = GetParam(param, ' ', 0);
if (taxAmount.empty())
{
PrintUserCmdText(client, L"Usage:");
PrintUserCmdText(client, L"/tax <credits>");
}
const uint taxValue = MultiplyUIntBySuffix(taxAmount);
if (taxValue > global->config->maxTax)
{
PrintUserCmdText(client, std::format(L"Error: Maximum tax value is {} credits.", global->config->maxTax));
return;
}
const auto characterName = Hk::Client::GetCharacterNameByID(client);
const auto clientTargetObject = Hk::Player::GetTargetClientID(client);
if (clientTargetObject.has_error())
{
PrintUserCmdText(client, L"Error: You are not targeting a player.");
return;
}
const auto clientTarget = clientTargetObject.value();
const auto secs = Hk::Player::GetOnlineTime(client);
const auto targetCharacterName = Hk::Client::GetCharacterNameByID(clientTarget);
if (secs.has_error() || secs.value() < global->config->minplaytimeSec)
{
PrintUserCmdText(client, L"Error: This player doesn't have enough playtime.");
return;
}
for (const auto& [targetId, initiatorId, target, initiator, cash, f1] : global->lsttax)
{
if (targetId == clientTarget)
{
PrintUserCmdText(client, L"Error: There already is a tax request pending for this player.");
return;
}
}
Tax tax;
tax.initiatorId = client;
tax.targetId = clientTarget;
tax.cash = taxValue;
global->lsttax.push_back(tax);
std::wstring msg;
if (taxValue == 0)
msg = Hk::Message::FormatMsg(global->config->customColor,
global->config->customFormat,
std::vformat(global->config->huntingMessage, std::make_wformat_args(characterName.value())));
else
msg = Hk::Message::FormatMsg(global->config->customColor,
global->config->customFormat,
std::vformat(global->config->taxRequestReceived, std::make_wformat_args(taxValue, characterName.value())));
Hk::Message::FMsg(clientTarget, msg);
// send confirmation msg
if (taxValue > 0)
PrintUserCmdText(client, std::format(L"Tax request of {} credits sent to {}!", taxValue, targetCharacterName.value()));
else
PrintUserCmdText(client, std::vformat(global->config->huntingMessageOriginator, std::make_wformat_args(targetCharacterName.value())));
}
void UserCmdPay(ClientId& client, [[maybe_unused]] const std::wstring& param)
{
for (auto& it : global->lsttax)
if (it.targetId == client)
{
if (it.cash == 0)
{
PrintUserCmdText(client, global->config->cannotPay);
return;
}
if (const auto cash = Hk::Player::GetCash(client); cash.has_error() || cash.value() < it.cash)
{
PrintUserCmdText(client, L"You have not enough money to pay the tax.");
PrintUserCmdText(it.initiatorId, L"The player does not have enough money to pay the tax.");
return;
}
Hk::Player::RemoveCash(client, it.cash);
PrintUserCmdText(client, L"You paid the tax.");
Hk::Player::AddCash(it.initiatorId, it.cash);
const auto characterName = Hk::Client::GetCharacterNameByID(client);
PrintUserCmdText(it.initiatorId, std::format(L"{} paid the tax!", characterName.value()));
RemoveTax(it);
Hk::Player::SaveChar(client);
Hk::Player::SaveChar(it.initiatorId);
return;
}
PrintUserCmdText(client, L"Error: No tax request was found that could be accepted!");
}
void TimerF1Check()
{
PlayerData* playerData = nullptr;
while ((playerData = Players.traverse_active(playerData)))
{
ClientId client = playerData->iOnlineId;
if (ClientInfo[client].tmF1TimeDisconnect)
continue;
if (ClientInfo[client].tmF1Time && (Hk::Time::GetUnixMiliseconds() >= ClientInfo[client].tmF1Time)) // f1
{
// tax
for (const auto& it : global->lsttax)
{
if (it.targetId == client)
{
if (uint ship = Hk::Player::GetShip(client).value(); ship && global->config->killDisconnectingPlayers)
{
// F1 -> Kill
pub::SpaceObj::SetRelativeHealth(ship, 0.0);
}
const auto characterName = Hk::Client::GetCharacterNameByID(it.targetId);
PrintUserCmdText(it.initiatorId, std::format(L"Tax request to {} aborted.", characterName.value()));
RemoveTax(it);
break;
}
}
}
else if (ClientInfo[client].tmF1TimeDisconnect && (Hk::Time::GetUnixMiliseconds() >= ClientInfo[client].tmF1TimeDisconnect))
{
// tax
for (const auto& it : global->lsttax)
{
if (it.targetId == client)
{
if (uint ship = Hk::Player::GetShip(client).value())
{
// F1 -> Kill
pub::SpaceObj::SetRelativeHealth(ship, 0.0);
}
const auto characterName = Hk::Client::GetCharacterNameByID(it.targetId);
PrintUserCmdText(it.initiatorId, std::format(L"Tax request to {} aborted.", characterName.value()));
RemoveTax(it);
break;
}
}
}
}
}
// Hooks
const std::vector<Timer> timers = {{TimerF1Check, 1}};
void DisConnect([[maybe_unused]] ClientId& client, [[maybe_unused]] const enum EFLConnection& state)
{
TimerF1Check();
}
// Load Settings
void LoadSettings()
{
auto config = Serializer::JsonToObject<Config>();
global->config = std::make_unique<Config>(config);
}
// Client command processing
const std::vector commands = {{
CreateUserCommand(L"/tax", L"<amount>", UserCmdTax, L"Demand listed amount from your current target."),
CreateUserCommand(L"/pay", L"", UserCmdPay, L"Pays a tax request that has been issued to you."),
}};
} // namespace Plugins::Tax
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FLHOOK STUFF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace Plugins::Tax;
REFL_AUTO(type(Config), field(minplaytimeSec, AttrMin {0u}), field(maxTax, AttrMin {0u}), field(customColor), field(customFormat),
field(taxRequestReceived, AttrNotEmpty<std::wstring> {}), field(huntingMessage, AttrNotEmpty<std::wstring> {}),
field(huntingMessageOriginator, AttrNotEmpty<std::wstring> {}), field(cannotPay, AttrNotEmpty<std::wstring> {}), field(killDisconnectingPlayers))
DefaultDllMainSettings(LoadSettings);
extern "C" EXPORT void ExportPluginInfo(PluginInfo* pi)
{
pi->name("tax");
pi->shortName("tax");
pi->mayUnload(true);
pi->commands(&commands);
pi->timers(&timers);
pi->returnCode(&global->returnCode);
pi->versionMajor(PluginMajorVersion::VERSION_04);
pi->versionMinor(PluginMinorVersion::VERSION_00);
pi->emplaceHook(HookedCall::FLHook__LoadSettings, &LoadSettings, HookStep::After);
pi->emplaceHook(HookedCall::IServerImpl__DisConnect, &DisConnect);
}
| 8,601
|
C++
|
.cpp
| 224
| 34.691964
| 149
| 0.684602
|
TheStarport/FLHook
| 30
| 15
| 67
|
GPL-3.0
|
9/20/2024, 10:44:43 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.