Login  Register

Re: Adding color onto a model

Posted by Xerxes Rånby on Jun 25, 2013; 7:23pm
URL: https://forum.jogamp.org/Adding-color-onto-a-model-tp4029468p4029470.html

Sesquipedaliac wrote
Hi everyone,

I'm rather new to Java and JOGL, and had a question about drawing a color onto a model.

For example, I load a 3D model of a rod and then want to have the code draw and update a color gradient along the rod (say, for temperature).
You may think of it in terms that the temperature data is part of your model. Its your codes job to prepare the model data and then feed JOGL and hence your OpenGL driver with this data.

There is several ways to solve this, i would recommend you to split your model into two models, one static model containing the thermometer hull and another model containing only the rod. When you prepare data for the rod you may choose to do the gradient using the fragment shader of your GPU in order to create mathematically smooth gradients; If you prefer divide the rod into stacked slices and then paint each slice according to your temperature data.

You then need to choose from writing your own 3D engine that can dynamically update the model or use an existing 3D engine. The purpose of JOGL is basically to allow the 3D engine to open an window and obtain an OpenGL surface and handle user input. Its the 3D engines task to update the model.

Sesquipedaliac wrote
Or another scenario: I've got a model of a satellite, and as it spins and moves around a globe, I want the part of the satellite visible from a point on the globe to be colored.
Try solve this by using an 3d engine with an API suitable for the task of solving the underlying mathematical calculations needed to update the models. The task of making a part of a globe highlighted can easily be accomplish using the NASA WorldWind SDK. WorldWind is an API especially designed to do visual presentation on top of the globe. WorldWind is used internally by many satellite tracking software to ease generation of these kind of visuals. WorldWind 2.0 use JogAmp JOGL internally for the OpenGL binding.
http://goworldwind.org/demos/
http://worldwind.arc.nasa.gov/java/index.html

Sesquipedaliac wrote
Is it possible to do this?

Thanks for your time!
I recommend you to read a generic book on OpenGL with focus on using the programmable pipeline in order to get familiar with using modern OpenGL. The ideas from any OpenGL book can be applied when using JOGL since its the same API.
http://www.arcsynthesis.org/gltut/ - Jason L. McKesson: Learning Modern 3D Graphics Programming - e-book

Yes it is all possible, and you're welcome.
Xerxes