April 19, 2024, 08:07:41 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Changing the texture on a loaded mesh?

Started by Kale, September 08, 2006, 02:17:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Kale

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();
}

J B Wood (Zumwalt)

What happens if you set clr to 1?

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

Kale

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.

J B Wood (Zumwalt)

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.

Ionic Wind Support Team

Ionic Wind Support Team

Kale

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.

J B Wood (Zumwalt)

Worked fine for me in both modes.
I didn't have any anomoly.
Maybe its the video card?