Register Latest Topics
 
 
 


Reply
  Author   Comment  
rolfcoppter

Wanting the recipes
Registered:
Posts: 69
Reply with quote  #1 
Hey guys,

I'm having a little trouble wrapping my head around the array expression node when the array has more than one value per index. I want to run a for loop inside this array but I can't quite figure out how it should be formatted.

So say I have a float $array[] connected to inArray 1 and for example $array[0] = (1, 4, 6)
and $array[1] = (5,9)

To get the array expression to calculate each number in the index is this the correct expression for the for loop?

for ($a=0; $a<( size($E[$a]))$a++){
      $E3[($E[$a])] = $E3[($E[$a])] *10;
}

Is this Correct?

0
pshipkov

SOuP Jedi
Registered:
Posts: 4,732
Reply with quote  #2 
I think i forgot to answer this one.
You don't need any of that.
just do $E *= $E2;
Then connect arrayExpression.outArray to whatever you need.
0
rolfcoppter

Wanting the recipes
Registered:
Posts: 69
Reply with quote  #3 
I cant seem to get it working so il try to explain my self a little better,

I have an Array from your KD tree Node PointID PP that as 1-4 IDs per point. 

What I want to do is have all the IDs from each Point have the same World Space Position.

So I have 3 arrays:
-Point ID PP $E2
-Position PP

so is the * what i use to iterate though an array that as more than one value per Index?

Would the expression be like this?

$EX[$E2*]=$EX;

$EY[$E2*]=$EY;

$EZ[$E2*]=$EZ;



0
pshipkov

SOuP Jedi
Registered:
Posts: 4,732
Reply with quote  #4 
The array expression itself puts you inside the loop scope.

for(i = 0; i = someCount; ++i)
{
// array expression is this space inside the loop, so the iterator is already rolling, you just put your code inside it
}

I am not sure i fallow your explanation. Sorry.

quote: all the IDs from each Point have the same World Space Position.
There is exactly one ID per-point. The ID itself is a whole positive number starting and including 0.
What do you mean with ID from each point to have the same world position ?

The *= operator is a syntax sugar. I am sorry if that was confusing to you.
$E *= $E2; is the same as $E = $E * $E2;


$EX[$E2*]=$EX; wont work - there is no such math/programming expression.


As i said in the beginning of this message, the node will iterate on your code for all the elements.
So if you type something like this:
$E = $E + 1;
it equates to this:
for(i = 0; i < num_elements; ++i)
{
    element[i] = element[i] + 1;
}

for vector array (points) you can type this:
$EX += 1;  // which is the same as $EX = $EX + 1;
$EY += 1;
$EZ += 1;

which equates to this:
for(i = 0; i < num_elements; ++i)
{
    element[i].x = element[i].x + 1;
    element[i].y = element[i].y + 1;
    element[i].z = element[i].z + 1;
}

Let's try one more time to define the problem and i am sure i will be able to provide you with a solution.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.