Position of a model?

Jan 12, 2013 at 3:43 PM

Hi,

I'm experimenting with Vector3.Distance, however I can't seem to get a Vector3 out of my model.

var Npc = scene.FindName<Nine.Graphics.Model>("Npc");           
var Player = scene.FindName<Nine.Graphics.Model>("mmm");           
dist = Vector3.Distance(Npc, Player);

I tried working like this, but the Npc and the Player are not Vector3's. 

I found this little piece of code with positions:
var dist : float = Vector3.Distance(box.position, transform.position);

How can I get the Vector3 / Position from a model? 

Coordinator
Jan 13, 2013 at 3:17 AM

Model.AbsoluteTransform.Translation

Jan 14, 2013 at 12:44 PM

Great, thanks!

Works perfectly. 

Jan 15, 2013 at 8:39 AM

Now I'm stuck again with finding an Instance in my scene.

Here's my code setup:

Game1.cs is in my NineQ project and it has:

var Bullet = scene.Find<Nine.Instance>(bullet);


RapidShooter.cs is in my NineQData library project and it has stuff like:

var bullet = new Instance() { Template = BulletTemplate };
Scene.Add(bullet); 


The new instance of the bullet is in a library project, but it is added to the Scene eventually.

How can I 'find' this instance in my Game1.cs?
 

Coordinator
Jan 15, 2013 at 8:57 AM
When an instance is added to a scene, it is no longer an Instance, but turned into the actual type used in the root element of the template. So try Find<Group> if your template is a group.

发件人: stefanorie
发送时间: 2013/1/15 16:39
收件人: yufeih@live.com
主题: Re: Position of a model? [nine:429389]

From: stefanorie

Now I'm stuck again with finding an Instance in my scene.

Here's my code setup:

Game1.cs is in my NineQ project and it has:

var Bullet = scene.Find<Nine.Instance>(bullet);


RapidShooter.cs is in my NineQData library project and it has stuff like:

var bullet = new Instance() { Template = BulletTemplate };
Scene.Add(bullet);


The new instance of the bullet is in a library project, but it is added to the Scene eventually.

How can I 'find' this instance in my Game1.cs?

Jan 15, 2013 at 9:07 AM
Edited Jan 15, 2013 at 9:24 AM

Oh yeah I see the template is a group, I will try that!

I was thinking, if I shoot 3 bullets rapidly after eachother, how can I only remove the first one I shot? 

 

EDIT:
It's not working or I'm doing something wrong:
in Game1:
var Bullet = scene.FindName<Group>("bullet"); 

the bullet.xaml:
<Group Name="bullet"