IonicWind Software

Aurora Compiler => 3D Graphics => Topic started by: Kale on September 08, 2006, 02:17:06 PM

Title: Changing the texture on a loaded mesh?
Post by: Kale on September 08, 2006, 02:17:06 PM
Is it possible to load a textured .x mesh and then using code remove that texture and apply another one? I tried 'C3DMesh::LoadTexture' but that didn't seem to do anything. Is this the right approach?


Declare import, Sleep(int Milliseconds);

global sub main()
{
C3DScreen Screen;
C3DCamera Camera;
C3DMesh Mesh, Floor;

C3DObject Scene;
C3DLight Light;
CDirectInput DirectInput;
float Rotation = 0.0f;

Screen.CreateWindowed(0, 0, 800, 600, AWS_CENTERED | AWS_CAPTION | AWS_VISIBLE | AWS_SIZE, 0, "3D Test", NULL, false);
DirectInput.Init(Screen);

Camera.Create(Screen);
Camera.Position(0, 20, 100);
Camera.LookAt(0, 0.25, 0);
Camera.SetFrontPlane(10);
Camera.SetBackPlane(1000);

Mesh.LoadX(Screen, GetStartPath() + "CubeTest.x");
Mesh.LoadTexture(1, GetStartPath() + "Floor.jpg", 0);
Mesh.EnableLighting(false);

Floor.LoadX(Screen, GetStartPath() + "Floor.x");
Floor.EnableLighting(false);

Light.Create(Screen,LIGHT_SPOT, 1);
Light.Position(0, 25, 25);
Light.SetAttenuation(0,1/400.0,0);
Light.SetDirection(0, 0, 0);

Scene.CreateScene(Screen);
Scene.AddChild(Light);
Scene.AddChild(Mesh);
Scene.AddChild(Floor);

while (!DirectInput.KeyDown(DIK_ESCAPE))
{
Screen.Clear(RGBA(32, 23, 30, 255));
Screen.BeginScene(Camera);
Scene.Draw();
Screen.RenderScene();
Rotation += 0.01f;
Mesh.Rotate(0, Rotation, 0);
Floor.Rotate(0, Rotation, 0);
Sleep(1);
}
Scene.Free();
}
Title: Re: Changing the texture on a loaded mesh?
Post by: J B Wood (Zumwalt) on September 08, 2006, 02:33:44 PM
What happens if you set clr to 1?

Mesh.LoadTexture(1, GetStartPath() + "Floor.jpg", 1);
Title: Re: Changing the texture on a loaded mesh?
Post by: Kale on September 08, 2006, 02:57:00 PM
Quote from: zumwalt on September 08, 2006, 02:33:44 PM
What happens if you set clr to 1?

Mesh.LoadTexture(1, GetStartPath() + "Floor.jpg", 1);


Nothing.
Title: Re: Changing the texture on a loaded mesh?
Post by: J B Wood (Zumwalt) on September 08, 2006, 05:06:47 PM
I have not gotten around to messing with this yet.
Maybe the "mesh" requires that it has no default texture and you add it via code?
I hope to see how this turns out because I will need it.
Title: Re: Changing the texture on a loaded mesh?
Post by: Ionic Wind Support Team on September 08, 2006, 09:28:43 PM
Texture numbers start at 0
Title: Re: Changing the texture on a loaded mesh?
Post by: Kale on September 09, 2006, 06:57:08 AM
Quote from: Paul Turley on September 08, 2006, 09:28:43 PM
Texture numbers start at 0

When i change the texture number to '0' it works, but now i have another anomaly. The floor mesh dissapears and then re-appears when the floor and wall sections are rotating. This only happens however when the exe is launched from the IDE. if you run the exe from the folder on its own, the floor and wall are fine. Very strange because it is the same exe. Give it a try.
Title: Re: Changing the texture on a loaded mesh?
Post by: J B Wood (Zumwalt) on September 09, 2006, 10:09:13 AM
Worked fine for me in both modes.
I didn't have any anomoly.
Maybe its the video card?