[Programming] Shadow Algorithm

20 12 2011

user posted image

Download link

Red: points projected to Y = 0
Black: min,max X of min,max Z
Green: max X
Blue: min X

The source code won’t be uploaded until optimized

So, It works like this:
1. Get all the vertices (position) [Indices of polygons don’t matter]
The prm loading’s source can be found in Tools -> nVolt
[projecting to Y = 0]
2. Sorting algorithm (I used Bubble sorting) [by Z]
3. get the min and the max [by Z], then min, max [by X]
we now get 4 points: that’s the rectangle (I used distance between .Z -> .Z)
4. Now We’re going to split virtually the points (into cubes-alike) [see Math explication for this]
5. Finally, We link all of them

pseudo-C

CODE

vertex[] v = getVertices();
vector2D[] point;
For (i=0;i
{
point = Scalar_product(v[i],getVector(1,0,1));
}
BubbleSort(point); //sort by bubble
BubbleSort(SearchNeighborPoints(point[0]))[0]; //min
BubbleSort(SearchNeighborPoints(point[0])).getLatest(); //max
BubbleSort(SearchNeighborPoints(point.getLatest))[0];
BubbleSort(SearchNeighborPoints(point.getLatest)).getLatest(); 

Pseudo-Math

QUOTE

init <– 0
for i:= 0 to length(points) [or use Repeat..Until ; Do… While]We define |x| = max(-x,x)

|point[i].z – point[init].z| < n
n = Positif Constant  . We take it by “precision”
We shall repeat this until |point[i].z – point[init].z| >= n
then, we move to:
init <– i+ 1
and until (i > length(points) – 1)

Now, after getting the wanted, We bubble Sort the points
then We checked if the min is on the left and the max is on the right

We calculate the boundingbox then for that :
for X, Y then Z each separately (XYZ) we’ve got:
MAX <– max(MAX,point[i].XYZ)
MIN <– min (MIN, point[i].XYZ)

The center shall be:Center <– MAX/2 + MIN/2

if (MAX – Center).z >0 then everything is alright (same with (MIN-Center).z )
otherwise drop, not to include

 

Finally, we link the max_points (0->length(max)) then min_points (length(min) -> 0) or the opposite (0->length(min) then length(max)->0)


Actions

Information

2 responses

21 12 2011
[Re-Volt] The PRM (car) Shader named AutoShader | Kallel Ahmed Yahia (theKDL)'s blog

[…] [Programming] Shadow Algorithm (thekdl.wordpress.com) 34.745159 10.761300 LD_AddCustomAttr("AdOpt", "1"); LD_AddCustomAttr("Origin", "other"); LD_AddCustomAttr("theme_bg", "F1F6F9"); LD_AddCustomAttr("theme_text", "333333"); LD_AddCustomAttr("theme_link", "EE6633"); LD_AddCustomAttr("theme_border", "296684"); LD_AddCustomAttr("theme_url", "4499BB"); LD_AddCustomAttr("LangId", "1"); LD_AddCustomAttr("Autotag", "technology"); LD_AddCustomAttr("Autotag", "education"); LD_AddCustomAttr("Tag", "carload"); LD_AddCustomAttr("Tag", "programming"); LD_AddCustomAttr("Tag", "re-volt"); LD_AddCustomAttr("Tag", "re-volt-live"); LD_AddCustomAttr("Tag", "re-volt"); LD_AddSlot("wpcom_below_post"); LD_GetBids(); Share this:ShareEmailFacebookTwitterDiggLike this:LikeBe the first to like this post. This entry was posted in Car::Load, Programming, Re-Volt, Re-Volt Live and tagged Re-Volt. Bookmark the permalink. […]

9 01 2012
[Programming] Shadow algorithm (for Re-Volt) | Kallel Ahmed Yahia (theKDL)'s blog

[…] [Programming] Shadow Algorithm (thekdl.wordpress.com) 34.745159 10.761300 Share this:ShareEmailFacebookTwitterDiggLike this:LikeBe the first to like this post. This entry was posted in Programming, Re-Volt, Visual Basic.NET 2008. Bookmark the permalink. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s




%d bloggers like this: