www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Melssj5 on May 18, 2006, 08:49:43 am

Title: Set a Color for an object3D
Post by: Melssj5 on May 18, 2006, 08:49:43 am
Object3D.setColor ();

Hi, how can I set a color for a Object3D?? I know I can add it a texture with the setTexture () method. But what i I dont want to load a image but just use a Color!!!!!!

It should be a method called setColor or something on the Object3D!!

ANyway. What can I do to get my primitives painted on a rgb color??
Title: Set a Color for an object3D
Post by: EgonOlsen on May 18, 2006, 05:15:31 pm
Assign a single colored texture (8x8 or 16x16) to it. jPCT is texture mapping only by design. There is no way to disable it. The 3ds loader does exactly the same thing for textureless materials (as the docs state).
Title: Set a Color for an object3D
Post by: Melssj5 on May 19, 2006, 03:44:10 am
So, Its imposible to do it without having an image to use as a texture? I needed to asign a rgb color on it. But I guess I will only make 16 colors as jpg pics to add them as texture.
Title: Set a Color for an object3D
Post by: EgonOlsen on May 19, 2006, 08:49:27 am
Quote from: "Melssj5"
So, Its imposible to do it without having an image to use as a texture?
Exactly!
Title: Color with no texture
Post by: culli on May 20, 2006, 01:03:04 am
Have you tried Object3D.setAdditionalColor?  It works well for me:

Code: [Select]

public Piece3D(Color color) {
        super(Primitives.getCylinder(10, 1, 0.5f));
        this.setAdditionalColor(color);
        build();
}

...
Piece3D singlePiece = new Piece3D(new Color(255, 255, 0));
...


I also use this for highlighting the pieces when the mouse pointer is over them.

If you want, I can send a screenshot to make sure we're talking about the same thing.
Title: Set a Color for an object3D
Post by: Melssj5 on May 20, 2006, 01:51:44 am
Yeah, that would be great. Please post the sshot.
Title: Screen shot
Post by: culli on May 20, 2006, 05:56:04 am
Here's a picture of my simple application:

(http://members.networld.com/jcullison/screenshot.png)

As you can see, I'm making chinese checkers.  

When the mouse is over the pieces, they turn white.  If you click and drag the pieces, they'll move around the board.  They have no texture but the default Object3D texture assigned, plus the addtional color.  

Anyway, this seemed a good thing to start with because it has only a few rules, it has hex tiles which are good for war simulation games later, and I can do a bit of AI with it.  The model for the board has very few triangles and I'm still learning how to map the texture correctly, but it's not so important to me right now.  I'm more interested in the game play, what little there is.  I had a lot of the game logic done a while ago, now I'm finding problems with my hex tile representation.  I don't spend very much time on this, so it's going slowly.
Title: Set a Color for an object3D
Post by: Melssj5 on May 20, 2006, 06:05:50 am
Yeah, it worked but the color is too bright. I guess I will use this tecnique as secundary color and I will put some other textures by myself. Thanks a lot, was a useful advice. Bye.