1 registered members (AndrewAMD),
1,280
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: 3D Image Gallery
[Re: Theil]
#319509
04/15/10 13:33
04/15/10 13:33
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
hey, I thought to myself you should be able to achieve this is less than 100 lines of code, so set myself the challenge
#include <acknex.h>
#include <default.c>
#define PRAGMA_PATH "pics"
#include "debug.c"
ENTITY* ent_pic[8];
var var_offset = 0;
void main(){
wait(1);
level_load(NULL);
STRING* str_temp = str_create("");
VECTOR vec_temp;
vec_temp.z = 0;
int i;
for(i = 0; i < 8; i++){
str_cpy(str_temp, "pic");
str_cat_num(str_temp, "%.0f.jpg", i);
vec_temp.x = sin(i * 45) * 200;
vec_temp.y = cos(i * 45) * 200;
debug_str2("STR", str_temp);
ent_pic[i] = ent_create(str_temp, vec_temp, NULL);
vec_to_angle(ent_pic[i].pan, vec_temp);
}
//position camera
vec_set(camera.x, vector(-520, 0, 260));
vec_set(vec_temp, nullvector);
vec_sub(vec_temp, camera.x);
vec_to_angle(camera.pan, vec_temp); // now MY looks at YOU
vec_temp.z = 0;
while(1){
if(mouse_moving){
var_offset += mickey.x;
for(i = 0; i < 8; i++){
vec_temp.x = sin((i * 45) + var_offset) * 200;
vec_temp.y = cos((i * 45) + var_offset) * 200;
vec_set(ent_pic[i].x, vec_temp);
vec_to_angle(ent_pic[i].pan, vec_temp);
}
}
wait(1);
}
}
your pictures should be called pic0.jpg thro pic8.jpg hope this helps (58 lines including whitespace )
|
|
|
Re: 3D Image Gallery
[Re: Theil]
#320898
04/25/10 17:30
04/25/10 17:30
|
Joined: Aug 2002
Posts: 572 Toronto
MadMark
User
|
User
Joined: Aug 2002
Posts: 572
Toronto
|
Very cool, MrGuest. How would I alter this code so that the camera remains stationary, but the pictures rotate around the circle based on the mouse position?
Mark
People who live in glass houses shouldn't vacuum naked.
|
|
|
Re: 3D Image Gallery
[Re: MadMark]
#320979
04/26/10 12:57
04/26/10 12:57
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
errr, don't set the camera position, and add mickey.x to the camera.pan?
#include <acknex.h>
#include <default.c>
#define PRAGMA_PATH "pics"
#include "debug.c"
ENTITY* ent_pic[8];
var var_offset = 0;
var var_campos = 0;
void campos_change(){
var_campos = 1 - var_campos;
switch(var_campos){
case 0:
vec_set(camera.x, nullvector);
vec_set(camera.pan, nullvector);
break;
case 1:
vec_set(camera.x, vector(-520, 0, 260));
vec_set(vec_temp, nullvector);
vec_sub(vec_temp, camera.x);
vec_to_angle(camera.pan, vec_temp); // now MY looks at YOU
break;
}
}
void main(){
wait(1);
on_tab = campos_change;
level_load(NULL);
STRING* str_temp = str_create("");
VECTOR vec_temp;
vec_temp.z = 0;
int i;
for(i = 0; i < 8; i++){
str_cpy(str_temp, "pic");
str_cat_num(str_temp, "%.0f.jpg", i);
vec_temp.x = sin(i * 45) * 200;
vec_temp.y = cos(i * 45) * 200;
debug_str2("STR", str_temp);
ent_pic[i] = ent_create(str_temp, vec_temp, NULL);
vec_to_angle(ent_pic[i].pan, vec_temp);
}
while(1){
if(mouse_moving){
switch(var_campos){
case 0:
camera.pan += mickey.x;
break;
case 1:
var_offset += mickey.x;
for(i = 0; i < 8; i++){
vec_temp.x = sin((i * 45) + var_offset) * 200;
vec_temp.y = cos((i * 45) + var_offset) * 200;
vec_set(ent_pic[i].x, vec_temp);
vec_to_angle(ent_pic[i].pan, vec_temp);
}
break;
}
}
wait(1);
}
}
press tab to toggle views
|
|
|
|