scn_mp_arabian_village mp_arabian_village 256 none none 0.000000 0.000000 100.000000 100.000000 -100.000000 0x0000000050000000000310c4000000000000000000000000
0
0
outer_terrain_desert_b
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "scoReader.h"
#include "scoWriter.h"
#include "affine.h"
int main(int argc, char **argv)
{
if(argc < 3)
{
printf("Usage: %s input heightmap output\n", argv[0]);
return EXIT_FAILURE;
}
FILE *in = fopen(argv[1], "rb");
FILE *out = fopen(argv[2], "wb");
if(!in || !out)
{
printf("ERROR: file(s) not found\n");
return EXIT_FAILURE;
}
printf("Reading %s\n", argv[1]);
sco_file_t sco_file;
read_sco_file(in, &sco_file);
stack_t *stack = affine_init();
translate(stack, 310, 277, 33.23);
rotate(stack, -11 * M_PI / 16, 0, 0, 1);
int lcv1, lcv2;
int n;
int h;
// facade
n = 57;
h = 3;
for(lcv1 = 0; lcv1 < h; ++lcv1)
{
push_affine_matrix(stack);
for(lcv2 = 0; lcv2 < n; ++lcv2)
{
push_affine_matrix(stack);
rotate(stack, 2 * M_PI * lcv2 / n, 0, 0, 1);
translate(stack, 50, 0, 9 * lcv1);
rotate(stack, -M_PI / 2, 0, 0, 1);
place_object(&sco_file, "spr_bridge_modular_a", stack);
pop_affine_matrix(stack);
}
pop_affine_matrix(stack);
}
// walls
n = 19;
for(lcv1 = 0; lcv1 < n; ++lcv1)
{
push_affine_matrix(stack);
rotate(stack, 2 * M_PI * lcv1 / n, 0, 0, 1);
for(lcv2 = 0; lcv2 < 3; ++lcv2)
{
push_affine_matrix(stack);
translate(stack, 49 - 8 * lcv2, 0, 19 - 6.4 * lcv2);
rotate(stack, -M_PI / 2, 0, 0, 1);
rotate(stack, M_PI / 2, 1, 0, 0);
scale(stack, (49 - 8 * lcv2) / 100.0f, 0.5, 0.5);
place_object(&sco_file, "spr_arena_wall_a", stack);
pop_affine_matrix(stack);
if(lcv2 == 2)
{
push_affine_matrix(stack);
translate(stack, 32.5, 5.5, 10.77);
scale(stack, 5, 5, 4);
place_object(&sco_file, "spr_barrier_capsule", stack);
pop_affine_matrix(stack);
}
if(lcv1 == 0 && lcv2 == 2)
continue;
push_affine_matrix(stack);
translate(stack, 46 - 8 * lcv2, 0, 19 - 6.4 * lcv2);
rotate(stack, -M_PI / 2, 0, 0, 1);
scale(stack, 2, 1, 1);
place_object(&sco_file, "spr_stairs_a", stack);
pop_affine_matrix(stack);
push_affine_matrix(stack);
translate(stack, 50 - 8 * lcv2, 0, 20 - 6.4 * lcv2);
rotate(stack, -M_PI / 2, 0, 0, 1);
scale(stack, (50 - 8 * lcv2) / 100.0f, 0.5, 0.4);
place_object(&sco_file, "spr_arena_wall_a", stack);
pop_affine_matrix(stack);
}
if(lcv1 == 0)
continue;
for(lcv2 = 0; lcv2 < 2; ++lcv2)
{
push_affine_matrix(stack);
translate(stack, 34, 0, 0.8 - 6.4 * lcv2);
rotate(stack, -M_PI / 2, 0, 0, 1);
scale(stack, 0.34, 0.5, 0.4);
place_object(&sco_file, "spr_arena_wall_a", stack);
pop_affine_matrix(stack);
}
pop_affine_matrix(stack);
}
// inner ring
n = 12;
for(lcv1 = 0; lcv1 < n; ++lcv1)
{
push_affine_matrix(stack);
rotate(stack, 2 * M_PI * lcv1 / n, 0, 0, 1);
translate(stack, 24, 0, 0);
rotate(stack, -M_PI / 2, 0, 0, 1);
place_object(&sco_file, "spr_arena_barrier_b", stack);
translate(stack, 3, 0, 6.27);
place_object(&sco_file, "spr_castle_f_wall_way_a", stack);
translate(stack, -6, 0, 0);
place_object(&sco_file, "spr_castle_f_wall_way_a", stack);
pop_affine_matrix(stack);
push_affine_matrix(stack);
rotate(stack, 2 * M_PI * lcv1 / n, 0, 0, 1);
translate(stack, 29, 0, 0);
rotate(stack, -M_PI / 2, 0, 0, 1);
place_object(&sco_file, "spr_arabian_wall_b", stack);
pop_affine_matrix(stack);
}
// stairs
push_affine_matrix(stack);
translate(stack, 37.5, 5, -2);
for(lcv1 = 0; lcv1 < 5; ++lcv1)
{
push_affine_matrix(stack);
translate(stack, 0, -2.5 * lcv1, 0);
rotate(stack, M_PI, 0, 0, 1);
place_object(&sco_file, "spr_arabian_castle_stairs", stack);
pop_affine_matrix(stack);
}
pop_affine_matrix(stack);
affine_free(stack);
printf("Writing %s\n", argv[2]);
write_sco_file(out, &sco_file);
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "scoReader.h"
#include "scoWriter.h"
#include "affine.h"
int main(int argc, char **argv)
{
if(argc < 3)
{
printf("Usage: %s input heightmap output\n", argv[0]);
return EXIT_FAILURE;
}
FILE *in = fopen(argv[1], "rb");
FILE *out = fopen(argv[2], "wb");
if(!in || !out)
{
printf("ERROR: file(s) not found\n");
return EXIT_FAILURE;
}
printf("Reading %s\n", argv[1]);
sco_file_t sco_file;
read_sco_file(in, &sco_file);
stack_t *stack = affine_init();
int w = 4;
int l = 9;
int lcv1, lcv2;
translate(stack, 40, 130, 3.1);
rotate(stack, (90 - 77) * M_PI / 180, 0, 0, 1);
rotate(stack, asin(1.2 / (8 * l)), 1, 0, 0);
// width
push_affine_matrix(stack);
translate(stack, 4, 0, 0);
for(lcv1 = 0; lcv1 < w; ++lcv1)
{
for(lcv2 = 0; lcv2 < 2; ++lcv2)
{
push_affine_matrix(stack);
translate(stack, 8 * lcv1, 8 * l * lcv2, 0);
place_object(&sco_file, "spr_railing_a", stack);
pop_affine_matrix(stack);
}
}
pop_affine_matrix(stack);
// length
push_affine_matrix(stack);
translate(stack, 0, 4, 0);
for(lcv1 = 0; lcv1 < l; ++lcv1)
{
for(lcv2 = 0; lcv2 < 2; ++lcv2)
{
push_affine_matrix(stack);
translate(stack, 8 * w * lcv2, 8 * lcv1, 0);
rotate(stack, M_PI / 2, 0, 0, 1);
place_object(&sco_file, "spr_railing_a", stack);
pop_affine_matrix(stack);
}
}
for(lcv1 = 0; lcv1 < w - 1; ++lcv1)
{
for(lcv2 = 0; lcv2 < l - 2; ++lcv2)
{
push_affine_matrix(stack);
translate(stack, 8 * (lcv1 + 1), 8 * (lcv2 + 1), 0);
rotate(stack, M_PI / 2, 0, 0, 1);
place_object(&sco_file, "spr_railing_a", stack);
pop_affine_matrix(stack);
}
}
pop_affine_matrix(stack);
affine_free(stack);
printf("Writing %s\n", argv[2]);
write_sco_file(out, &sco_file);
return EXIT_SUCCESS;
}
If you don't care about a completely flat base you can get pretty close by lowering hill height and not have to worry about creating -A.
// 100 is the max height in-game, 886 is the max height used in your terrain software, 2625 is the max height available in your terrain software, and 1 is the water depth
sco_file.ground_paint->layers[lcv].cells[x * sco_file.ground_paint->size_y + y] += 100.0f * 886.0f / 2625.0f * r / 255.0f - 1.0f;
void set_layer(ground_paint_t *ground_paint, int layer, tga_data_t *map)
{
int max = ground_paint->size_x * ground_paint->size_y;
if(ground_paint->layers[layer].cells == NULL) {
ground_paint->layers[layer].continuity_count = malloc((max + 1) * sizeof(int));
ground_paint->layers[layer].cells = malloc(max * sizeof(float));
}
ground_paint->layers[layer].continuity_count[0] = max;
ground_paint->layers[layer].continuity_count[max] = 0;
int x, y;
for(y = 0; y < ground_paint->size_y; ++y)
{
for(x = 0; x < ground_paint->size_x; ++x)
{
int offset = (y * map->w + x) * map->depth / 8;
short int r = map->data[offset];
short int g = map->data[offset + 1];
short int b = map->data[offset + 2];
if(r != g || g != b) {
printf("ERROR: map was not grayscale\n");
return;
}
ground_paint->layers[layer].cells[x * ground_paint->size_y + y] = r / 255.0f;
}
}
}