About Store Forum Documentation Contact
Donations:
206$/mo



Post Reply 
New Materials using "Image" Type Maps?
Author Message
XeonXT Offline
Member

Post: #1
New Materials using "Image" Type Maps?
Hello,

How can I create a new material on-the-fly using diffuse maps and such from Image types that have already been created? In other words, can I "directly" assign a diffuse map to a material object rather than load one from file? I see that the maps within the material object are pointers, and I cannot figure out how to simply assign an image object to the map.

Thanks in advance!
01-17-2010 06:21 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: New Materials using "Image" Type Maps?
It is suggested to use Material::methods and import images from non GFX images
however you can use just pointer assigning:

Image image;
Material material;

...
material.diffuse=ℑ
...
01-17-2010 05:35 PM
Find all posts by this user Quote this message in a reply
XeonXT Offline
Member

Post: #3
RE: New Materials using "Image" Type Maps?
(01-17-2010 05:35 PM)Esenthel Wrote:  It is suggested to use Material::methods and import images from non GFX images
however you can use just pointer assigning:

Image image;
Material material;

...
material.diffuse=ℑ
...
Thanks, sadly, I am still unable to figure this out..

Exporting and then loading doesn't seem to work (even when I save directly as GFX):
Code:
Image LandTex;
LandTex.create2D(128,128,IMAGE_A8R8G8B8,1);
LandTex.lock();
REPD(y,LandTex.y()){
    REPD(x,LandTex.x()){
        LandTex.color(x,y,Color(255,Random(255),Random(255),Random(255)));}}
LandTex.unlock();
LandTex.ExportJPG("LandTex.jpg");

Material Land;
Land.reset();
Land.importDetail("LandTex.jpg","LandTex.jpg","LandTex.jpg","");
Land.validate();

mesh.setMaterial(Land);

Pointing to the image creates a completely black landscape:
Code:
Image LandTex;
LandTex.create2D(128,128,IMAGE_A8R8G8B8,1);
LandTex.lock();
REPD(y,LandTex.y()){
    REPD(x,LandTex.x()){
        LandTex.color(x,y,Color(255,Random(255),Random(255),Random(255)));}}
LandTex.unlock();

Material Land;
Land.reset();
Land.diffuse = &LandTex;
Land.validate();

mesh.setMaterial(Land);

What am I missing?

Thanks for the help smile
Bah! How stupid, I forgot to make the Image global. That fixed the problem, using pointers now works flawlessly. That's all I needed.

Thanks for your help, and congratulations on a simply outstanding engine.

I look forward to purchasing a license in the near future grin
(This post was last modified: 01-17-2010 10:13 PM by XeonXT.)
01-17-2010 10:03 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: New Materials using "Image" Type Maps?
Are you declaring your material and image 'Land' 'LandTex' locally inside a function?

If yes, then they get deleted when the function returns, please define those variables globally.
01-17-2010 10:17 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #5
RE: New Materials using "Image" Type Maps?
how can i access materials settings by code?
if i have already saved material in an object and the object has been loaded trough WE.
things like glow or rgb lighting.?
01-17-2010 10:52 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: New Materials using "Image" Type Maps?
if(Material *material=obj.material())material->
01-17-2010 11:02 PM
Find all posts by this user Quote this message in a reply
XeonXT Offline
Member

Post: #7
RE: New Materials using "Image" Type Maps?
(01-17-2010 10:17 PM)Esenthel Wrote:  Are you declaring your material and image 'Land' 'LandTex' locally inside a function?

If yes, then they get deleted when the function returns, please define those variables globally.

Yes, that is what was happening.

From the edit in my last post:
Quote:Bah! How stupid, I forgot to make the Image global. That fixed the problem, using pointers now works flawlessly. That's all I needed.

Thanks for your help, and congratulations on a simply outstanding engine.

I look forward to purchasing a license in the near future
01-18-2010 02:55 AM
Find all posts by this user Quote this message in a reply
Post Reply