Author Topic: Issue creating a primitive  (Read 7897 times)

0 Members and 1 Guest are viewing this topic.

gamegeek

  • Associate
  • Posts: 1
Issue creating a primitive
« on: August 14, 2008, 09:08:09 PM »
When I create a box primitive via XML like this:

Code: [Select]
<primitive name="testBox01" shape_type="BOX" />
I get a nice white boxloaded in the center of the scene that I can manipulate from LUA without issue. For example, I know I can put a texture on it by assigning it a material then applying an existing texture to that material like so:

Code: [Select]
HYP_Object.SetMaterial( "testBox01", "myMaterial");
HYP_Object.AttachTexture( "testBox01", "myTexture", "myMaterial", 0);

That all seems to work fine. The problem arises when I attempt to create the same primitive totally from LUA. The following code successfully creates a box primitive in the center of the screen, however this box has a rainbow hue and simply ignores requests to change the texture using the technique in the code sample above.

Code: [Select]
local id = HYP_Primitive.CreateBox("testBox);
I used what data I could gather from the various HYP_Object.Get... functions to compare the data between the two boxes. It seems like two methods (XML vs. Lua) create a box with different default values. Of the data i could inspect I found that the default size, texturing state, and blending factors are different. I attempted to correct for this in the Lua box by using HYP_Object.Set functions to correct the texturing state and blending factors but this was either ignored by the Lua box or not really the problem.

What am I missing here? Is there some way for me to create a box (or other primitive) in Lua so that I can subsequently alter the texture? I assume it's a bug that the defaults vary between the two methods but perhaps it's not. Any information I can get on this would be very much appreciated.

JeGX

  • Global Moderator
  • Capo Crimine
  • *****
  • Posts: 2385
    • oZone3D.Net
Re: Issue creating a primitive
« Reply #1 on: August 19, 2008, 04:03:08 PM »
oops, didn't see you post. Will look at your problem now.

JeGX

  • Global Moderator
  • Capo Crimine
  • *****
  • Posts: 2385
    • oZone3D.Net
Re: Issue creating a primitive
« Reply #2 on: August 19, 2008, 04:47:08 PM »
The rainbow hue was due to the box init in Demoniak3D. Now it's fixed and the box is white.

Here is a code snippet that dynamically creates a box, material and texture:
Code: [Select]
box = HYP_Primitive.CreateBox();
material = HYP_Material.Create();
local RGB_BYTE_PIXEL_FORMAT = 2;
local compress = 0;
texture = HYP_Texture.LoadTex2D("texture.jpg", RGB_BYTE_PIXEL_FORMAT, compress);
HYP_Material.AttachTexture(material, texture, 0);
HYP_Object.SetMaterial(box, material);
HYP_Object.SetTexturingState(box, 1);
This code is valid for Demoniak3D 1.30.0 and up because there is no longer need to pass a parameter to HYP_Primitive.CreateBox() function (as well as to HYP_Material.Create()). For Demoniak3D < 1.30.0, just add a name as param...
Demoniak3D 1.30.0 will be available in the next few days.


irving

  • Associate
  • Posts: 3
Re: Issue creating a primitive
« Reply #3 on: October 05, 2008, 08:37:01 PM »
Im new with this forum thing. So if ever i have problems regarding technical terms, then i could post it here, and in return wait for someone to provide me a solution?

shadow

  • Capo Regime
  • ***
  • Posts: 353
Re: Issue creating a primitive
« Reply #4 on: October 05, 2008, 08:48:55 PM »
Quote
Im new with this forum thing. So if ever i have problems regarding technical terms, then i could post it here, and in return wait for someone to provide me a solution?
Exactly, that's the idea.
You can search in the forum (or use the search tool at the top) to check if someone already had a similar issue, and if you still can't find any answer, just open a new thread and explain your problem. Other users will then try to help you !
3D, photos panoramiques : http://www.shadows.fr