ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperLicht
forum topic indicator Moving an object with the mouse
person icon
bagg
Registered User
Quote
2010-09-30 11:39:20

Hi niko.

Thanks for your quick reply on my previous post.It worked.But i think there is a bug in gotoSceneByName(scene, ignorecase) .Have a look at it.Now i want to ask you if you can post a tutorial or give me an example on how to move an object with the mouse.Let us say that we have two cubes and we want to select and move the one cube with the mouse(Scenenode position will be mouse coordinates).And If it's possible can you include collision detection when the box that is moving is colliding with the other?
And another question.Is it possible an Animator to return the scenenode that is attached to?

Thanks in advance.

person icon
niko
Moderator
Quote
2010-10-01 09:25:48

What exactly is the bug you mention in gotoSceneByName? What happens?

About moving the mouse: You'll have to write this yourself, simply react to the mouse event, test what object is under it using CopperLichts collision detection, and move it accordingly. There are even several methods in CopperLicht to get the 2D position from a 3D position and the other way round, so it should be pretty easy. I don't think I can write a specific tutorial for exactly this case.

Animators don't store the scene node they are attached to, so this is currently not possible, but there is nothing preventing you from storing this in the animator yourself.

person icon
bagg
Registered User
Quote
2010-10-01 12:40:06

Ok i will try it.
The bug in the engine.gotoSceneByName('somescene', true or false) is that it's not working.It's not switching to the "somescene'.I tried with two scenes that i created in coppercube and the engine is started with
var engine =startCopperLichtFromFile('3darea','copperlichtdata/test.ccbjs');
Now can you please help me with what is wrong on the following code and i'ts not working?The mesh is an inserted static mesh inside coppercube.

var Scenes = engine.getScenes();
engine.gotoScene(Scenes[1]);
var newscene = engine.getScene();
var MyMesh = newscene.getSceneNodeFromName('Base7225').getMesh();
if (MyMesh)
{
alert ("Gotit");//This screen message is working so the MyMesh Exists
var BBox = MyMesh.getBoundingBox();
if (BBox)
{alert ("OK");}//This screen message is not working so the BBox dosen't Exists
var meshBuffer = MyMesh.GetMeshBuffers();
if (meshBuffer)
{
for (var j = 0; j < meshBuffer.length; j++)
{
var BufVertices = meshBuffer[j].Vertices;
for (var k = 0; k < BufVertices.length; k++)
{
var VertexPos = BufVertices[k].Pos.X;
// if i put an alert here it will bring me the Pos.X
if (VertexPos > 0) {VertexPos = VertexPos + 100};
if (VertexPos < 0) {VertexPos = VertexPos - 100};
}
}
meshBuffer[j].update ;
meshBuffer[j].recalculateBoundingBox();
}
}

Thanks and sorry if i make you feel dizziness but as i told you i am not e very good developer emoji icon_smile

person icon
bagg
Registered User
Quote
2010-10-02 11:38:34

Never mind that solve it but now how am i going to update the scenenode bounding box because when i print it it's not updated.

Thanks again

person icon
niko
Moderator
Quote
2010-10-03 09:12:52

ok :)


Create reply:










 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |