Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (vicknick, dr_panther, VoroneTZ), 1,255 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: 3D Image Gallery [Re: Theil] #319509
04/15/10 13:33
04/15/10 13:33
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

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 laugh
Code:
#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 grin )

Re: 3D Image Gallery [Re: MrGuest] #319606
04/16/10 02:57
04/16/10 02:57
Joined: Sep 2009
Posts: 84
Theil Offline OP
Junior Member
Theil  Offline OP
Junior Member

Joined: Sep 2009
Posts: 84
works pretty well thanks really grin

Re: 3D Image Gallery [Re: Theil] #320898
04/25/10 17:30
04/25/10 17:30
Joined: Aug 2002
Posts: 572
Toronto
MadMark Offline
User
MadMark  Offline
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
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
errr, don't set the camera position, and add mickey.x to the camera.pan?

Code:
#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

Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1