Skip to content

Instantly share code, notes, and snippets.

View zulman's full-sized avatar
:octocat:
undefined string

Oleg Chumakov zulman

:octocat:
undefined string
View GitHub Profile
/*Функция возвращет объект Date. В нем записано сколько времени до полуночи в часовом поясе пользователя*/
function datetimeUntilMidnight() {
var midnight = new Date();
midnight.setHours( 24 );
midnight.setMinutes( 0 );
midnight.setSeconds( 0 );
midnight.setMilliseconds( 0 );
return ( midnight - new Date() );
}
@zulman
zulman / gist:3010816
Created June 28, 2012 11:36
LooToRotation
void Matrix4x4::BuildLookAtMatrix(float posx,float posy,float posz,float eyex,float eyey, float eyez,float upx,float upy, float upz)
{
float x[3], y[3], z[3];
float mag;
z[0] = eyex - posx;
z[1] = eyey - posy;
z[2] = eyez - posz;
mag = sqrt( z[0]*z[0] + z[1]*z[1] + z[2]*z[2] );
if (mag>.0001)
@zulman
zulman / gist:3010954
Created June 28, 2012 12:03
Scale Attempt
void CompositeTransformController::Rotation::set( Quaternion^ value )
{
if( controllers->Length <= 1 || !IsGlobal)
{
CQuat native = value->Native;
native.Normalize();
for each ( IObjectTransformController^ controller in controllers )
controller->Rotation = gcnew Quaternion( native );
}
controller->Location += gcnew Vector3((A.x-controller->Location.x) * value->Native->X,(A.y-controller->Location.y) * value->Native->Y, controller->Location.z);
Где A - Vector3
{
x = (x1+x2+...+xn)/n
y = (y1+y2+...+yn)/n
z = (z1+z2+...+zn)/n
}
1..n - члены скалируемой группы объектов
@zulman
zulman / gist:3097560
Created July 12, 2012 11:24
ResourcesTable
//Предмет приносящий деньги:
var someItem =
{
name:"name"
...
resources:
{
gold:5,
silver:25,
gems:0
@zulman
zulman / gist:3347152
Created August 14, 2012 07:19
ConditionHelper
private static int Condition_Dialog_CastleTutorial_Conditions_m11_0( IScriptData data )
{
var Heroes = data.Heroes;
var Buildings = data.Buildings;
var Lord = data.Lord;
int result = 0;
foreach(var building in Buildings)
{
if(building.PersistentId=="Production_Resource2")
{
@zulman
zulman / gist:3379422
Created August 17, 2012 14:51
callstack
catch:Traceback (most recent call last):\n File \"C:\\pw.test.9.4.0\\social\\handlers.py\", line 486, in onLoggedAction\n return actionHandler.onStart()\n File \"C:\\pw.test.9.4.0\\social\\subaction.py\", line 62, in wrapper\n return method(self, *args, **kwargs)\n File \"C:\\pw.test.9.4.0\\social\\subaction.py\", line 47, in wrapper\n return method(self, *args, **kwargs)\n File \"C:\\pw.test.9.4.0\\social\\logic\\change_fraction.py\", line 37, in onStart\n self.onBuy({ \"code\" : ibilling.ERROR_CODE_OK } )\n File \"C:\\pw.test.9.4.0\\social\\logic\\change_fraction.py\", line 60, in onBuy\n self.changeFraction()\n File \"C:\\pw.test.9.4.0\\social\\logic\\change_fraction.py\", line 146, in changeFraction\n hero.PersistentId = crc32( hero.class_name )\nTypeError: crc32() argument 1 must be string or read-only buffer, not None\n
@zulman
zulman / gist:3831829
Created October 4, 2012 06:33
public show image
var publicShowImage;
$(function() {
// ======================= imagesLoaded Plugin ===============================
// https://github.com/desandro/imagesloaded
// $('#my-container').imagesLoaded(myFunction)
// execute a callback when all images have loaded.
// needed because .load() doesn't work on cached images
// callback function gets image collection as argument
@zulman
zulman / gist:3904179
Created October 17, 2012 07:15
OSX input for cyrillic
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void OnGUI() {
Event e = Event.current;
if (e.isKey)
Debug.Log("Detected character: " + e.character);
}
@zulman
zulman / gist:3904361
Created October 17, 2012 08:19
Green static types
//Monster
staticTypes.Object = function() {
this.name = "noname";
this.image = "default.png";
this.bonuses = [];
this.locale = "en";
this.location = "world";
this.packId = "init_pack1";
this.authorName = "noname";
this.authorId = "noname";