Tv3D PhysX - problem getVertex

0

Witam, mam problem z getvertex, uzywam Tv3D + PhysX. Kod:

        public Actor CreateMeshActor(TVMesh mesh, TV_3DVECTOR pos)
        {
            int vert_count, index_count;
            TV_3DVECTOR[] vertices;
            int[] indices;

            vert_count = mesh.GetVertexCount();
            index_count = mesh.GetTriangleCount();
            vertices = new TV_3DVECTOR[(int)vert_count / 3];
            indices = new int[index_count * 3];

            float[] f = new float[10]; int iColor;
            for (int i = 0; i < vert_count; i++)
            {
                <b>mesh.GetVertex(i, f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], f[8], f[9], iColor);</b>
                if (i % 3 == 0) vertices[(int)i / 3].x = f[0];
                if (i % 3 == 1) vertices[(int)i / 3].y = f[1];
                if (i % 3 == 2) vertices[(int)i / 3].z = f[2];
            }

            int[] t = new int[4];
            for (int i = 0; i < index_count; i++)
            {
                <b>mesh.GetTriangleInfo(i, t[0], t[1], t[2], t[3]);</b>
                indices[i * 3 / 3] = t[0];
                indices[i * 3 + 1] = t[1];
                indices[i * 3 + 2] = t[2]; 
            }

            .
            .
            .

Error 1 The best overloaded method match for 'MTV3D65.TVMesh.GetVertex(int, ref float, ref float, ref float, ref float, ref float, ref float, ref float, ref float, ref float, ref float, ref int)' has some invalid arguments C:\Documents and Settings\Bartek\Moje dokumenty\Visual Studio 2008\Projects\Slr3\Slr3\Vehicle.cs

Error 13 The best overloaded method match for 'MTV3D65.TVMesh.GetTriangleInfo(int, ref int, ref int, ref int, ref int)' has some invalid arguments C:\Documents and Settings\Bartek\Moje dokumenty\Visual Studio 2008\Projects\Slr3\Slr3\Vehicle.cs

Probowałem wszystkiego... ale pierwszy raz spotkałem się z takim dziwnym problemem. Argumenty są w porządku, tyle ile powinno byc. Gdyby ktoś mógł mi pomóc byłbym wdzięczny.

Pozdrawiam Marcin

0

W wywołaniu metody musisz dodać modyfikator ref przed argumentem tam gdzie to jest wymagane.
np. mesh.GetVertex(i, ref f[0], ref f[1], ref f[2].....

0
Marcinlll napisał(a)

Witam, mam problem z getvertex, uzywam Tv3D + PhysX. Kod:

public Actor CreateMeshActor(TVMesh mesh, TV_3DVECTOR pos)
{
int vert_count, index_count;
TV_3DVECTOR[] vertices;
int[] indices;

        vert_count = mesh.GetVertexCount();
        index_count = mesh.GetTriangleCount();
        vertices = new TV_3DVECTOR[(int)vert_count / 3];
        indices = new int[index_count * 3];

        float[] f = new float[10]; int iColor;
        for (int i = 0; i < vert_count; i++)
        {
            <b>mesh.GetVertex(i, f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], f[8], f[9], iColor);</b>
            if (i % 3 == 0) vertices[(int)i / 3].x = f[0];
            if (i % 3 == 1) vertices[(int)i / 3].y = f[1];
            if (i % 3 == 2) vertices[(int)i / 3].z = f[2];
        }

        int[] t = new int[4];
        for (int i = 0; i < index_count; i++)
        {
            <b>mesh.GetTriangleInfo(i, t[0], t[1], t[2], t[3]);</b>
            indices[i * 3 / 3] = t[0];
            indices[i * 3 + 1] = t[1];
            indices[i * 3 + 2] = t[2]; 
        }

        .
        .
        .
> 
> 
> > Error	1	The best overloaded method match for 'MTV3D65.TVMesh.GetVertex(int, ref float, ref float, ref float, ref float, ref float, ref float, ref float, ref float, ref float, ref float, ref int)' has some invalid arguments	C:\Documents and Settings\Bartek\Moje dokumenty\Visual Studio 2008\Projects\Slr3\Slr3\Vehicle.cs
> 
> 
> > Error	13	The best overloaded method match for 'MTV3D65.TVMesh.GetTriangleInfo(int, ref int, ref int, ref int, ref int)' has some invalid arguments	C:\Documents and Settings\Bartek\Moje dokumenty\Visual Studio 2008\Projects\Slr3\Slr3\Vehicle.cs
> 
> 
> Probowałem wszystkiego... ale pierwszy raz spotkałem się z takim dziwnym problemem. Argumenty są w porządku, tyle ile powinno byc. Gdyby ktoś mógł mi pomóc byłbym wdzięczny.
> 
> Pozdrawiam Marcin


Wielkie dzięki, pierwszy raz się z tym spotkałem :) Bede pamiętał na przyszłość

Pozdrawiam, Marcin
0

Witam ponownie, mam też inny problem, a mianowicie nic co z PhysX nie wyświetla mi się na ekranie...

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

using MTV3D65;
using MTV3D65.PhysX;

namespace StreetLeg
{
    class frmMain : System.Windows.Forms.Form
    {
        // Declare the TV Objects.
        public TVEngine Engine;
		public TVScene Scene;
		public TVInputEngine Input;
		public TVGlobals Globals;
		public bool bDoLoop;

        public Vehicle vehicle;
        public SkySphere sky;
        public Camera camera;

		private System.ComponentModel.Container components = null;

        //PhysX
        public Physics pPhys;
        public Scene pScene;

        Actor tActor = null;
       
		public frmMain()
		{
            InitializeComponent();
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		private void InitializeComponent()
		{
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(800, 600);
			this.Name = "Slr3";
            this.Text = "Lambo Racing";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.frmMain_Closing);
			this.Load += new System.EventHandler(this.frmMain_Load);
		}

		[STAThread]
		static void Main() 
		{
			Application.Run(new frmMain());
		}

        public void initPhysX()
        {
            //setPhysics
            pPhys = Physics.Create();
            pPhys.Parameters.SkinWidth = 1.0f;
            pPhys.Parameters.VisualizationScale = 1.0f;
            pPhys.Parameters.VisualizeCollisionSpheres = 1.0f;
            pPhys.Parameters.VisualizeActorAxes = 1.0f;
            pPhys.Parameters.VisualizeJointLimits = 1.0f;
            pPhys.Parameters.VisualizeJointLocalAxes = 1.0f;
            pPhys.Parameters.VisualizeBodyAxes = 1.0f;

            SceneDesc sceneDesc = new SceneDesc();
            sceneDesc.Gravity = new TV_3DVECTOR(0, -9.81f, 0);
            sceneDesc.SimulationType = SimulationTypes.Hardware;
            pScene = pPhys.CreateScene(sceneDesc);

            Material defMaterial = pScene.Materials[0];
            defMaterial.DynamicFriction = 0.2f;
            defMaterial.StaticFriction = 0.2f;
            defMaterial.Restitution = 0.5f;

            pScene.Simulate(1.0f / 6.0f);
            pScene.FlushStream();
            pScene.FetchResults(SimulationStatuses.AllFinished, true);
        }

        private void frmMain_Load(object sender, System.EventArgs e)
        {
            Engine = new TVEngine();
            Scene = new TVScene();
            Globals = new TVGlobals();
            Input = new TVInputEngine();

            // Create the TV Interface first:
            Engine.SetDebugMode(true, true);
            Engine.SetDebugFile(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\debugfile.txt");
            Engine.Init3DWindowed(this.Handle, true);
            Engine.GetViewport().SetAutoResize(true);
            Engine.DisplayFPS(true);
            Engine.SetAngleSystem(MTV3D65.CONST_TV_ANGLE.TV_ANGLE_DEGREE);
            Engine.SetAntialiasing(true, CONST_TV_MULTISAMPLE_TYPE.TV_MULTISAMPLE_4_SAMPLES);
            Engine.GetCamera().SetViewFrustum(45f, 100f, 0f);
            Engine.GetCamera().SetPosition(0f, 100f, 0f);
            Engine.AllowMultithreading(true);
            Engine.SetFPUPrecision(true);
            Engine.SetEffectCompileMode(true);

            Scene.SetTextureFilter(CONST_TV_TEXTUREFILTER.TV_FILTER_ANISOTROPIC);
            Scene.SetAutoTransColor((int)CONST_TV_COLORKEY.TV_COLORKEY_USE_ALPHA_CHANNEL);
            Scene.SetMaxAnisotropy(16);
            Scene.SetMipmappingPrecision(0.1f);
            Scene.SetShadowParameters(128, true);

            Input = new TVInputEngine();
            Input.Initialize(true, true);

            initPhysX();
            createShapeGround();

            bDoLoop = true;
            this.Show();
            this.Focus();

            // LOADING
            vehicle = new Vehicle();
            vehicle.load(this, "Murcie");

            sky = new SkySphere();
            sky.load(this);

            camera = new Camera();
            camera.load(this);

            while (bDoLoop)
            {
                if (this.Focused)
                {
                    Engine.Clear(false);
                    Scene.RenderAll(true);
                    sky.env.SkySphere_Render();

                    camera.update();
                    //camera.changeCamera(1);

                    Scene.FinalizeShadows();
                    Engine.RenderToScreen();

                    if (Input.IsKeyPressed(MTV3D65.CONST_TV_KEY.TV_KEY_ESCAPE))
                    {
                        bDoLoop = false;
                    };
                }
                else
                {
                    System.Threading.Thread.Sleep(50);
                }

                Application.DoEvents();
            }

            Engine.ReleaseAll();
            this.Close();
        }

		private void frmMain_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			bDoLoop = false;
		}

        public Actor createShapeGround()
        {
            ActorDesc actorDesc = new ActorDesc();
            BodyDesc bodyDesc = new BodyDesc();

            BoxShapeDesc boxShapeDesc = new BoxShapeDesc();
            boxShapeDesc.Dimensions = new TV_3DVECTOR(90f, 1f, 90f);
            boxShapeDesc.SetToDefault();

            actorDesc.Shapes.Add(boxShapeDesc);
            actorDesc.Body = bodyDesc;

            return pScene.CreateActor(actorDesc);
        }
	}
}

Może ktoś uzywal Phys'a ...
Ja pierwszy raz i nic się nie dzieje. Od dłuższego czasu męczę aby mi wyświetliło ziemię jako plane lub płaski box ale nic z tego... Jeśli ktoś może to niech mnie naprowadzi :)

Pozdrawiam, Marcin

1 użytkowników online, w tym zalogowanych: 0, gości: 1