Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: AddVertex/Mesh problem: can't see it (C#)  (Read 135 times)
squirlhntr
Community Member
*
Posts: 1


« on: July 07, 2008, 04:19:24 PM »

Hi all. Completely new to this engine and am I bit stuck on some code. I know the problem is simple but I was hoping someone could lend me a hand. Basically I can init the engine but when I try to create a mesh (via AddVertex) it never displays.

Any suggestions?


Code:
... usual C# init code (forms, setup, etc) ...

// vis_engine is an object of type TVEngine

private void Main_Loop() {
   vis_engine.SetViewport(vis_engine.tv_viewport);

   while (ContinueRender == true)
   {
       vis_engine.Clear(false);
       vis_engine.tv_scene.RenderAllMeshes(true);
       vis_engine.RenderToScreen();
       System.Windows.Forms.Application.DoEvents();
   }
}



    public class VisualizationEngine : TVEngineClass {
        //TVEngine tv_engine;
        public TVViewport tv_viewport;
        public TVScene tv_scene;
        public TVInputEngine tv_input;
        public TVGlobals tv_globals;
        public TVMaterialFactory tv_material;
        public TVCamera tv_camera;

        TVMesh testMesh;
        public TV_3DVECTOR cameraPos;



        public VisualizationEngine(int handle)
        {
            InitEngine(handle);
        }

        private void InitEngine(int handle) {
            this.Init3DWindowed(handle, true);
            this.SetSearchDirectory(Application.StartupPath);
            this.SetDebugFile(Application.StartupPath + "\\Debug.txt");
            this.SetAntialiasing(true, CONST_TV_MULTISAMPLE_TYPE.TV_MULTISAMPLE_4_SAMPLES);
            this.DisplayFPS(true, 1);

            tv_globals = new TVGlobals();
            tv_scene = new TVScene();
            tv_input = new TVInputEngine();
            tv_input.Initialize(true, true);
           
            tv_viewport = new TVViewport();
            tv_viewport = this.CreateViewport(handle, "tv_viewport");
            tv_viewport.SetAutoResize(true);
            tv_viewport.SetBackgroundColor(tv_globals.RGBA(1f, 1f, 1f, 0f));

            ShowSplashScreen();
        }

        // draw a cylinder
        public void ShowSplashScreen()
        {
            testMesh = new TVMesh();
            testMesh = tv_scene.CreateMeshBuilder("test");
            testMesh.SetPrimitiveType(CONST_TV_PRIMITIVETYPE.TV_TRIANGLESTRIP);
            testMesh.SetColor(tv_globals.RGBA(0.8f, 0.5f, 0.5f, 1f), true);
            int sides = 30;
            float inc = 2 * (float)System.Math.PI / sides;
            float x = 0;
            float y = 0;
            float z = 0;
            float theta = 0;
            int radius = 40;
            int height = 40;
            testMesh.SetPosition(0.0f, 0.0f, 0.0f);
            tv_scene.SetCamera(0.0f, 0.0f, -15.0f, 0.0f, 0.0f, 10.0f);

            for (int i=0; i<sides; i++) {
                x = radius * (float)System.Math.Cos(theta);
                y = height;
                z = radius * (float)System.Math.Sin(theta);
               
                testMesh.AddVertex(x, 0, z, 0, 0, 1, 0, 0, 0, 0, 200);
                testMesh.AddVertex(x, y, z, 0, 0, 1, 0, 0, 0, 0, 200);
               
                theta += inc;
            }

        }

    }


[/size]
Logged
jviper
Community Member
*
Posts: 1282

Discipline in training


« Reply #1 on: July 20, 2008, 10:53:25 AM »

This is a tutorial which is in the wiki:
http://wiki.truevision3d.com/tutorialsarticlesandexamples/building_a_cylinder

Hopefully this helps.
Welcome Aboard.
Logged

JAbstract.....Don't just imagine, make it happen!
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks