diff --git a/planet/Tutorials.ocf/Sandbox.ocs/Scenario.txt b/planet/Tutorials.ocf/Sandbox.ocs/Scenario.txt index 547f45bd3..4e3af3d39 100644 --- a/planet/Tutorials.ocf/Sandbox.ocs/Scenario.txt +++ b/planet/Tutorials.ocf/Sandbox.ocs/Scenario.txt @@ -2,6 +2,10 @@ Title=Sandbox Icon=17 +[Definitions] +Definition1=Objects.ocd +Definition2=Decoration.ocd/Misc.ocd/SprayCan.ocd + [Landscape] SkyScrollMode=2 Secret=false \ No newline at end of file diff --git a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/DefCore.txt b/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/DefCore.txt deleted file mode 100644 index 06cbbc31e..000000000 --- a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/DefCore.txt +++ /dev/null @@ -1,14 +0,0 @@ -[DefCore] -id=SprayCan -Version=8,0 -Category=C4D_Object -Width=9 -Height=3 -Offset=-4,-2 -Vertices=4 -VertexX=-4,4,-4,4 -VertexY=1,1,-2,-2 -VertexFriction=40,40,40,40 -Value=5 -Mass=10 -Rotate=1 \ No newline at end of file diff --git a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/Graphics.mesh b/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/Graphics.mesh deleted file mode 100644 index e3a1ebeb1..000000000 Binary files a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/Graphics.mesh and /dev/null differ diff --git a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/Graphics.skeleton b/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/Graphics.skeleton deleted file mode 100644 index 715b84b45..000000000 Binary files a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/Graphics.skeleton and /dev/null differ diff --git a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/Overlay.png b/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/Overlay.png deleted file mode 100644 index dce8940c4..000000000 Binary files a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/Overlay.png and /dev/null differ diff --git a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/Script.c b/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/Script.c deleted file mode 100644 index 30ed055d3..000000000 --- a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/Script.c +++ /dev/null @@ -1,123 +0,0 @@ -/** - Spray can - - @author K-Pone, Sven2 -*/ - -local last_x, last_y, last_ldx, last_ldy; -local paint_col; -local paint_bg; -local max_dist = 50; -local brushmode = 1; // 1 = Draw Brush, 2 = Quad Brush, 3 = Eraser - -func Construction() -{ - SetColor(RGB(Random(256),Random(256),Random(256))); -} - -// Impact sound -public func Hit() -{ - Sound("Hits::GeneralHit?"); -} - -// Item activation -public func ControlUseStart(object clonk, int x, int y) -{ - paint_col = clonk.SelectedBrushMaterial; - paint_bg = clonk.SelectedBrushBgMaterial; - brushmode = clonk.SelectedBrushMode; - return ControlUseHolding(clonk, x, y); -} - -public func HoldingEnabled() { return true; } - -public func ControlUseHolding(object clonk, int new_x, int new_y) -{ - // Out of reach? Stop spraying. // Not for Gods like Sandboxers ;) - //if (Distance(0,0,new_x,new_y) > max_dist) - //{ - //SetAction("Idle"); - //return true; - //} - - // Work in global coordinates - new_x += GetX(); new_y += GetY(); - - // (re-)start spraying - if (GetAction() != "Spraying") StartSpraying(clonk, new_x, new_y); - - // Spray paint if position moved - if (new_x==last_x && new_y == last_y) return true; - var wdt = clonk.SelectedBrushSize; - var dx=new_x-last_x, dy=new_y-last_y; - var d = Distance(dx,dy); - var ldx = dy*wdt/d, ldy = -dx*wdt/d; - if (!last_ldx && !last_ldy) { last_ldx=ldx; last_ldy=ldy; } - - if (brushmode == 1) - { - DrawMaterialQuad(paint_col, last_x-last_ldx,last_y-last_ldy, last_x+last_ldx,last_y+last_ldy, new_x+ldx,new_y+ldy, new_x-ldx,new_y-ldy, paint_bg); - } - - else if (brushmode == 2) - { - DrawMaterialQuad(paint_col, new_x - (wdt / 2), new_y - (wdt / 2), new_x + (wdt / 2), new_y - (wdt / 2), new_x + (wdt / 2), new_y + (wdt / 2), new_x - (wdt / 2), new_y + (wdt / 2), paint_bg ); - } - - else if (brushmode == 3) - { - // Draw something to set BG Mat to sky (workaround for not being able to draw Sky via DrawMaterialQuad) - DrawMaterialQuad(paint_col, new_x - (wdt / 2), new_y - (wdt / 2), new_x + (wdt / 2), new_y - (wdt / 2), new_x + (wdt / 2), new_y + (wdt / 2), new_x - (wdt / 2), new_y + (wdt / 2), DMQ_Sky ); - ClearFreeRect(new_x - (wdt / 2), new_y - (wdt / 2), wdt, wdt); - } - - last_x = new_x; last_y = new_y; - last_ldx = ldx; last_ldy = ldy; - return true; -} - -public func ControlUseStop(object clonk, int x, int y) -{ - SetAction("Idle"); - return true; -} - -public func ControlUseCancel(object clonk, int x, int y) -{ - SetAction("Idle"); - return true; -} - -private func StartSpraying(object clonk, int x, int y) -{ - // Go into spray mode and place an initial blob - last_x = x; last_y = y; - last_ldx=last_ldy=0; - var r = Random(90), wdt = 2; - var ldx = Sin(r, wdt), ldy = Cos(r, wdt); - DrawMaterialQuad(paint_col, x-ldx,y-ldy, x-ldy,y+ldx, x+ldx,y+ldy, x+ldy,y-ldx, paint_bg); - SetAction("Spraying"); - return true; -} - - -local ActMap = { - Spraying = { - Prototype = Action, - FacetBase = 1, - Length = 1, - Delay = 1, - Name = "Spraying", - Sound = "SprayCan::SprayCan", - NextAction = "Spraying", - } -}; - -func Definition(def) { - SetProperty("PictureTransformation",Trans_Rotate(-30,0,1,1),def); -} - -local Collectible = 1; -local Name = "$Name$"; -local Description = "$Description$"; diff --git a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/SprayCan.jpg b/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/SprayCan.jpg deleted file mode 100644 index 4b287a591..000000000 Binary files a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/SprayCan.jpg and /dev/null differ diff --git a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/SprayCan.material b/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/SprayCan.material deleted file mode 100644 index c2b7cd5c9..000000000 --- a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/SprayCan.material +++ /dev/null @@ -1,37 +0,0 @@ -material SprayCan -{ - receive_shadows on - - technique - { - pass SprayCan - { - ambient 0.500000 0.500000 0.500000 1.000000 - diffuse 1.000000 1.000000 1.000000 1.000000 - specular 0.000000 0.000000 0.000000 1.000000 12.500000 - emissive 0.000000 0.000000 0.000000 1.000000 - - texture_unit Overlay - { - texture Overlay.png - tex_address_mode wrap - filtering trilinear - colour_op_ex modulate src_texture src_player_colour - } - texture_unit SprayCan - { - texture SprayCan.jpg - tex_address_mode wrap - filtering trilinear - colour_op_ex blend_current_alpha src_current src_texture - } - texture_unit Light - { - // apply lighting -- note this texture unit does not need an - // actual texture image: no hardware TIU will be used. - colour_op_ex modulate src_current src_diffuse - alpha_op_ex modulate src_current src_diffuse - } - } - } -} diff --git a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/SprayCan.wav b/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/SprayCan.wav deleted file mode 100644 index 16ed40fde..000000000 Binary files a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/SprayCan.wav and /dev/null differ diff --git a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/StringTblDE.txt b/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/StringTblDE.txt deleted file mode 100644 index e1fbaa874..000000000 --- a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/StringTblDE.txt +++ /dev/null @@ -1,2 +0,0 @@ -Name=Sprühdose -Description=Lasse den kleinen Künstler in dir heraus! \ No newline at end of file diff --git a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/StringTblUS.txt b/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/StringTblUS.txt deleted file mode 100644 index 3343a975e..000000000 --- a/planet/Tutorials.ocf/Sandbox.ocs/SprayCan.ocd/StringTblUS.txt +++ /dev/null @@ -1,2 +0,0 @@ -Name=Spray can -Description=Let out the little artist in you! \ No newline at end of file diff --git a/planet/Tutorials.ocf/Sandbox.ocs/System.ocg/SprayCan.c b/planet/Tutorials.ocf/Sandbox.ocs/System.ocg/SprayCan.c new file mode 100644 index 000000000..f50ec47c8 --- /dev/null +++ b/planet/Tutorials.ocf/Sandbox.ocs/System.ocg/SprayCan.c @@ -0,0 +1,68 @@ +// Convert spray can into material draw tool. + +#appendto SprayCan + +local paint_bg; +local brush_mode = 1; // 1 = Draw Brush, 2 = Quad Brush, 3 = Eraser + +public func Construction() +{ + SetColor(RGB(Random(256), Random(256), Random(256))); + return; +} + +// Item activation +public func ControlUseStart(object clonk, int x, int y) +{ + paint_col = clonk.SelectedBrushMaterial; + paint_bg = clonk.SelectedBrushBgMaterial; + brush_mode = clonk.SelectedBrushMode; + return ControlUseHolding(clonk, x, y); +} + +public func HoldingEnabled() { return true; } + +public func ControlUseHolding(object clonk, int new_x, int new_y) +{ + // Work in global coordinates. + new_x += GetX(); new_y += GetY(); + + // (re-)start spraying. + if (GetAction() != "Spraying") + StartSpraying(clonk, new_x, new_y); + + // Spray paint if position moved. + if (new_x == last_x && new_y == last_y) + return true; + var wdt = clonk.SelectedBrushSize; + var dx = new_x - last_x, dy = new_y - last_y; + var d = Distance(dx, dy); + var ldx = dy * wdt / d, ldy = -dx * wdt / d; + if (!last_ldx && !last_ldy) + { + last_ldx = ldx; + last_ldy = ldy; + } + + if (brush_mode == 1) + { + DrawMaterialQuad(paint_col, last_x - last_ldx, last_y - last_ldy, last_x + last_ldx, last_y + last_ldy, new_x + ldx,new_y + ldy, new_x - ldx, new_y - ldy, paint_bg); + } + + else if (brush_mode == 2) + { + DrawMaterialQuad(paint_col, new_x - (wdt / 2), new_y - (wdt / 2), new_x + (wdt / 2), new_y - (wdt / 2), new_x + (wdt / 2), new_y + (wdt / 2), new_x - (wdt / 2), new_y + (wdt / 2), paint_bg); + } + + else if (brush_mode == 3) + { + // Draw something to set BG Mat to sky (workaround for not being able to draw Sky via DrawMaterialQuad) + DrawMaterialQuad(paint_col, new_x - (wdt / 2), new_y - (wdt / 2), new_x + (wdt / 2), new_y - (wdt / 2), new_x + (wdt / 2), new_y + (wdt / 2), new_x - (wdt / 2), new_y + (wdt / 2), DMQ_Sky); + ClearFreeRect(new_x - (wdt / 2), new_y - (wdt / 2), wdt, wdt); + } + + last_x = new_x; last_y = new_y; + last_ldx = ldx; last_ldy = ldy; + return true; +} +