Add alt material selection to editor

alut-include-path
Sven Eberhardt 2017-02-26 14:46:27 -05:00
parent 0d01309958
commit a6c99e2cad
12 changed files with 172 additions and 72 deletions

View File

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -284,3 +284,68 @@ material CrashedAirplane
}
}
}
material LaserSword
{
receive_shadows on
technique
{
pass
{
ambient 0.500000 0.500000 0.500000 1.000000
diffuse 0.702745 0.702745 0.702745 1.000000
specular 0.000000 0.000000 0.000000 1.000000 12.500000
emissive 0.000000 0.000000 0.000000 1.000000
texture_unit
{
texture LaserSword.jpg
tex_address_mode wrap
filtering trilinear
}
}
}
}
material OgreSword
{
receive_shadows on
technique
{
pass
{
scene_blend alpha_blend
ambient 0.500000 0.500000 0.500000 1.000000
diffuse 0.702745 0.702745 0.702745 1.000000
specular 0.000000 0.000000 0.000000 1.000000 12.500000
emissive 0.000000 0.000000 0.000000 1.000000
texture_unit
{
texture OgreSword.png
tex_address_mode wrap
filtering trilinear
}
}
}
}
material NukePowderKeg
{
receive_shadows on
technique
{
pass
{
ambient 0.500000 0.500000 0.500000 1.000000
diffuse 0.800000 0.800000 0.800000 1.000000
specular 0.000000 0.000000 0.000000 1.000000 12.500000
emissive 0.000000 0.000000 0.000000 1.000000
texture_unit
{
texture NukePowderKeg.png
tex_address_mode wrap
filtering trilinear
}
}
}
}

View File

@ -0,0 +1,69 @@
/*
Alternative Materials
Authors: Sven2
A few alternative textures that can be put on various objects.
*/
local DefinitionPriority = -10; // load after the regular objects
public func AddMaterial(proplist target_def, string new_material_name, string editor_name, int index, string editor_help)
{
if (!Inside(index, 0, 2)) FatalError(Format("Deco_AltMaterials::AltAddMaterial: Material index our of range (%d)", index));
// Definition call to be run during Definition() callbacks
// Just add the editor prop. Saving is done regularly through the MeshMaterial property.
// (works only for material 0)
// Prepare editor prop in target definition
var prop_name = Format("alternative_material%d", index);
if (!target_def.EditorProps) target_def.EditorProps = {};
if (!target_def.EditorProps.alternative_material)
{
var get_fn = Format("GetMeshMaterial%d", index);
var set_fn = Format("SetMeshMaterial%d", index);
target_def[get_fn] = this[get_fn];
target_def[set_fn] = this[set_fn];
target_def.EditorProps.alternative_material = {
Name = "$AlternativeMaterial$",
EditorHelp = "$AlternativeMaterialHelp$",
Type = "enum",
AsyncGet = get_fn,
Set = set_fn,
Options = [ { Name="$Default$", Value=target_def->GetMeshMaterial() } ]
};
}
var opts = target_def.EditorProps.alternative_material.Options;
var new_material_option = {
Name = editor_name,
EditorHelp = editor_help,
Value = new_material_name
};
opts[GetLength(opts)] = new_material_option;
return new_material_option; // Return new option in case the user wants to do something with it
}
// We don't have lambdas yet
private func GetMeshMaterial0() { return GetMeshMaterial(0); }
private func GetMeshMaterial1() { return GetMeshMaterial(1); }
private func GetMeshMaterial2() { return GetMeshMaterial(2); }
private func SetMeshMaterial0(string to_mat) { return SetMeshMaterial(to_mat, 0); }
private func SetMeshMaterial1(string to_mat) { return SetMeshMaterial(to_mat, 1); }
private func SetMeshMaterial2(string to_mat) { return SetMeshMaterial(to_mat, 2); }
public func Definition(proplist def)
{
AddMaterial(Chest, "MetalChest", "$MetalChest$");
AddMaterial(Chest, "GoldenChest", "$GoldenChest$");
AddMaterial(Column, "AncientColumn", "$AncientColumn$");
AddMaterial(LargeCaveMushroom, "FlyAmanitaMushroom", "$FlyAmanitaMushroom$");
AddMaterial(LargeCaveMushroom, "FrozenCaveMushroom", "$FrozenCaveMushroom$");
AddMaterial(Cannon, "GoldenCannon", "$GoldenCannon$");
AddMaterial(Lorry, "RuinedLorry", "$RuinedLorry$");
AddMaterial(SpinWheel, "SpinWheelBaseAlt", "$SpinWheelBaseAlt$", 1);
AddMaterial(SpinWheel, "SpinWheelGearRed", "$SpinWheelGearRed$", 0);
AddMaterial(SpinWheel, "SpinWheelGearBlue", "$SpinWheelGearBlue$", 0);
AddMaterial(Idol, "IdolGrayColor", "$IdolGrayColor$");
AddMaterial(Airplane, "CrashedAirplane", "$CrashedAirplane$");
AddMaterial(Sword, "LaserSword", "$LaserSword$");
AddMaterial(Sword, "OgreSword", "$OgreSword$");
AddMaterial(PowderKeg, "NukePowderKeg", "$NukePowderKeg$");
}

View File

@ -0,0 +1,18 @@
AlternativeMaterial=Skin
AlternativeMaterialHelp=Aendert das Aussehen des Objektes.
Default=Standard
MetalChest=Metall
GoldenChest=Gold
AncientColumn=Uralt
FlyAmanitaMushroom=Fliegenpilz
FrozenCaveMushroom=Frostpilz
GoldenCannon=Gold
RuinedLorry=Verfallen
SpinWheelBaseAlt=Verfallen
SpinWheelGearRed=Rot
SpinWheelGearBlue=Blau
IdolGrayColor=Stein
CrashedAirplane=Zerstoert
LaserSword=Laserschwert
OgreSword=Ogerschwert
NukePowderKeg=Radioaktiv

View File

@ -0,0 +1,18 @@
AlternativeMaterial=Skin
AlternativeMaterialHelp=Changes the texture of the object.
Default=Default
MetalChest=Metal
GoldenChest=Gold
AncientColumn=Ancient
FlyAmanitaMushroom=Fly amanita
FrozenCaveMushroom=Frost mushroom
GoldenCannon=Gold
RuinedLorry=Ruined
SpinWheelBaseAlt=Ancient
SpinWheelGearRed=Red
SpinWheelGearBlue=Blue
IdolGrayColor=Rock
CrashedAirplane=Destroyed
LaserSword=Laser sword
OgreSword=Ogre sword
NukePowderKeg=Radioactive

View File

@ -1,6 +0,0 @@
[DefCore]
id=Deco_AltMaterials2
Version=6,0
Category=C4D_StaticBack
Width=1
Height=1

View File

@ -1 +0,0 @@
This definition is not created. It just serves as a container for custom mesh materials, which aren't loaded unless the definition is valid.

View File

@ -1,64 +0,0 @@
material LaserSword
{
receive_shadows on
technique
{
pass
{
ambient 0.500000 0.500000 0.500000 1.000000
diffuse 0.702745 0.702745 0.702745 1.000000
specular 0.000000 0.000000 0.000000 1.000000 12.500000
emissive 0.000000 0.000000 0.000000 1.000000
texture_unit
{
texture LaserSword.jpg
tex_address_mode wrap
filtering trilinear
}
}
}
}
material OgreSword
{
receive_shadows on
technique
{
pass
{
scene_blend alpha_blend
ambient 0.500000 0.500000 0.500000 1.000000
diffuse 0.702745 0.702745 0.702745 1.000000
specular 0.000000 0.000000 0.000000 1.000000 12.500000
emissive 0.000000 0.000000 0.000000 1.000000
texture_unit
{
texture OgreSword.png
tex_address_mode wrap
filtering trilinear
}
}
}
}
material NukePowderKeg
{
receive_shadows on
technique
{
pass
{
ambient 0.500000 0.500000 0.500000 1.000000
diffuse 0.800000 0.800000 0.800000 1.000000
specular 0.000000 0.000000 0.000000 1.000000 12.500000
emissive 0.000000 0.000000 0.000000 1.000000
texture_unit
{
texture NukePowderKeg.png
tex_address_mode wrap
filtering trilinear
}
}
}
}

View File

@ -7,6 +7,7 @@ MaxPlayerLeague=4
[Definitions]
Definition2=Decoration.ocd\Clonk.ocd\AltSkins.ocd
Definition3=Decoration.ocd\Misc.ocd\AltMaterials.ocd
[Game]

View File

@ -501,7 +501,7 @@ func InitWaveData()
// Define composition of waves
ENEMY_WAVE_DATA = [nil,
{ Name = "$WaveNewbies$", Bounty = 10, Enemies = [
new ogre { Num= 1, Interval=10, Side = WAVE_SIDE_LEFT }
new newbie { Num= 1, Interval=10, Side = WAVE_SIDE_LEFT }
]}, { Name = "$WaveBows$", Bounty = 15, Enemies = [
new newbie { Num= 2, Interval=10 },
new bowman { Delay= 30, Num= 3, Interval=10, Side = WAVE_SIDE_RIGHT },