last post is how I load nodes as an array using in realbasic
-
- Posts: 22
- Joined: Tue Nov 09, 2010 7:03 pm
- Location: ohiio
last post is how I load nodes as an array using in realbasic
I am loading 48 meshes that I would like to animate with user input.
I would like to use a loop to make changes in the node positions.
I am using Irrlicht in real studio, the Franklin3d plugin.
I have not done any programming since 1985 when I was learing Pascal.
Here is the code for the meshes I am loading. Feel free to point out any newbie mistakes:
dim mesh1 as scene_IAnimatedMesh
mesh1 = scene.getMesh("test/p1.3ds")
dim anim as scene_ISceneNodeAnimator
dim node as scene_IAnimatedMeshSceneNode
node = scene.addAnimatedMeshSceneNode(mesh1)
if node <> nil then
dim position as core_vector3df = new core_vector3df(0,0,30)
node.setPosition(position)
dim mat as integer
dim Texture as video_ITexture
Texture = driver.getTexture("test/yellow.bmp")
node.setMaterialTexture(0,Texture)
node.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING,true)
end if
dim mesh2 as scene_IAnimatedMesh
mesh2 = scene.getMesh("test/p2.3ds")
dim anim2 as scene_ISceneNodeAnimator
dim node2 as scene_IAnimatedMeshSceneNode
node2 = scene.addAnimatedMeshSceneNode(mesh2)
if node2 <> nil then
dim position2 as core_vector3df = new core_vector3df(0,0,30)
node2.setPosition(position2)
dim Texture2 as video_ITexture
Texture2 = driver.getTexture("test/red.bmp")
node2.setMaterialTexture(0,Texture2)
node2.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING,true)
end if
I repeat this 48 times
I tried to do this instead:
dim j As integer
dim s,partarray(49) as string
dim mesharray(49) as scene_IAnimatedMesh
dim animarray(49) as scene_ISceneNodeAnimator
dim nodearray(49) as scene_IAnimatedMeshSceneNode
dim textureArray(49) As video_ITexture
dim position as core_vector3df = new core_vector3df(0,0,30)
for j = 1 to 48
s = str(j)
partarray(j) = "p" + s + ".3ds"
mesharray(j) = scene.getMesh(str(partarray(j)))
msgbox partarray(j)
nodearray(j) =scene.addAnimatedMeshSceneNode(mesharray(j)
if nodearray(j) = nil then msgbox partarray(j)
Texturearray(j) = driver.getTexture("test/yellow.bmp")
nodearray(j).setMaterialTexture(0,textureArray(j))
nodearray(j).setPosition(position)
next
Thanks for looking
I would like to use a loop to make changes in the node positions.
I am using Irrlicht in real studio, the Franklin3d plugin.
I have not done any programming since 1985 when I was learing Pascal.
Here is the code for the meshes I am loading. Feel free to point out any newbie mistakes:
dim mesh1 as scene_IAnimatedMesh
mesh1 = scene.getMesh("test/p1.3ds")
dim anim as scene_ISceneNodeAnimator
dim node as scene_IAnimatedMeshSceneNode
node = scene.addAnimatedMeshSceneNode(mesh1)
if node <> nil then
dim position as core_vector3df = new core_vector3df(0,0,30)
node.setPosition(position)
dim mat as integer
dim Texture as video_ITexture
Texture = driver.getTexture("test/yellow.bmp")
node.setMaterialTexture(0,Texture)
node.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING,true)
end if
dim mesh2 as scene_IAnimatedMesh
mesh2 = scene.getMesh("test/p2.3ds")
dim anim2 as scene_ISceneNodeAnimator
dim node2 as scene_IAnimatedMeshSceneNode
node2 = scene.addAnimatedMeshSceneNode(mesh2)
if node2 <> nil then
dim position2 as core_vector3df = new core_vector3df(0,0,30)
node2.setPosition(position2)
dim Texture2 as video_ITexture
Texture2 = driver.getTexture("test/red.bmp")
node2.setMaterialTexture(0,Texture2)
node2.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING,true)
end if
I repeat this 48 times
I tried to do this instead:
dim j As integer
dim s,partarray(49) as string
dim mesharray(49) as scene_IAnimatedMesh
dim animarray(49) as scene_ISceneNodeAnimator
dim nodearray(49) as scene_IAnimatedMeshSceneNode
dim textureArray(49) As video_ITexture
dim position as core_vector3df = new core_vector3df(0,0,30)
for j = 1 to 48
s = str(j)
partarray(j) = "p" + s + ".3ds"
mesharray(j) = scene.getMesh(str(partarray(j)))
msgbox partarray(j)
nodearray(j) =scene.addAnimatedMeshSceneNode(mesharray(j)
if nodearray(j) = nil then msgbox partarray(j)
Texturearray(j) = driver.getTexture("test/yellow.bmp")
nodearray(j).setMaterialTexture(0,textureArray(j))
nodearray(j).setPosition(position)
next
Thanks for looking
Last edited by speedy15453 on Sat Nov 20, 2010 3:04 am, edited 1 time in total.
Only after disaster can we be resurrected.
speedy15453,
In Irrlicht all nodes stored as a tree. So there is a root of this tree, you can get it by sceneManager->getRootSceneNode(). Then use getChildren() to get the children of this single node only (you will not get children of children or deeper) -- you get only 1 level of deep.
So, if what i said above is clear, and if you need an array, you can do next:
- if you add all nodes only to the root node, so use its getChildren() and it would be your array of all the nodes;
- you may have your own array of pointers of all necessary nodes; so when you add a node to any parent, you just add its pointer to your array too, so you have a simple array access to all your nodes. But do not forget, if you remove some node from the SceneManager, you also must to remove it from your array;
- if you need an array of nodes and you do not care of performance, you can build an array of all the nodes on the fly each time you need it using recursion (by going from the root node to each child and its child and so on);
I would recommend second variant. Just wrap your adding/removing nodes functionality to some methods which will be responsible for adding/removing nodes in all the code.
In Irrlicht all nodes stored as a tree. So there is a root of this tree, you can get it by sceneManager->getRootSceneNode(). Then use getChildren() to get the children of this single node only (you will not get children of children or deeper) -- you get only 1 level of deep.
So, if what i said above is clear, and if you need an array, you can do next:
- if you add all nodes only to the root node, so use its getChildren() and it would be your array of all the nodes;
- you may have your own array of pointers of all necessary nodes; so when you add a node to any parent, you just add its pointer to your array too, so you have a simple array access to all your nodes. But do not forget, if you remove some node from the SceneManager, you also must to remove it from your array;
- if you need an array of nodes and you do not care of performance, you can build an array of all the nodes on the fly each time you need it using recursion (by going from the root node to each child and its child and so on);
I would recommend second variant. Just wrap your adding/removing nodes functionality to some methods which will be responsible for adding/removing nodes in all the code.
No, it is not Lime, because i don't recognize types.slavik262 wrote:I'm confused. Are you using Irrlicht Lime with VB.NET?
-
- Posts: 22
- Joined: Tue Nov 09, 2010 7:03 pm
- Location: ohiio
Parent / Child Nodes
I'm having trouble with the child / parent nodes
Do you have to setparent first?
Can you show me what the code should look like with one parent and 2 child nodes.
If you rotate the parent node will the child nodes match the parent's movements?
Thanks for trying to help!
By the way I am using Franklin3d (Irrlicht plugin) for RealBasic.
I have been converting whatever code I can to work in this IDE
Do you have to setparent first?
Can you show me what the code should look like with one parent and 2 child nodes.
If you rotate the parent node will the child nodes match the parent's movements?
Thanks for trying to help!
By the way I am using Franklin3d (Irrlicht plugin) for RealBasic.
I have been converting whatever code I can to work in this IDE
Only after disaster can we be resurrected.
Re: Parent / Child Nodes
You do this when you add node to the manager. For example look at ISceneManager interface ( http://irrlicht.sourceforge.net/docu/cl ... nager.html ), every call of addXXXXXX() has a paramter "parent", which looks like "ISceneNode *parent=0", so if you pass 0, you add node to the root, if you pass particular scene node, you add the child to it.speedy15453 wrote:Do you have to setparent first?
Here it is:speedy15453 wrote:Can you show me what the code should look like with one parent and 2 child nodes.
Code: Select all
ISceneNode* cube1 = smgr->addCubeSceneNode(20.0f, 0, -1, vector3df(0, 0, 0));
ISceneNode* cube11 = smgr->addCubeSceneNode(20.0f, cube1, -1, vector3df(50, 0, 0));
ISceneNode* cube12 = smgr->addCubeSceneNode(20.0f, cube1, -1, vector3df(0, 50, 0));
ISceneNode* cube13 = smgr->addCubeSceneNode(20.0f, cube1, -1, vector3df(0, 0, 50));
ISceneNode* cube131 = smgr->addCubeSceneNode(20.0f, cube13, -1, vector3df(0, 0, 50));
Yes. According to the code above, if you move, rotate or scale cube1, the, all children (including cube131) will have also updated. Do not worry about value of getPosition() of cube131, it will be the same as you set it before using setPosition(). The real position calculates just before rendering. I'm just saying next:speedy15453 wrote:If you rotate the parent node will the child nodes match the parent's movements?
Code: Select all
cube131->setPosition(vector3df(100,0,0));
cube1->setPosition(vector3df(50, 60, 70));
All above i described how it works in native Irrlicht Engine (C++), but i do not know how it looks like in Franklin3d for RealBasic.speedy15453 wrote:By the way I am using Franklin3d (Irrlicht plugin) for RealBasic.
-
- Posts: 22
- Joined: Tue Nov 09, 2010 7:03 pm
- Location: ohiio
I searched forum for 3 days
My IDE won't accept parameters to add parent when creating the nodes from mesh input.(it will for a light, billboard or primatives) I'm sure there is a way but I tried every variation of the code.
I need to do it on the fly anyway to change groups of children to get the desired movement of the groups of nodes I need for the program.
My problem now is upon accepting input "X" I set the parent of
"node1"( a mesh I want to be able to rotate around a sphere) to
"nodes"(the sphere) As soon a "x" is pressed "node1" dissapears from the scene. All the other nodes remain and rotate. Then if "X" is entered again the program crashes.
My question is what is happening to node1? It seams that after I set it as a child of the sphere it is deleted from the scene.
I also tried to to use the the addCHild to make the pointer and this had no effect what so ever.
Am I missing something.
Is there more code that I need to use setParent, or can it be used on the fly.
Thanks For Looking, Maybe I should just start learning C
John
I need to do it on the fly anyway to change groups of children to get the desired movement of the groups of nodes I need for the program.
My problem now is upon accepting input "X" I set the parent of
"node1"( a mesh I want to be able to rotate around a sphere) to
"nodes"(the sphere) As soon a "x" is pressed "node1" dissapears from the scene. All the other nodes remain and rotate. Then if "X" is entered again the program crashes.
My question is what is happening to node1? It seams that after I set it as a child of the sphere it is deleted from the scene.
I also tried to to use the the addCHild to make the pointer and this had no effect what so ever.
Am I missing something.
Is there more code that I need to use setParent, or can it be used on the fly.
Code: Select all
dim sphere1 as scene_IAnimatedMesh
sphere1 = scene.getMesh("test/sphere1.3ds")
dim nodes as scene_IAnimatedMeshSceneNode
nodes = scene.addAnimatedMeshSceneNode(sphere1)
if nodes <> nil then
dim positions as core_vector3df = new core_vector3df(0,0,0)
nodes.setPosition(positions)
dim Textures as video_ITexture
Textures = driver.getTexture("test/blue2.bmp")
nodes.setMaterialTexture(0,Textures)
end if
dim mesh1 as scene_IAnimatedMesh
mesh1 = scene.getMesh("test/p1.3ds")
dim node1 as scene_IAnimatedMeshSceneNode
node1 = scene.addAnimatedMeshSceneNode(mesh1)
if node1 <> nil then
dim position as core_vector3df = new core_vector3df(0,0,0)
node1.setPosition(position)
dim Texture as video_ITexture
Texture = driver.getTexture("test/yellow.bmp")
node1.setMaterialTexture(0,Texture)
node1.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING,true)
end if
dim mesh2 as scene_IAnimatedMesh
mesh2 = scene.getMesh("test/p2.3ds")
dim node2 as scene_IAnimatedMeshSceneNode
node2 = scene.addAnimatedMeshSceneNode(mesh2)
if node2 <> nil then
dim position2 as core_vector3df = new core_vector3df(0,0,0)
node2.setPosition(position2)
dim Texture2 as video_ITexture
Texture2 = driver.getTexture("test/red.bmp")
node2.setMaterialTexture(0,Texture2)
node2.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING,true)
end if
while device.run()
'rotate sphere and children 45 degrees
dim j as integer
if IsKeyDown(EKEY_CODE.KEY_KEY_X) = true then
KeyIsDown(EKEY_CODE.KEY_KEY_X) = false
node2.setParent(nodes)
dim positions as core_vector3df = new core_vector3df(xs,ys,zs)
dim color2 as video_SColor = new video_SColor(2,2,2,2)
for j = 1 to 45
xs = xs +1
positions = new core_vector3df(xs,ys,zs)
nodes.setRotation( positions )
nodes.updateAbsolutePosition()
if xs =360 then x=0
bool = driver.beginScene(true,true,color2)
scene.drawAll()// draw the 3d scene
bool = driver.endScene()
next
end
' rotate sphere only 45 degrees
if IsKeyDown(EKEY_CODE.KEY_KEY_Y) = true then
KeyIsDown(EKEY_CODE.KEY_KEY_Y) = false
for j = 1 to 45
ys = ys +1
dim positions as core_vector3df = new core_vector3df(xs,ys,zs)
positions = new core_vector3df(xs,ys,zs)
nodes.setRotation( positions )
nodes.updateAbsolutePosition()
if xs =360 then x=0
dim color2 as video_SColor = new video_SColor(2,2,2,2)
bool = driver.beginScene(true,true,color2)
scene.drawAll()// draw the 3d scene
'gui.drawAll()// draw the gui environment (the logo)
bool = driver.endScene()
next
end
' rotate sphere only 45 degrees
if IsKeyDown(EKEY_CODE.KEY_KEY_Z) = true then
KeyIsDown(EKEY_CODE.KEY_KEY_Z) = false
for j = 1 to 45
zs = zs +1
dim positions as core_vector3df = new core_vector3df(xs,ys,zs)
positions = new core_vector3df(xs,ys,zs)
nodes.setRotation( positions )
nodes.updateAbsolutePosition()
if xs =360 then x=0
dim color2 as video_SColor = new video_SColor(2,2,2,2)
bool = driver.beginScene(true,true,color2)
scene.drawAll()// draw the 3d scene
'gui.drawAll()// draw the gui environment (the logo)
bool = driver.endScene()
next
end
' rotate node2 45 degrees around sphere
if IsKeyDown(EKEY_CODE.KEY_KEY_K) = true then
KeyIsDown(EKEY_CODE.KEY_KEY_K) = false
for i =1 to 45
y2=0
x2=0
dim position2 as core_vector3df = new core_vector3df(x2,y2,z2)
z2=z2 +1
position2 = new core_vector3df(x2,y2,z2)
node2.setRotation( position2 )
node2.updateAbsolutePosition()
if x2 =360 then x2=0
if y2 =360 then y2=0
if z2 = 360 then z2=0
dim color2 as video_SColor = new video_SColor(2,2,2,2)
bool = driver.beginScene(true,true,color2)
scene.drawAll()// draw the 3d scene
'gui.drawAll()// draw the gui environment (the logo)
bool = driver.endScene()
dim nam,str as string
nam = driver.getName()
str = "Speegle's Sphere " + Str(x) + " " + str(y) + " " + str(z) +" "+ Str(x2) + " " + str(y2) + " " + str(z2)
device.setWindowCaption(str)
next
dim position2 as core_vector3df = new core_vector3df(x2,y2,z2)
node2.updateAbsolutePosition()
end
dim color2 as video_SColor = new video_SColor(2,2,2,2)
bool = driver.beginScene(true,true,color2)
scene.drawAll()// draw the 3d scene
'gui.drawAll()// draw the gui environment (the logo)
bool = driver.endScene()
dim nam,str as string
nam = driver.getName()
str = "Speegle's Sphere " + Str(x) + " " + str(y) + " " + str(z) +" "+ Str(x2) + " " + str(y2) + " " + str(z2)
device.setWindowCaption(str)
Wend
//return visible of cursor
cursor.setVisible(true)
'In the end, delete the Irrlicht device.
bool = device.drop()
John
Only after disaster can we be resurrected.
-
- Posts: 22
- Joined: Tue Nov 09, 2010 7:03 pm
- Location: ohiio
I searched forum for 3 days
My IDE won't accept parameters to add parent when creating the nodes from mesh input.(it will for a light, billboard or primatives) I'm sure there is a way but I tried every variation of the code.
I need to do it on the fly anyway to change groups of children to get the desired movement of the groups of nodes I need for the program.
My problem now is upon accepting input "X" I set the parent of
"node1"( a mesh I want to be able to rotate around a sphere) to
"nodes"(the sphere) As soon a "x" is pressed "node1" dissapears from the scene. All the other nodes remain and rotate. Then if "X" is entered again the program crashes.
My question is what is happening to node1? It seams that after I set it as a child of the sphere it is deleted from the scene.
I also tried to to use the the addCHild to make the pointer and this had no effect what so ever.
Am I missing something.
Is there more code that I need to use setParent, or can it be used on the fly.
Thanks For Looking, Maybe I should just start learning C
John
I need to do it on the fly anyway to change groups of children to get the desired movement of the groups of nodes I need for the program.
My problem now is upon accepting input "X" I set the parent of
"node1"( a mesh I want to be able to rotate around a sphere) to
"nodes"(the sphere) As soon a "x" is pressed "node1" dissapears from the scene. All the other nodes remain and rotate. Then if "X" is entered again the program crashes.
My question is what is happening to node1? It seams that after I set it as a child of the sphere it is deleted from the scene.
I also tried to to use the the addCHild to make the pointer and this had no effect what so ever.
Am I missing something.
Is there more code that I need to use setParent, or can it be used on the fly.
Code: Select all
dim sphere1 as scene_IAnimatedMesh
sphere1 = scene.getMesh("test/sphere1.3ds")
dim nodes as scene_IAnimatedMeshSceneNode
nodes = scene.addAnimatedMeshSceneNode(sphere1)
if nodes <> nil then
dim positions as core_vector3df = new core_vector3df(0,0,0)
nodes.setPosition(positions)
dim Textures as video_ITexture
Textures = driver.getTexture("test/blue2.bmp")
nodes.setMaterialTexture(0,Textures)
end if
dim mesh1 as scene_IAnimatedMesh
mesh1 = scene.getMesh("test/p1.3ds")
dim node1 as scene_IAnimatedMeshSceneNode
node1 = scene.addAnimatedMeshSceneNode(mesh1)
if node1 <> nil then
dim position as core_vector3df = new core_vector3df(0,0,0)
node1.setPosition(position)
dim Texture as video_ITexture
Texture = driver.getTexture("test/yellow.bmp")
node1.setMaterialTexture(0,Texture)
node1.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING,true)
end if
dim mesh2 as scene_IAnimatedMesh
mesh2 = scene.getMesh("test/p2.3ds")
dim node2 as scene_IAnimatedMeshSceneNode
node2 = scene.addAnimatedMeshSceneNode(mesh2)
if node2 <> nil then
dim position2 as core_vector3df = new core_vector3df(0,0,0)
node2.setPosition(position2)
dim Texture2 as video_ITexture
Texture2 = driver.getTexture("test/red.bmp")
node2.setMaterialTexture(0,Texture2)
node2.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING,true)
end if
while device.run()
'rotate sphere and children 45 degrees
dim j as integer
if IsKeyDown(EKEY_CODE.KEY_KEY_X) = true then
KeyIsDown(EKEY_CODE.KEY_KEY_X) = false
node2.setParent(nodes)
dim positions as core_vector3df = new core_vector3df(xs,ys,zs)
dim color2 as video_SColor = new video_SColor(2,2,2,2)
for j = 1 to 45
xs = xs +1
positions = new core_vector3df(xs,ys,zs)
nodes.setRotation( positions )
nodes.updateAbsolutePosition()
if xs =360 then x=0
bool = driver.beginScene(true,true,color2)
scene.drawAll()// draw the 3d scene
bool = driver.endScene()
next
end
' rotate sphere only 45 degrees
if IsKeyDown(EKEY_CODE.KEY_KEY_Y) = true then
KeyIsDown(EKEY_CODE.KEY_KEY_Y) = false
for j = 1 to 45
ys = ys +1
dim positions as core_vector3df = new core_vector3df(xs,ys,zs)
positions = new core_vector3df(xs,ys,zs)
nodes.setRotation( positions )
nodes.updateAbsolutePosition()
if xs =360 then x=0
dim color2 as video_SColor = new video_SColor(2,2,2,2)
bool = driver.beginScene(true,true,color2)
scene.drawAll()// draw the 3d scene
'gui.drawAll()// draw the gui environment (the logo)
bool = driver.endScene()
next
end
' rotate sphere only 45 degrees
if IsKeyDown(EKEY_CODE.KEY_KEY_Z) = true then
KeyIsDown(EKEY_CODE.KEY_KEY_Z) = false
for j = 1 to 45
zs = zs +1
dim positions as core_vector3df = new core_vector3df(xs,ys,zs)
positions = new core_vector3df(xs,ys,zs)
nodes.setRotation( positions )
nodes.updateAbsolutePosition()
if xs =360 then x=0
dim color2 as video_SColor = new video_SColor(2,2,2,2)
bool = driver.beginScene(true,true,color2)
scene.drawAll()// draw the 3d scene
'gui.drawAll()// draw the gui environment (the logo)
bool = driver.endScene()
next
end
' rotate node2 45 degrees around sphere
if IsKeyDown(EKEY_CODE.KEY_KEY_K) = true then
KeyIsDown(EKEY_CODE.KEY_KEY_K) = false
for i =1 to 45
y2=0
x2=0
dim position2 as core_vector3df = new core_vector3df(x2,y2,z2)
z2=z2 +1
position2 = new core_vector3df(x2,y2,z2)
node2.setRotation( position2 )
node2.updateAbsolutePosition()
if x2 =360 then x2=0
if y2 =360 then y2=0
if z2 = 360 then z2=0
dim color2 as video_SColor = new video_SColor(2,2,2,2)
bool = driver.beginScene(true,true,color2)
scene.drawAll()// draw the 3d scene
'gui.drawAll()// draw the gui environment (the logo)
bool = driver.endScene()
dim nam,str as string
nam = driver.getName()
str = "Speegle's Sphere " + Str(x) + " " + str(y) + " " + str(z) +" "+ Str(x2) + " " + str(y2) + " " + str(z2)
device.setWindowCaption(str)
next
dim position2 as core_vector3df = new core_vector3df(x2,y2,z2)
node2.updateAbsolutePosition()
end
dim color2 as video_SColor = new video_SColor(2,2,2,2)
bool = driver.beginScene(true,true,color2)
scene.drawAll()// draw the 3d scene
'gui.drawAll()// draw the gui environment (the logo)
bool = driver.endScene()
dim nam,str as string
nam = driver.getName()
str = "Speegle's Sphere " + Str(x) + " " + str(y) + " " + str(z) +" "+ Str(x2) + " " + str(y2) + " " + str(z2)
device.setWindowCaption(str)
Wend
//return visible of cursor
cursor.setVisible(true)
'In the end, delete the Irrlicht device.
bool = device.drop()
John
Only after disaster can we be resurrected.
-
- Posts: 22
- Joined: Tue Nov 09, 2010 7:03 pm
- Location: ohiio
I Also removed th setParent from the loop to a different key
Code: Select all
if IsKeyDown(EKEY_CODE.KEY_KEY_P) = true then
KeyIsDown(EKEY_CODE.KEY_KEY_P) = false
node2.setParent(nodes)
end
45 degrees the program crashes.
Only after disaster can we be resurrected.
-
- Posts: 22
- Joined: Tue Nov 09, 2010 7:03 pm
- Location: ohiio
I got it to set parent when creating the node
Code: Select all
node2 = scene.addAnimatedMeshSceneNode(mesh2,nodes.get_parent)
now to figure out how to removeChild and set parent on the fly
Only after disaster can we be resurrected.
-
- Posts: 22
- Joined: Tue Nov 09, 2010 7:03 pm
- Location: ohiio
I guess I needed 3.5 days
this code adds and removes child for my IDE
(realstudio with franklin3d"Irrlicht plugin")
now I need to figure out how to make the nodes remain in the same position when switching parents, currently they jump around to their default positions.
(realstudio with franklin3d"Irrlicht plugin")
Code: Select all
if IsKeyDown(EKEY_CODE.KEY_KEY_P) = true then
KeyIsDown(EKEY_CODE.KEY_KEY_P) = false
dim newParent as scene_ISceneNode
newParent = scene.getRootSceneNode()
node1.setParent(newParent)
node1.setrotation(positions)
end
if IsKeyDown(EKEY_CODE.KEY_KEY_O) = true then
KeyIsDown(EKEY_CODE.KEY_KEY_O) = False
dim newParent as scene_ISceneNode
newParent = nodes.get_parent
node1.setParent(newParent)
node1.setrotation(positions)
end
Only after disaster can we be resurrected.
Re: I guess I needed 3.5 days
Here is my thoughs:speedy15453 wrote:now I need to figure out how to make the nodes remain in the same position when switching parents, currently they jump around to their default positions.
And the implementation that should do the trick:
Code: Select all
// childNode must not be 0
// childNode may have no parent
// newParentNode may be 0
void ChangeParentWithKeepingAbsolutePosition(SceneNode* childNode, SceneNode* newParentNode)
{
vector3df childNodePos = childNode->getPosition();
SceneNode* oldParentNode = childNode->getParent();
vector3df oldParentAbsolutePos = oldParentNode == 0 ? vector3df(0, 0, 0) : oldParentNode->getAbsolutePosition();
vector3df newParentAbsolutePos = newParentNode == 0 ? vector3df(0, 0, 0) : newParentNode->getAbsolutePosition();
childNode->setParent(newParentNode);
childNode->setPosition(childNodePos + oldParentAbsolutePos - newParentAbsolutePos);
}
-
- Posts: 22
- Joined: Tue Nov 09, 2010 7:03 pm
- Location: ohiio
I have all the rotations working.
I used 4 spheres as parents
parent sphere - child sphere(45 degree offset) - piece node
parent sphere2 - child sphere2(45 degree offset)
to maintain positions I use the first parent spheres to rotate vertically, horizontally, and the first child sphere to rotate diagonally.
If there are pieces that should not rotate I make the second set of spheres parent and unrotate the pieces then reparent with the first set of spheres.
cpu usage is almost 100% - not good, But I am going to finish this before I explore other options.
I can not find the code to return the x,y,z values of absolutePositon.
I know I have seen it in the forum i was wondering if anyone could help.
here is some of my code....
absPos is core_vector3df
I need the values to determing which node should move and which should remain stationary.
Thanks!
parent sphere - child sphere(45 degree offset) - piece node
parent sphere2 - child sphere2(45 degree offset)
to maintain positions I use the first parent spheres to rotate vertically, horizontally, and the first child sphere to rotate diagonally.
If there are pieces that should not rotate I make the second set of spheres parent and unrotate the pieces then reparent with the first set of spheres.
cpu usage is almost 100% - not good, But I am going to finish this before I explore other options.
I can not find the code to return the x,y,z values of absolutePositon.
I know I have seen it in the forum i was wondering if anyone could help.
here is some of my code....
Code: Select all
node1.updateAbsolutePosition ()
absPos= node1.getAbsolutePosition ()
'x = abspos.get x()
I need the values to determing which node should move and which should remain stationary.
Thanks!
Only after disaster can we be resurrected.
-
- Posts: 22
- Joined: Tue Nov 09, 2010 7:03 pm
- Location: ohiio
nodes loaded as an array
Code: Select all
dim node_array(255) as scene_ISceneNode
scene.getSceneNodesFromType(ESCENE_NODE_TYPE.ESNT_ANY,node_array())
dim count as integer = 0
while (node_array(count+1)<>nil)
count = count+1
Wend
Only after disaster can we be resurrected.