Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

Commit

Permalink
Initial commit (26.05.20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolay B. aka RD_AAOW committed May 25, 2020
1 parent 6e3f80a commit 2d7fe27
Show file tree
Hide file tree
Showing 9 changed files with 978 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Changes.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Make CST changes log

Version 1.5u:
• Application namespace, icon and development environment have been unified;
• Publication on GitHub

Version 1.4
• Added support for direct extraction of model's shape from DFF (not for all versions for now)
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Николай
Copyright (c) 26.05.2020 Barkhatov N. aka RD_AAOW

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,29 @@
# MakeCST
# MakeCST v 1.5u

A tool for converting DFF models and QHullOFF objects to GTA Vice city collision scripts

Инструмент для преобразования моделей DFF и объектов QHullOFF в скрипты столкновений GTA Vice city

#

Version 1.4 supports direct extraction of model's shape from DFF (not for all versions
for now) and immediate creation of GTA Vice city CST script. But as so as before it is
possible to generate CST from QHull OFF object that can be retrieved from DFF

Версия 1.4 поддерживает прямое извлечение формы модели из DFF (пока не для всех версий)
и немедленное создание скрипта CST GTA Vice city. Но, как и раньше, можно генерировать
CST из объекта QHull OFF, который можно получить из DFF

#

We've formalized our [Applications development policy (ADP)](https://vk.com/@rdaaow_fupl-adp).
We're strongly recommend reading it before using our products.

Мы формализовали нашу [Политику разработки приложений (ADP)](https://vk.com/@rdaaow_fupl-adp).
Настоятельно рекомендуем ознакомиться с ней перед использованием наших продуктов.

#

Needs Windows XP and newer, Framework 4.0 and newer. Interface languages: en_us

Требуется ОС Windows XP и новее, Framework 4.0 и новее. Языки интерфейса: en_us
124 changes: 124 additions & 0 deletions src/CST.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;

namespace RD_AAOW
{
/// <summary>
/// Класс описывает спецификации форматов CST1 и CST2
/// </summary>
public class CSTWriter
{
// Переменные

// Определитель формата чисел
private static CultureInfo cie = new CultureInfo ("en-us");

/// <summary>
/// Расширение формата файла
/// </summary>
public const string MasterExtension = "cst";

/// <summary>
/// Метод создаёт CST-скрипт по указанным точкам
/// </summary>
/// <param name="FileName">Имя создаваемого файла</param>
/// <param name="Points">Вершины модели</param>
/// <param name="Triangles">Треугольники модели</param>
/// <returns>Возвращает true в случае успеха</returns>
public static bool WriteCST (string FileName, List<Point3D> Points, List<Triangle3D> Triangles)
{
return WriteCST (FileName, false, Points, Triangles);
}

/// <summary>
/// Метод создаёт CST-скрипт по указанным точкам
/// </summary>
/// <param name="FileName">Имя создаваемого файла</param>
/// <param name="CST1">Флаг указывает на необходимость записи скрипта первой версии</param>
/// <param name="Points">Вершины модели</param>
/// <param name="Triangles">Треугольники модели</param>
/// <returns>Возвращает true в случае успеха</returns>
public static bool WriteCST (string FileName, bool CST1, List<Point3D> Points, List<Triangle3D> Triangles)
{
FileStream FS = null;
try
{
FS = new FileStream (FileName + MasterExtension, FileMode.Create);
}
catch
{
return false;
}
StreamWriter SW = new StreamWriter (FS);

// Заголовок и пустые поля
SW.WriteLine ("# Converted with " + ProgramDescription.AssemblyDescription + "\n");
if (CST1)
{
SW.WriteLine ("=> Spheres: 0\n");
SW.WriteLine ("=> Boxes: 0\n");
}
else
{
SW.WriteLine ("CST2\n");
}

// Запись точек
if (CST1)
{
SW.WriteLine ("=> Vertex count: " + Points.Count.ToString ());
}
else
{
SW.WriteLine (Points.Count.ToString () + ", Vertex");
}

for (int p = 0; p < Points.Count; p++)
{
if (CST1)
{
SW.WriteLine ("V " + p.ToString ("D03") + ": " + Points[p].X.ToString (cie.NumberFormat) + "; " +
Points[p].Y.ToString (cie.NumberFormat) + "; " + Points[p].Z.ToString (cie.NumberFormat));
}
else
{
SW.WriteLine (Points[p].X.ToString (cie.NumberFormat) + ", " +
Points[p].Y.ToString (cie.NumberFormat) + ", " + Points[p].Z.ToString (cie.NumberFormat));
}
}

// Запись треугольников
if (CST1)
{
SW.WriteLine ("\n=> Face count: " + Triangles.Count.ToString ());
}
else
{
SW.WriteLine ("\n" + Triangles.Count.ToString () + ", Face");
}

for (int t = 0; t < Triangles.Count; t++)
{
// Непрямой порядок треугольников требуется для того, чтобы избежать "выворачивания" модели
if (CST1)
{
SW.WriteLine ("F " + t.ToString ("D03") + ": " + Triangles[t].Point2ArrayPosition.ToString () + "; " +
Triangles[t].Point1ArrayPosition.ToString () + "; " + Triangles[t].Point3ArrayPosition.ToString () +
" | [0]");
}
else
{
SW.WriteLine (Triangles[t].Point2ArrayPosition.ToString () + ", " +
Triangles[t].Point1ArrayPosition.ToString () + ", " + Triangles[t].Point3ArrayPosition.ToString () +
", 0, 0, 0, 0");
}
}

// Завершение
SW.Close ();
FS.Close ();
return true;
}
}
}
Loading

0 comments on commit 2d7fe27

Please sign in to comment.