Hi Everyone, I have got a project in which I need to create 3D meshes and embed them in the windows forms. To achieve this, I am using, 1. c#.net 4.0, Windows forms. 2. Autodesk Maya -- to create 3D meshes 3. Deep expression -- To convert the 3D meshes to .x format 4 .True vision 3D -- API.
5. DirectX
I am getting the error,
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Below is my code,
using System;using System.Drawing;using System.Drawing.Printing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using TV3D65;using TV3DMedia;
//Declaring and initializing the objects for the rendering Engine,
//Input Engine, Light Engine, Texture Factory, Material Factory,
//Scene, and Global classes of TrueVision (TV) library
TVEngine TV ;
TVInputEngine Inp = new TVInputEngine();
TVLightEngine TVLightEngine = new TVLightEngine();
//TVTextureFactoryClass TexFactory = new TVTextureFactoryClass();
TVMaterialFactory MatFactory = new TVMaterialFactory();
TVScene TVScene = new TVScene();
TVGlobals global = new TVGlobals();
TVMesh obj1;
TVMeshClass Room;
TVTextureFactoryClass TvTextureFatory = new TVTextureFactoryClass();
privatevoid Form1_Load(object sender, EventArgs e)
{
//Before trying to play with TrueVision, we have to create the TV8 object.
TV = newTVEngine();
//Now create a windows handle for the pictureBox1 so that all the rendering
//will be done on the picture box
//TV.Init3DWindowedMode(this.pictureBox1.Handle.ToInt32(), true);
//This is the path where our media (texture and meshes) files are placed
TV.SetSearchDirectory(System.Windows.Forms.Application.ExecutablePath);
//This is to set the rotation angle to degrees (the other option is radians)
TV.SetAngleSystem(CONST_TV_ANGLE.TV_ANGLE_DEGREE);
obj1 = newTVMesh();
Room = (TVMeshClass)TVScene.CreateMeshBuilder("BMS");// Getting error here.
TvTextureFatory.LoadTexture("D:\\BMS.x", "BMS", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, false);
Room.AddWall(global.GetTex("BMS"), 350.0f, -350.0f, -350.0f, -350.0f, 350.0f, 5.0f, -50.0f, 5.0f, true);
Room.AddWall2(global.GetTex("BMS"), 350.0f, -350.0f, -350.0f, -350.0f, 350.0f, 5.0f, -50.0f, 5.0f, 10.0f, 10.0f, true);
Room.AddWall3D(global.GetTex("BMS"), 350.0f, -350.0f, -350.0f, -350.0f, 350.0f, 5.0f, true, false, -50.0f, 5.0f, 1.0f);
Room.AddWall3D(global.GetTex("BMS"), -350.0f, -350.0f, -350.0f, 350.0f, 350.0f, 5.0f, true, false, -50.0f, 5.0f, 1.0f);
Room.AddWall3D(global.GetTex("BMS"), -350.0f, 350.0f, 350.0f, 350.0f, 350.0f, 5.0f, true, false, -50.0f, 5.0f, 1.0f);
Room.AddWall3D(global.GetTex("BMS"), 350.0f, 350.0f, 350.0f, -350.0f, 350.0f, 5.0f, true, false, -50.0f, 5.0f, 1.0f);
Room.AddFloor(global.GetTex("BMS"), -350.0f, -350 - 0f, 350.0f, 350.0f, -50.0f, 10.0f, 10.0f, true);
Room.AddFloor(global.GetTex("BMS"), -350.0f, -350 - 0f, 350.0f, 350.0f, 300.0f, 10.0f, 10.0f, true);
}
Please help me to sort out this.