Tuesday, June 30, 2020

Python single line for loop

# example of single line for loop
x = [1,2,3,4]
print( sum(e for e in x) )

I can get 10. What if we don't have a single line for loop?

s = 0
for e in x:
    s += e
print(s)

Wednesday, May 20, 2020

Selector, Sequence

Selector : Executes all the commands until it finds a success.
Sequence : Executes all the command until it finds a fail.

Tuesday, May 12, 2020

Data compression needs!

Many people are not interested about the data compression but it is important!
Recently I'm working on a project which is using GLTF and there is a library 'draco' but it seems animation data compression feature is a little bit missing as expected.

If the model has really big animations then size of the model will be big. This is not acceptable in some cases where passing the model data via network and so on.

I hope someone should be working on this issue ASAP! then you will get a credit!

Thursday, May 7, 2020

Logarithmic Depth Buffer


If your model is big then you should use logarithmic depth buffer like down below

renderer = new THREE.WebGLRenderer( { antialias: true, logarithmicDepthBuffer: true } );

or just scale down the models. :)


Sunday, April 5, 2020

마야 노드 에디터

마야의 노드 에디터를 활용하면 멜 스크립트를 사용하지 않고도 원하는 로직 실행이 가능하다.
가령 A라는 오브젝트의 x 위치값이 바뀔 때 오브젝트 B의 스케일 Y값을 변경하려면
보통 다음과 같이 코딩을 하게 되는데

B.scaleY = A.translateX

이런 코드를 직접 작성하지 않고 노드로 표현 가능하다.

Simple implementation of Decision Tree with C++

Simple implementation of Decision Tree with C++
=================================


#include <iostream>

using namespace std;

bool val_visible = false;
bool val_evidence = true;
bool val_hungry = false;
float val_distance = 50;

class GameWorldEnv
{
public:
float GetPlayerDistance()
{
return rand() % 100;
}
};

class DecisionNode
{
public:
virtual DecisionNode* Decision() { return nullptr; };
virtual void Action() {};
};

class Decision : public DecisionNode
{
public:

};

class Boolean : public Decision
{
public:
Boolean(bool* val, DecisionNode* yes, DecisionNode* no)
: mTestValue(val)
, mYesNode(yes)
, mNoNode(no)
{

}

DecisionNode* Decision()
{
if (*mTestValue)
{
return mYesNode;
}
return mNoNode;
}

DecisionNode* mYesNode;
DecisionNode* mNoNode;
bool* mTestValue;
};

class Close : public Decision
{
public:
Close(float* distance, GameWorldEnv* env, DecisionNode* yes, DecisionNode* no)
: mTestDistance(distance)
, mEnv(env)
, mYesNode(yes)
, mNoNode(no)
{

}

DecisionNode* Decision()
{
if (mEnv->GetPlayerDistance() < *mTestDistance)
{
return mYesNode;
}
return mNoNode;
}

DecisionNode* mYesNode;
DecisionNode* mNoNode;

GameWorldEnv* mEnv;
float* mTestDistance;
};

class Action : public DecisionNode
{
public:

};

class Eat : public Action
{
public:
void Action()
{
cout << "Action Executed : Eat" << endl;
}
};

class Wander : public Action
{
public:
void Action()
{
cout << "Action Executed : Wander" << endl;
}
};

class Attack : public Action
{
public:
void Action()
{
cout << "Action Executed : Attack" << endl;
}
};

class Trace : public Action
{
public:
void Action()
{
cout << "Action Executed : Trace" << endl;
}

};

// Action은 Wander, Eat, Trace, Attack
// 총 4개가 있다.

void Process(DecisionNode* node)
{
DecisionNode* newNode = node->Decision();
if (newNode != nullptr)
{
Process(newNode);
}
else
{
// action
node->Action();
}
}

int main()
{
Eat eatNode;
Wander wanderNode;
Attack attackNode;
Trace traceNode;

GameWorldEnv env;
Close closeNode(&val_distance, &env, &attackNode, &traceNode);
Boolean hungryNode(&val_hungry, &eatNode, &wanderNode);
Boolean evidenceNode(&val_evidence, &closeNode, &hungryNode);
Boolean visibleNode(&val_visible, &closeNode, &evidenceNode);

DecisionNode* root = &visibleNode;

// Make a decision tree
for (int i = 0; i < 3; ++i)
{
Process(root);
Process(root);
}
}

Task in UnrealEngine

 https://www.youtube.com/watch?v=1lBadANnJaw