SetParent. Don't work

Irrlicht.Net is no longer developed or supported, Irrlicht.Net Cross Platform is a much more complete wrapper. Please ask your C# related questions on their forums first.
Locked
Jenc
Posts: 1
Joined: Wed Dec 20, 2006 4:06 pm

SetParent. Don't work

Post by Jenc »

Hey
I just start with irrlichtin c# my problem ist to set a parent. I just post all my code. I user the example models usw.
I habe tried so much :(

Perhaps anybody can help me?

Wer deutsch kann kann auch auf deutsch antworten. :)

Code: Select all

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Irrlicht;
using Irrlicht.Video;
using Irrlicht.Core;
using Irrlicht.Scene;
using Irrlicht.GUI;

namespace _02.Quake3Map
{
    class Program
    {
        /// <summary>
        /// Main entry point for the program.
        /// </summary>
        /// <param name="args">Arguments to pass the software.</param>
        [STAThread]
        static void Main(string[] args)
        {
            
            DriverType driverType;
            driverType = DriverType.DIRECT3D9;
            IrrlichtDevice device = new IrrlichtDevice(driverType, new Dimension2D(1024, 768), 32, true, true, true);

            device.FileSystem.AddZipFileArchive("map-20kdm2.pk3");

            IVideoDriver driver = device.VideoDriver;
            ISceneManager smgr = device.SceneManager;
            IAnimatedMesh map_mesh = device.SceneManager.GetMesh("20kdm2.bsp");
            ISceneNode map_node = null;
            // Engel laden
            Material material = new Material();
            material.Texture1 = driver.GetTexture("faerie2.bmp");
            material.Lighting = true;

            IAnimatedMeshSceneNode engel_node = null;
            IAnimatedMesh faerie = smgr.GetMesh("faerie.md2");
            if (faerie != null)
            {
                engel_node = smgr.AddAnimatedMeshSceneNode(faerie, null, 0);
                engel_node.Position = new Vector3D(-170, 0, 0);
                engel_node.SetMD2Animation(MD2AnimationType.JUMP);
                engel_node.SetMaterial(0, material);
            }
            material.Texture1 = null;
            material.Lighting = false;

            //Add a light
            smgr.AddLightSceneNode(null, new Vector3D(-60, 100, 400),
               new Colorf(1.0f, 1.0f, 1.0f, 1.0f), 600, 0); 
            
            // Engel laden ende

            if (map_mesh != null)
                map_node = device.SceneManager.AddOctTreeSceneNode(map_mesh, null, 0);

            if (map_node != null)
                map_node.Position = (new Vector3D(-1300, -144, -1249));

            ITriangleSelector selector = null;
            if (map_node != null)
            {
                map_node.Position = new Vector3D(-1370, -130, -1400);
                selector = smgr.CreateOctTreeTriangleSelector(map_mesh.GetMesh(0), map_node, 128);
            }
            ICameraSceneNode camera = smgr.AddCameraSceneNodeFPS(null, 100, 300, 0);
            ISceneNodeAnimator anim = smgr.CreateCollisionResponseAnimator(
               selector, camera, new Vector3D(30, 50, 30),
               new Vector3D(0, -3, 0), new Vector3D(0, 50, 0), 0);
            camera.AddAnimator(anim);

            device.CursorControl.Visible = false;
            
            int lastFPS = -1;

            while (device.Run())
            {
                if (device.WindowActive)
                {                                
                    IGUIEnvironment env = device.GUIEnvironment;
                    env.AddStaticText("Habe dich nicht", new Rect(150, 20, 350, 40), true, false, null, 0); 
                    int gently caress = 0;
                    if(camera.Position.GetDistanceFrom(engel_node.Position) < 100 && gently caress == 0)
                    {
                       engel_node.SetParent(camera);
                       engel_node.Position.Set(new Vector3D(72, -90, 90));
                        //engel_node.Position.Set(new Vector3D(0,0,40));
                        env.AddStaticText("Habe dich", new Rect(300, 20, 350, 40), true, false, null, 0);
                        gently caress = 1;
                    } 

                    device.VideoDriver.BeginScene(true, true, new Color(0, 200, 200, 200));
                    device.SceneManager.DrawAll();
                    device.GUIEnvironment.DrawAll(); 
                    device.VideoDriver.EndScene();
                    

                    int fps = device.VideoDriver.FPS;
                    if (lastFPS != fps)
                    {
                        device.WindowCaption = "Jens Jensen GAME [" +
                                               device.VideoDriver.Name + "] FPS:" + fps.ToString();
                        lastFPS = fps;
                    }
                }
            }

            GC.Collect();

        }
    }
}
DarkKiller
Posts: 1
Joined: Mon Dec 25, 2006 5:03 pm

Re: SetParent. Don't work

Post by DarkKiller »

Jenc wrote:Wer deutsch kann kann auch auf deutsch antworten. :)
Ich denke, dass du diesen Abschnitt meinst

Code: Select all

                    if(camera.Position.GetDistanceFrom(engel_node.Position) < 100 && ***** == 0) 
                    { 
                       engel_node.SetParent(camera); 
                       engel_node.Position.Set(new Vector3D(72, -90, 90)); 
                        //engel_node.Position.Set(new Vector3D(0,0,40)); 
                        env.AddStaticText("Habe dich", new Rect(300, 20, 350, 40), true, false, null, 0); 
                        ***** = 1; 
                    }
schon mal probiert, ob die Bedingung irgendwann zutrifft? Du könntest zum testen mal was in der Konsole ausgeben, wenn die Bedingung zutrifft.

btw: Dein Englisch ist scheisse!
Locked