LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

3d Labview simulation

 Why is it that when I change color it des not change at all?

 

Because lighting is enabled.  In that case the material colors are what are used, not the "color" on the geometry.  You can either setup a material, turn off lighting or set the Material.ColorMode to IgnoreDiffuse to get it to work as expected.

 

The order of operations matters here.  These are really just short cuts to do a matrix multiplication.  As you probably know, that is not commutative.

 

Here is a link to give you some details about how these operations work, it isn't LabVIEW specific, but deals with OpenGL, but is very relevant here.

http://glprogramming.com/red/chapter03.html#name2

 

You are applying a scale to the object that holds the geometry for the ball.  If what you mean is that you are applying the scale after you assign the sphere geometry, that is irrelevant. You are build a tree of nodes that you manipulate by setting properties. 

 

Only when we assign the scene to the 3d picture is the tree traversed and rendered.

0 Kudos
Message 11 of 24
(1,413 Views)

Hi Saqib,

 

One of my colleagues passed this VI to me because he knew I was interested in 3D... As soon as I opened up the football pitch, I knew that it was yours!

 

Great work!


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

0 Kudos
Message 12 of 24
(1,408 Views)

@ Peter:

 

Thanks I will have a look at that link and get back to you soon. I will also apply what you have said and see what happens. If I can not solve it I will be back 🙂

 

@ Alex:

 

Its a small world and you got my VI one way another haha. Well have fun with my VI. I still need to know how to scale the football movement correctly with relation to the real world.
I will see what I can do.

 

...........Side information:

 

I have made progress too. I can now detect when the ball has crossed the line haha Smiley Very Happy using an ni example for detecting coordinates within a range. Very simple and elegant. So to pack this all together - I just need to scale it correctly with respect to my webcam and then I should be done. Then the final step of the project I would think is to use Stereovision to obtain the 3d coordinates of the ball in real life.

 

 

0 Kudos
Message 13 of 24
(1,402 Views)

@saqib_zahir wrote:

@ Peter:

 

Thanks I will have a look at that link and get back to you soon. I will also apply what you have said and see what happens. If I can not solve it I will be back 🙂

 

@ Alex:

 

Its a small world and you got my VI one way another haha. Well have fun with my VI. I still need to know how to scale the football movement correctly with relation to the real world.
I will see what I can do.

 

...........Side information:

 

I have made progress too. I can now detect when the ball has crossed the line haha Smiley Very Happy using an ni example for detecting coordinates within a range. Very simple and elegant. So to pack this all together - I just need to scale it correctly with respect to my webcam and then I should be done. Then the final step of the project I would think is to use Stereovision to obtain the 3d coordinates of the ball in real life.

 

 


This all sounds fantastic. I'm so glad that you came on the forums, the amount of help people give here is phenominal!

 

For placing the football in a position in the 3D simulation that is reflective of the real world, I'd recommend ensuring that the pitch size in the 3D world is directly proportional to the area. This means that when you retrieve position information for the ball, you'd only have to multiply the data by a constant of proportionality in order to produce co-ordinates which are relative to the simulation model. Then based on this information, you should be able to translate the 3D Object accordingly using the Translate Object VI.

 

Best regards,


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

0 Kudos
Message 14 of 24
(1,400 Views)

Thanks Alex. I will look into what you say too. Actually for your info, the CAD drawing I did was all to scale as it is. i.e.

 

Posts are 2.44m from ground to underneath of crossbar, Crossbarr is 7.32m wide. I also made the diameter of the posts and the lines all the same that are 12cm.

 

The 5 yards box is 5.5m and is from the center of the posts.

 

So all of this is all to scale definately in the 3d drawing simulation model.

 

When I drew the ball in the VI though, I have changed the ball size but do not know if it is in diameter ~21cm. I just used my general feel for how the ball should look like on this sort of pitch. However, I will work it out though and I think it is just inserting the appropriate radius and correct scale. It all is as you say - a scaling problem. This text I am reading at the moment is interesting and hopefully it will allow me to sort it all out - even the translation bit. Thanks Peter.

 

Hear from you all soon.

 

Saqib 

 

 

0 Kudos
Message 15 of 24
(1,395 Views)

HELLO WORLD - I am back...and I know its the weekend and so may as well make the most of your time today before I get stuck again haha.


Well actually, I sorted the scaling problem!

 

At first I thought that the VI that enables you to scale - I actuallly thought that it would scale the translation and well this was NOT true after playing with my football simulations and the one attatched. In fact - when the scale numbers were changed from the control - only the object size had changed BUT the translation did not change. After understanding this - then I realised for me to change the translation scale - I had to simply pull out the (x,y,z) coordinates and simply scale them using the multipliers.  

 

However, the way I have coded it seems a bit of a mess. Is there an easier way because the way I have done it is:

 

1) unbundled the 3d coordinates

2) Scaled the elements by same amount

3) used the results to replace the original (x,y,z) cluster

 

IT seems to work but it just seems like it is a long method.  There should be a more nicer way to scale than the way I have done right or is this fine?

 

Now a new problem I also have is - when should I learn to close these references in the objects. Because you know my memory when running the football VI especially - it increases linearly - and then - my PC crashes. Need to resolve this issue if you guys can help. Maybe it happens on your computers too? maybe... Is it related to me no closing the references? WHy should I bother to close the references?

 

I guess for me to test the scaling code I wrote (attatched) is to integrate it with my 3d simulation football pitch - and test with a live input camera. I will try this and see how things get along. Oh Peter - I thought about using color but then why do that when I can add a texture. So I have prefered to do that as it will look more like a football too. (to be honest it looks more like a beach ball lol)

 

While I do the above by end of today - would perhaps anybody know anywhere I can start with stereovision. Any links, reading material and most importantly your advice! I am to use 2 usb cameras (will choose better ones later in time) and to obtain the 3D ocordinates of a football in real world. Because essentially, I want to use this information and feed it into the football simulation vi.

 

Anymore information you need - please let me know...

 

Saqib

 

PS make sure you use the attatched image as the texture for the ball

 

 

Download All
0 Kudos
Message 16 of 24
(1,375 Views)

On the scaling...

I am not sure why you are scaling at all.  I would think that you would just create the ball the right size and translate it using the same units as the field.  Maybe I am missing something, but I would try to avoid scaling just to keep it simpler.

 

On the reference problem.  You should close refereneces as soon as you are done with them, but that isn't the problem in your case.  In your case you are allocating a sphere geometry and a scene object every frame of the while loop.  You don't have to do this. 

 

What you should do is create your scene and just use property nodes in the loop for the things that change.  You can close the reference to the allocated sceneobject when the program shuts down.

 

Attached is a version of your old VI with examples of the correct way to allocate and dispose of references. (I didn't correct the coloring or scaling problems in this VI, just used it as a starting point to demonstrate how you should manage scene item allocation, disposal, etc)

 

 

 

 

0 Kudos
Message 17 of 24
(1,366 Views)

Thank you Peter

 

I will use the reference structure you have constructed for me. I will integrate my "texture" vi into it. Oh by the way - yes we do not need the scaling vi, i placed it initially ever since starting 3D because I thought it would scale the translation. Since it doesnt and only affected size of object- it is true I dont need it as I can change the radius.

 

SMall questions

1) when you first draw a spherical geometry, and translate or make a radius of 1 => in terms of units it doesn't mean anything right? Unless we manually do some maths to represent say a unit increment of the ball is say 1cm. To make such a statement like that - I would have to make sure the Area of interest is to scale and that when translating I insert the scale inside the code, like i did in the texture vi.

 

2) Also, how can I guarantee the ball is eactly 0.2cm diameter with respect to the football field? Would I use the same translation scale to the number I insert for the radius.

 

Anyways - More or less done almost. At the end of today I should have this fully working and then I only need to do some stereovision.

Thanks for all your help.

 

SAqib

 

PS. Im new to these forums. What are these kudos and how many can you give and when should you give it? THanks in advance.

0 Kudos
Message 18 of 24
(1,363 Views)

Sorry I just reread your response Peter:

 

You know I htink you are right actually. When I made the CAD package I made sure the widest part of the pitch was 20m.

When I move the ball from (0.0.0) to make it of screen it is 10 units to the right, Same to the left hand side - its -10,

 

So this means that each increment is 1m! You see I was confused as to what 1 unit was representing too. I think this is clear.

 

So if I want 20cm ball then all I insert in the radius in 0.2! Please correct me if I am wrong.

 

I think its starting to make more sense now actually...

 

Does this mean always then - when you import a CAD model, Labview will always its scale with respect to it.

 

Thanks

 

SAqib

0 Kudos
Message 19 of 24
(1,359 Views)

The numbers in the 3d picture control don't have any meaning until you assign them.  For example, you mentioned that you have a crossbar which is 7.32m wide in real-life.  How big is the model for it? 

 

Lets say that it 7.32 scene units wide - that means that 1 scene unit == 1m.  You should then make sure everything in your scene uses these proportions.

 

It is of course just as valid to say that 1 scene unit == 7.32m or 1 scene unit == 1 cm.  As long as you are consistent it doesn't matter.  Just choose something that is easy for you.

 

Again, I don't really understand why you are using scaling.  You should just create the scene in the right proportions and then use translation to set the X,Y,Z position of the ball.  I don't expect to see the SetScale methods at all.  Other than that, I think I agree with your first statement.

 

You guarantee that it will be to scale by creating it with the right radius computed as follows

 

FieldInSceneUnits / FieldInRealLifeUnits * BallInRealLifeUnits = BallInSceneUnits

 

I would like to hear more about what you are trying to do with "stereovision". 

 

On the forums -- I hope you are finding them useful.  Kudos are just ways of saying "I appreciate this post" I guess.  You should give them whenever you feel that an answer was helpful or informative.  Here is a thread about Kudos

 

http://forums.ni.com/t5/LabVIEW/what-is-kudos/m-p/913265/highlight/true#M411278

 

 

 

 

 

 

 

 

0 Kudos
Message 20 of 24
(1,352 Views)