mirror of
https://github.com/simtactics/niotso.git
synced 2025-03-15 08:11:22 +00:00
Mirrored rendering by libvitaboy Renderer
The next task is to add functionality to the far library to make it suitable for use directly by libvitaboy Renderer.# Please enter the commit message for your changes. Lines starting
This commit is contained in:
parent
6393955683
commit
bb904c4698
14 changed files with 116 additions and 75 deletions
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.6)
|
||||||
project(far)
|
project(far)
|
||||||
|
|
||||||
set(FAR_SOURCES
|
set(FAR_SOURCES
|
||||||
libfar.c
|
far.c
|
||||||
refpack_dec.c
|
refpack_dec.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
/* config.h - libfar build configuration */
|
/* config.h - far build configuration */
|
||||||
|
|
||||||
/* Define if you have the <stdint.h> header file. */
|
/* Define if you have the <stdint.h> header file. */
|
||||||
#define HAVE_STDINT_H
|
#define HAVE_STDINT_H
|
||||||
|
|
||||||
/* compile-in support */
|
/* compile-in support */
|
||||||
#define LIBFAR_ARCHIVEREAD
|
#define FAR_ARCHIVEREAD
|
||||||
#define LIBFAR_ARCHIVEWRITE
|
#define FAR_ARCHIVEWRITE
|
||||||
#define LIBFAR_REFPACK_DECOMPRESS
|
#define FAR_REFPACK_DECOMPRESS
|
||||||
#define LIBFAR_REFPACK_COMPRESS
|
#define FAR_REFPACK_COMPRESS
|
||||||
#define LIBFAR_SUPPORT_FAR
|
#define FAR_SUPPORT_FAR
|
||||||
#define LIBFAR_SUPPORT_DBPF
|
#define FAR_SUPPORT_DBPF
|
||||||
#define LIBFAR_SUPPORT_PERSIST
|
#define FAR_SUPPORT_PERSIST
|
||||||
#define LIBFAR_DEBUGSUPPORT
|
#define FAR_DEBUGSUPPORT
|
||||||
#define LIBFAR_FILEIO
|
#define FAR_FILEIO
|
||||||
#define LIBFAR_EMBEDDEDFUNCTIONS
|
#define FAR_EMBEDDEDFUNCTIONS
|
||||||
/* end of compile-in support */
|
/* end of compile-in support */
|
||||||
|
|
||||||
/* preferences -- on non-numerical definitions, define to 1 for "yes", 0 for "no"; */
|
/* preferences -- on non-numerical definitions, define to 1 for "yes", 0 for "no" */
|
||||||
#define LIBFAR_DEFAULT_1A 0
|
#define FAR_DEFAULT_1A 0
|
||||||
#define LIBFAR_DEFAULT_DBPF_COMPRESSED 0
|
#define FAR_DEFAULT_DBPF_COMPRESSED 0
|
||||||
#define LIBFAR_DEFAULT_MAX_FILE_NAME_LENGTH 255
|
#define FAR_DEFAULT_MAX_FILE_NAME_LENGTH 255
|
||||||
#define LIBFAR_DEFAULT_REFPACK_HNSV 0xFB
|
#define FAR_DEFAULT_REFPACK_HNSV 0xFB
|
||||||
/* end of default preferences */
|
/* end of default preferences */
|
||||||
|
|
|
@ -22,14 +22,14 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "libfar.h"
|
#include "far.h"
|
||||||
|
|
||||||
#if defined(LIBFAR_SUPPORT_PERSIST)
|
#if defined(FAR_SUPPORT_PERSIST)
|
||||||
#define LIBFAR_MINSIZE_ANY MINSIZE_PERSIST
|
#define FAR_MINSIZE_ANY MINSIZE_PERSIST
|
||||||
#elif defined(LIBFAR_SUPPORT_FAR)
|
#elif defined(FAR_SUPPORT_FAR)
|
||||||
#define LIBFAR_MINSIZE_ANY MINSIZE_FAR
|
#define FAR_MINSIZE_ANY MINSIZE_FAR
|
||||||
#else
|
#else
|
||||||
#define LIBFAR_MINSIZE_ANY MINSIZE_DBPF
|
#define FAR_MINSIZE_ANY MINSIZE_DBPF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef read_int32
|
#ifndef read_int32
|
||||||
|
@ -52,10 +52,10 @@
|
||||||
|
|
||||||
/* These options can be changed during runtime */
|
/* These options can be changed during runtime */
|
||||||
static int libfarOptions[] = {
|
static int libfarOptions[] = {
|
||||||
LIBFAR_DEFAULT_1A,
|
FAR_DEFAULT_1A,
|
||||||
LIBFAR_DEFAULT_DBPF_COMPRESSED,
|
FAR_DEFAULT_DBPF_COMPRESSED,
|
||||||
LIBFAR_DEFAULT_MAX_FILE_NAME_LENGTH,
|
FAR_DEFAULT_MAX_FILE_NAME_LENGTH,
|
||||||
LIBFAR_DEFAULT_REFPACK_HNSV
|
FAR_DEFAULT_REFPACK_HNSV
|
||||||
};
|
};
|
||||||
|
|
||||||
void libfar_set_option(int Option, int Value){
|
void libfar_set_option(int Option, int Value){
|
||||||
|
@ -68,22 +68,22 @@ int libfar_get_option(int Option){
|
||||||
int far_identify(const uint8_t * Buffer, unsigned FileSize)
|
int far_identify(const uint8_t * Buffer, unsigned FileSize)
|
||||||
{
|
{
|
||||||
if(!FileSize) FileSize = ~0;
|
if(!FileSize) FileSize = ~0;
|
||||||
else if(FileSize < LIBFAR_MINSIZE_ANY)
|
else if(FileSize < FAR_MINSIZE_ANY)
|
||||||
return FAR_TYPE_INVALID;
|
return FAR_TYPE_INVALID;
|
||||||
|
|
||||||
#ifdef LIBFAR_SUPPORT_FAR
|
#ifdef FAR_SUPPORT_FAR
|
||||||
if(FileSize >= MINSIZE_FAR)
|
if(FileSize >= MINSIZE_FAR)
|
||||||
if(!memcmp(Buffer, Header_FAR, 8))
|
if(!memcmp(Buffer, Header_FAR, 8))
|
||||||
return FAR_TYPE_FAR;
|
return FAR_TYPE_FAR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LIBFAR_SUPPORT_DBPF
|
#ifdef FAR_SUPPORT_DBPF
|
||||||
if(FileSize >= MINSIZE_DBPF)
|
if(FileSize >= MINSIZE_DBPF)
|
||||||
if(!memcmp(Buffer, Header_DBPF, 4))
|
if(!memcmp(Buffer, Header_DBPF, 4))
|
||||||
return FAR_TYPE_DBPF;
|
return FAR_TYPE_DBPF;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LIBFAR_SUPPORT_PERSIST
|
#ifdef FAR_SUPPORT_PERSIST
|
||||||
if(FileSize >= MINSIZE_PERSIST)
|
if(FileSize >= MINSIZE_PERSIST)
|
||||||
if(Buffer[0] == 0x01)
|
if(Buffer[0] == 0x01)
|
||||||
return FAR_TYPE_PERSIST;
|
return FAR_TYPE_PERSIST;
|
||||||
|
@ -158,10 +158,10 @@ FAREntryNode * far_add_entry(FARFile * FARFileInfo, int Position)
|
||||||
int far_read_header(FARFile * FARFileInfo, const uint8_t * Buffer, unsigned FileSize)
|
int far_read_header(FARFile * FARFileInfo, const uint8_t * Buffer, unsigned FileSize)
|
||||||
{
|
{
|
||||||
if(!FileSize) FileSize = ~0;
|
if(!FileSize) FileSize = ~0;
|
||||||
else if(FileSize < LIBFAR_MINSIZE_ANY)
|
else if(FileSize < FAR_MINSIZE_ANY)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#ifdef LIBFAR_SUPPORT_FAR
|
#ifdef FAR_SUPPORT_FAR
|
||||||
if(FARFileInfo->Type == FAR_TYPE_FAR){
|
if(FARFileInfo->Type == FAR_TYPE_FAR){
|
||||||
FARFileInfo->MajorVersion = read_uint32(Buffer+8);
|
FARFileInfo->MajorVersion = read_uint32(Buffer+8);
|
||||||
FARFileInfo->IndexOffset = read_uint32(Buffer+12);
|
FARFileInfo->IndexOffset = read_uint32(Buffer+12);
|
||||||
|
@ -170,7 +170,7 @@ int far_read_header(FARFile * FARFileInfo, const uint8_t * Buffer, unsigned File
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(FARFileInfo->MajorVersion == 1)
|
if(FARFileInfo->MajorVersion == 1)
|
||||||
FARFileInfo->Revision = !libfarOptions[LIBFAR_CONFIG_DEFAULT_TO_1A];
|
FARFileInfo->Revision = !libfarOptions[FAR_CONFIG_DEFAULT_TO_1A];
|
||||||
|
|
||||||
if(FARFileInfo->IndexOffset > FileSize-4)
|
if(FARFileInfo->IndexOffset > FileSize-4)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -187,7 +187,7 @@ int far_read_header(FARFile * FARFileInfo, const uint8_t * Buffer, unsigned File
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LIBFAR_SUPPORT_DBPF
|
#ifdef FAR_SUPPORT_DBPF
|
||||||
if(FARFileInfo->Type == FAR_TYPE_DBPF){
|
if(FARFileInfo->Type == FAR_TYPE_DBPF){
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ int far_read_entry(const FARFile * FARFileInfo, FAREntry * FAREntryInfo,
|
||||||
if(MaxEntrySize == 0) MaxEntrySize = ~0;
|
if(MaxEntrySize == 0) MaxEntrySize = ~0;
|
||||||
if(ArchiveSize == 0) ArchiveSize = ~0;
|
if(ArchiveSize == 0) ArchiveSize = ~0;
|
||||||
|
|
||||||
#ifdef LIBFAR_SUPPORT_FAR
|
#ifdef FAR_SUPPORT_FAR
|
||||||
if(FARFileInfo->Type == FAR_TYPE_FAR){
|
if(FARFileInfo->Type == FAR_TYPE_FAR){
|
||||||
unsigned MinEntrySize =
|
unsigned MinEntrySize =
|
||||||
(MajorVersion == 1) ? (
|
(MajorVersion == 1) ? (
|
||||||
|
@ -269,7 +269,7 @@ int far_read_entry(const FARFile * FARFileInfo, FAREntry * FAREntryInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
if(FAREntryInfo->FilenameLength > MaxEntrySize - MinEntrySize) return 0;
|
if(FAREntryInfo->FilenameLength > MaxEntrySize - MinEntrySize) return 0;
|
||||||
if(FAREntryInfo->FilenameLength > (unsigned)libfarOptions[LIBFAR_CONFIG_MAX_FILE_NAME_LENGTH]) return 0;
|
if(FAREntryInfo->FilenameLength > (unsigned)libfarOptions[FAR_CONFIG_MAX_FILE_NAME_LENGTH]) return 0;
|
||||||
|
|
||||||
if(FAREntryInfo->CompressedSize > FAREntryInfo->DecompressedSize) return 0;
|
if(FAREntryInfo->CompressedSize > FAREntryInfo->DecompressedSize) return 0;
|
||||||
if(FAREntryInfo->DecompressedSize != 0){
|
if(FAREntryInfo->DecompressedSize != 0){
|
||||||
|
@ -286,7 +286,7 @@ int far_read_entry(const FARFile * FARFileInfo, FAREntry * FAREntryInfo,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LIBFAR_SUPPORT_DBPF
|
#ifdef FAR_SUPPORT_DBPF
|
||||||
if(FARFileInfo->Type == FAR_TYPE_DBPF){
|
if(FARFileInfo->Type == FAR_TYPE_DBPF){
|
||||||
if(MaxEntrySize < SIZEOF_ENTRY_DBPF) return 0;
|
if(MaxEntrySize < SIZEOF_ENTRY_DBPF) return 0;
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ int far_read_entry_data(const FARFile * FARFileInfo, FAREntry * FAREntryInfo, ui
|
||||||
int Compressed = (FARFileInfo->Type == FAR_TYPE_FAR) ? (
|
int Compressed = (FARFileInfo->Type == FAR_TYPE_FAR) ? (
|
||||||
(FARFileInfo->MajorVersion == 1) ? (
|
(FARFileInfo->MajorVersion == 1) ? (
|
||||||
FAREntryInfo->DecompressedSize != FAREntryInfo->CompressedSize
|
FAREntryInfo->DecompressedSize != FAREntryInfo->CompressedSize
|
||||||
) : FAREntryInfo->DataType == 0x80) : libfarOptions[LIBFAR_CONFIG_DBPF_COMPRESSED];
|
) : FAREntryInfo->DataType == 0x80) : libfarOptions[FAR_CONFIG_DBPF_COMPRESSED];
|
||||||
|
|
||||||
FAREntryInfo->CompressedData = Buffer+FAREntryInfo->DataOffset;
|
FAREntryInfo->CompressedData = Buffer+FAREntryInfo->DataOffset;
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ int far_read_persist_data(PersistFile * PersistData, uint8_t * CompressedData)
|
||||||
|
|
||||||
if(!RefPackDecompress(PersistData->CompressedData, PersistData->CompressedSize-9,
|
if(!RefPackDecompress(PersistData->CompressedData, PersistData->CompressedSize-9,
|
||||||
PersistData->DecompressedData, PersistData->DecompressedSize,
|
PersistData->DecompressedData, PersistData->DecompressedSize,
|
||||||
libfarOptions[LIBFAR_CONFIG_REFPACK_HNSV])){
|
libfarOptions[FAR_CONFIG_REFPACK_HNSV])){
|
||||||
free(PersistData->DecompressedData);
|
free(PersistData->DecompressedData);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -21,10 +21,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* libfarOptions array members */
|
/* libfarOptions array members */
|
||||||
#define LIBFAR_CONFIG_DEFAULT_TO_1A 0
|
#define FAR_CONFIG_DEFAULT_TO_1A 0
|
||||||
#define LIBFAR_CONFIG_DBPF_COMPRESSED 1
|
#define FAR_CONFIG_DBPF_COMPRESSED 1
|
||||||
#define LIBFAR_CONFIG_MAX_FILE_NAME_LENGTH 2
|
#define FAR_CONFIG_MAX_FILE_NAME_LENGTH 2
|
||||||
#define LIBFAR_CONFIG_REFPACK_HNSV 3
|
#define FAR_CONFIG_REFPACK_HNSV 3
|
||||||
|
|
||||||
/* Archive types */
|
/* Archive types */
|
||||||
#define FAR_TYPE_INVALID 0
|
#define FAR_TYPE_INVALID 0
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
#define FAR_TYPE_PERSIST 3
|
#define FAR_TYPE_PERSIST 3
|
||||||
|
|
||||||
/* Numerical constants */
|
/* Numerical constants */
|
||||||
#define LIBFAR_ARCHIVE_MINIMUM_SIZE 14
|
#define FAR_ARCHIVE_MINIMUM_SIZE 14
|
||||||
#define MINSIZE_FAR 20
|
#define MINSIZE_FAR 20
|
||||||
#define MINSIZE_DBPF 64
|
#define MINSIZE_DBPF 64
|
||||||
#define MINSIZE_ENTRY_FAR_1A 16
|
#define MINSIZE_ENTRY_FAR_1A 16
|
|
@ -22,7 +22,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "libfar.h"
|
#include "far.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
profile_ts1 = 1,
|
profile_ts1 = 1,
|
||||||
|
@ -100,9 +100,9 @@ int main(int argc, char *argv[]){
|
||||||
** Handle profile settings
|
** Handle profile settings
|
||||||
*/
|
*/
|
||||||
if(!profile) profile = profile_tso;
|
if(!profile) profile = profile_tso;
|
||||||
libfar_set_option(LIBFAR_CONFIG_DEFAULT_TO_1A, (profile == profile_ts1));
|
libfar_set_option(FAR_CONFIG_DEFAULT_TO_1A, (profile == profile_ts1));
|
||||||
libfar_set_option(LIBFAR_CONFIG_DBPF_COMPRESSED, (profile >= profile_sc4));
|
libfar_set_option(FAR_CONFIG_DBPF_COMPRESSED, (profile >= profile_sc4));
|
||||||
libfar_set_option(LIBFAR_CONFIG_REFPACK_HNSV, 0xFB);
|
libfar_set_option(FAR_CONFIG_REFPACK_HNSV, 0xFB);
|
||||||
|
|
||||||
/****
|
/****
|
||||||
** Open the file and read in the entire contents to memory
|
** Open the file and read in the entire contents to memory
|
||||||
|
|
|
@ -148,6 +148,7 @@ static int InitGL()
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glDepthFunc(GL_LEQUAL);
|
glDepthFunc(GL_LEQUAL);
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||||
|
glFrontFace(GL_CW);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,6 +161,7 @@ static int ResizeScene(uint16_t width, uint16_t height)
|
||||||
|
|
||||||
// Calculate The Aspect Ratio Of The Window
|
// Calculate The Aspect Ratio Of The Window
|
||||||
gluPerspective(45.0f, (GLfloat)width/(GLfloat)height, 0.1f, 100.0f);
|
gluPerspective(45.0f, (GLfloat)width/(GLfloat)height, 0.1f, 100.0f);
|
||||||
|
// glScalef(-1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -300,28 +302,17 @@ static void AdvanceFrame(Skeleton_t& Skeleton, Animation_t& Animation, float Tim
|
||||||
Rotation_t& Rotation = Animation.Motions[i].Rotations[Frame];
|
Rotation_t& Rotation = Animation.Motions[i].Rotations[Frame];
|
||||||
Rotation_t& NextRotation = Animation.Motions[i].Rotations[NextFrame];
|
Rotation_t& NextRotation = Animation.Motions[i].Rotations[NextFrame];
|
||||||
|
|
||||||
//Use Slerp to interpolate
|
//Use nlerp to interpolate
|
||||||
float w1, w2 = 1;
|
float w1 = 1.0f - FractionShown, w2 = FractionShown;
|
||||||
float cosTheta = DotProduct(&Rotation, &NextRotation);
|
if(DotProduct(&Rotation, &NextRotation) < 0)
|
||||||
if(cosTheta < 0){
|
w1 *= -1;
|
||||||
cosTheta *= -1;
|
|
||||||
w2 *= -1;
|
|
||||||
}
|
|
||||||
float theta = (float) acos(cosTheta);
|
|
||||||
float sinTheta = (float) sin(theta);
|
|
||||||
|
|
||||||
if(sinTheta > 0.001f){
|
|
||||||
w1 = (float) sin((1.0f-FractionShown)*theta)/sinTheta;
|
|
||||||
w2 *= (float) sin(FractionShown *theta)/sinTheta;
|
|
||||||
} else {
|
|
||||||
w1 = 1.0f - FractionShown;
|
|
||||||
w2 = FractionShown;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bone.Rotation.x = w1*Rotation.x + w2*NextRotation.x;
|
Bone.Rotation.x = w1*Rotation.x + w2*NextRotation.x;
|
||||||
Bone.Rotation.y = w1*Rotation.y + w2*NextRotation.y;
|
Bone.Rotation.y = w1*Rotation.y + w2*NextRotation.y;
|
||||||
Bone.Rotation.z = w1*Rotation.z + w2*NextRotation.z;
|
Bone.Rotation.z = w1*Rotation.z + w2*NextRotation.z;
|
||||||
Bone.Rotation.w = w1*Rotation.w + w2*NextRotation.w;
|
Bone.Rotation.w = w1*Rotation.w + w2*NextRotation.w;
|
||||||
|
|
||||||
|
Normalize(&Bone.Rotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ void ReadMotion(Animation_t& Animation, Motion_t& Motion){
|
||||||
unsigned pos = VBFile.getpos();
|
unsigned pos = VBFile.getpos();
|
||||||
VBFile.seekto(Animation.TranslationsOffset + 12*Motion.FirstTranslation);
|
VBFile.seekto(Animation.TranslationsOffset + 12*Motion.FirstTranslation);
|
||||||
for(unsigned i=0; i<Motion.FrameCount; i++){
|
for(unsigned i=0; i<Motion.FrameCount; i++){
|
||||||
Motion.Translations[i].x = VBFile.readfloat();
|
Motion.Translations[i].x = -VBFile.readfloat();
|
||||||
Motion.Translations[i].y = VBFile.readfloat();
|
Motion.Translations[i].y = VBFile.readfloat();
|
||||||
Motion.Translations[i].z = VBFile.readfloat();
|
Motion.Translations[i].z = VBFile.readfloat();
|
||||||
}
|
}
|
||||||
|
@ -94,8 +94,8 @@ void ReadMotion(Animation_t& Animation, Motion_t& Motion){
|
||||||
VBFile.seekto(Animation.RotationsOffset + 16*Motion.FirstRotation);
|
VBFile.seekto(Animation.RotationsOffset + 16*Motion.FirstRotation);
|
||||||
for(unsigned i=0; i<Motion.FrameCount; i++){
|
for(unsigned i=0; i<Motion.FrameCount; i++){
|
||||||
Motion.Rotations[i].x = VBFile.readfloat();
|
Motion.Rotations[i].x = VBFile.readfloat();
|
||||||
Motion.Rotations[i].y = VBFile.readfloat();
|
Motion.Rotations[i].y = -VBFile.readfloat();
|
||||||
Motion.Rotations[i].z = VBFile.readfloat();
|
Motion.Rotations[i].z = -VBFile.readfloat();
|
||||||
Motion.Rotations[i].w = VBFile.readfloat();
|
Motion.Rotations[i].w = VBFile.readfloat();
|
||||||
}
|
}
|
||||||
VBFile.seekto(pos);
|
VBFile.seekto(pos);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
#include "libvitaboy.hpp"
|
#include "libvitaboy.hpp"
|
||||||
|
|
||||||
VBFile_t VBFile;
|
VBFile_t VBFile;
|
||||||
|
@ -51,6 +52,17 @@ float DotProduct(Rotation_t * q1, Rotation_t * q2){
|
||||||
return q1->x*q2->x + q1->y*q2->y + q1->z*q2->z + q1->w*q2->w;
|
return q1->x*q2->x + q1->y*q2->y + q1->z*q2->z + q1->w*q2->w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Normalize(Rotation_t * q){
|
||||||
|
float magnitude = q->x*q->x + q->y*q->y + q->z*q->z + q->w*q->w;
|
||||||
|
if(magnitude != 0){
|
||||||
|
magnitude = 1.0f/sqrt(magnitude);
|
||||||
|
q->x *= magnitude;
|
||||||
|
q->y *= magnitude;
|
||||||
|
q->z *= magnitude;
|
||||||
|
q->w *= magnitude;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FindQuaternionMatrix(float * Matrix, Rotation_t * Quaternion){
|
void FindQuaternionMatrix(float * Matrix, Rotation_t * Quaternion){
|
||||||
float x2 = Quaternion->x * Quaternion->x;
|
float x2 = Quaternion->x * Quaternion->x;
|
||||||
float y2 = Quaternion->y * Quaternion->y;
|
float y2 = Quaternion->y * Quaternion->y;
|
||||||
|
|
|
@ -25,6 +25,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <FileHandler.hpp>
|
#include <FileHandler.hpp>
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Bytestream
|
||||||
|
*/
|
||||||
|
|
||||||
class VBFile_t {
|
class VBFile_t {
|
||||||
private:
|
private:
|
||||||
const uint8_t *Buffer, *Position;
|
const uint8_t *Buffer, *Position;
|
||||||
|
@ -139,6 +143,7 @@ void ReadPropEntry(KeyValuePair_t& Entry);
|
||||||
void ReadPropEntries(Prop_t& Prop);
|
void ReadPropEntries(Prop_t& Prop);
|
||||||
void ReadPropsList(PropsList_t& PropsList);
|
void ReadPropsList(PropsList_t& PropsList);
|
||||||
float DotProduct(Rotation_t * q1, Rotation_t * q2);
|
float DotProduct(Rotation_t * q1, Rotation_t * q2);
|
||||||
|
void Normalize(Rotation_t * q);
|
||||||
void CombineQuaternions(Rotation_t * Destination, Rotation_t * Source);
|
void CombineQuaternions(Rotation_t * Destination, Rotation_t * Source);
|
||||||
void FindQuaternionMatrix(float * Matrix, Rotation_t * Quaternion);
|
void FindQuaternionMatrix(float * Matrix, Rotation_t * Quaternion);
|
||||||
|
|
||||||
|
@ -214,6 +219,7 @@ struct Appearance_t {
|
||||||
|
|
||||||
void ReadAppearance(Appearance_t& Appearance);
|
void ReadAppearance(Appearance_t& Appearance);
|
||||||
|
|
||||||
|
|
||||||
/****
|
/****
|
||||||
** Binding (*.bnd)
|
** Binding (*.bnd)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -72,10 +72,10 @@ void ReadMesh(Mesh_t& Mesh){
|
||||||
Mesh.VertexData = (Vertex_t*) malloc(Mesh.TotalVertexCount * sizeof(Vertex_t));
|
Mesh.VertexData = (Vertex_t*) malloc(Mesh.TotalVertexCount * sizeof(Vertex_t));
|
||||||
Mesh.TransformedVertexData = (Vertex_t*) malloc(Mesh.TotalVertexCount * sizeof(Vertex_t));
|
Mesh.TransformedVertexData = (Vertex_t*) malloc(Mesh.TotalVertexCount * sizeof(Vertex_t));
|
||||||
for(unsigned i=0; i<Mesh.TotalVertexCount; i++){
|
for(unsigned i=0; i<Mesh.TotalVertexCount; i++){
|
||||||
Mesh.VertexData[i].Coord.x = VBFile.readfloat();
|
Mesh.VertexData[i].Coord.x = -VBFile.readfloat();
|
||||||
Mesh.VertexData[i].Coord.y = VBFile.readfloat();
|
Mesh.VertexData[i].Coord.y = VBFile.readfloat();
|
||||||
Mesh.VertexData[i].Coord.z = VBFile.readfloat();
|
Mesh.VertexData[i].Coord.z = VBFile.readfloat();
|
||||||
Mesh.TransformedVertexData[i].NormalCoord.x = VBFile.readfloat();
|
Mesh.TransformedVertexData[i].NormalCoord.x = -VBFile.readfloat();
|
||||||
Mesh.TransformedVertexData[i].NormalCoord.y = VBFile.readfloat();
|
Mesh.TransformedVertexData[i].NormalCoord.y = VBFile.readfloat();
|
||||||
Mesh.TransformedVertexData[i].NormalCoord.z = VBFile.readfloat();
|
Mesh.TransformedVertexData[i].NormalCoord.z = VBFile.readfloat();
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ void ReadBone(Skeleton_t& Skeleton, Bone_t& Bone, unsigned Index){
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" | Translation:\n");
|
printf(" | Translation:\n");
|
||||||
Bone.Translation.x = VBFile.readfloat();
|
Bone.Translation.x = -VBFile.readfloat();
|
||||||
printf(" | | x: %g\n", Bone.Translation.x);
|
printf(" | | x: %g\n", Bone.Translation.x);
|
||||||
Bone.Translation.y = VBFile.readfloat();
|
Bone.Translation.y = VBFile.readfloat();
|
||||||
printf(" | | y: %g\n", Bone.Translation.y);
|
printf(" | | y: %g\n", Bone.Translation.y);
|
||||||
|
@ -58,9 +58,9 @@ void ReadBone(Skeleton_t& Skeleton, Bone_t& Bone, unsigned Index){
|
||||||
printf(" | Rotation:\n");
|
printf(" | Rotation:\n");
|
||||||
Bone.Rotation.x = VBFile.readfloat();
|
Bone.Rotation.x = VBFile.readfloat();
|
||||||
printf(" | | x: %g\n", Bone.Rotation.x);
|
printf(" | | x: %g\n", Bone.Rotation.x);
|
||||||
Bone.Rotation.y = VBFile.readfloat();
|
Bone.Rotation.y = -VBFile.readfloat();
|
||||||
printf(" | | y: %g\n", Bone.Rotation.y);
|
printf(" | | y: %g\n", Bone.Rotation.y);
|
||||||
Bone.Rotation.z = VBFile.readfloat();
|
Bone.Rotation.z = -VBFile.readfloat();
|
||||||
printf(" | | z: %g\n", Bone.Rotation.z);
|
printf(" | | z: %g\n", Bone.Rotation.z);
|
||||||
Bone.Rotation.w = VBFile.readfloat();
|
Bone.Rotation.w = VBFile.readfloat();
|
||||||
printf(" | | w: %g\n", Bone.Rotation.w);
|
printf(" | | w: %g\n", Bone.Rotation.w);
|
||||||
|
|
|
@ -10,7 +10,7 @@ Stable builds and source packages are provided at http://niotso.org/pub/stable/.
|
||||||
|
|
||||||
## Compiling instructions
|
## Compiling instructions
|
||||||
|
|
||||||
For compiling instructions, please see http://wiki.niotso.org/Niotso_-_Compiling_instructions.
|
For compiling instructions, please see http://wiki.niotso.org/Niotso_-_Compile_guide.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
|
|
0
Tools/Translate Tool/CMakeLists.txt
Normal file
0
Tools/Translate Tool/CMakeLists.txt
Normal file
32
Tools/Translate Tool/TranslateTool.hpp
Normal file
32
Tools/Translate Tool/TranslateTool.hpp
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
The Sims Online Translation Tool - Graphical Translation Writer for TSO
|
||||||
|
TranslateTool.hpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Translation {
|
||||||
|
extern wchar_t Path[1024], Filename[1024];
|
||||||
|
|
||||||
|
extern bool IsOpen;
|
||||||
|
extern bool IsModified;
|
||||||
|
|
||||||
|
bool Add(const wchar_t * Path);
|
||||||
|
bool Close();
|
||||||
|
bool Open();
|
||||||
|
bool PopulateEntries();
|
||||||
|
bool Save();
|
||||||
|
bool SaveAs();
|
||||||
|
bool SetWorkspace();
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue